SwaptionPhysicalFixedIborSABRMethod { public MultipleCurrencyAmount presentValue(final SwaptionPhysicalFixedIbor swaption, final SABRSwaptionProviderInterface sabrData) { ArgumentChecker.notNull(swaption, "Swaption"); ArgumentChecker.notNull(sabrData, "SABR swaption provider"); final DayCount dayCountModification = sabrData.getSABRGenerator().getFixedLegDayCount(); final MulticurveProviderInterface multicurves = sabrData.getMulticurveProvider(); final double pvbpModified = METHOD_SWAP.presentValueBasisPoint(swaption.getUnderlyingSwap(), dayCountModification, multicurves); final double forwardModified = PRDC.visitFixedCouponSwap(swaption.getUnderlyingSwap(), dayCountModification, multicurves); final double strikeModified = METHOD_SWAP.couponEquivalent(swaption.getUnderlyingSwap(), pvbpModified, multicurves); final double maturity = swaption.getMaturityTime(); final EuropeanVanillaOption option = new EuropeanVanillaOption(strikeModified, swaption.getTimeToExpiry(), swaption.isCall()); final BlackPriceFunction blackFunction = new BlackPriceFunction(); final double volatility = sabrData.getSABRParameter().getVolatility(swaption.getTimeToExpiry(), maturity, strikeModified, forwardModified); final BlackFunctionData dataBlack = new BlackFunctionData(forwardModified, pvbpModified, volatility); final Function1D<BlackFunctionData, Double> func = blackFunction.getPriceFunction(option); final double pv = func.evaluate(dataBlack) * (swaption.isLong() ? 1.0 : -1.0); return MultipleCurrencyAmount.of(swaption.getCurrency(), pv); } 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 testPresentValue() { final MultipleCurrencyAmount priceLongPayer = METHOD_SWPT_SABR.presentValue(SWAPTION_LONG_PAYER, SABR_MULTICURVES); final MultipleCurrencyAmount priceShortPayer = METHOD_SWPT_SABR.presentValue(SWAPTION_SHORT_PAYER, SABR_MULTICURVES); final MultipleCurrencyAmount priceLongReceiver = METHOD_SWPT_SABR.presentValue(SWAPTION_LONG_RECEIVER, SABR_MULTICURVES); final MultipleCurrencyAmount priceShortReceiver = METHOD_SWPT_SABR.presentValue(SWAPTION_SHORT_RECEIVER, SABR_MULTICURVES); final double pvbp = METHOD_SWAP.presentValueBasisPoint(SWAP_PAYER, MULTICURVES); final double forward = SWAP_PAYER.accept(PRDC, MULTICURVES); final double maturity = SWAP_PAYER.getFirstLeg().getNthPayment(SWAP_PAYER.getFirstLeg().getNumberOfPayments() - 1).getPaymentTime() - SWAPTION_LONG_PAYER.getSettlementTime(); assertEquals(maturity, ANNUITY_TENOR_YEAR, 1E-2); final double volatility = SABR_PARAMETER.getVolatility(SWAPTION_LONG_PAYER.getTimeToExpiry(), maturity, RATE, forward); assertEquals("SwaptionPhysicalFixedIborSABRMethod: implied volatility", volatility, METHOD_SWPT_SABR.impliedVolatility(SWAPTION_LONG_PAYER, SABR_MULTICURVES), TOLERANCE_PV); final BlackFunctionData data = new BlackFunctionData(forward, pvbp, volatility); final Function1D<BlackFunctionData, Double> func = BLACK_FUNCTION.getPriceFunction(SWAPTION_LONG_PAYER); final double expectedPrice = func.evaluate(data); assertEquals("SwaptionPhysicalFixedIborSABRMethod: presentValue", expectedPrice, priceLongPayer.getAmount(EUR), TOLERANCE_PV); assertEquals("SwaptionPhysicalFixedIborSABRMethod: presentValue", priceLongPayer.getAmount(EUR), -priceShortPayer.getAmount(EUR), TOLERANCE_PV); assertEquals("SwaptionPhysicalFixedIborSABRMethod: presentValue", priceLongReceiver.getAmount(EUR), -priceShortReceiver.getAmount(EUR), TOLERANCE_PV); final MultipleCurrencyAmount priceSwapPayer = SWAP_PAYER.accept(PVDC, MULTICURVES); final MultipleCurrencyAmount priceSwapReceiver = SWAP_RECEIVER.accept(PVDC, MULTICURVES); assertEquals("SwaptionPhysicalFixedIborSABRMethod: presentValue", priceSwapPayer.getAmount(EUR), priceLongPayer.getAmount(EUR) + priceShortReceiver.getAmount(EUR), TOLERANCE_PV); assertEquals("SwaptionPhysicalFixedIborSABRMethod: presentValue", priceSwapReceiver.getAmount(EUR), priceLongReceiver.getAmount(EUR) + priceShortPayer.getAmount(EUR), TOLERANCE_PV); }
@Test public void testPresentValueConventionArbitrage() { final double rate360 = 0.0360; final IndexSwap index360 = new IndexSwap(EUR1YEURIBOR6M.getFixedLegPeriod(), DayCounts.ACT_360, EURIBOR6M, ANNUITY_TENOR, CALENDAR); final SwapFixedIborDefinition swap360 = SwapFixedIborDefinition.from(SETTLEMENT_DATE, index360, NOTIONAL, rate360, true, CALENDAR); final SwaptionPhysicalFixedIborDefinition swaption360Definition = SwaptionPhysicalFixedIborDefinition.from(EXPIRY_DATE, swap360, true, IS_LONG); final SwaptionPhysicalFixedIbor swaption360 = swaption360Definition.toDerivative(REFERENCE_DATE); final double rate365 = 0.0365; final IndexSwap index365 = new IndexSwap(EUR1YEURIBOR6M.getFixedLegPeriod(), DayCounts.ACT_365, EURIBOR6M, ANNUITY_TENOR, CALENDAR); final SwapFixedIborDefinition swap365 = SwapFixedIborDefinition.from(SETTLEMENT_DATE, index365, NOTIONAL, rate365, true, CALENDAR); final SwaptionPhysicalFixedIborDefinition swaption365Definition = SwaptionPhysicalFixedIborDefinition.from(EXPIRY_DATE, swap365, true, IS_LONG); final SwaptionPhysicalFixedIbor swaption365 = swaption365Definition.toDerivative(REFERENCE_DATE); final MultipleCurrencyAmount price360 = METHOD_SWPT_SABR.presentValue(swaption360, SABR_MULTICURVES); final MultipleCurrencyAmount price365 = METHOD_SWPT_SABR.presentValue(swaption365, SABR_MULTICURVES); assertEquals("SwaptionPhysicalFixedIborSABRMethod: presentValue", price360.getAmount(EUR), price365.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueMethodVsCalculator() { final MultipleCurrencyAmount pvMethod = METHOD_SWPT_SABR.presentValue(SWAPTION_LONG_PAYER, SABR_MULTICURVES); final MultipleCurrencyAmount pvCalculator = PVSSC.visit(SWAPTION_LONG_PAYER, SABR_MULTICURVES); assertEquals("SwaptionPhysicalFixedIborSABRMethod: present value : method and calculator", pvMethod, pvCalculator); }