get_cumulative_return
- AssetList.get_cumulative_return(period=None, real=False)
Calculate the expanding cumulative return time series for each asset.
The cumulative return is the total compounded change in the asset price from the start of the selected period up to and including each subsequent month. The last row contains the cumulative return over the full selected period.
Inflation adjusted cumulative returns (real cumulative returns) are shown with real=True option. Inflation data is taken from the same period if inflation=True in the AssetList.
- Parameters:
- periodstr or int or None, default None
Trailing period in years. Period should be greater than 0. None - full time cumulative return. ‘YTD’ - (Year To Date) period of time beginning the first day of the calendar year up to the last month.
- realbool, default False
Cumulative return is adjusted for inflation (real cumulative return) if True. AssetList should be initiated with inflation=True for real cumulative return.
- Returns:
- DataFrame
Time series of cumulative return for each asset and cumulative inflation (if inflation=True in AssetList and real=False).
See also
get_rolling_cagrCalculate rolling CAGR.
get_cagrCalculate CAGR.
get_rolling_cumulative_returnCalculate rolling cumulative return.
annual_returnCalculate annualized mean return (arithmetic mean).
Examples
>>> x = ok.AssetList(["MCFTR.INDX"], ccy="RUB") >>> x.get_cumulative_return(period="YTD").tail() MCFTR.INDX RUB.INFL 2024-08 0.083117 0.031241 2024-09 0.094772 0.035987 2024-10 0.118014 0.042601 2024-11 0.131562 0.046832 2024-12 0.148300 0.048500
The last row contains the YTD cumulative return values.