@@ -2497,7 +2497,7 @@ def initial_amount_pv(self) -> Optional[float]:
24972497 return self .parent .initial_amount / (1.0 + self .parent .discount_rate ) ** self .parent .period_length
24982498
24992499 def monte_carlo_wealth (
2500- self , first_value : float = 1000.0 , distr : str = "norm" , years : int = 1 , n : int = 100
2500+ self , first_value : Optional [ float ] = None , distr : str = "norm" , years : int = 1 , n : int = 100
25012501 ) -> pd .DataFrame :
25022502 """
25032503 Generate portfolio wealth indexes with cash flows (withdrawals/contributions) by Monte Carlo simulation.
@@ -2511,8 +2511,8 @@ def monte_carlo_wealth(
25112511
25122512 Parameters
25132513 ----------
2514- first_value : float, default 1000 ,
2515- Portfolio initial investment.
2514+ first_value : float, optional ,
2515+ Portfolio initial investment. If None initial_amount of Portfolio is used.
25162516
25172517 distr : {'norm', 'lognorm', 't'}, default 'norm'
25182518 Distribution type for the rate of return of portfolio.
@@ -2546,11 +2546,12 @@ def monte_carlo_wealth(
25462546 """
25472547 if distr not in ["norm" , "lognorm" , "t" ]:
25482548 raise ValueError ('distr should be "norm" (default), "lognorm" or "t".' )
2549+ fv = self .parent .initial_amount if not first_value else first_value
25492550 return_ts = self .parent .monte_carlo_returns_ts (distr = distr , years = years , n = n )
25502551 df = return_ts .apply (
25512552 helpers .Frame .get_wealth_indexes_with_cashflow ,
25522553 axis = 0 ,
2553- args = (None , None , self .parent .discount_rate , first_value , self .parent .cashflow ),
2554+ args = (None , None , self .parent .discount_rate , fv , self .parent .cashflow ),
25542555 )
25552556
25562557 def remove_negative_values (s ):
0 commit comments