SABRBlackEquivalentVolatilitySurfaceModel implements VolatilitySurfaceModel<OptionDefinition, SABRDataBundle> { @Override public VolatilitySurface getSurface(final OptionDefinition option, final SABRDataBundle data) { Validate.notNull(option, "option definition"); Validate.notNull(data); final double k = option.getStrike(); final double t = option.getTimeToExpiry(data.getDate()); final double alpha = data.getAlpha(); final double beta = data.getBeta(); final double rho = data.getRho(); final double ksi = data.getVolOfVol(); final double b = data.getCostOfCarry(); final double f = data.getSpot() * Math.exp(b * t); return new VolatilitySurface(ConstantDoublesSurface.from(SABR_FUNCTION.getVolatilityFunction(new EuropeanVanillaOption(k, t, true), f).evaluate(new SABRFormulaData(alpha, beta, rho, ksi)))); }  @Override VolatilitySurface getSurface(final OptionDefinition option, final SABRDataBundle data);  }
@Test public void testBetaApproachesOne() { final SABRDataBundle data = DATA.withBeta(1 - 1e-12); assertEquals(MODEL.getSurface(OPTION, DATA).getVolatility(PAIR), MODEL.getSurface(OPTION, data).getVolatility(PAIR), 1e-9); }
@Test public void testBetaApproachesZero() { final SABRDataBundle data = DATA.withBeta(1e-12); assertEquals(MODEL.getSurface(OPTION, DATA.withBeta(1e-12)).getVolatility(PAIR), MODEL.getSurface(OPTION, data).getVolatility(PAIR), 1e-9); }
@Test public void testWithZeroVolOfVol() { final SABRDataBundle data = DATA.withVolOfVol(0); assertEquals(MODEL.getSurface(OPTION, data).getVolatility(PAIR), ATM_VOL.getVolatility(PAIR)); }
@Test public void test() { assertEquals(MODEL.getSurface(OPTION, DATA).getVolatility(PAIR), 0.3454, EPS); SABRDataBundle data1 = DATA.withRho(-0.75).withBeta(0.999); SABRDataBundle data2 = DATA.withRho(0).withBeta(0.999); SABRDataBundle data3 = DATA.withRho(0.5).withBeta(0.999); OptionDefinition option = new EuropeanVanillaOptionDefinition(70, EXPIRY, false); data1 = CALIBRATION.calibrate(option, data1); data2 = CALIBRATION.calibrate(option, data2); data3 = CALIBRATION.calibrate(option, data3); assertEquals(MODEL.getSurface(option, data1).getVolatility(PAIR), 0.3668, EPS); assertEquals(MODEL.getSurface(option, data2).getVolatility(PAIR), 0.3165, EPS); assertEquals(MODEL.getSurface(option, data3).getVolatility(PAIR), 0.2709, EPS); option = new EuropeanVanillaOptionDefinition(80, EXPIRY, false); data1 = CALIBRATION.calibrate(option, data1); data2 = CALIBRATION.calibrate(option, data2); data3 = CALIBRATION.calibrate(option, data3); assertEquals(MODEL.getSurface(option, data1).getVolatility(PAIR), 0.3418, EPS); assertEquals(MODEL.getSurface(option, data2).getVolatility(PAIR), 0.3068, EPS); assertEquals(MODEL.getSurface(option, data3).getVolatility(PAIR), 0.2774, EPS); option = new EuropeanVanillaOptionDefinition(90, EXPIRY, false); data1 = CALIBRATION.calibrate(option, data1); data2 = CALIBRATION.calibrate(option, data2); data3 = CALIBRATION.calibrate(option, data3); assertEquals(MODEL.getSurface(option, data1).getVolatility(PAIR), 0.3197, EPS); assertEquals(MODEL.getSurface(option, data2).getVolatility(PAIR), 0.3016, EPS); assertEquals(MODEL.getSurface(option, data3).getVolatility(PAIR), 0.2878, EPS); option = new EuropeanVanillaOptionDefinition(100, EXPIRY, false); data1 = CALIBRATION.calibrate(option, data1); data2 = CALIBRATION.calibrate(option, data2); data3 = CALIBRATION.calibrate(option, data3); assertEquals(MODEL.getSurface(option, data1).getVolatility(PAIR), 0.3000, EPS); assertEquals(MODEL.getSurface(option, data2).getVolatility(PAIR), 0.3000, EPS); assertEquals(MODEL.getSurface(option, data3).getVolatility(PAIR), 0.3000, EPS); option = new EuropeanVanillaOptionDefinition(110, EXPIRY, false); data1 = CALIBRATION.calibrate(option, data1); data2 = CALIBRATION.calibrate(option, data2); data3 = CALIBRATION.calibrate(option, data3); assertEquals(MODEL.getSurface(option, data1).getVolatility(PAIR), 0.2826, EPS); assertEquals(MODEL.getSurface(option, data2).getVolatility(PAIR), 0.3013, EPS); assertEquals(MODEL.getSurface(option, data3).getVolatility(PAIR), 0.3128, EPS); option = new EuropeanVanillaOptionDefinition(120, EXPIRY, false); data1 = CALIBRATION.calibrate(option, data1); data2 = CALIBRATION.calibrate(option, data2); data3 = CALIBRATION.calibrate(option, data3); assertEquals(MODEL.getSurface(option, data1).getVolatility(PAIR), 0.2674, EPS); assertEquals(MODEL.getSurface(option, data2).getVolatility(PAIR), 0.3046, EPS); assertEquals(MODEL.getSurface(option, data3).getVolatility(PAIR), 0.3255, EPS); option = new EuropeanVanillaOptionDefinition(130, EXPIRY, false); data1 = CALIBRATION.calibrate(option, data1); data2 = CALIBRATION.calibrate(option, data2); data3 = CALIBRATION.calibrate(option, data3); assertEquals(MODEL.getSurface(option, data1).getVolatility(PAIR), 0.2546, EPS); assertEquals(MODEL.getSurface(option, data2).getVolatility(PAIR), 0.3092, EPS); assertEquals(MODEL.getSurface(option, data3).getVolatility(PAIR), 0.3378, EPS); }