SwaptionCashFixedIborSABRExtrapolationRightMethod { public PresentValueSABRSensitivityDataBundle presentValueSABRSensitivity(final SwaptionCashFixedIbor swaption, final SABRSwaptionProviderInterface sabrData) { ArgumentChecker.notNull(swaption, "Swaption"); ArgumentChecker.notNull(sabrData, "SABR swaption provider"); final MulticurveProviderInterface multicurves = sabrData.getMulticurveProvider(); final Currency ccy = swaption.getCurrency(); final PresentValueSABRSensitivityDataBundle sensi = new PresentValueSABRSensitivityDataBundle(); final AnnuityCouponFixed annuityFixed = swaption.getUnderlyingSwap().getFixedLeg(); final double forward = swaption.getUnderlyingSwap().accept(PRDC, multicurves); final double pvbp = METHOD_SWAP.getAnnuityCash(swaption.getUnderlyingSwap(), forward); final double maturity = annuityFixed.getNthPayment(annuityFixed.getNumberOfPayments() - 1).getPaymentTime() - swaption.getSettlementTime(); final double discountFactorSettle = multicurves.getDiscountFactor(ccy, swaption.getSettlementTime()); final DoublesPair expiryMaturity = DoublesPair.of(swaption.getTimeToExpiry(), maturity); final double alpha = sabrData.getSABRParameter().getAlpha(expiryMaturity); final double beta = sabrData.getSABRParameter().getBeta(expiryMaturity); final double rho = sabrData.getSABRParameter().getRho(expiryMaturity); final double nu = sabrData.getSABRParameter().getNu(expiryMaturity); final SABRFormulaData sabrParam = new SABRFormulaData(alpha, beta, rho, nu); final SABRExtrapolationRightFunction sabrExtrapolation = new SABRExtrapolationRightFunction(forward, sabrParam, _cutOffStrike, swaption.getTimeToExpiry(), _mu); final double[] priceDSabr = new double[4]; sabrExtrapolation.priceAdjointSABR(swaption, priceDSabr); final double omega = (swaption.isLong() ? 1.0 : -1.0); sensi.addAlpha(expiryMaturity, omega * discountFactorSettle * pvbp * priceDSabr[0]); sensi.addBeta(expiryMaturity, omega * discountFactorSettle * pvbp * priceDSabr[1]); sensi.addRho(expiryMaturity, omega * discountFactorSettle * pvbp * priceDSabr[2]); sensi.addNu(expiryMaturity, omega * discountFactorSettle * pvbp * priceDSabr[3]); return sensi; } SwaptionCashFixedIborSABRExtrapolationRightMethod(final double cutOffStrike, final double mu); MultipleCurrencyAmount presentValue(final SwaptionCashFixedIbor swaption, final SABRSwaptionProviderInterface sabrData); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final SwaptionCashFixedIbor swaption, final SABRSwaptionProviderInterface sabrData); PresentValueSABRSensitivityDataBundle presentValueSABRSensitivity(final SwaptionCashFixedIbor swaption, final SABRSwaptionProviderInterface sabrData);  }
@Test public void presentValueSABRSensitivity() { final PresentValueSABRSensitivityDataBundle pvsLongPayer = METHOD_EXTRAPOLATION.presentValueSABRSensitivity(SWAPTION_LONG_PAYER_HIGH, SABR_MULTICURVES); PresentValueSABRSensitivityDataBundle pvsShortPayer = METHOD_EXTRAPOLATION.presentValueSABRSensitivity(SWAPTION_SHORT_PAYER_HIGH, SABR_MULTICURVES); pvsShortPayer = pvsShortPayer.multiplyBy(-1.0); assertEquals(pvsLongPayer.getAlpha(), pvsShortPayer.getAlpha()); final double pvLongPayer = METHOD_EXTRAPOLATION.presentValue(SWAPTION_LONG_PAYER_HIGH, SABR_MULTICURVES).getAmount(EUR); final DoublesPair expectedExpiryTenor = DoublesPair.of(SWAPTION_LONG_PAYER_HIGH.getTimeToExpiry(), ANNUITY_TENOR_YEAR); final double shift = 0.000005; final SABRInterestRateParameters sabrParameterAlphaBumped = SABRDataSets.createSABR1AlphaBumped(shift); final SABRSwaptionProviderDiscount sabrBundleAlphaBumped = new SABRSwaptionProviderDiscount(MULTICURVES, sabrParameterAlphaBumped, EUR1YEURIBOR6M); final double pvLongPayerAlphaBumped = METHOD_EXTRAPOLATION.presentValue(SWAPTION_LONG_PAYER_HIGH, 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", expectedAlphaSensi, pvsLongPayer.getAlpha().getMap().get(expectedExpiryTenor), 2.0E+3); final SABRInterestRateParameters sabrParameterRhoBumped = SABRDataSets.createSABR1RhoBumped(shift); final SABRSwaptionProviderDiscount sabrBundleRhoBumped = new SABRSwaptionProviderDiscount(MULTICURVES, sabrParameterRhoBumped, EUR1YEURIBOR6M); final double pvLongPayerRhoBumped = METHOD_EXTRAPOLATION.presentValue(SWAPTION_LONG_PAYER_HIGH, 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", expectedRhoSensi, pvsLongPayer.getRho().getMap().get(expectedExpiryTenor), 2.0E+0); final SABRInterestRateParameters sabrParameterNuBumped = SABRDataSets.createSABR1NuBumped(shift); final SABRSwaptionProviderDiscount sabrBundleNuBumped = new SABRSwaptionProviderDiscount(MULTICURVES, sabrParameterNuBumped, EUR1YEURIBOR6M); final double pvLongPayerNuBumped = METHOD_EXTRAPOLATION.presentValue(SWAPTION_LONG_PAYER_HIGH, 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", expectedNuSensi, pvsLongPayer.getNu().getMap().get(expectedExpiryTenor), 5.0E+1); }
@Test public void presentValueSABRSensitivityMethodVsCalculator() { final PresentValueSABRSensitivityDataBundle pvssMethod = METHOD_EXTRAPOLATION.presentValueSABRSensitivity(SWAPTION_LONG_PAYER_HIGH, SABR_MULTICURVES); final PresentValueSABRSensitivityDataBundle pvssCalculator = SWAPTION_LONG_PAYER_HIGH.accept(PVSSSSXC, SABR_MULTICURVES); assertEquals("SwaptionCashFixedIborSABRExtrapolationRightMethod: presentValueCurveSensitivity ", pvssMethod, pvssCalculator); }