Token Subscription for ticks

chinmay_23
chinmay_23 edited June 2021 in Python client
"
def on_ticks(ws, ticks):
pass

def on_connect(ws, response):
ws.subscribe(tokens)
ws.set_mode(ws.MODE_FULL,tokens)

kws.on_ticks = on_ticks
kws.on_connect = on_connect

kws.connect()
''
We use the above on_connect function for subscribing stocks for tick data, we pass the list with instrument_tokens of all the instruments whose tick value we want. Can i by any means change the token list in the middle of the code execution.

For Ex: I'm examining banknifty future and i have some conditions, and if that conditions stands true then i would want ticks data of the option with the nearest strike price. Then i would want to update my subscribed tokens list in the middle of the execution.

Is it possible to do so? and how?
  • rakeshr
    Can i by any means change the token list in the middle of the code execution?
    You can go through Websocket FAQs here.
Sign In or Register to comment.