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

changed CAGR default preiods to 365 from 252 #302

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yarimiz
Copy link
Contributor

@yarimiz yarimiz commented Sep 6, 2023

When calculating CAGR, you are using calendar year of 365 days (see https://www.investopedia.com/terms/c/cagr.asp#:~:text=To%20calculate%20the%20CAGR%20of,one%20from%20the%20subsequent%20result.)

Using 252 periods is wrong and will produce misleading CAGR.

For a simple example:
Say the between 2022-01-01 and 2022-12-31, I turned $100 to $200.
My return is 100% and my CAGR is 100%
Using 252 periods, my CAGR would be 61.83%, which is totally wrong.

@gnzsnz
Copy link

gnzsnz commented Sep 13, 2023

this is a duplicate with PR 281

unfortunately i haven't had an answer from the maintainers. I'm currently installing quantstats from my fork

pip install git+https://github.com/gnzsnz/quantstats-cagr.git@cagr

not ideal.....

@PauloTupi10
Copy link

I agree. Use 365 days right the wrong.

@alex-muci
Copy link

alex-muci commented Dec 12, 2023

A quick patch, whilst we wait for the maintener to merge the PR, can be inserting the following lines after your import statements (incl. "import quantstats as qs"), which is probably better/faster than installing some forks:

qs_cagr = qs.stats.cagr
def temp_cagr(returns, rf=0.0, compounded=True, periods=365):
    return qs_cagr(returns, rf, compounded, periods)
qs.stats.cagr = temp_cagr

@grzesir
Copy link

grzesir commented Jan 31, 2024

Since this library no longer seems to be maintained, we have created a duplicate of it that we plan to maintain and improve over time. If you'd like to use our version check it out here: https://github.com/Lumiwealth/quantstats_lumi

Please feel free to fork and send your pull request to this new library, we will be actively monitoring the library and approving PRs

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

Successfully merging this pull request may close these issues.

5 participants