okama.PortfolioDCF.plot_forecast_monte_carlo

PortfolioDCF.plot_forecast_monte_carlo(backtest=True, figsize=None)

Plot Monte Carlo simulation for portfolio future wealth indexes optionally together with historical wealth index.

Wealth index (Cumulative Wealth Index) is a time series that presents the value of portfolio over time period considering cash flows (portfolio withdrawals/contributions).

Random wealth indexes are generated according to a given distribution.

Parameters:
backtestbool, default ‘True’

Include historical wealth index if ‘True’.

figsize(float, float), optional

Width, height in inches. If None default matplotlib figsize value is used.

Returns:
None

Examples

>>> import matplotlib.pyplot as plt
>>> pf = ok.Portfolio(assets=['SPY.US', 'AGG.US', 'GLD.US'], weights=[.60, .35, .05], rebalancing_period='year')
>>> # Set Monte Carlo parameters
>>> pf.dcf.set_mc_parameters(distribution="norm", period=50, number=200)
>>> # set cash flow parameters
>>> ind = ok.IndexationStrategy(pf)  # create cash flow strategy linked to the portfolio
>>> ind.initial_investment = 10_000  # add initial investment to cash flow strategy
>>> ind.amount = -500  # set withdrawal size
>>> ind.frequency = "year"  # set withdrawal frequency
>>> pf.dcf.cashflow_parameters = ind  # assign cash flow strategy to portfolio
>>> pf.dcf.plot_forecast_monte_carlo(backtest=True)
>>> plt.yscale("log")  # Y-axis has logarithmic scale
>>> plt.show()
../_images/okama-PortfolioDCF-plot_forecast_monte_carlo-1.png