Issue with tick data when large number of tokens are subscribed
-
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
-
@DevPatel Feed type should be the feed token you receive from authentication response
-
@nitish-bane I tried this code and i got this error
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);
}); -
@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
} -
@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
-
@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 -
@Moderator_1 @Moderator_2 @admin Can some one please help here?
-
@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.
-
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
-
@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