Version 4.1.0 - Python updates
— Firstock
There is a new major feature has been released in the websockets where now the developers can run the websokcets in background on a thread.
Without Thread
from thefirstock import thefirstock
handler = thefirstock.WebSocketHandler("{userId}")
listOfTradingSymbol = ["Nifty Bank", "Nifty 50"]
def subscribe_feed_data(data):
print(data)
# Modify the websocket_connection function to accept the handler as an argument
thread = thefirstock.websocket_connection(
handler,
listOfTradingSymbol,
socket_connection=1,
activate_sub_feed=True,
callback_sub_feed=subscribe_feed_data
)
Running in background
from thefirstock import thefirstock
handler = thefirstock.WebSocketHandler("PV0013")
listOfTradingSymbol = ["Nifty Bank", "Nifty 50"]
def subscribe_feed_data(data):
print(data)
# Modify the websocket_connection function to accept the handler as an argument
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()