"timestamp" missing from websocket data briefly today

neel2323
Hi, today around 2:30pm 2 tickets from websocket didnt have the "timestamp" field in them causing issues with my code. I have fixed my code for this redundancy. Any idea why this happened? Also do you have a thread with known bugs so that we can incorporate for them in our codes?

Below are the some of the ticks received with missing timestamp field


{'tradable': True, 'mode': 'quote', 'instrument_token': 9905154, 'last_price': 2.5, 'last_quantity': 1450, 'average_price': 3.22, 'volume': 11887600, 'buy_quantity': 766200, 'sell_quantity': 489850, 'ohlc': {'open': 4.0, 'high': 4.5, 'low': 2.5, 'close': 3.55}, 'change': -29.577464788732392}
{'tradable': True, 'mode': 'quote', 'instrument_token': 11432962, 'last_price': 4.25, 'last_quantity': 50, 'average_price': 4.99, 'volume': 8152850, 'buy_quantity': 843300, 'sell_quantity': 238750, 'ohlc': {'open': 5.8, 'high': 6.4, 'low': 4.05, 'close': 7.25}, 'change': -41.37931034482759}
{'tradable': True, 'mode': 'quote', 'instrument_token': 11440130, 'last_price': 338.3, 'last_quantity': 50, 'average_price': 323.27, 'volume': 845000, 'buy_quantity': 105300, 'sell_quantity': 52100, 'ohlc': {'open': 300.0, 'high': 367.55, 'low': 283.95, 'close': 262.05}, 'change': 29.097500477008204}
{'tradable': True, 'mode': 'quote', 'instrument_token': 9359874, 'last_price': 427.35, 'last_quantity': 50, 'average_price': 453.84, 'volume': 1850, 'buy_quantity': 78200, 'sell_quantity': 31050, 'ohlc': {'open': 498.5, 'high': 498.5, 'low': 425.05, 'close': 535.25}, 'change': -20.158804297057447}
{'tradable': True, 'mode': 'quote', 'instrument_token': 11413762, 'last_price': 1.35, 'last_quantity': 50, 'average_price': 1.49, 'volume': 704900, 'buy_quantity': 227250, 'sell_quantity': 144500, 'ohlc': {'open': 1.75, 'high': 1.75, 'low': 1.35, 'close': 1.75}, 'change': -22.857142857142854}
{'tradable': True, 'mode': 'quote', 'instrument_token': 11416322, 'last_price': 1.45, 'last_quantity': 150, 'average_price': 1.57, 'volume': 55250, 'buy_quantity': 96050, 'sell_quantity': 38550, 'ohlc': {'open': 1.85, 'high': 1.9, 'low': 1.35, 'close': 1.85}, 'change': -21.621621621621628}
{'tradable': True, 'mode': 'quote', 'instrument_token': 11427586, 'last_price': 1264.4, 'last_quantity': 50, 'average_price': 1271.5, 'volume': 100, 'buy_quantity': 12400, 'sell_quantity': 10650, 'ohlc': {'open': 1278.6, 'high': 1278.6, 'low': 1264.4, 'close': 1170.0}, 'change': 8.068376068376077}
{'tradable': True, 'mode': 'quote', 'instrument_token': 11433474, 'last_price': 4.65, 'last_quantity': 50, 'average_price': 5.51, 'volume': 414050, 'buy_quantity': 103600, 'sell_quantity': 52450, 'ohlc': {'open': 7.15, 'high': 7.55, 'low': 4.5, 'close': 7.9}, 'change': -41.13924050632911}
{'tradable': True, 'mode': 'quote', 'instrument_token': 11437570, 'last_price': 11.5, 'last_quantity': 50, 'average_price': 14.37, 'volume': 8621650, 'buy_quantity': 300550, 'sell_quantity': 224400, 'ohlc': {'open': 22.9, 'high': 22.9, 'low': 10.9, 'close': 23.4}, 'change': -50.854700854700845}
{'tradable': True, 'mode': 'quote', 'instrument_token': 11442690, 'last_price': 68.15, 'last_quantity': 50, 'average_price': 82.64, 'volume': 41622050, 'buy_quantity': 813800, 'sell_quantity': 873000, 'ohlc': {'open': 109.65, 'high': 109.65, 'low': 62.05, 'close': 120.45}, 'change': -43.420506434205066}
{'tradable': True, 'mode': 'quote', 'instrument_token': 10987266, 'last_price': 0.0, 'last_quantity': 25, 'average_price': 0.0, 'volume': 0, 'buy_quantity': 14650, 'sell_quantity': 12900, 'ohlc': {'open': 0.0, 'high': 0.0, 'low': 0.0, 'close': 1556.3}, 'change': -100.0}
{'tradable': True, 'mode': 'quote', 'instrument_token': 11435266, 'last_price': 6.2, 'last_quantity': 700, 'average_price': 7.47, 'volume': 5337400, 'buy_quantity': 334650, 'sell_quantity': 126650, 'ohlc': {'open': 8.95, 'high': 10.4, 'low': 6.0, 'close': 11.85}, 'change': -47.67932489451477}
{'tradable': True, 'mode': 'quote', 'instrument_token': 9362178, 'last_price': 3.85, 'last_quantity': 950, 'average_price': 4.99, 'volume': 9026800, 'buy_quantity': 377400, 'sell_quantity': 174800, 'ohlc': {'open': 5.1, 'high': 7.8, 'low': 3.65, 'close': 4.9}, 'change': -21.428571428571434}
  • rakeshr
    {'tradable': True, 'mode': 'quote',
    From your above response, subscription mode is quote. You need to subscribe to Full mode, to fetch exchange timestamp field. You can check complete tick packet structure here.
  • neel2323
    @rakeshr my subscription mode was "FULL" however i received "quote" items for only 2 ticks. My websocket worked well throughout the day. Possibility of a bug at the api end?


    def on_ticks(ws, ticks):
    q.put(ticks)

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

    def on_close(ws, code, reason):
    ws.stop()
  • trade_then
    trade_then edited October 8
    I apologize I am not a python guy. So I may be wrong. But my
    suggestion is valid if above thing happened on reconnection attempt or on its first attempt to connect with websocket.


    your ws.subscribe(websocket_tokens) request above lands here.

    you can clearly see that Kite server will not know
    what kind of Tick you want.

    So your client library is inserting a default mode here which is "QUOTE".

    Now if your application or network is not able to make
    ws.set_mode(ws.MODE_FULL, websocket_tokens) request fast enough. which would land you here. Then any reconnection will try to
    subscribe in Quote mode as well. More over Quote mode might be the default mode which kite server is throwing at you.

    In which case this seems to be a common case amongst the Kite libraries.

    Thanks
    Regards
  • rakeshr
    Yes, the default mode at Websocket subscription mode is Quote. subscribed_tokens dict maintains instrument token and modes for re-connection. So, in case of re-connection first tick received will be in Quote mode after that subscribed_tokens dict set the mode as per your request.
  • neel2323
    @trade_then @rakeshr thank you for the help and diagnosing the problem. That was indeed the root cause! Thanks again guys!
Sign In or Register to comment.