# How to find ATM for NIFTY

How to find the ATM strike for Nifty based on the LTP
Tagged:
• You can check out here or you may place an order and check the error message which shows the allowed range.
• thanks @sujith for your response....Actually i wanted to know how to fetch ATM using kiteconnect api .....for python library
• thanks @ALGO_Developer ....but your code works good for bank nifty.....i want to fetch for Nifty only....
• @tony_ dude it is real simple.. just change this from "tradingsymbol='NIFTY BANK' " to "tradingsymbol='NIFTY 50'"
• okay @ALGO_Developer so here the code---
nifty_ltp =(kite.ltp('NSE:NIFTY 50')).get('NSE:NIFTY 50').get('last_price')
nifty_ltp
Out: 15740.1
val = nifty_ltp
val2 = math.fmod(val, 100)
#print('val2', val2)
x = val - val2
abs_val = "{:.0f}".format(x) # to remove .0 string.
print('\n Identified CE ATM:',"{:.0f}".format(x))
Out: Identified CE ATM: 15700
but the current ATM should be 15750
val = nifty_ltp
val2 = math.fmod(val, 50)
val3 = 0
if val2 >= 25:
val3 = 50
else:
val3 = 0
#print('val2', val2)
x = val - val2 + val3
• yup now its correct....thanks for the logic.... @ALGO_Developer
• import math

def calculate_atm_strik(last_price, strik_def):
val1 = math.floor(last_price / strik_def) * strik_def
val2 = math.ceil(last_price / strik_def) * strik_def
return val1 if abs(last_price - val1) < abs(last_price - val2) else val2

current_atm_strik = calculate_atm_strik(45958.45, 100)
print("Current ATM Strik is:", current_atm_strik)

-----------
OUTPUT IS# Current ATM Strik is: 46000