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’
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.