-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbinanceIchimoku.py
77 lines (65 loc) · 3.2 KB
/
binanceIchimoku.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import utils
from time import sleep
client = utils.setProfile()
#coins = client.get_all_coins_info()
pumpvolume = utils.findPump(client)
if len(pumpvolume) == 0:
print("Oh no, no pumps in the last hours :'( ")
exit(0)
else:
print("The coin pairs with a pump in last hours :", pumpvolume)
kijunsen = utils.getKijunsen(client, pumpvolume)
# Personal account operations
print("Cassa: " + client.get_asset_balance("BTC")["free"])
# TODO: creare uno schema
# getTot disponibile e diviso per len(pumpVolume)
# if prezzo attuale >*kinjunsen*0.95 allora place kinjunsen order (orderid in lista), altrimenti delete da lista
# when order kinjun è completo place oco order con 5% (oco orderid in lista) delete da lista
# when normal order è canceled delete da lista
currentOrder = []
# for sul pumpvolume
for c in range(len(pumpvolume)):
# quantity= [coin/price]
prezzoatt = client.get_symbol_ticker(symbol=pumpvolume[c])["price"]
if float(client.get_asset_balance("BTC")["free"]) > 0.002: # around $40
print("prezzoatt:" + str(pumpvolume[c]) + " -" + str(prezzoatt))
if float(kijunsen[c]) > float(prezzoatt) > float(kijunsen[c]) * 0.96:
prezzobuy = prezzoatt
elif float(prezzoatt) > float(kijunsen[c]) * 0.96:
prezzobuy = utils.formatForBinance(str(prezzoatt), str(kijunsen[c]))
else:
break
print("prezzobuy:" + str(prezzobuy))
# order BUY
precision = client.get_symbol_info(symbol=pumpvolume[c])["filters"][0]["tickSize"]
quantity = utils.formatForBinance(precision, (0.002 / float(prezzoatt)))
print(str(quantity))
try:
currentOrder.insert(c, client.order_limit_buy(symbol=pumpvolume[c],
quantity=quantity,
price=str(prezzobuy)))
except IOError as err:
print("Order error: {0}".format(err))
print(str(currentOrder[c]))
# oco orders
while len(pumpvolume) > 0:
for d in range(len(pumpvolume) - 1):
currentOrd = client.get_order(symbol=pumpvolume[d], orderId=currentOrder[d]["orderId"])
if currentOrd[d]["status"] == 'FILLED':
try:
client.order_oco_sell(symbol=pumpvolume[d],
quantity=currentOrder[d]["executedQty"],
price=utils.formatForBinance(currentOrder[d]["price"], str(kijunsen[d] * 1.04)),
stopPrice=utils.formatForBinance(currentOrder[d]["price"],
str(kijunsen[d] * 0.96)),
stopLimitPrice=utils.formatForBinance(currentOrder[d]["price"],
str(kijunsen[d] * 0.96)),
stopLimitTimeInForce='FOK')
except IOError as err:
print("OCO order error: {0}".format(err))
del kijunsen[d]
del pumpvolume[d]
del currentOrder[d]
sleep(300)
# delete the orders which in 3h haven't been still FILLED
utils.clean(client, currentOrder)