okama.MonteCarlo

class MonteCarlo(parent)

Bases: object

Monte Carlo simulation parameters for investment portfolio.

Parameters:
parentPortfolioDCF

Parent PortfolioDCF instance.

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='t',
... 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-MonteCarlo-1.png

Methods & Attributes

distribution

The type of a distribution to generate random rate of return.

number

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

period

Forecast period in years for portfolio wealth index time series.

property distribution

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)

Returns:
str
property period

Forecast period in years for portfolio wealth index time series.

Returns:
int
property number

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

Returns:
int