I am able to get daily historical data for BANKNIFTY ( time frame 1D) .How to fetch 1 minute data and convert it into 5 mins data. I am trying to do some backtesting and want to use for algo trading and stuck here . Can someone please help.
from dhanhq import dhanhq
import pandas as pd
dhan = dhanhq("1000***","**apikey**")
#print(dhan.get_fund_limits())
#Get historical data of 7th June , 8th June and 9th June
histdata = dhan.historical_minute_charts(
symbol='BANKNIFTY',
exchange_segment='IDX_I',
instrument_type='INDEX',
expiry_code=0,
from_date='2023-06-06',
to_date='2023-06-11'
)
intdf = pd.DataFrame(histdata['data'])
print(intdf)
temp_list = []
for i in intdf['start_Time']:
temp = dhan.convert_to_date_time(i)
temp_list.append(temp)
intdf['Date'] = temp_list
print(intdf)
Currently, we only provide 1D (daily) timeframe data as part of historical data API. Hence, you will be able to get only 1 day OHLC data. In case you face any errors in that, would be happy to assist you in the same.