Hi,
I'm able to retrive historical data but don't know why macd value is bit off, not matching angel macd value.
can you please guide why is that so ?
def calculate_macd(df, short_window=12, long_window=26, signal_window=9):
df['EMA_12'] = df['close'].ewm(span=short_window, adjust=False).mean()
df['EMA_26'] = df['close'].ewm(span=long_window, adjust=False).mean()
df['MACD'] = df['EMA_12'] - df['EMA_26']
df['Signal_Line'] = df['MACD'].ewm(span=signal_window, adjust=False).mean()
return df
candle_data = hist_data(["HDFCBANK", "HCLTECH", "AXISBANK", "ICICIBANK"], 10, "ONE_MINUTE", instrument_list)
Apply MACD calculation to each ticker's data
for ticker, df in candle_data.items():
candle_data[ticker] = calculate_macd(df)