Skip to content

Commit

Permalink
Update stats.py - fix cagr calculation
Browse files Browse the repository at this point in the history
remove periods=252 paramter. cagr parameter done by dividing number of days by 365.
  • Loading branch information
gnzsnz authored Jul 15, 2023
1 parent fa0a91a commit cf61c8b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions quantstats/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def gain_to_pain_ratio(returns, rf=0, resolution="D"):
return returns.sum() / downside


def cagr(returns, rf=0.0, compounded=True, periods=252):
def cagr(returns, rf=0.0, compounded=True):
"""
Calculates the communicative annualized growth return
(CAGR%) of access returns
Expand All @@ -526,7 +526,7 @@ def cagr(returns, rf=0.0, compounded=True, periods=252):
else:
total = _np.sum(total)

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

res = abs(total + 1.0) ** (1.0 / years) - 1

Expand Down

0 comments on commit cf61c8b

Please sign in to comment.