SwaptionPhysicalFixedIborSpreadBlackMethod { 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 = METHOD_SWAP.forwardSwapSpreadModified(swaption.getUnderlyingSwap(), pvbpModified, multicurves); final double strikeModified = METHOD_SWAP.couponEquivalentSpreadModified(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  SwaptionPhysicalFixedIborSpreadBlackMethod(); static SwaptionPhysicalFixedIborSpreadBlackMethod getInstance(); MultipleCurrencyAmount presentValue(final SwaptionPhysicalFixedIbor swaption, final BlackSwaptionFlatProviderInterface blackMulticurves);  }
@Test public void presentValue() { final MultipleCurrencyAmount pvComputed = METHOD_SWAPTION_SPREAD.presentValue(SWAPTION_SPREAD_EUR1Y3M, BLACK_MULTICURVES); final double pvbp = METHOD_SWAP_SPREAD.presentValueBasisPoint(SWAP_SPREAD_EUR1Y3M, EUR1YEURIBOR3M.getFixedLegDayCount(), MULTICURVES); final double forward = METHOD_SWAP_SPREAD.forwardSwapSpreadModified(SWAP_SPREAD_EUR1Y3M, pvbp, MULTICURVES); final double strike = METHOD_SWAP_SPREAD.couponEquivalentSpreadModified(SWAP_SPREAD_EUR1Y3M, pvbp, MULTICURVES); final double volatility = BLACK.getVolatility(SWAPTION_SPREAD_EUR1Y3M.getTimeToExpiry(), SWAPTION_SPREAD_EUR1Y3M.getMaturityTime()); final EuropeanVanillaOption option = new EuropeanVanillaOption(strike, SWAPTION_SPREAD_EUR1Y3M.getTimeToExpiry(), SWAPTION_SPREAD_EUR1Y3M.isCall()); final BlackPriceFunction blackFunction = new BlackPriceFunction(); final BlackFunctionData dataBlack = new BlackFunctionData(forward, pvbp, volatility); final Function1D<BlackFunctionData, Double> func = blackFunction.getPriceFunction(option); final double pvExpected = func.evaluate(dataBlack) * (IS_LONG ? 1.0 : -1.0); assertEquals("SwaptionPhysicalFixedIborSpreadBlackMethod: presentValue", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueNoSpread() { final MultipleCurrencyAmount pvComputed = METHOD_SWAPTION_SPREAD.presentValue(SWAPTION_SPREAD_EUR3M3M, BLACK_MULTICURVES); final MultipleCurrencyAmount pvExpected = METHOD_SWAPTION.presentValue(SWAPTION_NOSPREAD_EUR3M3M, BLACK_MULTICURVES); assertEquals("SwaptionPhysicalFixedIborSpreadBlackMethod: presentValue", pvExpected.getAmount(EUR), pvComputed.getAmount(EUR), TOLERANCE_PV); }