To get the at the money (ATM) strikes of Banknifty index we will use the NSEpython module in python.

Please make sure that you have the nsepython module installed, else:

Type this in the terminal:

  • $pip install nsepython

First we will have to get the LTP of Banknifty. The following code will print the LTP:

index = (nse_index())
j=index[index.indexName == 'NIFTY BANK']
y = j['last'].values[0]
y = y.replace(',', '')
y = int(float(y))
print("\nNifty bank LTP: " + str(y))

Now to get the ATM strike:

nifty_bank = round(y/100)*100
print("Nifty bank ATM strike: "+ str(nifty_bank))
The result will look like this:

3 Comments

  1. Thanks for the nice tutorial. Sometimes it is difficult to guess the nearest ATM for a stock. Can the same code be used for strategy individual stocks too?

    1. rajista's avatar rajista says:

      you’re welcome. I think for stocks this method won’t work as we have different strike prices that can sometimes be in decimals as well. I will post another article on how to get atm strikes for stocks.

  2. Infotron's avatar Infotron says:

    I prefer two methods here.
    For ATM,
    Using Round(underlying, -2)

    But i prefer to calculate delta on all strike and sell those strikes which are near to +/- 0.5 delta

Leave a Reply