static void Main(string[] args) { //input needed information from keyboard Console.WriteLine("Input spot price of underlying asset:"); double spotPrice = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Input option strike price:"); double strikePrice = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Input time to maturity of this option:"); double timeToMaturity = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Input drift parameter for brownian motion:"); double Mu = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Input volatility parameter for brownian motion:"); double sigma = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Input number of scenarios generated by MC simulation:"); int numOfScenarios = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input number of time steps for Euler discretization:"); int timeSteps = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input whether to use antithetic variance reduction technique " + "(true for yes,false for no): "); bool antithetic = Convert.ToBoolean(Console.ReadLine()); EuropeanCallOption Option = new EuropeanCallOption(timeToMaturity, strikePrice); EulerSchemeForBSModel Euler = new EulerSchemeForBSModel(); StochasticAssetPrice Asset = new StochasticAssetPrice(Mu, sigma, spotPrice); if (antithetic) { double[] s1 = Option.PricingByMCSim(Asset, Euler, numOfScenarios, timeSteps, true); Console.WriteLine("Option price estimated by Monte Carlo Simulation and " + "antithetic variance reduction is:\n {0:#0.00} \n Standard error is:\n {1:#0.000} ", s1[0], s1[1]); } else { double[] s2 = Option.PricingByMCSim(Asset, Euler, numOfScenarios, timeSteps, false); Console.WriteLine("Option price estimated by Monte Carlo Simulation is:\n {0:#0.00} \n" + "Standard error is:\n {1:#0.000} ", s2[0], s2[1]); } Console.ReadLine(); }
static void Main(string[] args) { //input needed information from keyboard Console.WriteLine("Input spot price of underlying asset:"); double spotPrice = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Input option strike price:"); double strikePrice = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Input time to maturity of this option:"); double timeToMaturity = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Input drift parameter for brownian motion:"); double Mu = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Input volatility parameter for brownian motion:"); double sigma = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Input number of scenarios generated by MC simulation:"); int numOfScenarios = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input number of time steps for Euler discretization:"); int timeSteps = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input whether to use antithetic variance reduction technique " + "(true for yes,false for no): "); bool antithetic = Convert.ToBoolean(Console.ReadLine()); EuropeanCallOption Option = new EuropeanCallOption(timeToMaturity, strikePrice); EulerSchemeForBSModel Euler = new EulerSchemeForBSModel(); StochasticAssetPrice Asset = new StochasticAssetPrice(Mu, sigma, spotPrice); if (antithetic) { double[] s1 = Option.PricingByMCSim(Asset, Euler, numOfScenarios, timeSteps, true); Console.WriteLine("Option price estimated by Monte Carlo Simulation and " + "antithetic variance reduction is:\n {0:#0.00} \n Standard error is:\n {1:#0.000} ", s1[0], s1[1]); } else { double[] s2 = Option.PricingByMCSim(Asset, Euler, numOfScenarios, timeSteps, false); Console.WriteLine("Option price estimated by Monte Carlo Simulation is:\n {0:#0.00} \n" + "Standard error is:\n {1:#0.000} ", s2[0], s2[1]); } Console.ReadLine(); }