Not getting data for All NSE subscribed and tick.getLastTradedTime() is returning null

pashriva
I subscribed for random 100 NSE tokens.
I am not getting data for more than 20 tokens in one tick. The tick.getTickTimestamp() and tick.getLastTradedTime() are continously returning null. Today is the first time I have run the websocket code.

  • pashriva
    @admin - please share if there is any existing thread that is having detailed info about how java websocket works that I can use to set my expectations correctly.
  • SRIJAN
    https://kite.trade/forum/discussion/6632/not-getting-prices-from-every-tick

    For which tokens,tick timestamp and ltt are null? Can you give a few examples?
  • pashriva
    One example ONGC

    tokens.add(633601L);

    System.out.println("******** tick timestamp " + Tick.getTickTimestamp());
    System.out.println("******** last traded time " + tick.getLastTradedTime());


    ******** last price 177.9
    ******** tick timestamp null
    ******** last traded time null
    ticks size 1
  • pashriva
    Also tried with
    tokens.add(1195009L);
    tokens.add(3050241L);
    tokens.add(136402436L);
  • pashriva
    I have gone through the link above and I understood this concept.
    But still it is difficult to believe that out of 1700 + stocks of nse only a 300 to 400 are getting updated once a second. I understand the snapshot data concept but still every 1 second more number of stocks should have changed their LTP.
  • pashriva
    Also when I added the BSE stocks also to the webstock, the total number of stocks subscribed became about 4500. Still only 300 to 400 ticks are being received.
  • pashriva
    - Trying all BSE Stocks via Websocket (after removing NSE stocks), Less than 50 ticks being received per second against about 2800 subscribed for.
  • pashriva
    pashriva edited March 2022
    @admin @SRIJAN - I can share the list of BSE and NSE tokens if you ask me but looks like there is no respite from the null LTT
  • SRIJAN
    You are doing it wrong. Its not Tick.getTickTimestamp(), ticks.get(0).getTickTimestamp(). The ticks received is a list of all the tick of individual instruments. So you have to specify the index and then use getTickTimestamp() or whatever field you want.
  • SRIJAN
    It is what it is,you will get tick for instruments where any of the fields change. KiteConnect just relays whatever they get from the exchange,no modification.
  • pashriva
    pashriva edited March 2022
    @admin , @SRIJAN - please see my code below, I am looping through the ticks getting a single tick in each iteration and calling function on it. Don't think it is wrong. And also it is returning last traded price correctly.

    public void onTicks(ArrayList ticks) {
    System.out.println("ticks size " + ticks.size());
    if (ticks.size() > 0) {
    for (Tick tick : ticks) {
    System.out.println(tick.getInstrumentToken());
    System.out.println("******** last price " + tick.getLastTradedPrice());
    // System.out.println("******** change " + formatter.format(tick.getChange())); //imp:- This is Percentage change.
    System.out.println("******** tick timestamp " + tick.getTickTimestamp());
    System.out.println("******** last traded time " + tick.getLastTradedTime());
  • pashriva
    pashriva edited March 2022
    @admin, @SRIJAN,@sujith - For the websocket data, I humbly think someone should look into it. I don't think that out of 2800 BSE stocks only 30 or so will be changing every second to generate tick data.
  • SRIJAN
    SRIJAN edited March 2022
    Look bro,I tried with your ONGC and one other token,tick timestamp and ltt are working fine for me . As for your code,I don't know Java so I can't tell the problem. Maybe Sujith Sir or Rakesh Sir can help you.
  • pashriva
    pashriva edited March 2022
    Ok Thanks @SRIJAN for your input.
    Hi @sujith, @admin ,@rakeshshr Could you please help here. I am getting null values for last traded time and below is my code. 2nd Issue is that the number of ticks per second is less than 300 for 1700+ stock subscribed from NSE and less than 50 for 2800+ stocks subscribed from BSE.

    public void onTicks(ArrayList ticks) {
    System.out.println("ticks size " + ticks.size());
    if (ticks.size() > 0) {
    for (Tick tick : ticks) {
    System.out.println(tick.getInstrumentToken());
    System.out.println("******** last price " + tick.getLastTradedPrice());
    // System.out.println("******** change " + formatter.format(tick.getChange())); //imp:- This is Percentage change.
    System.out.println("******** tick timestamp " + tick.getTickTimestamp());
    System.out.println("******** last traded time " + tick.getLastTradedTime());
  • sujith
    There was some issue with NSE EQ ticks. You can know more here.

    If this is not related, you need to make a note that you will only receive a cached tick when you subscribe for a token. There after you will receive data only when there is a change.

    There are three modes of data currently on Websocket API, LTP mode, QUOTE mode, FULL mode.
    You will not receive last traded timestamp in the LTP and QUOTE mode. You can know more about it here.
  • pashriva
    pashriva edited March 2022
    Thanks @sujith , @admin , @rakeshr
    I changed the mode to Full and I started getting the timestamp.

    But still it is difficult to understand why only so less number of stocks are genering data for every tick. For BSE Tokesn about 2800 + I am getting ticks only for less than 50 stocks.

    Do you think this is very low and requires some re-look.
  • sujith
    You will only receive tick when there is a change in data.
  • pashriva
    @sujith ,@admin, @rakeshr - I understood that I will get the tick when there is a change in data. But what I am not able to believe is that out of 2800 tickers from BSE only less than 50 stocks are changing every second. Don't think BSE is so illiquid.

    Question 2. Please tell me how is the getLTP() method working. Does it bring the prices from the same snapshot data or does it have a different flow where in it reaches the NSE servers and get the data back? What will be outcome of a simple test to compare the results from getLTP() vs price data from websocket?
  • sujith
    @pashriva,
    If you don't see ticks for some tokens every second then you can compare it with kite web. We use the same ticker of all of our platforms and there is no issue with that.
    Not every instrument tick often.

    The getLTP or getQuote will fetch data from the same Websocket API.
  • pashriva
    Ok Great @sujith , thanks for confirming. You have a great day !
This discussion has been closed.