Skip to main content
Asked a question 4 months ago

No RESPONCE / Blank Response PLEASE HELP how to get tick values from fyers_api.websocket import ws client_id=open('C:/Python310/app_id.txt','r').read() token=open('C:/Python310/token.txt','r').read().strip() access_token = client_id+":"+token data_type = 'symbolData' symbol = ['NSE:TATAMOTORS-EQ','NSE:ITC-EQ'] def custom_message(ticks): print(ticks.response) ws.FyersSocket.websocket_data = custom_message fs=ws.FyersSocket(access_token,data_type,symbol) fs.subscribe()

Join FYERS Community to pick others' brains on Trading/Investing

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

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


if __name__ == '__main__':