Skip to main content
Question
FYERS API
Asked a question 2 months ago

What is the correct way to obtain order update as well as ticks on websocket in Python? Please share the sample working code. For us not receiving the order updates on websocket

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

Hi,
Can you try the below code,

from fyers_api.Websocket import ws

 

 

def run_process_order_update(access_token):

   data_type = "orderUpdate"

   fs = ws.FyersSocket(access_token=access_token,log_path="/home/user/logs")

   fs.websocket_data = custom_message

   fs.subscribe(data_type=data_type)

   fs.keep_running()

 

 

def custom_message(msg):

   print (f"Custom:{msg}")

 

 

def main():

   access_token = "SPXXXXE7-100:eyJ0eXAiOiJK***.eyJpc3MiOiJhcGkuZnllcnM***.IzcuRxg4tnXiULCx3***"

   run_process_order_update(access_token)

 

 

if __name__ == '__main__':

 main()