i have some code files that i have written myself. But i am facing a problem of fetching tick data from websocket and also closing the websockets (closing handshakes). Need troubleshooting. In python language
while True: for api_info in api_data.get('api_keys', []): time.sleep(5) api_key = api_info.get('api_key', '') with open('access tokens list.txt', 'r') as fp: # to read a json file hya = json.load(fp) ref_name = api_info.get('ref_name', '') access_token = hya[ref_name]['act'] if not api_key or not access_token: print("Invalid API key or access token in the JSON file.") continue kite = KiteConnect(api_key=api_key) kite.set_access_token(access_token) kws = KiteTicker(api_key, access_token) abc = {} tick_queue = queue.Queue() # Function to process tick data def process_ticks(): while True: tick = tick_queue.get() inst_token = tick['instrument_token'] last_price = tick['last_price'] abc[inst_token]['last_price'] = last_price
https://drive.google.com/file/d/1Yfe9l83yPJnka_aYNa9x4b3gUveavn4u/view?usp=sharing