-
-
Notifications
You must be signed in to change notification settings - Fork 855
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
Suggestion for Improving the CAGR Calculation in Your Package #359
Comments
Awesome! It took me days to weeks to debug my shit here inside my framework im building, and then out of the sudden;
Popped up over and over - i thrown everything apart, besides turn of Quantstats. Then, out of sudden this happend;
Your fix is just my lifesaver right now, over spend another couple hours figure this out. Many thanks! <3 |
Has this issue been fixed? I am still seeing incorrect CAGRs due to my data being weekly data and quantstats recognizing only daily data. |
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 |
Dear
I hope this email finds you well. I have been using your [package name] and find it incredibly useful for my work. However, I encountered an issue with the cagr function that I believe could be improved.
Currently, the calculation of years in the cagr function is performed as follows:
years = (returns.index[-1] - returns.index[0]).days / periods
This method assumes that the periods parameter represents the number of days in a year (e.g., 252 for trading days), but it doesn't account for cases where the number of returns may not span the entire period or if there are missing days in the time series. This can lead to inaccurate results, especially in time series with irregular data points.
I suggest modifying the calculation of years to:
years = len(returns) / periods
This approach uses the length of the returns series to calculate the total number of periods, which provides a more accurate estimation of the years, especially when dealing with incomplete data.
Here's the revised version of the cagr function:
def cagr(returns, rf=0.0, compounded=True, periods=252):
"""
Calculates the communicative annualized growth return (CAGR%) of access returns
I believe this adjustment will enhance the accuracy and robustness of the CAGR calculation in various scenarios.
Thank you for your time and for maintaining such a valuable package. I look forward to your thoughts on this suggestion.
Best regards,
yuxue wang
wangyx0629@nepu.edu.cn
The text was updated successfully, but these errors were encountered: