#!/usr/bin/perl ## ## Oldham, Jeffrey D. ## 2000Apr30 ## CS3352 ## Program to Run the C++ Financial Engine Simulation ## Following is Perl code to run the simulation program. First, we ## use variables to establish values for all the parameters. Then, we ## build the command-line using these parameter values. ## This particular example has a for loop to cycle through different ## possible values for the large-company stock allocation. Write your ## own C-style for loop for your experiments. Be sure to add '$' to ## the beginning of variable names. You can also modify the print ## statement in the heart of the loop. ## Be sure to make the Perl script executable, using a command like ## "chmod +x runSimulations.pl". Enjoy. # Program Name $ProgramName = "./financial"; # Monetary Amounts $InitialAmount = 0; $IncrementAmount = 100; $InflatedIncrement = 1; # true $FinancialTarget = 0; $FinancialTargetInflation = 1; # true # Time Periods $TimeFrame = 300; # in months $IncrementTimePeriod = 12; # in months # Asset Allocations $AgeVaryingAllocation = 0; # false $AgeFormula = 1; # used only if age-varying formula $Age = 25; # used only if age-varying formula $LargeCoStocks = 100; # used only if not age-varying formula $LTGovtBonds = 0; # used only if not age-varying formula $ITGovtBonds = 0; # used only if not age-varying formula $USTreasury = 0; # used only if not age-varying formula # Taxes $TaxesP = 0; # false $CapGainsTaxRate = 20; # used only if using taxes $OrdinaryIncomeTaxRate = 28; # used only if using taxes $AssetHoldingPeriod = 60; # in months; used only if using taxes # Sensitivity Analysis $MonthlyModificationRate = -0.10; # i.e., -0.10% # Historical Return Rate Files $LargeCoStockCapAppr = "lcoca"; $LargeCoStockIncome = "lcoin"; $LTGovtBondsCapAppr = "ltgbca"; $LTGovtBondsIncome = "ltgbin"; $ITGovtBondsCapAppr = "itgbca"; $ITGovtBondsIncome = "itgbin"; $TreasuryFile = "trto"; $InflationFile = "cpi"; # Run the Simulations. for ($LargeCoStocks = 100; $LargeCoStocks >= 0; $LargeCoStocks -= 25) { $USTreasury = 100-$LargeCoStocks; # build the command line $CommandLine = $ProgramName; $CommandLine = join(' ', $CommandLine, $InitialAmount, $IncrementAmount, $InflatedIncrement, $FinancialTarget, $FinancialTargetInflation); $CommandLine = join(' ', $CommandLine, $TimeFrame, $IncrementTimePeriod); if ($AgeVaryingAllocation) { $CommandLine = join(' ', $CommandLine, $AgeVaryingAllocation, $AgeFormula, $Age); } else { $CommandLine = join(' ', $CommandLine, $AgeVaryingAllocation, $LargeCoStocks, $LTGovtBonds, $ITGovtBonds, $USTreasury); } if ($TaxesP) { $CommandLine = join(' ', $CommandLine, $TaxesP, $CapGainsTaxRate, $OrdinaryIncomeTaxRate, $AssetHoldingPeriod); } else { $CommandLine = join(' ', $CommandLine, $TaxesP); } $CommandLine = join(' ', $CommandLine, $MonthlyModificationRate); $CommandLine = join(' ', $CommandLine, $LargeCoStockCapAppr, $LargeCoStockIncome, $LTGovtBondsCapAppr, $LTGovtBondsIncome, $ITGovtBondsCapAppr, $ITGovtBondsIncome, $TreasuryFile, $InflationFile); $CommandLine .= " |"; # run an individual simulation open(ANSWER, $CommandLine) or die("Failed to run the simulation."); while () { ($Success, $Probability, $Average, $StandardDeviation) = split; print("LargeCoStocks = $LargeCoStocks\t", join("\t", $Probability, $Average, $StandardDeviation), "\n"); } close(ANSWER); die("Failed to finish the simulation") if $?; }