I am facing following problem. I have a list of equities in my subscription list. Sometimes, I see that it has stopped subscribing to certain equities in the list .
Do you know why it happens and can you suggest a way out of it ?
import cPickle as pickle from kiteconnect importWebSocket import time from datetime import datetime fromQueueimportQueue,LifoQueue from threading importThread import pandas as pd importMySQLdb df = pd.DataFrame()
q =LifoQueue(maxsize=10) #max size is to ensure that the program is not running even after the WebSocket has broken for long #tickData = 0
# Callback for successful connection. def on_connect(ws): # Subscribe to a list of instrument_tokens (RELIANCE and ACC here). listSubscription =[134657,1629185,895745,3924993,348929,758529,359937,784129,3001089,415745,2796801,356865,140033] ws.subscribe(listSubscription)
# Set RELIANCE to tick in `full` mode. ws.set_mode(ws.MODE_QUOTE, listSubscription)
# Infinite loop on the main thread. Nothing after this will run. # You have to use the pre-defined callbacks to manage subscriptions. kws.connect(threaded =True) test ={} data_instrument_token = pd.DataFrame(columns =['last_price','timeStamp','ratiobuysell']) #data = {738561:{'last_price':[],'timeStamp':[]}} #data_instrument_token.set_index('timeStamp') ltpDict ={134657:0,1629185:0,895745:0,3924993:0,348929:0,758529:0,359937:0,784129:0,3001089:0,415745:0,2796801:0,356865:0,140033:0} test['universe']={134657:'BPCL',1629185:'NATIONALUM',895745:'TATASTEEL',3924993:'NMDC',348929:'HINDALCO',758529:'SAIL',359937:'HINDPETRO',784129:'VEDL',3001089:'JSWSTEEL',415745:'IOC',2796801:'GODREJIND',356865:'HINDUNILVR',140033:'BRITANNIA'} 1,1 ratiobuysell =0 i=0 #A Pandas Thread whileTrue:
Is it because of the Queue I am storing data into? Is it that I miss a lot of ticks and hence the update doesnt happen ? as I can clearly see that my system lags the original movement in the market.