get_rolling_cumulative_return

Portfolio.get_rolling_cumulative_return(window=12, real=False)

Calculate rolling cumulative return.

The cumulative return is the total change in the portfolio price.

Parameters:
windowint, default 12

Size of the moving window in months.

realbool, default False

Cumulative return is adjusted for inflation (real cumulative return) if True. Portfolio should be initiated with Inflation=True for real cumulative return.

Returns:
DataFrame

Time series of rolling cumulative return and inflation (optional).

Examples

>>> pf = ok.Portfolio(
...     ["SPY.US", "AGG.US", "GLD.US"],
...     weights=[0.6, 0.35, 0.05],
...     rebalancing_strategy=ok.Rebalance(period="year"),
... )
>>> pf.get_rolling_cumulative_return(window=24, real=True)
         portfolio_9012.PF
2006-11           0.125728
2006-12           0.104348
2007-01           0.129601
2007-02           0.110680
2007-03           0.132610
                    ...
2021-03           0.263755
2021-04           0.275474
2021-05           0.322736
2021-06           0.264963
2021-07           0.273801
[177 rows x 1 columns]