find_the_largest_withdrawals_size

PortfolioDCF.find_the_largest_withdrawals_size(goal, withdrawals_range=(0, 1), target_survival_period=25, percentile=20, threshold=0, tolerance_rel=0.1, iter_max=20)

Find the largest withdrawal size for Monte Carlo simulation according to a cash flow strategy.

You can find the largest withdrawal size for three goals:

  • ‘maintain_balance_pv’ to keep the purchasing power of the investments after inflation for the whole period defined in Monte Carlo parameters.

  • ‘maintain_balance_fv’ to keep the nominal size of the investments for the whole period defined in Monte Carlo parameters.

  • ‘survival_period’ to keep a positive balance for a period defined by target_survival_period.

The method works with IndexationStrategy and PercentageStrategy only.

The withdrawal size defined in cash flow strategy must be negative.

The result of finding a solution has the following parameters: - ‘success’ - whether the solution was found or not. - ‘withdrawal_abs’ - the absolute amount of withdrawal size (the best solution if found). - ‘withdrawal_rel’ - the relative amount of withdrawal size (the best solution if found). - ‘error_rel’ - characterizes how accurately the goal is fulfilled. - ‘solutions’ - the history of attempts to find solutions (withdrawal values and error level).

The algorithm uses the bisection method to find the largest withdrawal size.

Parameters:
goal{‘maintain_balance_fv’, ‘maintain_balance_pv’, ‘survival_period’}

‘maintain_balance_fv’ - the goal is to maintain the balance not lower than the nominal amount of the initial investment for the whole period defined in Monte Carlo parameters. ‘maintain_balance_pv’ - the goal is to keep the purchasing power of the investments after inflation for the whole period defined in Monte Carlo parameters. ‘survival_period’ - the goal is to keep positive balance for a period defined by ‘target_survival_period’.

withdrawals_rangetuple of (float, float), default (0, 1)

The expected range of annualized withdrawal size measured as a percentage of the Initial Investment (CashFlow.initial_investment). 0.01 stands for 1%. (0.02, 0.05) means that expected withdrawal is in range from 2% to 5% of Initial Investment. The first value is expected minimum withdrawal. The second value is expected maximum withdrawal. The search for a solution occurs only within this range.

percentileint, default 20

The percentile of Monte-Carlo simulation distribution where the goal is achieved. Percentile must be from 0 to 100. 1st or 5th percentiles are the examples of “bad” scenarios. 50th is median. 95th or 99th are optimistic scenarios.

thresholdfloat, default 0

The percentage of initial investments when the portfolio balance is considered voided. Important for the “fixed_percentage” Cash flow strategy.

target_survival_periodint, default 25

The smallest acceptable survival period. It works with the ‘survival_period’ goal only. The value must be less than the MonteCarlo.priod parameter.

iter_maxint, default 20

The maximum number of iterations to find the solution.

tolerance_relfloat, default 0.10

The allowed tolerance for the solution. The tolerance is the largest error for the achieved goal.

Returns:
Result

The result of the solution search.

Examples

>>> pf = ok.Portfolio(
...     assets=["MCFTR.INDX", "RUCBTRNS.INDX"],
...     weights=[0.3, 0.7],
...     inflation=True,
...     ccy="RUB",
...     rebalancing_strategy=ok.Rebalance(period="year"),
... )
>>> # Fixed Percentage strategy
>>> pc = ok.PercentageStrategy(pf)
>>> pc.initial_investment = 10_000
>>> pc.frequency = "year"
>>> # Assign a strategy
>>> pf.dcf.cashflow_parameters = pc
>>> # Set Monte Carlo parameters
>>> pf.dcf.set_mc_parameters(distribution="norm", period=50, mc_number=200)
>>> res = pf.dcf.find_the_largest_withdrawals_size(
...     percentile=50,
...     goal="survival_period",
...     threshold=0.05,
...     target_survival_period=25,
... )
>>> res
success                True
withdrawal_abs   -917.96875
withdrawal_rel     0.091797
error_rel           0.00442
attempts                 10
dtype: object

In the result, withdrawal_abs is the absolute value of the withdrawal (the first withdrawal value), and withdrawal_rel is the relative withdrawal size (the first withdrawal value divided by the initial investment).

If the solution was not found, it is still possible to see the intermediate steps.

>>> res.solutions
  withdrawal_abs withdrawal_rel error_rel error_rel_change
0       -10000.0              1     0.968                0
1        -5000.0            0.5     0.848            -0.12
2        -2500.0           0.25    0.6082          -0.2398
3        -1250.0          0.125   0.24816         -0.36004
4         -625.0         0.0625   0.55576           0.3076
5         -937.5        0.09375   0.00442         -0.55134