SwaptionPhysicalFixedIborSABRMethod { public PresentValueSABRSensitivityDataBundle presentValueSABRSensitivity(final SwaptionPhysicalFixedIbor swaption, final SABRSwaptionProviderInterface sabrData) { ArgumentChecker.notNull(swaption, "Swaption"); ArgumentChecker.notNull(sabrData, "SABR swaption provider"); final DayCount dayCountModification = sabrData.getSABRGenerator().getFixedLegDayCount(); final double pvbpModified = METHOD_SWAP.presentValueBasisPoint(swaption.getUnderlyingSwap(), dayCountModification, sabrData.getMulticurveProvider()); final double forwardModified = PRDC.visitFixedCouponSwap(swaption.getUnderlyingSwap(), dayCountModification, sabrData.getMulticurveProvider()); final double strikeModified = METHOD_SWAP.couponEquivalent(swaption.getUnderlyingSwap(), pvbpModified, sabrData.getMulticurveProvider()); final double maturity = swaption.getMaturityTime(); final PresentValueSABRSensitivityDataBundle sensi = new PresentValueSABRSensitivityDataBundle(); final DoublesPair expiryMaturity = DoublesPair.of(swaption.getTimeToExpiry(), maturity); final EuropeanVanillaOption option = new EuropeanVanillaOption(strikeModified, swaption.getTimeToExpiry(), swaption.isCall()); final BlackPriceFunction blackFunction = new BlackPriceFunction(); final double[] volatilityAdjoint = sabrData.getSABRParameter().getVolatilityAdjoint(swaption.getTimeToExpiry(), maturity, strikeModified, forwardModified); final BlackFunctionData dataBlack = new BlackFunctionData(forwardModified, 1.0, volatilityAdjoint[0]); final double[] bsAdjoint = blackFunction.getPriceAdjoint(option, dataBlack); final double omega = (swaption.isLong() ? 1.0 : -1.0); sensi.addAlpha(expiryMaturity, omega * pvbpModified * bsAdjoint[2] * volatilityAdjoint[3]); sensi.addBeta(expiryMaturity, omega * pvbpModified * bsAdjoint[2] * volatilityAdjoint[4]); sensi.addRho(expiryMaturity, omega * pvbpModified * bsAdjoint[2] * volatilityAdjoint[5]); sensi.addNu(expiryMaturity, omega * pvbpModified * bsAdjoint[2] * volatilityAdjoint[6]); return sensi; } private  SwaptionPhysicalFixedIborSABRMethod(); static SwaptionPhysicalFixedIborSABRMethod getInstance(); MultipleCurrencyAmount presentValue(final SwaptionPhysicalFixedIbor swaption, final SABRSwaptionProviderInterface sabrData); double impliedVolatility(final SwaptionPhysicalFixedIbor swaption, final SABRSwaptionProviderInterface sabrData); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final SwaptionPhysicalFixedIbor swaption, final SABRSwaptionProviderInterface sabrData); PresentValueSABRSensitivityDataBundle presentValueSABRSensitivity(final SwaptionPhysicalFixedIbor swaption, final SABRSwaptionProviderInterface sabrData); Triple<MultipleCurrencyAmount, MultipleCurrencyMulticurveSensitivity, PresentValueSABRSensitivityDataBundle> presentValueAD(final SwaptionPhysicalFixedIbor swaption,
      final SABRSwaptionProviderInterface sabrData);  }
@Test public void presentValueSABRSensitivity() { final PresentValueSABRSensitivityDataBundle pvsLongPayer = METHOD_SWPT_SABR.presentValueSABRSensitivity(SWAPTION_LONG_PAYER, SABR_MULTICURVES); PresentValueSABRSensitivityDataBundle pvsShortPayer = METHOD_SWPT_SABR.presentValueSABRSensitivity(SWAPTION_SHORT_PAYER, SABR_MULTICURVES); pvsShortPayer = pvsShortPayer.multiplyBy(-1.0); assertEquals("SwaptionPhysicalFixedIborSABRMethod: presentValueSABRSensitivity", pvsLongPayer.getAlpha(), pvsShortPayer.getAlpha()); final double pvLongPayer = METHOD_SWPT_SABR.presentValue(SWAPTION_LONG_PAYER, SABR_MULTICURVES).getAmount(EUR); final double shift = 1.0E-8; final DoublesPair expectedExpiryTenor = DoublesPair.of(SWAPTION_LONG_PAYER.getTimeToExpiry(), ANNUITY_TENOR_YEAR); final SABRInterestRateParameters sabrParameterAlphaBumped = SABRDataSets.createSABR1AlphaBumped(shift); final SABRSwaptionProviderDiscount sabrBundleAlphaBumped = new SABRSwaptionProviderDiscount(MULTICURVES, sabrParameterAlphaBumped, EUR1YEURIBOR6M); final double pvLongPayerAlphaBumped = METHOD_SWPT_SABR.presentValue(SWAPTION_LONG_PAYER, sabrBundleAlphaBumped).getAmount(EUR); final double expectedAlphaSensi = (pvLongPayerAlphaBumped - pvLongPayer) / shift; assertEquals("Number of alpha sensitivity", pvsLongPayer.getAlpha().getMap().keySet().size(), 1); assertEquals("Alpha sensitivity expiry/tenor", pvsLongPayer.getAlpha().getMap().keySet().contains(expectedExpiryTenor), true); assertEquals("Alpha sensitivity value", pvsLongPayer.getAlpha().getMap().get(expectedExpiryTenor), expectedAlphaSensi, 1.0E+1); final SABRInterestRateParameters sabrParameterRhoBumped = SABRDataSets.createSABR1RhoBumped(shift); final SABRSwaptionProviderDiscount sabrBundleRhoBumped = new SABRSwaptionProviderDiscount(MULTICURVES, sabrParameterRhoBumped, EUR1YEURIBOR6M); final double pvLongPayerRhoBumped = METHOD_SWPT_SABR.presentValue(SWAPTION_LONG_PAYER, sabrBundleRhoBumped).getAmount(EUR); final double expectedRhoSensi = (pvLongPayerRhoBumped - pvLongPayer) / shift; assertEquals("Number of rho sensitivity", pvsLongPayer.getRho().getMap().keySet().size(), 1); assertEquals("Rho sensitivity expiry/tenor", pvsLongPayer.getRho().getMap().keySet().contains(expectedExpiryTenor), true); assertEquals("Rho sensitivity value", pvsLongPayer.getRho().getMap().get(expectedExpiryTenor), expectedRhoSensi, 5.0E-1); final SABRInterestRateParameters sabrParameterNuBumped = SABRDataSets.createSABR1NuBumped(shift); final SABRSwaptionProviderDiscount sabrBundleNuBumped = new SABRSwaptionProviderDiscount(MULTICURVES, sabrParameterNuBumped, EUR1YEURIBOR6M); final double pvLongPayerNuBumped = METHOD_SWPT_SABR.presentValue(SWAPTION_LONG_PAYER, sabrBundleNuBumped).getAmount(EUR); final double expectedNuSensi = (pvLongPayerNuBumped - pvLongPayer) / shift; assertEquals("Number of nu sensitivity", pvsLongPayer.getNu().getMap().keySet().size(), 1); assertEquals("Nu sensitivity expiry/tenor", pvsLongPayer.getNu().getMap().keySet().contains(expectedExpiryTenor), true); assertEquals("Nu sensitivity value", pvsLongPayer.getNu().getMap().get(expectedExpiryTenor), expectedNuSensi, 1.0E+0); }
@Test public void presentValueSABRSensitivityMethodVsCalculator() { final PresentValueSABRSensitivityDataBundle pvssMethod = METHOD_SWPT_SABR.presentValueSABRSensitivity(SWAPTION_LONG_PAYER, SABR_MULTICURVES); final PresentValueSABRSensitivityDataBundle pvssCalculator = PVSSSSC.visit(SWAPTION_LONG_PAYER, SABR_MULTICURVES); assertEquals("Swaption Physical SABR: Present value SABR sensitivity: method vs calculator", pvssMethod, pvssCalculator); }