Subscribing / Unsubscribing a new instrument during runtime

DA1077
I have already posted one query related to this topic earlier. In that thread I was clarified as below
"
You can subscribe for any token any time during the execution. Consider you already have a connection and getting ticks for RELIANCE and HDFCBANK, you can subscribe to TATASTEEL as follows,

Ticker.Subscribe("TATASTEEL")

The same rule applies to unsubscribe as well.
"

However I tried subscribing today during execution time and getting a error message from Kite saying "Invalid 'mode' message."

The two steps In my code are -

_ticker.Subscribe(SubscribeArray);
_ticker.SetMode(SubscribeArray, "QUOTE");

I verified that the ticker is connected and the Instrument Id array has valid token Ids. Please clarify on the error the error message.

  • DA1077
    Request you to please provide an update.
  • sujith
    Kite Ticker only accepts the instrument tokens. You can subscribe and unsubscribe to the token on the go.
    Please go through the API documentation to know more about Syntax.
  • DA1077
    Missed to clarify earlier -
    SubscribeArray is an array of type uint[] and contains 20 instrumentIds.

    code used is as below

    _ticker.Subscribe(SubscribeArray );
    _ticker.SetMode(SubscribeArray , Constants.MODE_QUOTE);


    Some InstrumentIds available in SubscribeArray , as I can see in debug mode are -

    3329
    5633
    41729
    70401

    And so on.

    But the code is getting error saying -

    "Error parsing instrument tokens."

  • DA1077
    Please provide an update on this
  • sujith
    Can you try using UInt32 array for tokens?
  • DA1077
    Tried that also. Same error message -

    "Error parsing instrument tokens."
  • DA1077
    Provide an Update pls.
  • sujith
    You can refer to the example here.
  • DA1077
    I have already referred that example !

    NOTE : The query clearly deals with Array and not an individual element.

    When I pass a single instrument ID the subscription is working fine and ticks are coming. The issue is coming up when an array of Instrument Ids are passed. Few months ago my same solution worked fine when array of Instrument Ids are passed and suddenly now it stopped working. What has changed so that Kite API no longer accepting array of Instrument IDs ?

    Can you check at your end and check whats wrong with array as subscription input ?

    Need to sort this out asap.
  • sujith
    We haven't changed the behavior.
    I just tried with the following and it seems to be working fine.
    {"a":"mode","v":["full",[265,256265,54177543,54177799]]}
  • DA1077
    Can you please check and let me know under which condition at your end below error message is thrown -

    "Error parsing instrument tokens."

    We are getting this message on some occasions and on other occasion the subscription is connecting.

    Dot net code used is as below where TradableInstruments is an uint[] array.

    _ticker.Subscribe(TradableInstruments);
    _ticker.SetMode(TradableInstruments, Constants.MODE_FULL);
  • tonystark
    @DA1077 There are two common instances when this can happen. One is when you send tokens in a different format like String. But that won't happen here because the library accepts only integers. Second is when you send an empty list of tokens. This issue was present in the initial version of the library. But not in the current production version which is 3.0.1.0.

    Can you check which version you are using? If you are not in the latest version try upgrading it. Otherwise please post a simple complete example that can reproduce this error. We will check.
  • DA1077
    My version is 3.0.0.0. I don't see a link for the version 3.0.1.0. The link https://github.com/zerodhatech/dotnetkiteconnect/releases/download/3.0.0beta2/KiteConnect.dll available on github also has a version 3.0.0.0. Request you to please share the link from where I can download version 3.0.1.0
  • tonystark
    You should use the official NuGet releases instead. You can find the package here and installation steps here.
Sign In or Register to comment.