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.
    • 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
                                        • N
                                          nitish.bane last edited by

                                          @Moderator_1 @Moderator_2 @admin123 Any update on the issue? I am not able to launch my strategy because of this

                                          1 Reply Last reply Reply Quote 0
                                          • A
                                            Ananth last edited by

                                            I'm also facing similar issue with feed data, In my case I subscribe to around 200 tokens (Nifty Option Script) and able to get tick data properly.

                                            But the problem is when I try to create candles out of that data, it dosen't match with angelone candles, There was a slight difference.

                                            Also there're two timestamps in websocket 2.0. exchange_timestamp & last_traded_timestamp I'm not sure which one to considered while creating candles.

                                            Though I tried both and none of them was matching with angelone candles

                                            Note:

                                            I've already tried Historical API (getCandleData) which is even worse.

                                            It gives accurate data for older candles Which means if I request for last ten 5 minutes candles the first 9 candles were good but the last candle (latest) was not matching with angelone.

                                            I absorbed that even angelone takes some time to settle down the candle data.

                                            F.e
                                            If the time is 12:00 and you request for 11:55 candle (Nifty Option Script), The received data was inappropriate, But if you request the same at 12:05, 11.55 candle should settled but 12:00 candle will be inappropriate.

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