Feb-17-2022, 03:38 AM
I want to run this loop but it skips all the conditions and always runs n==1.
At the start of the code, I want it to run n==0 and get the data from the exchange. Then match with the order_id for data and set n==2 and count +1.
if data is not found I want it to run n == 1: code. Every time the count value is higher than loop_speed it must get new data from the exchange.
I know there is some problem with the loop help me solve it.
At the start of the code, I want it to run n==0 and get the data from the exchange. Then match with the order_id for data and set n==2 and count +1.
if data is not found I want it to run n == 1: code. Every time the count value is higher than loop_speed it must get new data from the exchange.
I know there is some problem with the loop help me solve it.
global data global count count = 0 global n n = 1 loop_speed=10
def order_info(order_id):
# print (loop_speed)
# print (count)
global count
global n
global data
if count == 0:
try:
#order_id = 121553199503
data = exchange.fetchOpenOrders(symbol)
for d in data:
if float(d['id']) == order_id:
info = d['info']
count = count + 1
print ("new")
print (info)
print (count)
n = 2
except Exception as e:
print (type(e).__name__, str(e))
time.sleep(1)
elif count <= loop_speed:
# order_id = 121553198710
#order_id = 121840387739
print ('yess')
for d in data:
if float(d['id']) == order_id:
info = d['info']
print ("next")
print (info)
count = count + 1
n = 2
break
else:
n = 1
elif count >= loop_speed:
print (count)
count = 0
#order_id = 121840387739
print ('y')
for d in data:
if float(d['id']) == order_id:
info = d['info']
print ("max")
print (info)
n = 2
break
else:
n = 1
elif n == 1:
try:
print ('true')
info = exchange.fetchOrder(order_id)['info']
count = count + 1
print (info)
print (count)
except Exception as e:
print (type(e).__name__, str(e))
time.sleep(1)
n == False
return (info)
