SwaptionCashFixedIborLinearTSRMethod { public MultipleCurrencyAmount presentValue(final SwaptionCashFixedIbor swaption, final SABRSwaptionProviderInterface sabrData) { ArgumentChecker.notNull(swaption, "Swaption"); ArgumentChecker.notNull(sabrData, "SABR swaption provider"); MulticurveProviderInterface multicurves = sabrData.getMulticurveProvider(); Currency ccy = swaption.getCurrency(); final AnnuityCouponFixed annuityFixed = swaption.getUnderlyingSwap().getFixedLeg(); final double nominal = Math.abs(annuityFixed.getNthPayment(0).getNotional()); final double discountFactorSettle = multicurves.getDiscountFactor(ccy, swaption.getSettlementTime()); final double annuityPhysical = METHOD_SWAP.presentValueBasisPoint(swaption.getUnderlyingSwap(), multicurves) / nominal; final double strike = swaption.getStrike(); final double forward = swaption.getUnderlyingSwap().accept(PRDC, multicurves); final double[] alpha = new double[2]; for (int loopcpn = 0; loopcpn < annuityFixed.getNumberOfPayments(); loopcpn++) { alpha[1] += annuityFixed.getNthPayment(loopcpn).getPaymentYearFraction(); } alpha[1] = 1 / alpha[1]; alpha[0] = (discountFactorSettle / annuityPhysical - alpha[1]) / forward; final LinearTSRIntegrant integrant = new LinearTSRIntegrant(swaption, sabrData.getSABRParameter(), forward, alpha); @SuppressWarnings("synthetic-access") final double strikePart = integrant.k(strike) * integrant.bs(strike); final double absoluteTolerance = 1.0E-2; final double relativeTolerance = 1.0E-5; final RungeKuttaIntegrator1D integrator = new RungeKuttaIntegrator1D(absoluteTolerance, relativeTolerance, _nbIteration); double integralPart; try { if (swaption.isCall()) { integralPart = integrator.integrate(integrant, strike, strike + _integrationInterval); } else { integralPart = integrator.integrate(integrant, 0.0, strike); } } catch (final Exception e) { throw new RuntimeException(e); } final double pv = nominal * annuityPhysical * (strikePart + integralPart) * (swaption.isLong() ? 1.0 : -1.0); return MultipleCurrencyAmount.of(swaption.getCurrency(), pv); }  MultipleCurrencyAmount presentValue(final SwaptionCashFixedIbor swaption, final SABRSwaptionProviderInterface sabrData);  }
@Test(enabled = true) public void presentValue() { final MultipleCurrencyAmount pvPayerTSR = METHOD_CASH_TSR.presentValue(SWAPTION_PAYER_LONG, SABR_MULTICURVES); final double pvPayerExpected = 1917641.961; assertEquals("Cash-settled swaption: linear TSR: present value", pvPayerExpected, pvPayerTSR.getAmount(EUR), 1E+0); final MultipleCurrencyAmount pvReceiverTSR = METHOD_CASH_TSR.presentValue(SWAPTION_RECEIVER_LONG, SABR_MULTICURVES); final double pvReceiverExpected = 4102844.469; assertEquals("Cash-settled swaption: linear TSR: present value", pvReceiverExpected, pvReceiverTSR.getAmount(EUR), 1E+0); }
@Test(enabled = true) public void presentValueLongShortParity() { final MultipleCurrencyAmount pvLongTSR = METHOD_CASH_TSR.presentValue(SWAPTION_PAYER_LONG, SABR_MULTICURVES); final MultipleCurrencyAmount pvShortTSR = METHOD_CASH_TSR.presentValue(SWAPTION_PAYER_SHORT, SABR_MULTICURVES); assertEquals("Cash-settled swaption: linear TSR: present value - long/short parity", -pvLongTSR.getAmount(EUR), pvShortTSR.getAmount(EUR), 1E-2); }
@Test(enabled = true) public void presentValueMultiStrike() { final int nbStrike = 10; final double strikeMin = 0.030; final double strikeMax = 0.050; final double[] strike = new double[nbStrike + 1]; final SwapFixedIborDefinition[] swapDefinition = new SwapFixedIborDefinition[nbStrike + 1]; final SwaptionCashFixedIborDefinition[] swaptionCashDefinition = new SwaptionCashFixedIborDefinition[nbStrike + 1]; final SwaptionCashFixedIbor[] swaptionCash = new SwaptionCashFixedIbor[nbStrike + 1]; final SwaptionPhysicalFixedIborDefinition[] swaptionPhysDefinition = new SwaptionPhysicalFixedIborDefinition[nbStrike + 1]; final SwaptionPhysicalFixedIbor[] swaptionPhys = new SwaptionPhysicalFixedIbor[nbStrike + 1]; for (int loopstrike = 0; loopstrike < nbStrike + 1; loopstrike++) { strike[loopstrike] = strikeMin + loopstrike * (strikeMax - strikeMin) / nbStrike; swapDefinition[loopstrike] = SwapFixedIborDefinition.from(SETTLEMENT_DATE, CMS_INDEX, NOTIONAL, strike[loopstrike], FIXED_IS_PAYER, CALENDAR); swaptionCashDefinition[loopstrike] = SwaptionCashFixedIborDefinition.from(EXPIRY_DATE, swapDefinition[loopstrike], true, IS_LONG); swaptionCash[loopstrike] = swaptionCashDefinition[loopstrike].toDerivative(REFERENCE_DATE); swaptionPhysDefinition[loopstrike] = SwaptionPhysicalFixedIborDefinition.from(EXPIRY_DATE, swapDefinition[loopstrike], true, IS_LONG); swaptionPhys[loopstrike] = swaptionPhysDefinition[loopstrike].toDerivative(REFERENCE_DATE); } final double[] pvCashStandard = new double[nbStrike + 1]; final double[] pvCashTSR = new double[nbStrike + 1]; final double[] pvPhysical = new double[nbStrike + 1]; for (int loopstrike = 0; loopstrike < nbStrike + 1; loopstrike++) { pvCashStandard[loopstrike] = METHOD_CASH_SABR.presentValue(swaptionCash[loopstrike], SABR_MULTICURVES).getAmount(EUR); pvCashTSR[loopstrike] = METHOD_CASH_TSR.presentValue(swaptionCash[loopstrike], SABR_MULTICURVES).getAmount(EUR); pvPhysical[loopstrike] = METHOD_PHYS_SABR.presentValue(swaptionPhys[loopstrike], SABR_MULTICURVES).getAmount(EUR); } }