I am using the WebSocketHandler
in thefirstock
library and have successfully subscribed to two symbols (Nifty Bank
and Nifty 50
) at the start. However, I want to dynamically add more symbols after the WebSocket is already running.
Right now, my code looks like this:
handler = thefirstock.WebSocketHandler("PV0013")
listOfTradingSymbol = ["Nifty Bank", "Nifty 50"]
def subscribe_feed_data(data):
print(data)
thread = thefirstock.websocket_connection(
handler,
listOfTradingSymbol,
socket_connection=1,
activate_sub_feed=True,
callback_sub_feed=subscribe_feed_data,
run_in_background=True
)
if thread:
thread.join()
Could you please guide me on how I can add more symbols to the WebSocket in real-time without restarting the connection?
Looking forward to your response.
Best regards,
Akash Yadav