Ticker Disconnect end of day step

nkotwar
nkotwar edited May 2022 in Python client
Hello @sujith
How should I disconnect from KiteTicker(close websocket connection) at say 15:30 and reconnect again at login, without checking if time is xx:xx every few seconds

Edit:
reconnect at login, i already have working smooth, just the disconnect step at 15:30 is bugging me, any hints about that are appreciated.
  • rakeshr
    How should I disconnect from KiteTicker(close websocket connection) at say 15:30 and reconnect again at login, without checking if time is xx:xx every few seconds
    There is no individual API on this, you will have to build this logic at your end wrapped over stop() call to disconnect the ticker.
  • DD1365
    The following works pretty well for me in Python, I add this piece of code at the end of my main code in a threaded websocket connection:


    import datetime
    if datetime.datetime.now().hour>=hour:
    ----if datetime.datetime.now().minute>=minute:
    --------# Your position exiting code
    --------# Your position exiting code
    ----kws.stop()
    ----kws.unsubscribe(tokens)
    ----kws.close()
    ----raise SystemExit
  • DeepakTanpure
    where does this piece of code goes ?
    inside on_ticks or
    helper function called from on_ticks
  • DD1365
    Inside helper function called from on_ticks
Sign In or Register to comment.