Skip to content

changed CAGR default preiods to 365 from 252#302

Closed
yarimiz wants to merge 1 commit into
ranaroussi:mainfrom
yarimiz:fix-cagr-periods
Closed

changed CAGR default preiods to 365 from 252#302
yarimiz wants to merge 1 commit into
ranaroussi:mainfrom
yarimiz:fix-cagr-periods

Conversation

@yarimiz

@yarimiz yarimiz commented Sep 6, 2023

Copy link
Copy Markdown
Contributor

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

gnzsnz commented Sep 13, 2023

Copy link
Copy Markdown

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
Copy Markdown

I agree. Use 365 days right the wrong.

@alex-muci

alex-muci commented Dec 12, 2023

Copy link
Copy Markdown

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

grzesir commented Jan 31, 2024

Copy link
Copy Markdown

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.

6 participants