@Test
/**
* Tests the strikes in a range of strikes, volatilities and call/put.
*/
public void impliedStrike() {
final BlackPriceFunction function = new BlackPriceFunction();
final int nbStrike = STRIKES_INPUT.length;
final int nbVols = VOLS.length;
// double[][] delta = new double[2][nbStrike];
// double[][] strikeOutput = new double[2][nbStrike];
boolean callput = false;
for (int loopcall = 0; loopcall < 2; loopcall++) {
callput = !callput;
for (int loopstrike = 0; loopstrike < nbStrike; loopstrike++) {
for (int loopVols = 0; loopVols < nbVols; loopVols++) {
final EuropeanVanillaOption option = new EuropeanVanillaOption(STRIKES_INPUT[loopstrike], TIME_TO_EXPIRY, callput);
final BlackFunctionData data = new BlackFunctionData(FORWARD, 1.0, VOLS[loopVols]);
final double[] d = function.getPriceAdjoint(option, data);
final double delta = d[1];
final double strikeOutput = BlackFormulaRepository.impliedStrike(delta, callput, FORWARD, TIME_TO_EXPIRY, VOLS[loopVols]);
assertEquals("Implied strike: (data " + loopstrike + " / " + callput + ")", STRIKES_INPUT[loopstrike], strikeOutput, 1.0E-8);
}
}