okama.PortfolioDCF.set_mc_parameters

PortfolioDCF.set_mc_parameters(distribution, period, number)

Add Monte Carlo simulation parameters to PortfolioDCF.

Parameters:
distribution: str

The type of a distribution to generate random rate of return. Allowed values for distribution: -‘norm’ for normal distribution -‘lognorm’ for lognormal distribution -‘t’ for Student’s (t-distribution)

period: int

Forecast period for portfolio wealth index time series (in years).

number: int

Number of random wealth indexes to generate with Monte Carlo simulation.

Examples

>>> import matplotlib.pyplot as plt
>>> pf = ok.Portfolio(first_date="2015-01", last_date="2024-10")  # create Portfolio with default parameters
>>> # Set Monte Carlo parameters
>>> pf.dcf.set_mc_parameters(distribution="lognorm", period=10, number=100)
>>> # Set the cash flow strategy. It's required to generate random wealth indexes.
>>> ind = ok.IndexationStrategy(pf) # create IndexationStrategy linked to the portfolio
>>> ind.initial_investment = 10_000  # add initial investments size
>>> ind.frequency = "year"  # set cash flow frequency
>>> ind.amount = -1_500  # set withdrawal size
>>> ind.indexation = "inflation"
>>> # Assign the strategy to Portfolio
>>> pf.dcf.cashflow_parameters = ind
>>> pf.dcf.use_discounted_values = False  # do not discount initial investment value
>>> # Plot wealth index with cash flow
>>> pf.dcf.wealth_index.plot()
>>> plt.show()
../_images/okama-PortfolioDCF-set_mc_parameters-1.png