It looks like you're new here. If you want to get involved, click one of these buttons!
from kiteconnect import WebSocket# Initialise.kws = WebSocket("your_api_key", "your_public_token", "logged_in_user_id")totalTokens=# Callback for tick reception.def on_tick(tick, ws): print tick# Callback for successful connection.def on_connect(ws): # Subscribe to a list of instrument_tokens (RELIANCE and ACC here). ws.subscribe(totalTokens) # Set RELIANCE to tick in `full` mode. ws.set_mode(ws.MODE_FULL, )def on_disconnect(ws): print "Connection is dropped...subscribing again" on_connect()# Assign the callbacks.kws.on_tick = on_tickkws.on_connect = on_connectkws.on_disconnect=on_disconnect# Infinite loop on the main thread. Nothing after this will run.# You have to use the pre-defined callbacks to manage subscriptions.kws.connect()