Subscribed to MODE_FULL and getting some ticks in 'full' mode and some in 'quote'

@zartimus @sujith
Even after subscribing to 'full' mode for all the symbols, some ticks are coming in 'quote' mode and some in 'full'. Also, ticks which come in 'quote' mode don't have any 'timestamp' or 'last_trade_time' info. I am subscribed to ~7K-8K symbols and some of the symbols are exhibiting this wrong behavior (i.e. instrument_tokens 1586689, 1231105, 13835522, 29637378, 4127489, 2997505, 11886850, 3847042, 29195010, 29778690, 29278210 ,6532097, others)

Attaching a snapshot:

System Information:
conda version : 4.5.12
conda-build version : 3.17.6
python version :
base environment : C:\Users\hnazk\Anaconda3 (writable)
platform : win-64
user-agent : conda/4.5.12 requests/2.21.0 CPython/3.7.1 Windows/10 Windows/10.0.17134
administrator : False
  • sujith
    Can you check if there are multiple re-connections happening?
    Try logging every re-connection as well.
  • naz
    Yes. I am running 3 threads in parallel and there several disconnections/connections happening very frequently (about every ~10 seconds) with below error:
    Connection closed: 1006 - connection was closed uncleanly

    But I am assuming reconnections should set the mode to 'full' with the same on_connect function (defined below).

    def on_connect(ws, response):
    ws.set_mode(ws.MODE_FULL, sec_id_list)
  • sujith
    Kite Ticker default subscription will set the mode to modeQUOTE and then another request is sent to Kite Ticker to set the mode to modeFULL, while this is happening you might receive ticks in quote mode.

    The tick timestamp and last traded timestamp are only available in the FULL mode. You can go through the documentation for more details.

    I would suggest checking why there are so many disconnections at your end.
  • naz
    Thanks @sujith for the explanation.
    I was also debugging at my end. The same code code was working absolutely fine in the afternoon when I tried to stream NSE stocks/equities OR NSE indices OR NFO futures on stocks.
    Error started coming when I tried to stream ~4K NFO stock options. I have attached the list of instrument tokens that I used today for streaming.
    Do you find something wrong with these instrument tokens (I suspect that since yesterday was expiry, something went wrong with this).

  • sujith
    Are you offloading your calculations or DB operations to different thread?
  • tejasvgupta1
    @sujith why doing DB operations using different threads is leading to connection close?
  • zartimus
    @tejasvgupta1 All you have to do is to make sure that heavy tasks are not performed in callback handlers.
    ^ says it will drop connection if you block which cannot exceed 2 * PING_INTERVAL = 2 * 2.5 = 5 sec
    ideally heavy tasks should be delegated to a separate process/thread.
  • tejasvgupta1
    tejasvgupta1 edited December 2018
    @zartimus I am not doing any heavy tasks also this condition won't be true if last pong or tick is received within the interval, only when I am saving to DB in other threads this is getting dropped if not saving to db connection is working fine
  • zartimus
    @tejasvgupta1 Can you paste the code here? Simple example would do.
  • tejasvgupta1
    tejasvgupta1 edited December 2018
    @zartimus @sujith I am using same Java code as per the sample
    only change is I have commented these since I don't want to close socket
    // Unsubscribe for a token.

    // After using, close WebSocket connection.
    // tickerProvider.disconnect();
    but seems like roughly around 7 minutes after connect pong and ticks stop and then reconnect happens as per the code and then it disconnects
  • sujith
    You can comment your method call inside the onTick and add just print statements and check.
    The examples we have provided are already tested.
Sign In or Register to comment.