Can you let us know about the setup and the pykiteconnect version? Also please include the code and complete stack trace, we will check and get back to you.
Threaded is set as true when the ticker is started by calling start method as under: "def start(self, api_key: str, access_token: str, threaded = True):"
Further, is not thread, it's simply a class variable which stores the last updated tick for the instrument.
Also please include the code and complete stack trace, we will check and get back to you.
Here is my code:
from kiteconnect import KiteTicker, KiteConnect
import logging
log = logging.getLogger('Flask.Ticker')
class KiteWebsocket:
tick = {}
kws = None
def __init__(self):
pass
def start(self, api_key: str, access_token: str, threaded = True):
if not KiteWebsocket.kws:
log.info('Starting Kite Ticker...')
KiteWebsocket.kws = KiteTicker(api_key=api_key, access_token=access_token, reconnect=True)
kws = KiteWebsocket.kws
kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.on_close = on_close
kws.connect(threaded=threaded)
#---------------------------------------------------------
def on_ticks(ws, ticks):
# Callback to receive ticks.
for t in ticks:
KiteWebsocket.tick[t['instrument_token']] = t
def on_connect(ws, response):
# Callback on successful connect.
log.info('Ticker connection successful.')
def on_disconnect(ws, code, reason):
log.error('Ticker got disconnected. code = %d, reason = %s', code, reason)
def on_close(ws, code, reason):
# On connection close stop the main loop
# Reconnection will not happen after executing `ws.stop()`
pass
threaded
should beTrue
, if you are trying to spawn another thread to handle tick. Also, this should be post ticker callbacks. This operation seems to block the main ticker thread. You can go through this thread to know more about this.Threaded is set as true when the ticker is started by calling start method as under:
"def start(self, api_key: str, access_token: str, threaded = True):"
Further, is not thread, it's simply a class variable which stores the last updated tick for the instrument.