public void test_pvbp_compounding_flat_ibor() { LocalDate tradeDate = RATES_USD.getValuationDate(); LocalDate effectiveDate = USD_LIBOR_3M_LIBOR_6M.calculateSpotDateFromTradeDate(tradeDate, REF_DATA); LocalDate endDate = effectiveDate.plus(TENOR_10Y); double spread = 0.0015; double shift = 1.0E-6; RateCalculationSwapLeg leg0 = IborIborSwapConventions.USD_LIBOR_3M_LIBOR_6M.getSpreadLeg() .toLeg(effectiveDate, endDate, RECEIVE, NOTIONAL, spread); RateCalculationSwapLeg legP = IborIborSwapConventions.USD_LIBOR_3M_LIBOR_6M.getSpreadLeg() .toLeg(effectiveDate, endDate, RECEIVE, NOTIONAL, spread + shift); double parSpread = PRICER_LEG.pvbp(leg0.resolve(REF_DATA), RATES_USD); double pv0 = PRICER_LEG.presentValue(leg0.resolve(REF_DATA), RATES_USD).getAmount(); double pvP = PRICER_LEG.presentValue(legP.resolve(REF_DATA), RATES_USD).getAmount(); double parSpreadExpected = (pvP - pv0) / shift; assertEquals(parSpread, parSpreadExpected, TOLERANCE_PVBP_FD); }
public void test_pvbpSensitivity_compounding_flat_ibor() { LocalDate tradeDate = RATES_USD.getValuationDate(); LocalDate effectiveDate = USD_LIBOR_3M_LIBOR_6M.calculateSpotDateFromTradeDate(tradeDate, REF_DATA); LocalDate endDate = effectiveDate.plus(TENOR_10Y); double spread = 0.0015; RateCalculationSwapLeg leg = IborIborSwapConventions.USD_LIBOR_3M_LIBOR_6M.getSpreadLeg() .toLeg(effectiveDate, endDate, RECEIVE, NOTIONAL, spread); PointSensitivities pvbppts = PRICER_LEG.pvbpSensitivity(leg.resolve(REF_DATA), RATES_USD).build(); CurrencyParameterSensitivities psAd = RATES_USD.parameterSensitivity(pvbppts); CurrencyParameterSensitivities psFd = FINITE_DIFFERENCE_CALCULATOR.sensitivity( RATES_USD, (p) -> CurrencyAmount.of(USD, PRICER_LEG.pvbp(leg.resolve(REF_DATA), p))); ImmutableList<CurrencyParameterSensitivity> listAd = psAd.getSensitivities(); ImmutableList<CurrencyParameterSensitivity> listFd = psFd.getSensitivities(); assertEquals(listAd.size(), 2); // No Libor 6M sensitivity assertEquals(listFd.size(), 3); // Libor 6M sensitivity equal to 0 in Finite Difference assertTrue(psAd.equalWithTolerance(psFd, TOLERANCE_DELTA)); }
.calculation(rateCalc) .build() .resolve(REF_DATA); DiscountingSwapLegPricer pricer = DiscountingSwapLegPricer.DEFAULT; Map<Currency, Curve> dscCurve = RATES_GBP_INFLATION.getDiscountCurves();
.type(SwapLegType.INFLATION) .build(); ResolvedSwapLeg testResolved = test.resolve(REF_DATA); assertEquals(testResolved, expected);
.type(SwapLegType.INFLATION) .build(); ResolvedSwapLeg testExpand = test.resolve(REF_DATA); assertEquals(testExpand, expected);
HolidayCalendarIds.SAT_SUN, HolidayCalendars.SAT_SUN, HolidayCalendarIds.NO_HOLIDAYS, HolidayCalendars.NO_HOLIDAYS)); ResolvedSwapLeg expandedRecLeg = recLeg.resolve(refData); assertEquals(expandedRecLeg.getPaymentPeriods().size(), 4); assertIborPaymentPeriodCpd(expandedRecLeg, 0, 0, "2000-11-03", "2000-04-27", "2000-07-27", 100000000d, "2000-04-25"); ResolvedSwapLeg expandedPayLeg = payLeg.resolve(refData); assertEquals(expandedPayLeg.getPaymentPeriods().size(), 4); assertFixedPaymentPeriod(expandedPayLeg, 0, "2000-11-03", "2000-04-27", "2000-10-27", 100000000d, 0.0585d);
.resolve(REF_DATA); ResolvedSwap swapWithParRate = ResolvedSwap.of(INFLATION_MONTHLY_SWAP_LEG_REC_GBP, fixedLeg); double pvWithParRate = pricerSwap.presentValue(swapWithParRate, prov).getAmount(GBP).getAmount();
HolidayCalendarIds.SAT_SUN, HolidayCalendars.SAT_SUN, HolidayCalendarIds.NO_HOLIDAYS, HolidayCalendars.NO_HOLIDAYS)); ResolvedSwapLeg expandedPayLeg = payLeg.resolve(refData); assertEquals(expandedPayLeg.getPaymentPeriods().size(), 10); assertIborPaymentPeriod(expandedPayLeg, 0, "1995-06-14", "1995-01-16", "1995-06-14", 50000000d, "1995-01-12"); assertIborPaymentPeriod(expandedPayLeg, 8, "1999-06-14", "1998-12-14", "1999-06-14", 10000000d, "1998-12-10"); assertIborPaymentPeriod(expandedPayLeg, 9, "1999-12-14", "1999-06-14", "1999-12-14", 10000000d, "1999-06-10"); ResolvedSwapLeg expandedRecLeg = recLeg.resolve(refData); assertEquals(expandedRecLeg.getPaymentPeriods().size(), 5); assertFixedPaymentPeriod(expandedRecLeg, 0, "1995-12-14", "1995-01-16", "1995-12-14", 50000000d, 0.06d);
.type(SwapLegType.FIXED) .build(); ResolvedSwapLeg testExpand = test.resolve(REF_DATA); assertEquals(testExpand, expected);
.build()) .build() .resolve(REF_DATA); ResolvedSwap swap = ResolvedSwap.of(INFLATION_MONTHLY_SWAP_LEG_REC_GBP, fixedLeg); DiscountingSwapLegPricer pricerLeg = DiscountingSwapLegPricer.DEFAULT; .build()) .build() .resolve(REF_DATA); ResolvedSwap swapWithParRate = ResolvedSwap.of(INFLATION_MONTHLY_SWAP_LEG_REC_GBP, fixedLegWithParRate); double pvWithParRate = pricerSwap.presentValue(swapWithParRate, prov).getAmount(GBP).getAmount();
.build(); assertEquals(test.resolve(REF_DATA), ResolvedSwapLeg.builder() .type(FIXED) .payReceive(PAY)
.build(); assertEquals(test.resolve(REF_DATA), ResolvedSwapLeg.builder() .type(FIXED) .payReceive(PAY)
.build(); assertEquals(test.resolve(REF_DATA), ResolvedSwapLeg.builder() .type(FIXED) .payReceive(PAY)
CurrencyAmount.of(EUR, -1000d), DATE_04_09, FxIndexObservation.of(EUR_GBP_ECB, DATE_03_03, REF_DATA)); assertEquals(test.resolve(REF_DATA), ResolvedSwapLeg.builder() .type(FIXED) .payReceive(PAY)
NotionalExchange nexFinal = NotionalExchange.of(CurrencyAmount.of(GBP, -1500d), DATE_06_09); assertEquals(test.resolve(REF_DATA), ResolvedSwapLeg.builder() .type(IBOR) .payReceive(PAY)