get_cagr
- AssetList.get_cagr(period=None, real=False)
Calculate the expanding Compound Annual Growth Rate (CAGR) time series for each asset.
The expanding CAGR at each month is the annualized rate of return required for the investment to grow from its initial value to its value at that month, assuming all incomes were reinvested. The last row contains the CAGR over the full selected period.
Inflation adjusted annualized returns (real CAGR) are shown with real=True option. Annualized inflation is calculated for the same period if inflation=True in the AssetList.
- Parameters:
- periodint, default None
CAGR trailing period in years. If None, use the full available period.
- realbool, default False
CAGR is adjusted for inflation (real CAGR) if True. AssetList should be initiated with inflation=True for real CAGR.
- Returns:
- DataFrame
Time series of expanding CAGR for each asset and annualized inflation (if inflation=True in AssetList and real=False).
See also
get_rolling_cagrCalculate rolling CAGR.
get_cumulative_returnCalculate expanding cumulative return.
Notes
CAGR is not defined for periods less than 1 year. The first 11 rows are filled with NaN values.
Examples
>>> x = ok.AssetList(["SPY.US"], ccy="USD", inflation=True) >>> x.get_cagr(period=5).tail() SPY.US USD.INFL 2024-08 0.137419 0.030126 2024-09 0.144211 0.031120 2024-10 0.150951 0.032150 2024-11 0.146517 0.031044 2024-12 0.151012 0.029504
The last row contains the CAGR values over the full selected period.
To get inflation adjusted annualized return (real CAGR) add real=True option:
>>> x = ok.AssetList(["EURUSD.FX", "CNYUSD.FX"], inflation=True) >>> x.get_cagr(period=5, real=True).tail()