PLACE ORDER code not working - was working few months ago

D11458
Below is the structure - it used to work earlier, now not working. If I comment out for condition and order placement part and just print "Algo Running" then it runs correctly. Only order placement isnt working any more. Any assistance please.

while True:
def insert_ticks(ticks):
# pdb.set_trace()
# print (ticks)
# print ("Algo is Running")
# print ("\n")
for one_tick in ticks:
try:
ltp=one_tick['last_price']
# pdb.set_trace()
one_tick_token = one_tick['instrument_token']
name = stockname[one_tick_token]

if "bought" not in trd_list[one_tick_token].values():
kite.place_order(tradingsymbol=name,variety="regular",exchange=kite.EXCHANGE_NFO,transaction_type="BUY",quantity=trd_list[one_tick_token]['trade_qty'],order_type="MARKET",product="NRML")
trd_list[one_tick_token]['buy_price']=ltp
trd_list[one_tick_token]['status1']='bought'
print ("\n")
print ("BUY ORDER PLACED")

time.sleep(0.2)
except:
pass
  • sujith
    There shouldn't be any logic inside the on_tick method. One should only consume data and do all your calculations, insert to db or place order in other thread.
    Never block the main thread that is receiving ticks.
Sign In or Register to comment.