Get nearest Expiry for the index options

vishwas
Hi Kite Team,
Is there any way to determine the next nearest expiry f or any of the index options. Currently we need to form the symbol name based on expiry day manually.
I was thinking if there is way to fetch nearest expiry.

Please guide.
Thank you
Tagged:
  • rakeshr
    Is there any way to determine the next nearest expiry f or any of the index options
    Go through this thread.
  • vishwas
    Hi @rakeshr i read it through.
    But my question here is not to which day is which expiry. That's easy. M asking zerodha API to give us near by expiry of any index automatically rather we go and form a string by coding for date or day i.e,"BANKNIFTY24103"
    .
    We already see expiry and strikes in zerodha kite as we type in a strike, so we need that information via API. Thats what m asking for.
    Thanks
  • sujith
    @vishwas,
    You don't have to guess, you can fetch instruments master from the API and do all the operations on the app or frontend.
  • MAG
    If you know the dates, all you need is these three cli commands
    curl "https://api.kite.trade/instruments" > instrumentlist.csv 
    cat instrumentlist.csv | grep NFO-OPT | grep -i "BANKNIFTY" | grep -vE "MIDCPNIFTY|FINNIFTY" |grep '2024-01-03'
    cat instrumentlist.csv | grep NFO-OPT | grep -i "NIFTY" | grep -vE "MIDCPNIFTY|FINNIFTY" |grep '2024-01-04'
    Replace the datestring YYYY-MM-DD with the desired date.
  • vishwas
    Thank you @sujith and @MAG . This really helped. Much appreciated.!!!
  • vishwas
    Just to add on to same query, Is there a way to get Nifty 50 stocks (50 only) or Nifty 100, NIFTY BANK stocks? The stocks which are forming a specific Index? This will be of help.
  • MAG
    @vishwas This is not possible via the API.
    For this you have to generate your own maps based on data from nse website in the market data section
    https://www.nseindia.com/market-data/live-market-indices
Sign In or Register to comment.