ranaroussi / quantstats

Portfolio analytics for quants, written in Python
Apache License 2.0
4.82k stars 841 forks source link

Error - win_year / periods_per_year not passed to CAGR function #307

Open diegoturing opened 1 year ago

diegoturing commented 1 year ago

In line 839 of the file 'reports.py' the function '_stats.cagr' is called without passing the periods per year defined in the main call:

metrics["CAGR﹪%"] = _stats.cagr(df, rf, compounded) * pct

This causes the CAGR to always be calculated with the default periods per year (252), which leads to errors in the calculation when using other periods. It should be solved with:

metrics["CAGR﹪%"] = _stats.cagr(df, rf, compounded, periods=win_year) * pct

yarimiz commented 1 year ago

Duplicate of https://github.com/ranaroussi/quantstats/issues/291

Unfortunately, @ranaroussi is merging PR relatively slowly so this still is an active bug although a PR is available

BlackArbsCEO commented 10 months ago

I was coming to report the same error. I'm not sure it's a duplicate because the periods parameter is not being passed at all whereas the other issue recommends using 365 as the default number of periods if I understand correctly.