MCPcopy
hub / github.com/ranaroussi/quantstats / group_returns

Function group_returns

quantstats/utils.py:114–121  ·  view source on GitHub ↗

Summarize returns group_returns(df, df.index.year) group_returns(df, [df.index.year, df.index.month])

(returns, groupby, compounded=False)

Source from the content-addressed store, hash-verified

112
113
114def 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
124def aggregate_returns(returns, period=None, compounded=True):

Callers 1

aggregate_returnsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected