It looks like you're new here. If you want to get involved, click one of these buttons!
kite.quote()
is faster.
websocketQuotes = {}
def updateQuotes(ticks):
global websocketQuotes
global instrument_symbol_dic
for tick in ticks:
tradingSymbol = instrument_symbol_dic[int(tick["instrument_token"])]
websocketQuotes[tradingSymbol] = tick
def on_ticks(ws, ticks):
updateOrdersSQL_thread = Thread(target=updateQuotes,args=(ticks,))
updateOrdersSQL_thread.start()
def on_connect(ws, response):
ws.subscribe([738561])
ws.set_mode(ws.MODE_FULL, [738561])
def on_close(ws, code, reason):
ws.stop()
kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.on_close = on_close
kws.connect(threaded=True)
socketSlowTime = 0
for i in range(100):
quoteTime = kite.quote("NSE:RELIANCE")["NSE:RELIANCE"]["timestamp"]
socketTime = websocketQuotes["RELIANCE"]["timestamp"]
delay = (quoteTime-socketTime).seconds
socketSlowTime += delay
time.sleep(0.1)
print("socket total delay time is",socketSlowTime,"seconds")
The output was: