@@ -2497,7 +2497,7 @@ def initial_amount_pv(self) -> Optional[float]:
2497
2497
return self .parent .initial_amount / (1.0 + self .parent .discount_rate ) ** self .parent .period_length
2498
2498
2499
2499
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
2501
2501
) -> pd .DataFrame :
2502
2502
"""
2503
2503
Generate portfolio wealth indexes with cash flows (withdrawals/contributions) by Monte Carlo simulation.
@@ -2511,8 +2511,8 @@ def monte_carlo_wealth(
2511
2511
2512
2512
Parameters
2513
2513
----------
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.
2516
2516
2517
2517
distr : {'norm', 'lognorm', 't'}, default 'norm'
2518
2518
Distribution type for the rate of return of portfolio.
@@ -2546,11 +2546,12 @@ def monte_carlo_wealth(
2546
2546
"""
2547
2547
if distr not in ["norm" , "lognorm" , "t" ]:
2548
2548
raise ValueError ('distr should be "norm" (default), "lognorm" or "t".' )
2549
+ fv = self .parent .initial_amount if not first_value else first_value
2549
2550
return_ts = self .parent .monte_carlo_returns_ts (distr = distr , years = years , n = n )
2550
2551
df = return_ts .apply (
2551
2552
helpers .Frame .get_wealth_indexes_with_cashflow ,
2552
2553
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 ),
2554
2555
)
2555
2556
2556
2557
def remove_negative_values (s ):
0 commit comments