Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Issue with tick data when large number of tokens are subscribed

    Bugs
    0
    25
    151
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nitish.bane last edited by nitish.bane

      Hi Team,
      I am subscribing to all strike price of bank nifty which tallies to 198 tokens in one websocket connection. I am observing an issue where I am not receiving intermediate ticks for the each strike price because of which there is a discrepancy in the candle data that I am creating at my end. Please find the websocket request for 198 tokens for the current expiry.
      {
      correlationID: "abcde12345",
      action: 1,
      mode: 2,
      exchangeType: 2,
      tokens: [
      "53955",
      "39011",
      "54061",
      "53867",
      "54132",
      "54320",
      "53925",
      "54029",
      "54108",
      "54191",
      "47787",
      "48448",
      "49231",
      "54069",
      "54030",
      "53816",
      "53949",
      "53847",
      "54059",
      "39013",
      "54135",
      "39010",
      "53822",
      "53982",
      "53812",
      "53887",
      "54065",
      "53967",
      "48446",
      "54060",
      "54031",
      "54323",
      "53948",
      "54106",
      "53869",
      "53898",
      "53995",
      "53831",
      "54087",
      "47772",
      "47785",
      "53950",
      "53863",
      "39012",
      "53823",
      "54002",
      "53921",
      "54063",
      "54289",
      "54109",
      "53944",
      "53934",
      "54033",
      "53985",
      "53952",
      "53896",
      "53854",
      "48451",
      "54159",
      "53941",
      "54151",
      "54287",
      "54011",
      "53951",
      "54016",
      "47786",
      "54009",
      "54051",
      "53888",
      "53923",
      "54175",
      "54221",
      "54064",
      "53912",
      "48447",
      "53963",
      "47784",
      "54092",
      "54150",
      "39008",
      "54077",
      "53832",
      "54164",
      "53926",
      "54298",
      "54163",
      "53840",
      "54167",
      "45999",
      "53984",
      "54321",
      "54134",
      "39028",
      "53806",
      "53821",
      "49223",
      "54112",
      "54111",
      "54160",
      "47758",
      "54076",
      "53924",
      "54257",
      "39799",
      "53833",
      "39027",
      "53834",
      "54123",
      "54062",
      "39009",
      "54007",
      "54176",
      "54146",
      "53820",
      "54070",
      "47771",
      "49232",
      "53983",
      "53922",
      "54003",
      "39800",
      "53852",
      "53870",
      "54006",
      "54179",
      "54130",
      "53932",
      "54068",
      "54299",
      "54169",
      "54027",
      "53803",
      "53864",
      "53897",
      "53902",
      "54045",
      "53935",
      "54131",
      "53865",
      "54220",
      "54066",
      "53876",
      "54168",
      "47759",
      "53853",
      "54322",
      "54067",
      "54094",
      "53866",
      "54017",
      "53956",
      "53958",
      "53962",
      "54129",
      "54177",
      "39029",
      "54192",
      "54288",
      "48444",
      "53964",
      "53851",
      "54128",
      "54028",
      "53877",
      "53807",
      "48445",
      "54309",
      "53859",
      "53868",
      "53813",
      "53965",
      "54161",
      "54162",
      "53805",
      "53804",
      "53947",
      "53848",
      "54071",
      "53966",
      "54004",
      "39014",
      "53994",
      "53961",
      "54052",
      "54310",
      "45996",
      "54010",
      "54319",
      "54136",
      "54258",
      "54093",
      "54026",
      "49228",
      "54032",
      "54133",
      "54046",
      "53913",
      "53957",
      ],
      }

      Please note that tick data is working perfectly fine when I subscribe only to Nifty and Bank nifty index tokens.

      C J D 4 Replies Last reply Reply Quote 0
      • C
        chetansuri @nitish.bane last edited by

        @nitish-bane I guess there is some limit on websocket. you might want to check this limit. Hope this helps.

        The total limit/quota of token subscriptions is 1000 per WebSocket session.

        For example: If the client subscribes to Infosys NSE with LTP, Quote, and SnapQuote mode then this will be counted as 3 subscriptions.

        Duplicate subscriptions to the same token and mode will be gracefully ignored and will not be counted towards the quota

        N 1 Reply Last reply Reply Quote 0
        • D
          DevPatel last edited by

          Sir can you please share me websocket 2.0 code in nodejs. I have been looking for this code for a long time. Please help me

          N 1 Reply Last reply Reply Quote 0
          • N
            nitish.bane @chetansuri last edited by

            @chetansuri Even if I consider that case it should not exceed limit of 1000 tokens as I am only subscribing for all strike prices of bank nifty which counts for 198 tokens.

            1 Reply Last reply Reply Quote 0
            • N
              nitish.bane last edited by

              @Moderator_1 @Moderator_2 @admin Can some one please help here?

              1 Reply Last reply Reply Quote 0
              • J
                jaideep siddula @nitish.bane last edited by

                @nitish-bane
                Hello!, Hope you are doing well. I am just curious why would you get all of the bank nifty strikes. Might I know the use case? How will it help in developing a strategy?. Would love to learn from you. Hopefully, I would learn a thing or two

                N 1 Reply Last reply Reply Quote 0
                • N
                  nitish.bane @jaideep siddula last edited by

                  @jaideep-siddula I am developing a strategy where I need to select a strike price based on a premium criteria. There are two ways of doing it. Subscribe to all strike prices of an index to get premum prices or use market data api. I am trying the first way out so that I can develop any strategy in the future that may work on premium chart

                  J D 2 Replies Last reply Reply Quote 0
                  • N
                    nitish.bane @DevPatel last edited by

                    @DevPatel Please find the cide below
                    let {WebSocketV2} = require('smartapi-javascript');
                    let web_socket = new WebSocketV2({
                    jwttoken:jwtToken, // replace this with your own credentials
                    apikey: apiKey,
                    clientcode: clientId,
                    feedtype: feedToken,
                    });
                    web_socket.connect().then((res) => {
                    let json_req = {
                    correlationID: 'abcde12345',
                    action: 1,
                    mode: 2,
                    exchangeType: 1,
                    tokens: ["99926009","99926000"]// token for nifty and bank nifty
                    };

                        web_socket.fetchData(json_req);
                        web_socket.on('tick', receiveTick);
                    

                    function receiveTick(data) { // your code to process tick data
                    }

                    D 1 Reply Last reply Reply Quote 0
                    • D
                      DevPatel @nitish.bane last edited by

                      @nitish-bane I tried this code and i got this error
                      8fff9ed6-1df0-4d97-bd66-90b50e20d756.jpeg

                      Code:

                      let { WebSocketV2 } = require('smartapi-javascript');
                      var axios = require('axios');

                      const speakeasy = require('speakeasy');
                      const secretKey = '';

                      // Generate TOTP code
                      const totpCode = speakeasy.totp({
                      secret: secretKey,
                      encoding: 'base32',
                      });

                      var axios = require('axios');
                      var data = JSON.stringify({
                      "clientcode":"K55544670",
                      "password":"3123",
                      "totp":${totpCode}
                      });

                      var config = {
                      method: 'post',
                      url: 'https://apiconnect.angelbroking.com//rest/auth/angelbroking/user/v1/loginByPassword',

                      headers : {
                      'Content-Type': 'application/json',
                      'Accept': 'application/json',
                      'X-UserType': 'USER',
                      'X-SourceID': 'WEB',
                      'X-ClientLocalIP': '192.168.43.238',
                      'X-ClientPublicIP': '106.193.147.98',
                      'X-MACAddress': ' fe80::87f:98ff:fe5a:f5cb',
                      'X-PrivateKey': 'xL9TyAO8'
                      },
                      data : data
                      };

                      axios(config)
                      .then(function (response) {
                      let a=response.data;
                      console.log(a.data.feedToken+"\n\n\n")

                      console.log(a.data.jwtToken);
                      const jwt=a.data.jwtToken
                      
                      let web_socket = new WebSocketV2({
                          jwttoken: jwt, // replace this with your own credentials
                          apikey: 'hjdhdhdg',
                          clientcode: 'K55544670',
                          feedtype: 'order_feed',
                      });
                      web_socket.connect().then((res) => {
                          let json_req = {
                              correlationID: 'abcde12345',
                              action: 1,
                              mode: 2,
                              exchangeType: 1,
                              tokens: ["99926009", "99926000"]// token for nifty and bank nifty
                          };
                      
                          web_socket.fetchData(json_req);
                          web_socket.on('tick', receiveTick);
                          function receiveTick(data) { // your code to process tick data
                          }
                      }
                      )
                      

                      })
                      .catch(function (error) {
                      console.log(error);
                      });

                      N 1 Reply Last reply Reply Quote 0
                      • N
                        nitish.bane @DevPatel last edited by

                        @DevPatel Feed type should be the feed token you receive from authentication response

                        1 Reply Last reply Reply Quote 0
                        • N
                          nitish.bane last edited by

                          Hi @Moderator_1 @Moderator_2 Can you please look into this issue? I beleive websocket only works if we subscribe to less number of tokens. There are delays observed in ticks if we subscribe to more tokens. Please correct me if I am wrong

                          M 1 Reply Last reply Reply Quote 0
                          • J
                            jaideep siddula @nitish.bane last edited by

                            @nitish-bane

                            Hi, Nitish Bane!
                            I really appreciate for sharing this knowledge. This would help me in developing a strategy on my own with this idea.
                            Thank you.
                             
                            Regards,
                            Jaideep Siddula

                            1 Reply Last reply Reply Quote 0
                            • J
                              jaideep siddula @nitish.bane last edited by

                              @nitish-bane @chetansuri @Moderator_1
                              Screenshot 2024-04-03 165203.png
                              I found this on the forum, and this was like 15 days before from the present day i.e., 3rd April, 2024.

                              1 Reply Last reply Reply Quote 0
                              • M
                                Moderator_2 @nitish.bane last edited by

                                hi @nitish-bane

                                Apologies for the delayed response.
                                We are trying to reproduce the issue from our end, but we are getting the Websocket response in ms. Will update you asap for the same. Meanwhile kindly reverify on the business logic if any applied at your end is causing th delay.

                                Regards,
                                SmartAPI Team

                                N 1 Reply Last reply Reply Quote 0
                                • D
                                  DevPatel @nitish.bane last edited by

                                  @nitish-bane sir how can i get OHLC data of any timeframe ( i am using ltp request but i think in response i got OHLC of 1 day timeframe) . How can i send request of OHLC dara for any particular timeframe.

                                  Is there any parameter for timeframe in lpt request ??

                                  Please help

                                  N M 2 Replies Last reply Reply Quote 0
                                  • N
                                    nitish.bane @Moderator_2 last edited by

                                    @Moderator_2 I am just using the tick data to create candles. It is working fine for index tokens i.e for Nifty and Bank Nifty candles are matching with angel candles. However when I subscribe to large number of tokens there is delay observed in getting the ticks. I am getting one tick as part of one websocket response. I think websocket should contain data as an array of tokens subscribed.

                                    1 Reply Last reply Reply Quote 0
                                    • R
                                      robin last edited by

                                      Iam also facing same issue when i subscribe to 20 + tokens.
                                      @admin please help.

                                      R 1 Reply Last reply Reply Quote 1
                                      • N
                                        nitish.bane @DevPatel last edited by

                                        @DevPatel You need to use historical data or use getCandleData method from sdk.
                                        getCandleData({
                                        "exchange": exchange,
                                        "symboltoken": symboltoken,
                                        "interval": interval,
                                        "fromdate": fromdate,
                                        "todate": todate
                                        })

                                        1 Reply Last reply Reply Quote 0
                                        • D
                                          DevPatel @nitish.bane last edited by

                                          @nitish-bane sir i am also developing a strategy where I need to select a strike price based on a premium price category. How can i do that ? any idea. Please help…..

                                          1 Reply Last reply Reply Quote 0
                                          • R
                                            robin @robin last edited by

                                            @robin Iam facing same issue daily

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post