Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with cagr function in stats #356

Open
lemming78 opened this issue Jun 18, 2024 · 2 comments
Open

Issue with cagr function in stats #356

lemming78 opened this issue Jun 18, 2024 · 2 comments

Comments

@lemming78
Copy link

I believe there is a mistake in the code when the return series is monthly.

I had to amend the periods argument to 365 to get a cagr figure that made sense. I can't help further, i'm not a python developer but was looking to help on this.

def cagr(returns, rf=0.0, compounded=True, periods=365):
    """
    Calculates the communicative annualized growth return
    (CAGR%) of access returns

Could you kindly implement a fix? Total return is fine instead.

@jakewillms17
Copy link

Hey the reason they differ is because the utils_cagr function is incorrectly counting calendar days instead of trading days when identifying the annualization period.

years = (returns.index[-1] - returns.index[0]).days / periods

this method will unfortunately count calendar days, when in reality it would be more accurate to count the length of the returns object.

hopefully they fix this, I had to do this locally as I was getting incorrect CAGR's.

@grzesir
Copy link

grzesir commented Jul 30, 2024

Check out https://github.com/Lumiwealth/quantstats_lumi, which is being updated regularly. We are a fork of this library that is being maintained by Lumiwealth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants