Exemplo n.º 1
0
 public double computePayoff(double strike, double[] stockPath, PutCallOption putCallOption)
 {
     if (putCallOption == PutCallOption.CALL_OPTION)
     {
         return Math.Max(stockPath[stockPath.Length - 1] - strike, 0);
     }
     else
     {
         return Math.Max(strike - stockPath[stockPath.Length - 1], 0);
     }
 }
Exemplo n.º 2
0
 public static void MCPriceOption(double s0, double drift, double sigma, double maturity, double strike
                               , PutCallOption optionType, int numOfSteps
                               , StockPathGenerator stockpathGenerator, PayoffCalculator payoffCalculator
                               , RandomSequenceGenerator randomSequenceGenerator)
 {
     StatisticTracker tracker = new StatisticTracker();
     while (tracker.needMoreSimulation())
     {
         tracker.putNewResult(payoffCalculator.computePayoff(strike
         , stockpathGenerator.getPath(s0, drift, sigma, maturity, numOfSteps, randomSequenceGenerator)
         , optionType));
     }
     Console.Write("option price is ");
     Console.WriteLine(tracker.getMean());
     Console.Write("option price standard deviation is ");
     Console.WriteLine(tracker.getStdDev());
 }