Logic for ATM Strike

difference.append((Strike_Price - stock_price))
l = 0
neg_list = []
while l < len(difference):
if difference[l] < 0:
l += 1
l += 1
ki = (difference.index(max(neg_list))) * 10
ATM_Strike = Strike_Price[difference.index(max(neg_list))]
print(“ATM STRIKE:”)

def atm_strike(n,m):
    a = (n // m) * m
    b = a + m
    return int(b if n - a > b - n else a)

def futname(name):
    mydate = datetime.datetime.now()
    name = name+mydate.strftime("%y")+mydate.strftime("%b")+"FUT"    
    return name.upper()

def fut_ltp(var2):
    return kite.ltp(var5)[var5]['last_price']



Here is how we do for BankNIFTY. Please write full code. Otherwise, it looks like junk. kite.ltp() is a function of kite connect to fetch LTPs.

How is m decided, is it the difference between two Strike like in case of BN it is 100, in case of Nifty its 50 ?

1 Like
  1. Scan the Option chain.
  2. Take the strike price nearest to the LTP.
  3. Take the strike price second nearest to the LTP.
  4. If 2=3, then take the strike price third nearest to the LTP.

m is difference between these two strike prices!