You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current way to calculate CAGR is incorrect. The years component should be:
total_days = len(df.index)
years = total_days / 252.
it looks like the way it is currently configured it counting weekends in the numerator but not the denominator. this understates CAGR.
thanks
def cagr(returns, rf=0.0, compounded=True, periods=252):
"""
Calculates the communicative annualized growth return
(CAGR%) of access returns
If rf is non-zero, you must specify periods.
In this case, rf is assumed to be expressed in yearly (annualized) terms
"""
total = _utils._prepare_returns(returns, rf)
if compounded:
total = comp(total)
else:
total = _np.sum(total)
**years = (returns.index[-1] - returns.index[0]).days / periods**
res = abs(total + 1.0) ** (1.0 / years) - 1
if isinstance(returns, _pd.DataFrame):
res = _pd.Series(res)
res.index = returns.columns
return res
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The current way to calculate CAGR is incorrect. The years component should be:
total_days = len(df.index)
years = total_days / 252.
it looks like the way it is currently configured it counting weekends in the numerator but not the denominator. this understates CAGR.
thanks
def cagr(returns, rf=0.0, compounded=True, periods=252):
"""
Calculates the communicative annualized growth return
(CAGR%) of access returns
Beta Was this translation helpful? Give feedback.
All reactions