I am trying to print ltp price of the symbol for which positions is open. I want the program to keep on checking for active symbol and print there ltp. The below program fails if there is a change in position symbol. I think so the kws.close() is giving the issue
If you want data for new tokens then just call subscribe again, you don't have to close connection for that. If you don't want data for existing tokens, then you can unsubscribe for old tokens and then call subscribe for new tokens.
I basically want to get the ticker data for only active positions. SO is there a better way to handle it? My approach is currently as follow > Make a new connection with the list of the current positions. (If the position is empty then the empty token list will be passed because of which there is an error) > Continuously check for the active positions and if the previous position and current position is different then unsubscribe the previous token list and subscribe to the new list.
@Gafoor, You can't subscribe to an empty list of tokens. You need to add the check. The correct way to do this is to maintain a list of tokens at your end before doing subscribe and call unsubscribe for the ones that are being removed from that list.
If you don't want data for existing tokens, then you can unsubscribe for old tokens and then call subscribe for new tokens.
I basically want to get the ticker data for only active positions. SO is there a better way to handle it?
My approach is currently as follow
> Make a new connection with the list of the current positions. (If the position is empty then the empty token list will be passed because of which there is an error)
> Continuously check for the active positions and if the previous position and current position is different then unsubscribe the previous token list and subscribe to the new list.
And this approach is not working properly.
You can't subscribe to an empty list of tokens. You need to add the check.
The correct way to do this is to maintain a list of tokens at your end before doing subscribe and call unsubscribe for the ones that are being removed from that list.