CapFloorIborBlackSmileMethod { public MultipleCurrencyAmount presentValue(final CapFloorIbor cap, final BlackSmileCapProviderInterface black) { ArgumentChecker.notNull(cap, "The cap/floor shoud not be null"); ArgumentChecker.notNull(black, "Black provider"); final EuropeanVanillaOption option = new EuropeanVanillaOption(cap.getStrike(), cap.getFixingTime(), cap.isCap()); final double forward = black.getMulticurveProvider().getSimplyCompoundForwardRate(cap.getIndex(), cap.getFixingPeriodStartTime(), cap.getFixingPeriodEndTime(), cap.getFixingAccrualFactor()); final double df = black.getMulticurveProvider().getDiscountFactor(cap.getCurrency(), cap.getPaymentTime()); final double volatility = black.getBlackParameters().getVolatility(cap.getFixingTime(), cap.getStrike()); final BlackFunctionData dataBlack = new BlackFunctionData(forward, df, volatility); final Function1D<BlackFunctionData, Double> func = BLACK_FUNCTION.getPriceFunction(option); final double price = func.evaluate(dataBlack) * cap.getNotional() * cap.getPaymentYearFraction(); return MultipleCurrencyAmount.of(cap.getCurrency(), price); } private  CapFloorIborBlackSmileMethod(); static CapFloorIborBlackSmileMethod getInstance(); MultipleCurrencyAmount presentValue(final CapFloorIbor cap, final BlackSmileCapProviderInterface black); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CapFloorIbor cap, final BlackSmileCapProviderInterface black);  }
@Test public void presentValue() { final MultipleCurrencyAmount methodPrice = METHOD_CAP_BLACK.presentValue(CAP_LONG, BLACK_MULTICURVES); final double df = MULTICURVES.getDiscountFactor(EUR, CAP_LONG.getPaymentTime()); final double forward = MULTICURVES.getSimplyCompoundForwardRate(EURIBOR3M, CAP_LONG.getFixingPeriodStartTime(), CAP_LONG.getFixingPeriodEndTime(), CAP_LONG.getFixingAccrualFactor()); final double volatility = BLACK_SURF.getZValue(CAP_LONG.getFixingTime(), STRIKE); final BlackFunctionData dataBlack = new BlackFunctionData(forward, df, volatility); final EuropeanVanillaOption option = new EuropeanVanillaOption(STRIKE, CAP_LONG.getFixingTime(), IS_CAP); final Function1D<BlackFunctionData, Double> funcBlack = BLACK_FUNCTION.getPriceFunction(option); final double expectedPrice = funcBlack.evaluate(dataBlack) * CAP_LONG.getNotional() * CAP_LONG.getPaymentYearFraction(); assertEquals("Cap/floor: SABR pricing", expectedPrice, methodPrice.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueParity() { final double priceCapLong = METHOD_CAP_BLACK.presentValue(CAP_LONG, BLACK_MULTICURVES).getAmount(EUR); final double priceCapShort = METHOD_CAP_BLACK.presentValue(CAP_SHORT, BLACK_MULTICURVES).getAmount(EUR); assertEquals("Cap/floor - SABR pricing: long/short parity", -priceCapLong, priceCapShort, TOLERANCE_PV); final double priceFloorShort = METHOD_CAP_BLACK.presentValue(FLOOR_SHORT, BLACK_MULTICURVES).getAmount(EUR); final double priceIbor = COUPON_IBOR.accept(PVC, MULTICURVES).getAmount(EUR); final double priceStrike = COUPON_STRIKE.accept(PVC, MULTICURVES).getAmount(EUR); assertEquals("Cap/floor - SABR pricing: cap/floor parity", priceIbor - priceStrike, priceCapLong + priceFloorShort, TOLERANCE_PV); }