Hi Pratik,
Can you look into the below code,
from fyers_api.Websocket import ws
def run_process_foreground_symbol_data(access_token):
'''This function is used for running the symbolData in foreground
1. log_path here is configurable this specifies where the output will be stored for you
2. data_type == symbolData this specfies while using this function you will be able to connect to symbolwebsocket to get the symbolData
3. run_background = False specifies that the process will be running in foreground'''
data_type = "symbolData"
symbol = ["NSE:SBIN-EQ"] ##NSE,BSE sample symbols
fs = ws.FyersSocket(access_token=access_token,run_background=False,log_path="")
fs.websocket_data = custom_message
fs.subscribe(symbol=symbol,data_type=data_type)
fs.keep_running()
def custom_message(msg):
print (f"Custom:{msg}")
def main():
### Insert the accessToken and app_id over here in the following format (APP_ID:access_token)
access_token = "" #appid:accesstoken
run_process_foreground_symbol_data(access_token)
if __name__ == '__main__':
main()