Token Subscription

DM2290
Hi @rakeshr,

Can the list of tokens be provided only explicitly? When I write the following code in ticker.subscribe, it works -

var items = [15020290, 15020034, 877057]; //NIFTY23NOV19600PE, NIFTY23NOV19600CE, TATAPOWER
ticker.subscribe(items);
ticker.setMode(items);

but when for the same result, I assign a variable, it does not -

ticker.subscribe(global.tokenSubscriptionList);
ticker.setMode(ticker.modeLTP, global.tokenSubscriptionList);
// where global.tokenSubscriptionList is an array with values - 15020290, 15020034, 877057
Tagged:
  • sujith
    You can check the typeOf before subscribe and print the list as well before subscribe.
  • DM2290
    Hi @sujith,

    Yes I tried that and the typeOf shows up as object for both. But

    ticker.subscribe(global.tokenSubscriptionList);
    ticker.setMode(ticker.modeLTP, global.tokenSubscriptionList);

    is not working i.e. the ticks are not being returned.
  • DM2290
    DM2290 edited November 2023
    Option 1 -

    global.tokenSubscriptionList = [];

    global.tokenSubscriptionList.push('15020290')
    global.tokenSubscriptionList.push('15020034')
    global.tokenSubscriptionList.push('877057')

    console.log (global.tokenSubscriptionList + " global variable");
    //returns 15020290,15020034,877057 global variable

    Option 2 -
    var items = [15020290, 15020034, 877057];
    console.log (items + " items variable");
    //returns 15020290,15020034,877057 items variable

    but Option 1 does not trigger onTicks call at all whereas Option 2 does as expected.
  • DM2290
    @sujith
    Finally, it worked with
    global.tokenSubscriptionList.push(parseInt(15020290))

    The subscribe method expects only Integer type I guess.
This discussion has been closed.