Update in expiry symbols

spartacus
There seems to be a change in weekly expiry symbols for bank nifty. Earlier symbols used to like 'BANKNIFTYYYM[M]D[D]Strike[PE/CE]'. Example BANKNIFTY2392046200PE.

That seems to have changed now. Now for next week's expiry i.e. of Oct 4th 2023 44500 CE option, symbol is 'BANKNIFTY23O0444500CE' instead of 'BANKNIFTY23100444500CE' as per previous logic.

I used to generate symbols from code. And this change started breaking the script with exception.

```
kiteconnect.exceptions.InputException: The instrument you are placing an order for has either expired or does not exist.
```

Should these breaking changes be communicated in advance? Or am I missing something?
  • spartacus
    Also, that is the new format now for date expiry date? How would March 04 and May 04 expiry would be written?
  • sujith
    You can refer to this thread.
  • MAG
    @spartacus
    I track banknifty and nifty options and futures. The way I prevent these issues is I do not try to generate the symbolnames in code. I use the current days instrument list as the source of truth.

    I just need three things - the latest instrumentslist, the expiry, and the segment (NSE/NFO-OPT/NFO-FUT, etc)
    Just a command line example of the above statement


    I take the latest instrument list the day after every expiry, look for the next expiry date and get the relevant NFO-OPT instruments for that expiry. And then use either redis hash or python dictionary set up a lookup table where the instrumentcode is the key and symbolname is the value. And of course all this is /can be automated.

    in my code internally all references are to instrument code and wherever symbolnames are needed I do a look up which is always instant O(1). I have never had issues with wrong/invalid symbolnames in the last few years.

    The only part where I need to be careful is generating the kite ticker subscriptionlist list in python for the instruments I want to track and retrieve ticks for. And there is a separate script for that which is again automated takes just the expiry date as a param.

    If you do it this way you wont have to worry about invalid symbolnames esp for FNO. Use the current days instruments list as the source of truth. Set up a cron to download it afresh every morning sometime between 7:30 to 9:00 am.


  • spartacus
    Thanks @MAG and @sujith will use the instruments API.
This discussion has been closed.