public void Run() { int yearsOfRetirement = DeathAge - RetirementAge; int numberOfSimulations = VwelxHistoricalReturns.Count - yearsOfRetirement; var simList = new List <DynamicSwrSimulation>(); for (int i = 0; i < numberOfSimulations; i++) { var historicalReturns = VwelxHistoricalReturns.Select(_ => _ / 100).Reverse().Skip(i).Take(yearsOfRetirement); var dynamicSwrSim = new DynamicSwrSimulation(historicalReturns, RetirementAge, DeathAge); dynamicSwrSim.RunSimulation(StartingAmount); simList.Add(dynamicSwrSim); } System.Console.WriteLine("HistoricalAccountBalance"); foreach (var sim in simList) { System.Console.WriteLine(String.Join(',', sim.HistoricalAccountBalance)); } System.Console.WriteLine("HistoricalWithdrawalAmount"); foreach (var sim in simList) { System.Console.WriteLine(String.Join(',', sim.HistoricalWithdrawalAmount)); } }
public void Run() { var historicalReturns = VwelxHistoricalReturns.Select(_ => _ / 100).Reverse().ToList(); var dynamicSwrSim = new DynamicSwrSimulation(historicalReturns, 40, 100); var fourPercentSim = new StaticSwrSimulation(historicalReturns, HistoricalCpi, 0.04); var threePercentSim = new StaticSwrSimulation(historicalReturns, HistoricalCpi, 0.03); dynamicSwrSim.RunSimulation(StartingAmount); fourPercentSim.RunSimulation(StartingAmount); threePercentSim.RunSimulation(StartingAmount); System.Console.WriteLine("Dynamic SWR"); System.Console.WriteLine("Historical account balance:"); foreach (var item in dynamicSwrSim.HistoricalAccountBalance) { System.Console.WriteLine(item); } System.Console.WriteLine("Historical withdrawals:"); foreach (var item in dynamicSwrSim.HistoricalWithdrawalAmount) { System.Console.WriteLine(item); } System.Console.WriteLine(); System.Console.WriteLine("4% SWR"); System.Console.WriteLine("Historical account balance:"); foreach (var item in fourPercentSim.HistoricalAccountBalance) { System.Console.WriteLine(item); } System.Console.WriteLine("Historical withdrawals:"); foreach (var item in fourPercentSim.HistoricalWithdrawalAmount) { System.Console.WriteLine(item); } System.Console.WriteLine(); System.Console.WriteLine("3% SWR"); System.Console.WriteLine("Historical account balance:"); foreach (var item in threePercentSim.HistoricalAccountBalance) { System.Console.WriteLine(item); } System.Console.WriteLine("Historical withdrawals:"); foreach (var item in threePercentSim.HistoricalWithdrawalAmount) { System.Console.WriteLine(item); } }
public void DynamicSwrSimulationTest() { var historicalReturns = new List <double>() { .06, -.06 }; var sim = new DynamicSwrSimulation(historicalReturns, 40, 100); sim.RunSimulation(100); Assert.AreEqual(90.9661312, sim.HistoricalAccountBalance.Last(), 0.001); }