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 FourPercentSimulationTest() { var historicalCpi = new List <double>() { 1, 1.02 }; var historicalReturns = new List <double>() { .06, -.06 }; var sim = new StaticSwrSimulation(historicalReturns, historicalCpi, 0.04); sim.RunSimulation(100); Assert.AreEqual(91.8192, sim.HistoricalAccountBalance.Last(), 0.001); }
public void Run() { int yearsOfRetirement = DeathAge - RetirementAge; int numberOfSimulations = VwelxHistoricalReturns.Count - yearsOfRetirement; var simList = new List <StaticSwrSimulation>(); for (int i = 0; i < numberOfSimulations; i++) { var historicalReturns = VwelxHistoricalReturns.Select(_ => _ / 100).Reverse().Skip(i).Take(yearsOfRetirement); var historicalCpi = HistoricalCpi.Select(_ => _ / 100).Skip(i).Take(yearsOfRetirement); var staticSwrSim = new StaticSwrSimulation(historicalReturns, historicalCpi, 0.04); staticSwrSim.RunSimulation(StartingAmount); simList.Add(staticSwrSim); } 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)); } System.Console.WriteLine("Num payments left:"); foreach (var sim in simList) { var lastPayment = sim.HistoricalWithdrawalAmount.Last(); var finalBalance = sim.HistoricalAccountBalance.Last(); System.Console.WriteLine(finalBalance / lastPayment); } }