} // end // Put Create public void CreatePut(decimal currentPrice, decimal strikePrice, decimal riskFree, decimal vol, DateTime ExpiryDate) { decimal currPrice = currentPrice, spotPrice = strikePrice, riskFR = riskFree, iv = vol; // this allows to vary the inputs & Create with the original int differance = (ExpiryDate - DateTime.Now).Days; OptPrices = new List <OptionPrice>(); for (int count = 0; count < 3; count++) { // loop through the days for (int day = 1; day < differance + 1; day++) { OptionPrice optionPrices = new OptionPrice(); // each loop will create a new instance of OptionPrice class optionPrices.Price = optionPrices.Price = PutOption(currPrice, spotPrice, riskFR, iv, day); optionPrices.Day = DateTime.Now.AddDays(day); if (count == 0) { optionPrices.Varation = "ORIGINAL"; } else { optionPrices.Varation = "VARATION" + count + " CURR: " + currPrice + " SP: " + spotPrice + " RFR: " + riskFR + " % IV: " + iv + " %"; } OptPrices.Add(optionPrices); // add to the list } // end the inner loop if (count % 2 == 0) { currPrice += 1.75M; spotPrice -= 0.75M; iv += 12.25M; riskFR -= 0.01M; if (spotPrice <= 0.00M) { spotPrice = 5; } if (riskFR < 0.00M) { riskFR = 1.00M; } } else { currPrice -= 1.00M; spotPrice += 2.50M; riskFR += 0.02M; iv -= 7.25M; if (iv < 0.00M) // IV can never be negative { iv = 0; } if (currPrice <= 0.00M) { currPrice = 3.00M; } } } // end outer loop varation } // end
// public methods // The Create Controller will call these methods public void CreateCall(decimal currentPrice, decimal strikePrice, decimal riskFree, decimal vol, DateTime ExpiryDate) { decimal currPrice = currentPrice, spotPrice = strikePrice, riskFR = riskFree, iv = vol; // this allows to vary the inputs & Create with the original int differance = (ExpiryDate - DateTime.Now).Days; OptPrices = new List <OptionPrice>(); for (int count = 0; count < 3; count++) { // loop through the days for (int day = 1; day < differance + 1; day++) { OptionPrice optionPrices = new OptionPrice(); // each loop will create a new instance of OptionPrice class optionPrices.Price = CallOption(currPrice, spotPrice, riskFR, iv, day); optionPrices.Day = DateTime.Now.AddDays(day); if (count == 0) // 1st run through { optionPrices.Varation = "ORIGINAL"; } else { optionPrices.Varation = "VARATION" + count + " CURR: " + currPrice + " SP: " + spotPrice + " RFR: " + riskFR + " % IV: " + iv + " %"; } OptPrices.Add(optionPrices); // add to the list } // end the inner loop if (count % 2 == 0) // even { currPrice += 3.21M; spotPrice -= 1.5M; iv += 5; riskFR -= 0.01M; if (spotPrice <= 0.00M) // check that the strike price above 0.00 { spotPrice = 5.00M; // set to 5 if it is not } if (riskFR < 0.00M) { riskFR = 1.00M; } } else { currPrice -= 1.00M; spotPrice += 0.50M; riskFR += 0.02M; iv -= 5; if (iv < 0.00M) // IV can never be negative but can be zero { iv = 0; } if (currPrice <= 0.00M) // set current price to 3 if 0 or less { currPrice = 3.00M; } } } // end outer loop varation } // end