/** * Computes the implied volatility. * * @param optionPrice the option price * @return the volatility */ public double impliedVolatility(double optionPrice) { return impliedVolatility(optionPrice, VOL_GUESS); }
GenericImpliedVolatiltySolver solver = new GenericImpliedVolatiltySolver(priceFunc, vegaFunc); return solver.impliedVolatility(otmPrice, volGuess);
double[] temp = bracketRoot(optionPrice, volGuess); lowerSigma = temp[0]; upperSigma = temp[1]; return solveByBisection(optionPrice, lowerSigma, upperSigma); return solveByBisection(optionPrice, lowerSigma, upperSigma); return solveByBisection(optionPrice, lowerSigma, upperSigma);
for (int j = startIndex[i]; j < startIndex[i + 1]; ++j) { Function<Double, double[]> func = getValueVegaFunction(capList.get(j), ratesProvider, vols, prevExpiry, j); GenericImpliedVolatiltySolver solver = new GenericImpliedVolatiltySolver(func); double priceFixed = i == 0 ? 0d : priceFixed(capList.get(j), ratesProvider, vols, prevExpiry); double capletVol = solver.impliedVolatility(priceList.get(j) - priceFixed, initialVol.get(j)); vols = vols.withParameter(j, capletVol);