Websocket unsubscribe from instrument
-
I am able to subscribe and even send an additional instrument to be added to my subscription list. As in the example below, I first start streaming for 26000 data and after 5s, even 26009 data is sent along with 26000 data.
token = "nse_cm|26000"
ss.connect(threaded=True)
time.sleep(5)
token="nse_cm|26009
ss.send_request(token, "mw")However, I want to unsubscribe from 26000 and I'm not able to do that. The docs say (https://smartapi.angelbroking.com/docs/WebSocket) that a blank string has to be sent to unsubscribe. I tried this piece of code but I still end up getting data for both instruments. What should I do to stop getting 26000 data and only get 26009 after a certain time? I cannot kill the script and restart, this has to be done within the code.
token = "nse_cm|26000"
ss.connect(threaded=True)
time.sleep(5)
ss.send_request("", "mw")
token="nse_cm|26009
ss.send_request(token, "mw") -
hi @frog_26 please go through this thread
https://smartapi.angelbroking.com/topic/51/how-to-unsubscribe-symbol-from-websocket?_=1618296924024 -
Hi @frog_26 we cannot unsubscribe a single instrument from the websocket.
-
@admin has the unsubscribe feature been released yet?