In reports.py, the function metrics have the parameter periods_per_year=252. But this parameter is not passed down to CAGR calculation:
metrics["CAGR﹪%"] = _stats.cagr(df, rf, compounded) * pct in line 839.
Thus, when using the quantstats.reports function (full/html/basic) with non-default periods_per_year parameter (e.g. 365), the CAGR calculation will be incorrect.
Similarly on Calmar Ratio calculation, where in line 926 of reports.py is written as follow:
metrics["Calmar"] = _stats.calmar(df, prepare_returns=False)
No periods_per_year parameter is passed, making the Calmar Ratio calculation becomes incorrect.
The function stats.calmar also does not expect to receive periods parameter, but calmar ratio calculation requires CAGR. On stats.py line 572:
def calmar(returns, prepare_returns=True):
"""Calculates the calmar ratio (CAGR% / MaxDD%)"""
if prepare_returns:
returns = _utils._prepare_returns(returns)
cagr_ratio = cagr(returns)
max_dd = max_drawdown(returns)
return cagr_ratio / abs(max_dd)
Besides the periods parameter is not passed to CAGR calculation, the stats.calmar function is not even expecting the parameter.
To sum up, here is my proposal:
Add periods_per_year to be passed down to CAGR calculation in qs.reports.metrics
Add the parameter periods in qs.stats.calmar
In qs.stats.calmar, add periods parameter to be passed down to CAGR calculation
This will make the reports give more accurate results for non-default periods_per_year parameter. Thank you.
In reports.py, the function metrics have the parameter
periods_per_year=252
. But this parameter is not passed down to CAGR calculation:metrics["CAGR﹪%"] = _stats.cagr(df, rf, compounded) * pct
in line 839.Thus, when using the quantstats.reports function (full/html/basic) with non-default
periods_per_year
parameter (e.g. 365), the CAGR calculation will be incorrect.Similarly on Calmar Ratio calculation, where in line 926 of reports.py is written as follow:
metrics["Calmar"] = _stats.calmar(df, prepare_returns=False)
Noperiods_per_year
parameter is passed, making the Calmar Ratio calculation becomes incorrect.The function stats.calmar also does not expect to receive
periods
parameter, but calmar ratio calculation requires CAGR. On stats.py line 572:Besides the
periods
parameter is not passed to CAGR calculation, the stats.calmar function is not even expecting the parameter.To sum up, here is my proposal:
periods_per_year
to be passed down to CAGR calculation in qs.reports.metricsperiods
in qs.stats.calmarperiods
parameter to be passed down to CAGR calculationThis will make the reports give more accurate results for non-default
periods_per_year
parameter. Thank you.