SwaptionPhysicalFixedIborBlackMethod { public MultipleCurrencyAmount presentValue(final SwaptionPhysicalFixedIbor swaption, final BlackSwaptionFlatProviderInterface blackMulticurves) { ArgumentChecker.notNull(swaption, "Swaption"); ArgumentChecker.notNull(blackMulticurves, "Black volatility for swaption and multicurve"); final GeneratorInstrument<GeneratorAttributeIR> generatorSwap = blackMulticurves.getBlackParameters().getGeneratorSwap(); Calendar calendar; DayCount dayCountModification; if (generatorSwap instanceof GeneratorSwapFixedIbor) { final GeneratorSwapFixedIbor fixedIborGenerator = (GeneratorSwapFixedIbor) generatorSwap; calendar = fixedIborGenerator.getCalendar(); dayCountModification = fixedIborGenerator.getFixedLegDayCount(); } else if (generatorSwap instanceof GeneratorSwapFixedON) { final GeneratorSwapFixedON fixedONGenerator = (GeneratorSwapFixedON) generatorSwap; calendar = fixedONGenerator.getOvernightCalendar(); dayCountModification = fixedONGenerator.getFixedLegDayCount(); } else if (generatorSwap instanceof GeneratorSwapFixedCompoundedONCompounded) { final GeneratorSwapFixedCompoundedONCompounded fixedCompoundedON = (GeneratorSwapFixedCompoundedONCompounded) generatorSwap; calendar = fixedCompoundedON.getOvernightCalendar(); dayCountModification = fixedCompoundedON.getFixedLegDayCount(); } else { throw new IllegalArgumentException("Cannot handle swap with underlying generator of type " + generatorSwap.getClass()); } final MulticurveProviderInterface multicurves = blackMulticurves.getMulticurveProvider(); final double pvbpModified = METHOD_SWAP.presentValueBasisPoint(swaption.getUnderlyingSwap(), dayCountModification, calendar, 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 = blackMulticurves.getBlackParameters().getVolatility(swaption.getTimeToExpiry(), maturity); 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  SwaptionPhysicalFixedIborBlackMethod(); static SwaptionPhysicalFixedIborBlackMethod getInstance(); MultipleCurrencyAmount presentValue(final SwaptionPhysicalFixedIbor swaption, final BlackSwaptionFlatProviderInterface blackMulticurves); double impliedVolatility(final SwaptionPhysicalFixedIbor swaption, final BlackSwaptionFlatProviderInterface blackMulticurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final SwaptionPhysicalFixedIbor swaption, final BlackSwaptionFlatProviderInterface blackMulticurves); MultipleCurrencyMulticurveSensitivity presentValueSecondOrderCurveSensitivity(final SwaptionPhysicalFixedIbor swaption, final BlackSwaptionFlatProviderInterface blackMulticurves); PresentValueSwaptionSurfaceSensitivity presentValueBlackSensitivity(final SwaptionPhysicalFixedIbor swaption, final BlackSwaptionFlatProviderInterface blackMulticurves);  }
@Test public void presentValue() { final MultipleCurrencyAmount pvMethod = METHOD_BLACK.presentValue(SWAPTION_LONG_REC, BLACK_MULTICURVES); final double forward = SWAPTION_LONG_REC.getUnderlyingSwap().accept(PRDC, MULTICURVES); final double pvbp = METHOD_SWAP.presentValueBasisPoint(SWAPTION_LONG_REC.getUnderlyingSwap(), MULTICURVES); final double volatility = BLACK.getVolatility(SWAPTION_LONG_REC.getTimeToExpiry(), SWAPTION_LONG_REC.getMaturityTime()); final BlackPriceFunction blackFunction = new BlackPriceFunction(); final BlackFunctionData dataBlack = new BlackFunctionData(forward, pvbp, volatility); final Function1D<BlackFunctionData, Double> func = blackFunction.getPriceFunction(SWAPTION_LONG_REC); final double pvExpected = func.evaluate(dataBlack); assertEquals("Swaption Black method: present value", pvExpected, pvMethod.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValuePayerReceiverParity() { final SwapFixedIborDefinition swapDefinitionPay = SwapFixedIborDefinition.from(SETTLE_DATE, SWAP_TENOR, GENERATOR_EUR1YEURIBOR6M, NOTIONAL, RATE, true); final SwaptionPhysicalFixedIborDefinition swaptionDefinitionShortPayer = SwaptionPhysicalFixedIborDefinition.from(EXPIRY_DATE, swapDefinitionPay, true, false); final SwaptionPhysicalFixedIbor swaptionShortPayer = swaptionDefinitionShortPayer.toDerivative(REFERENCE_DATE); final InstrumentDerivative swapRec = SWAP_DEFINITION_REC.toDerivative(REFERENCE_DATE); final MultipleCurrencyAmount pvLR = METHOD_BLACK.presentValue(SWAPTION_LONG_REC, BLACK_MULTICURVES); final MultipleCurrencyAmount pvSP = METHOD_BLACK.presentValue(swaptionShortPayer, BLACK_MULTICURVES); final MultipleCurrencyAmount pvSwap = swapRec.accept(PVDC, MULTICURVES); assertEquals("Swaption Black method: present value", pvSwap.getAmount(EUR), pvLR.getAmount(EUR) + pvSP.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueMethodVsCalculator() { final MultipleCurrencyAmount pvMethod = METHOD_BLACK.presentValue(SWAPTION_LONG_REC, BLACK_MULTICURVES); final MultipleCurrencyAmount pvCalculator = SWAPTION_LONG_REC.accept(PVBSC, BLACK_MULTICURVES); assertEquals("Swaption Black method: present value", pvCalculator.getAmount(EUR), pvMethod.getAmount(EUR), TOLERANCE_PV); }