Summarize returns group_returns(df, df.index.year) group_returns(df, [df.index.year, df.index.month])
(returns, groupby, compounded=False)
| 112 | |
| 113 | |
| 114 | def group_returns(returns, groupby, compounded=False): |
| 115 | """Summarize returns |
| 116 | group_returns(df, df.index.year) |
| 117 | group_returns(df, [df.index.year, df.index.month]) |
| 118 | """ |
| 119 | if compounded: |
| 120 | return returns.groupby(groupby).apply(_stats.comp) |
| 121 | return returns.groupby(groupby).sum() |
| 122 | |
| 123 | |
| 124 | def aggregate_returns(returns, period=None, compounded=True): |