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
I temporarily fixed by setting 'res' to zero when year==0:
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)
# Bug: https://github.com/ranaroussi/quantstats/issues/334
years = (returns.index[-1] - returns.index[0]).days / periods
res = abs(total + 1.0) ** (1.0 / years) - 1 if years!=0 else 0
if res and isinstance(returns, _pd.DataFrame):
res = _pd.Series(res)
res.index = returns.columns
return res
hi Team,
stats.py: res = abs(total + 1.0) ** (1.0 / years) - 1 <-- ZeroDivisionError
To reproduce, use this sample file: singlelegta_total_equity_cache_4.csv
The text was updated successfully, but these errors were encountered: