Fyers Data Feed

Hi, I have created Python code based on the V3 documents. The hist api and websocket is working fine independent. But when I use them together in my live code, there is no feed coming from websocket. I need help. Can anyone screenshare with me?

response = fyers.history(data=data)

AttributeError: ‘FyersDataSocket’ object has no attribute ‘history’

In fyersApi log file, below error is coming.

{“level”:“ERROR”,“location”:“[exception:108] fyers_logger”,“message”:“‘fyToken’”,“timestamp”:“2024-02-14 13:26:12,821+0530”,“service”:“FyersDataSocket”,“exception”:“Traceback (most recent call last):\n File "C:\Users\arind\anaconda3\lib\site-packages\fyers_apiv3\FyersWebsocket\data_ws.py", line 87, in symbol_to_hsmtoken\n values["fyToken"] = data["v"]["fyToken"]\nKeyError: ‘fyToken’”,“exception_name”:“KeyError”}

{“level”:“ERROR”,“location”:“[exception:108] fyers_logger”,“message”:“‘NoneType’ object is not subscriptable”,“timestamp”:“2024-02-14 13:26:12,821+0530”,“service”:“FyersDataSocket”,“exception”:“Traceback (most recent call last):\n File "C:\Users\arind\anaconda3\lib\site-packages\fyers_apiv3\FyersWebsocket\data_ws.py", line 1327, in __symbol_conversion\n symbol_dict.update(symbol_dict, **symbol_value[0])\nTypeError: ‘NoneType’ object is not subscriptable”,“exception_name”:“TypeError”}

Hey @arindam_ghosh

As you’re trying to fetch both History and data socket at once , you will have to import both the packages for the same .

For example this is package for History - from fyers_apiv3 import fyersModel
This is the package for websocket - fyers_apiv3.FyersWebsocket import data_ws

I did that as was mentioned in the V3 document. What was required was to change the object name so that it is not the same as the hist api object.

So instead of fyers = data_ws.FyersDataSocket(…), I needed fyers_ws = data_ws.FyersDataSocket(…). This fixed the conflict.