SwaptionCashFixedIborBlackMethod { public PresentValueSwaptionSurfaceSensitivity presentValueBlackSensitivity(final SwaptionCashFixedIbor swaption, final BlackSwaptionFlatProviderInterface curveBlack) { ArgumentChecker.notNull(swaption, "Swaption"); ArgumentChecker.notNull(curveBlack, "Curves with Black volatility"); final double forward = swaption.getUnderlyingSwap().accept(PRDC, curveBlack.getMulticurveProvider()); final double pvbp = METHOD_SWAP.getAnnuityCash(swaption.getUnderlyingSwap(), forward); final double discountFactorSettle = curveBlack.getMulticurveProvider().getDiscountFactor(swaption.getCurrency(), swaption.getSettlementTime()); final DoublesPair point = DoublesPair.of(swaption.getTimeToExpiry(), swaption.getMaturityTime()); final BlackPriceFunction blackFunction = new BlackPriceFunction(); final double volatility = curveBlack.getBlackParameters().getVolatility(point); final BlackFunctionData dataBlack = new BlackFunctionData(forward, 1.0, volatility); final double[] bsAdjoint = blackFunction.getPriceAdjoint(swaption, dataBlack); final Map<DoublesPair, Double> sensitivity = new HashMap<>(); sensitivity.put(point, bsAdjoint[2] * pvbp * discountFactorSettle * (swaption.isLong() ? 1.0 : -1.0)); return new PresentValueSwaptionSurfaceSensitivity(sensitivity, curveBlack.getBlackParameters().getGeneratorSwap()); } private  SwaptionCashFixedIborBlackMethod(); static SwaptionCashFixedIborBlackMethod getInstance(); MultipleCurrencyAmount presentValue(final SwaptionCashFixedIbor swaption, final BlackSwaptionFlatProviderInterface curveBlack); double impliedVolatility(final SwaptionCashFixedIbor swaption, final BlackSwaptionFlatProviderInterface blackMulticurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final SwaptionCashFixedIbor swaption, final BlackSwaptionFlatProviderInterface curveBlack); MultipleCurrencyMulticurveSensitivity presentValueSecondOrderCurveSensitivity(final SwaptionCashFixedIbor swaption, final BlackSwaptionFlatProviderInterface curveBlack); PresentValueSwaptionSurfaceSensitivity presentValueBlackSensitivity(final SwaptionCashFixedIbor swaption, final BlackSwaptionFlatProviderInterface curveBlack);  }
@Test public void presentValueBlackSensitivity() { final double shift = 1.0E-6; final PresentValueSwaptionSurfaceSensitivity pvbvs = METHOD_BLACK.presentValueBlackSensitivity(SWAPTION_LONG_REC, BLACK_MULTICURVES); final BlackFlatSwaptionParameters blackP = BlackDataSets.createBlackSwaptionEUR6Shift(shift); final BlackSwaptionFlatProvider curvesBlackP = new BlackSwaptionFlatProvider(MULTICURVES, blackP); final MultipleCurrencyAmount pvP = METHOD_BLACK.presentValue(SWAPTION_LONG_REC, curvesBlackP); final BlackFlatSwaptionParameters blackM = BlackDataSets.createBlackSwaptionEUR6Shift(-shift); final BlackSwaptionFlatProvider curvesBlackM = new BlackSwaptionFlatProvider(MULTICURVES, blackM); final MultipleCurrencyAmount pvM = METHOD_BLACK.presentValue(SWAPTION_LONG_REC, curvesBlackM); final DoublesPair point = DoublesPair.of(SWAPTION_LONG_REC.getTimeToExpiry(), SWAPTION_LONG_REC.getMaturityTime()); final Double volatilitySensitivity = pvbvs.getSensitivity().getMap().get(point); assertEquals("Swaption Black method: present value volatility sensitivity", (pvP.getCurrencyAmounts()[0].getAmount() - pvM.getCurrencyAmounts()[0].getAmount()) / (2 * shift), volatilitySensitivity, TOLERANCE_DELTA); }
@Test public void presentValueBlackSensitivityMethodVsCalculator() { final PresentValueSwaptionSurfaceSensitivity pvbsMethod = METHOD_BLACK.presentValueBlackSensitivity(SWAPTION_LONG_REC, BLACK_MULTICURVES); final PresentValueSwaptionSurfaceSensitivity pvbsCalculator = SWAPTION_LONG_REC.accept(PVBSSBSC, BLACK_MULTICURVES); assertEquals("Swaption Black method: vega", pvbsMethod, pvbsCalculator); }