get_rolling_cagr
- AssetList.get_rolling_cagr(window=12, real=False)
Calculate rolling CAGR for each asset.
Compound annual growth rate (CAGR) is the rate of return that would be required for an investment to grow from its initial to its final value, assuming all incomes were reinvested.
Inflation adjusted annualized returns (real CAGR) are shown with real=True option.
- Parameters:
- windowint, default 12
Size of the moving window in months. Window size should be at least 12 months for CAGR.
- 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 rolling CAGR and mean inflation (optionally).
See also
get_rolling_cagrCalculate rolling CAGR.
get_cagrCalculate CAGR.
get_rolling_cumulative_returnCalculate rolling cumulative return.
annual_returnCalculate annualized mean return (arithmetic mean).
Notes
CAGR is not defined for periods less than 1 year (NaN values are returned).
Examples
>>> import matplotlib.pyplot as plt
>>> x = ok.AssetList(["SPY.US", "AGG.US"], ccy="USD", inflation=True) >>> x.get_rolling_cagr(window=5 * 12).plot() >>> plt.show()
For inflation adjusted rolling CAGR add ‘real=True’ option:
>>> x.get_rolling_cagr(window=5 * 12, real=True).plot() >>> plt.show()