I have the following list of stocks:
For each one I would like to separate by day of month as this explanatory drawing:
With this separation I can perform the cumulative return for each day and separate by max and min cumulative returns for each stock symbol.
I am doing the following (example from another stock list) from SO: Call a report from a dictionary of dataframes :
data_dict = dict() # create an empty dict here
for k, df in df_dict.items():
df_dict[k]['Return %'] = df.iloc[:, 0].pct_change(-1)*100
# aggregate the max and min of Return
mm = df_dict[k]['Return %'].agg(['max', 'min'])
# add it to the dict, with ticker as the key
data_dict[k] = {'max': mm.max(), 'min': mm.min()}
# convert to a dataframe if you want
mm_df = pd.DataFrame.from_dict(data_dict, orient='index')
# display(mm_df)
max min
aapl 8.70284 -4.90070
msft 6.60377 -4.08443
This results in a linear analysis of the stocks in the list and do not separate by day as I wish to do as per drawing above..
Question:
- How can I insert a step to split by day of month and then perform the above code?