I currently have a KiteTicker instance running to stream live ticks for the Nifty index. Now, I want to track live ticks for one or more Nifty option contracts during their respective trade periods (which can be different and short-lived).
Here's the design I'm considering:
Create a separate REST endpoint that handles ticks for option contracts.
Use a separate KiteTicker instance dedicated to these contracts.
Subscribe and unsubscribe to contract tokens dynamically as trades start and end.
Use only modeLTP, since I only care about the last traded price (close price behavior).
Question 1: Does this approach sound correct for use with KiteTicker?
Question 2: Do I need to manually manage the list of currently subscribed tokens, or will the KiteTicker handle that internally?
For example, if I call subscribe([token]) with a new token, will it safely add it without disturbing already subscribed tokens? Similarly, will unsubscribe([token]) remove just that one without affecting others?
You may run one ticker program that fetches data for all your strategies. Kite Ticker supports up to 3000 instruments per Websocket connection. And you may use 3 Websocket connections at a time for an api_key.
The optimal and scalable way is to create a central ticker consumer at your end a subscribe and unsubscribe as and when it is required. Kite Connect library handles the list of subscribed tokens and it will add and remove from the list of tokens as and when subscribe and unsubscribe is called. Also note that if you have set reconnection true then library handles the subscription after the reconnection as well.
Thanks, Sujith. That's very helpful. I think I will need separate ticker for contracts because there I just need modeLtp. For the existing ticker for Nifty, I'm using modeFull. It doesn't seem possible to mix and match mode in the same ticker.
The optimal and scalable way is to create a central ticker consumer at your end a subscribe and unsubscribe as and when it is required. Kite Connect library handles the list of subscribed tokens and it will add and remove from the list of tokens as and when subscribe and unsubscribe is called.
Also note that if you have set reconnection true then library handles the subscription after the reconnection as well.