I am having issues with following code which compares prev day high with current close of 15 min candle

Viewed 20

so what should I do to improve the code

from traceback import print_tb
import pandas as pd
import numpy as np
import pandas_ta as tax
import talib
import datetime as dt
df = pd.read_excel('ADANIENT--15minute.xlsx')

df["max"] = talib.MAX(df['close'], 15)
df['sma'] = tax.sma(df['volume'], 21)
day_high = df.groupby(pd.to_datetime(df['date']).dt.date)['high'].max()
day_high = pd.DataFrame({'date': day_high.index, 'high': day_high.values})
print(day_high['date'])
for i in range(len(df)):

    prev_day = day_high['date'][i] - pd.to_timedelta(1, unit='d')
    prev_day = pd.to_datetime(prev_day).date()
    df.loc[df['close'][i] >= day_high.loc[day_high['date']
                                          == prev_day, ['high']], ['day']] = 'BUY'
    print(df['day'])

the above code gives an error of none of index are in the index

0 Answers
Related