get_cumulative_return

Portfolio.get_cumulative_return(period=None, real=False)

Calculate the expanding cumulative return time series for the portfolio.

The cumulative return is the total compounded change in the portfolio 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 Portfolio.

Parameters:
periodstr or int or None, default None

Trailing period in years. 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. Portfolio should be initiated with Inflation=True for real cumulative return.

Returns:
DataFrame

Time series of cumulative return for the portfolio and cumulative inflation (if inflation=True in Portfolio and real=False).

Examples

>>> pf = ok.Portfolio(["BTC-USD.CC", "LTC-USD.CC"], weights=[0.8, 0.2], last_date="2021-03")
>>> pf.get_cumulative_return(period=2, real=True).tail()
         portfolio_6232.PF
2020-11           3.624500
2020-12           5.125700
2021-01           7.328400
2021-02           8.612000
2021-03           9.393810

The last row contains the cumulative return over the full selected period.