@SuppressWarnings("unused")
private Function1D<Double, Double> getStrikeForDeltaFunction(final double forward, final double expiry, final boolean isCall,
final Function1D<Double, Double> volFunc) {
final BracketRoot bracketer = new BracketRoot();
final BisectionSingleRootFinder rootFinder = new BisectionSingleRootFinder(1e-8);
return new Function1D<Double, Double>() {
@Override
public Double evaluate(final Double delta) {
final Function1D<Double, Double> deltaFunc = new Function1D<Double, Double>() {
@Override
public Double evaluate(final Double strike) {
final double vol = volFunc.evaluate(strike);
final double deltaTry = BlackFormulaRepository.delta(forward, strike, expiry, vol, isCall);
return deltaTry - delta;
}
};
final double[] brackets = bracketer.getBracketedPoints(deltaFunc, 0.5, 1.5, 0, 5);
return rootFinder.getRoot(deltaFunc, brackets[0], brackets[1]);
}
};
}