forked from ElGafasTrading/AutoTpBinance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
78 lines (66 loc) · 2.42 KB
/
script.py
File metadata and controls
78 lines (66 loc) · 2.42 KB
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
78
import time
from functions import *
print("")
print("##################################")
print("########-CRIPTO SPARTANS-#########")
print("###############TP#################")
print(" By ElgafasTrading")
print("")
tick = ""
entryPrice = 0.0
positionAMT = 0.0
tpAuto = 0
orderID = 0
tick_size = 0.0
while True:
while len(tick) == 0:
tick = input("INGRESE EL TICK: ").upper()
tick = tick + 'USDT'
if tpAuto == 0:
while True:
try:
tpAuto = float(input("INGRESE EL PORCENTAJE DEL TAKE PROFIT: "))
break
except:
print("VALOR INVALIDO, INGRESE UN NUMERO VALIDO")
info = positionInfo(tick)
if info:
if float(info[0].get('positionAmt')) != 0:
print("positionAmt: " + str(info[0].get('positionAmt')) + " entryPrice: " + str(
info[0].get('entryPrice')) + " leverage: " + str(info[0].get('leverage')))
if entryPrice != float(info[0].get('entryPrice')) or positionAMT != float(info[0].get('positionAmt')):
entryPrice = float(info[0].get('entryPrice'))
positionAMT = float(info[0].get('positionAmt'))
if orderID != 0:
client.futures_cancel_order(symbol=tick, orderId=orderID)
print("ORDEN TAKE PROFIT CANCELADA")
time.sleep(1)
precioTP = 0
side = 'BUY'
if positionAMT < 0:
precioTP = entryPrice - (entryPrice * tpAuto) / 100
else:
precioTP = entryPrice + (entryPrice * tpAuto) / 100
side = 'SELL'
pricePrecision = get_quantity_precision(tick)
precioTP = takeProfit(precioTP, pricePrecision[0])
crear = createTpOrder(tick, positionAMT, precioTP, side)
orderID = crear['orderId']
else:
print("NO HAY POSICIONES ABIERTAS EN: " + tick)
openOrders = client.futures_get_open_orders(symbol=tick)
if len(openOrders) > 0:
client.futures_cancel_all_open_orders(symbol=tick)
tick = ""
tpAuto = 0
entryPrice = 0.0
positionAMT = 0.0
orderID = 0
time.sleep(2)
else:
tick = ""
tpAuto = 0
entryPrice = 0.0
positionAMT = 0.0
orderID = 0
time.sleep(2)