INCORRECT EMA(10), EMA(20) values for Banknifty Options

sridharcs
I'm getting incorrect values for EMA for banknifty options (way off the mark). Below is the code snippet. I'm using TALIB for calculating EMA.
I even printed the "close" price for each interval...they are not same as the one we see on the zerodha chart.

records = kite.historical_data(9496834,
from_date=from_date,
to_date=to_date,
interval=interval
)
df = pd.DataFrame(records)
df.drop(df.tail(1).index,inplace=True)
open = df['open'].values
close = df['close'].values
volume = df['volume'].values
ema10 = talib.EMA(close,10)
ema20 = talib.EMA(close,20)
print(ema10)
  • sridharcs
    @sujith - Can you please help with this
  • dinezh
    dinezh edited November 20
    please make sure you're comparing right token and symbol on Kite web app and on your script
  • abinthomas
    window = 10
    sma = df['close'].rolling(window=window, min_periods=window).mean()[:window]
    rest = df['close'][window:]
    df.loc[:, 'ema'] = pd.concat([sma, rest]).ewm(span=window, adjust=False).mean()
Sign In or Register to comment.