while True: def insert_ticks(ticks): for one_tick in ticks: **my workings** # pdb.set_trace() time.sleep(0.5) if condition meets: kite.modify_order(trd_list[one_tick_token]['m_id'],order_type="MARKET")
now = datetime.datetime.now() if (now.hour >= 11 and now.minute >= 22 ): kws.on_ticks=on_ticks kws.on_connect=on_connect kws.connect() if (now.hour >= 15 and now.minute >= 35): sys.exit() time.sleep(0.5) ================================ Initially I was using the main ticks thread for strategy workings and placing order and same thing happened, worked fine for a few minutes then threw error of Toomanyrequests so I tried to move to another thread as above but still same issue.
FYI - Despite this error the code resumes functioning properly in some time but we miss the right price and poses big risk.
I am running just the above code that too for only 4 instruments. I was earlier placing 4 separate modify orders in this code, so thought that might be >3 connections issue so clubbed that in one modify order as shown in above code. Still same issue. Note: After posting this query I commented out "if condition meets: kite.modify_order(trd_list[one_tick_token]['m_id'],order_type="MARKET")" and used print command just to check, and it is running without any problem since more than 2 hours. FYI - I have gone through multiple threads no help.
Abrupt disconnections don't get registered at the server. You need to make sure you are not suspending the script which might result in hanging connection at the server and check all the edge-cases in your code wherein disconnect is not called.
Note: After posting this query I commented out "if condition meets:
kite.modify_order(trd_list[one_tick_token]['m_id'],order_type="MARKET")" and used print command just to check, and it is running without any problem since more than 2 hours.
FYI - I have gone through multiple threads no help.
api_key=open('D:/Data/python/zerodha_k.txt','r').read()
access_token=open('D:/Data/python/zerodha_t.txt','r').read()
kite=KiteConnect(api_key=api_key)
kite.set_access_token(access_token)
kws = KiteTicker(api_key, access_token)