I have 1-min ticker information of Apple in a dataframe as so:
Local time Open High Low Close Volume
0 2018-04-19 15:00:00 46.707 46.708 46.687 46.687 0.0150
1 2018-04-19 15:01:00 46.688 46.688 46.667 46.688 0.0320
2 2018-04-19 15:02:00 46.687 46.728 46.677 46.728 0.0091
3 2018-04-19 15:03:00 46.727 46.728 46.708 46.717 0.0332
4 2018-04-19 15:04:00 46.708 46.718 46.677 46.677 0.0243
I have converted the "Local time" column into datetime using pd.to_datetime(df['Local time'])
. I want to go through each day individually to backtest a strategy. But I do not know how to loop through chunks of the df one at a time defined by a change in date. I tried using some for loops but they did not work since the number of minutes traded is apparently different on some days (not 390):
index = 390 #Number of traded minutes on most days
rows = 286155 #number of rows in the dataset
for x in range(286155/390):
index = index * x
index2 = index * (x-1)
for y in df[index2:index]:
'''Strategy to be Executed for that day'''
How can I achieve what I want to do?