Subscribing to more than 3000 tokens

Gjain75
I want to download ticks data for 15000 tokens, how do I unscubscribe old tokens (not more than 3000) and subscribe to new 3000 tokens (4 times in a loop) for ticks data using the same connection.

I looked at documentation, but could not figure out.

Can someone help.
  • Gjain75
    @rakeshr Mr. Rakesh Ranjan - You are a champion! You possess extraordinary talent with eagle eye for precision!

    I was going bonkers over this for over a month, got it working today.


    Thanks a million Chief, You got me out of a rabbit hole on this!



    reproducing code below, in case someone needs help on same issue in future:

    while True:
    def on_ticks(ws, ticks):
    logging.debug(f"inside while loop, Current mode: {ticks[0]['mode']}")

    for symbol, tokens in tokens_dict.items():
    # format of tokens_dict is {"symbol" : [instrument_tokens]} # symbol is name, not tradingsymbol, [instrument_tokens] is a python list
    ws.subscribe(tokens) # before kws.connect, create tokens = [some tokens] for kws.connect to work from earlier statements
    logging.info(f"downloading ticks for {symbol}")
    TickProcess(ticks)
    ws.unsubscribe(tokens)

    # kws.on_ticks = on_ticks

    def TickProcess(ticks):
    tick_data.append(ticks)
    # rest of your working on ticks goes hereon
    kws.on_ticks = on_ticks

Sign In or Register to comment.