Websockket connection Instrument key not found in data dictonary

I am writing algo using upstox web socket to pull live option chain data and perticular LTP and spot price. for this i need to use instrument key which is provided in excel (I think this is getting refreshed on daily basis). Used following link to download excel and extract required instrument key, however i am getting following error. It is not able to find specific instrument key in data dictionary. Any help is really appreciated.

URL to download instrument key excel.

Error Message
[Running] python -u “c:\Python Source\web_socket_date.py”
Connection established
Traceback (most recent call last):
File “c:\Python Source\web_socket_date.py”, line 118, in
PE_ltp = data_dict[‘feeds’][‘NSE_FO|72924’][‘ff’][‘marketFF’][‘ltpc’][‘ltp’]
KeyError: ‘NSE_FO|72924’


Thank you for reaching out.

I’ve checked and the instrument key seems to be functioning properly. Could you ensure that the information is being provided in the correct format?

For guidance, this gist might be helpful as a starting point - Upstox API - Market Feeder - Sample for Dynamic Subscription · GitHub


Shanmu, thanks for response.

Yes, Instrument key is present.
There are four instrument keys in my strategy, what happening is every response is not returning data for all the four. Sometimes it is giving LTP for 3 keys and sometime for 4 keys. May be, if there is no price change it is not returning instrumeny key in the feed. Please confirm?


Exactly, that’s the functionality of the feeder. Our goal is to stream updates in real-time as they occur, rather than sending the entire payload for all instrument_keys every time.

Thank you!