public bool SimpleImpliedVolatilityTest() { OptionType type = OptionType.Call; double strike = 31.21; double spot = 31.525; double volatility = 0.25116165; double riskFreeRate = 0.085209; double ttm = (double)35 / 365; EquityOptionStaticData staticData = new EquityOptionStaticData(type, strike, spot, volatility, riskFreeRate, ttm); IPriceable priceable = staticData.BuildPriceable(); double price = priceable.Price(); BlackScholes bs = new BlackScholes(); double volGuess = 0.25; double relTolerance = 0.00001; int maxAttempts = 10; price = 1.28; double impliedVol = bs.GetImpliedVolatility(type, price, spot, strike, riskFreeRate, ttm, volGuess, relTolerance, maxAttempts); double relDiff = Math.Abs(impliedVol - volatility) / volatility; if (relDiff <= relTolerance) { return(true); } else { return(false); } }
public double CallPrice() { OptionType type = OptionType.Call; double strike = 29.14; double spot = 27.04; double volatility = 0.47; double riskFreeRate = 0.1413; double ttm = 11 / 252; EquityOptionStaticData staticData = new EquityOptionStaticData(type, strike, spot, volatility, riskFreeRate, ttm); IPriceable priceable = staticData.BuildPriceable(); double price = priceable.Price(); return(price); }
public Rental(IPriceable movie, int daysRented) { Movie = movie; DaysRented = daysRented; }
private decimal getCost(IPriceable Sellable, decimal reduction, Pizza pizza) { decimal duplicator = 1; if (Sellable is Ingredient) { string formaat = pizza.Formaat; string vorm = pizza.Vorm; int[] numbers = new int[6]; string number = ""; decimal Oppervlakte = 0; switch (vorm) { case "Vierkant": foreach (char thisChar in formaat) { if (thisChar == 'c') { break; } number += thisChar; } Oppervlakte = Convert.ToDecimal(Convert.ToInt32(number) * Math.PI); break; case "Rechthoek": foreach (char thisChar in formaat) { if (thisChar == 'x') { numbers[0] = Convert.ToInt32(number); number = ""; } else if (thisChar == 'c') { numbers[1] = Convert.ToInt32(number); break; } else { number += thisChar; } } Oppervlakte = Convert.ToDecimal(numbers[0] * numbers[1]); break; case "Driehoek": int x = 0; foreach (char thisChar in formaat) { if (thisChar == 'x') { numbers[x] = Convert.ToInt32(number); number = ""; x++; } else if (thisChar == 'c') { numbers[2] = Convert.ToInt32(number); break; } else { number += thisChar; } } Oppervlakte = Convert.ToDecimal(0.5 * number[0] * number[1]); break; } duplicator = Oppervlakte; } return(Sellable.VerkoopPrijs - (Sellable.VerkoopPrijs * reduction)); }