-
Notifications
You must be signed in to change notification settings - Fork 0
/
cnymaker.py
62 lines (50 loc) · 3.06 KB
/
cnymaker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import json
import collections
import random
from grapheneexchange import GrapheneExchange
from datetime import datetime, timedelta
from maker import Maker
import time
from Crypto.Cipher import AES
h = open("config.json", 'rb')
print('please input the decipher key:')
key = input()
cipher = AES.new(key)
encrypted = h.read()
unpad = lambda s: s[0:-ord(s[-1])]
globalconfig = json.loads(unpad(cipher.decrypt(encrypted).decode('utf-8')))
h.close()
pairs = [{"Initsuccess": False, "pair": ' ', "maker": 0, "asset":'GDEX.BTC', "base":'CNY', "priceuplimit": 200000, "pricedownlimit": 10000, "Gaprate": 0.01, "spreadrate": 0.008, "size":4, "amount": 5000}]
pairs.append ({"Initsuccess": False, "pair": ' ', "maker": 0, "asset":'GDEX.ETH', "base":'CNY', "priceuplimit": 20000, "pricedownlimit": 1000, "Gaprate": 0.01, "spreadrate": 0.008, "size":4, "amount": 5000})
pairs.append({"Initsuccess": False, "pair": ' ', "maker": 0, "asset":'GDEX.EOS', "base":'CNY', "priceuplimit": 400, "pricedownlimit": 10, "Gaprate": 0.01, "spreadrate": 0.008, "size":4, "amount": 5000})
pairs.append({"Initsuccess": False, "pair": ' ', "maker": 0, "asset":'GDEX.NEO', "base":'CNY', "priceuplimit": 4000, "pricedownlimit": 100, "Gaprate": 0.011, "spreadrate": 0.0088, "size":6, "amount": 5000})
pairs.append({"Initsuccess": False, "pair": ' ', "maker": 0, "asset":'GDEX.GAS', "base":'CNY', "priceuplimit": 1000, "pricedownlimit": 70, "Gaprate": 0.01, "spreadrate": 0.008, "size":6, "amount": 5000})
pairs.append({"Initsuccess": False, "pair": ' ', "maker": 0, "asset":'GDEX.QTUM', "base":'CNY', "priceuplimit": 1000, "pricedownlimit": 50, "Gaprate": 0.01, "spreadrate": 0.008, "size":6, "amount": 5000})
pairs.append({"Initsuccess": False, "pair": ' ', "maker": 0, "asset":'GDEX.ATN', "base":'CNY', "priceuplimit": 40, "pricedownlimit": 1, "Gaprate": 0.01, "spreadrate": 0.008, "size":4, "amount": 5000})
maker = {}
for pair in pairs:
pair['pair'] = pair['base']+"/"+pair['asset']
print('pleae input the middle price for ' + pair['pair'] + ':')
inputprice = float(input())
pair['maker'] = Maker(globalconfig, inputprice, ex='dex', asset=pair['asset'], base=pair['base'], priceuplimit=pair['priceuplimit'], pricedownlimit=pair['pricedownlimit'],
Gaprate=pair['Gaprate'], spreadrate=pair['spreadrate'], size=pair['size'], amount=pair['amount'])
while True:
for pair in pairs:
if not pair['Initsuccess']:
try:
pair['Initsuccess'] = pair['maker'].InitOrderPlace()
except Exception as e:
print(pair['pair'] + "failed to initialize orders, error:", e)
pair['Initsuccess'] = False
time.sleep(5)
if pair['Initsuccess']:
today = datetime.now()
yesterday = today + timedelta(hours=-24)
strYesterday = str(yesterday)[:10]
try:
pair['maker'].ReviewOrders()
except Exception as e:
print(pair['pair'] + "error:", e)
pair['maker'].ReconnectBTS(globalconfig)
time.sleep(5)
time.sleep(5)