@Override public ResolvedDsf resolve(ReferenceData refData) { ResolvedSwap resolvedSwap = underlyingSwap.resolve(refData); return new ResolvedDsf(securityId, notional, deliveryDate, lastTradeDate, resolvedSwap); }
@Override public ResolvedSwapTrade resolve(ReferenceData refData) { return new ResolvedSwapTrade(info, product.resolve(refData)); }
@Override public ResolvedSwaption resolve(ReferenceData refData) { return ResolvedSwaption.builder() .expiry(expiryDate.adjusted(refData).atTime(expiryTime).atZone(expiryZone)) .longShort(longShort) .swaptionSettlement(swaptionSettlement) .underlying(underlying.resolve(refData)) .build(); }
public void test_resolve() { Swaption base = sut(); ResolvedSwaption test = base.resolve(REF_DATA); assertEquals(test.getExpiry(), ADJUSTMENT.adjust(EXPIRY_DATE, REF_DATA).atTime(EXPIRY_TIME).atZone(ZONE)); assertEquals(test.getLongShort(), LONG); assertEquals(test.getSwaptionSettlement(), PHYSICAL_SETTLE); assertEquals(test.getUnderlying(), SWAP.resolve(REF_DATA)); }
public void test_currentCash_convention() { // Check that standard conventions return a compounded ZC fixed leg FixedInflationSwapConvention US_CPI = FixedInflationSwapConventions.USD_FIXED_ZC_US_CPI; double rate = 0.10; int nbYears = 5; LocalDate endDate = VAL_DATE_INFLATION.plusYears(nbYears); SwapTrade swap = US_CPI.toTrade(VAL_DATE_INFLATION, VAL_DATE_INFLATION, endDate, BuySell.BUY, NOTIONAL, rate); ResolvedSwap resolved = swap.getProduct().resolve(REF_DATA); DiscountingSwapLegPricer pricer = DiscountingSwapLegPricer.DEFAULT; RatesProvider providerEndDate = new MockRatesProvider(endDate); CurrencyAmount c = pricer.currentCash(resolved.getLegs(SwapLegType.FIXED).get(0), providerEndDate); assertEquals(c.getAmount(), -(Math.pow(1 + rate, nbYears) - 1.0) * NOTIONAL, NOTIONAL * EPS); }
public void test_parSpread_iborIbor() { double ps = SWAP_PRODUCT_PRICER.parSpread(SWAP_USD_LIBOR_3M_LIBOR_6M_5Y.getProduct().resolve(REF_DATA), MULTI_USD); SwapTrade swap0 = IborIborSwapTemplate .of(Period.ZERO, TENOR_5Y, CONV_USD_LIBOR3M_LIBOR6M) .createTrade(MULTI_USD.getValuationDate(), BUY, NOTIONAL_SWAP, SPREAD + ps, REF_DATA); CurrencyAmount pv0 = SWAP_PRODUCT_PRICER.presentValue(swap0.getProduct().resolve(REF_DATA), USD, MULTI_USD); assertEquals(pv0.getAmount(), 0, TOLERANCE_PV); }
@Test(dataProvider = "stubIbor") public void test_stub_ibor(IborIborSwapConvention convention, Tenor tenor) { LocalDate tradeDate = LocalDate.of(2015, 10, 20); SwapTrade swap = convention.createTrade(tradeDate, tenor, BuySell.BUY, 1, 0.01, REF_DATA); ResolvedSwap swapResolved = swap.getProduct().resolve(REF_DATA); LocalDate endDate = swapResolved.getLeg(PayReceive.PAY).get().getEndDate(); assertTrue(endDate.isAfter(tradeDate.plus(tenor).minusMonths(1))); assertTrue(endDate.isBefore(tradeDate.plus(tenor).plusMonths(1))); }
@Test(dataProvider = "stubIbor") public void test_stub_ibor(FixedIborSwapConvention convention, Tenor tenor) { LocalDate tradeDate = LocalDate.of(2015, 10, 20); SwapTrade swap = convention.createTrade(tradeDate, tenor, BuySell.BUY, 1, 0.01, REF_DATA); ResolvedSwap swapResolved = swap.getProduct().resolve(REF_DATA); LocalDate endDate = swapResolved.getLeg(PayReceive.PAY).get().getEndDate(); assertTrue(endDate.isAfter(tradeDate.plus(tenor).minusMonths(1))); assertTrue(endDate.isBefore(tradeDate.plus(tenor).plusMonths(1))); }
@Test(dataProvider = "stubOn") public void test_stub_overnight(OvernightIborSwapConvention convention, Tenor tenor) { LocalDate tradeDate = LocalDate.of(2015, 10, 20); SwapTrade swap = convention.createTrade(tradeDate, tenor, BuySell.BUY, 1, 0.01, REF_DATA); ResolvedSwap swapResolved = swap.getProduct().resolve(REF_DATA); LocalDate endDate = swapResolved.getLeg(PayReceive.PAY).get().getEndDate(); assertTrue(endDate.isAfter(tradeDate.plus(tenor).minusDays(7))); assertTrue(endDate.isBefore(tradeDate.plus(tenor).plusDays(7))); }
@Test(dataProvider = "stubIbor") public void test_stub_ibor(ThreeLegBasisSwapConvention convention, Tenor tenor) { LocalDate tradeDate = LocalDate.of(2015, 10, 20); SwapTrade swap = convention.createTrade(tradeDate, tenor, BuySell.BUY, 1, 0.01, REF_DATA); ResolvedSwap swapResolved = swap.getProduct().resolve(REF_DATA); LocalDate endDate = swapResolved.getLeg(PayReceive.PAY).get().getEndDate(); assertTrue(endDate.isAfter(tradeDate.plus(tenor).minusMonths(1))); assertTrue(endDate.isBefore(tradeDate.plus(tenor).plusMonths(1))); }
public void test_parSpread_iborCmpIbor() { SwapTrade trade = USD_LIBOR_3M_LIBOR_6M .createTrade(MULTI_USD.getValuationDate(), TENOR_5Y, BUY, NOTIONAL_SWAP, SPREAD, REF_DATA); double ps = SWAP_PRODUCT_PRICER.parSpread(trade.getProduct().resolve(REF_DATA), MULTI_USD); SwapTrade swap0 = USD_LIBOR_3M_LIBOR_6M .createTrade(MULTI_USD.getValuationDate(), TENOR_5Y, BUY, NOTIONAL_SWAP, SPREAD + ps, REF_DATA); CurrencyAmount pv0 = SWAP_PRODUCT_PRICER.presentValue(swap0.getProduct().resolve(REF_DATA), USD, MULTI_USD); assertEquals(pv0.getAmount(), 0, TOLERANCE_PV); }
public void test_parSpread_iborCmpIbor_1period() { SwapTrade trade = USD_LIBOR_3M_LIBOR_6M .createTrade(MULTI_USD.getValuationDate(), Tenor.TENOR_6M, BUY, NOTIONAL_SWAP, SPREAD, REF_DATA); double ps = SWAP_PRODUCT_PRICER.parSpread(trade.getProduct().resolve(REF_DATA), MULTI_USD); SwapTrade swap0 = USD_LIBOR_3M_LIBOR_6M .createTrade(MULTI_USD.getValuationDate(), Tenor.TENOR_6M, BUY, NOTIONAL_SWAP, SPREAD + ps, REF_DATA); CurrencyAmount pv0 = SWAP_PRODUCT_PRICER.presentValue(swap0.getProduct().resolve(REF_DATA), USD, MULTI_USD); assertEquals(pv0.getAmount(), 0, TOLERANCE_PV); }
public void test_parRate_brl_swap() { DiscountingSwapLegPricer pricerLeg = DiscountingSwapLegPricer.DEFAULT; DiscountingSwapProductPricer pricerSwap = new DiscountingSwapProductPricer(pricerLeg); double parRateComputed = pricerSwap.parRate(BRL_SWAP, BRL_DSCON); RateCalculationSwapLeg fixedLeg = BRL_FIXED_LEG_CONV.toLeg(START_DATE, END_DATE, PAY, NOTIONAL, parRateComputed); ResolvedSwap swapWithParRate = Swap.of(BRL_FLOATING_LEG, fixedLeg).resolve(REF_DATA); double pvWithParRate = pricerSwap.presentValue(swapWithParRate, BRL_DSCON).getAmount(BRL).getAmount(); assertEquals(pvWithParRate, 0.0d, NOTIONAL * TOLERANCE_RATE); }
public void test_parSpread_brl_swap() { DiscountingSwapLegPricer pricerLeg = DiscountingSwapLegPricer.DEFAULT; DiscountingSwapProductPricer pricerSwap = new DiscountingSwapProductPricer(pricerLeg); double parSpreadComputed = pricerSwap.parSpread(BRL_SWAP, BRL_DSCON); RateCalculationSwapLeg fixedLeg = BRL_FIXED_LEG_CONV.toLeg(START_DATE, END_DATE, PAY, NOTIONAL, COUPON + parSpreadComputed); ResolvedSwap swapWithParSpread = Swap.of(BRL_FLOATING_LEG, fixedLeg).resolve(REF_DATA); double pvWithParSpread = pricerSwap.presentValue(swapWithParSpread, BRL_DSCON).getAmount(BRL).getAmount(); assertEquals(pvWithParSpread, 0.0d, NOTIONAL * TOLERANCE_RATE); }
public void test_parSpread_fixedInflation() { ResolvedSwapTrade tradeZc = SWAP_GBP_ZC_INFLATION_5Y.resolve(REF_DATA); double ps = SWAP_PRODUCT_PRICER.parSpread(tradeZc.getProduct(), RATES_GBP_INFLATION); SwapTrade swap0 = FixedInflationSwapConventions.GBP_FIXED_ZC_GB_RPI .createTrade(VAL_DATE_INFLATION, TENOR_5Y, BUY, NOTIONAL_SWAP, FIXED_RATE + ps, REF_DATA); CurrencyAmount pv0 = SWAP_PRODUCT_PRICER.presentValue(swap0.getProduct().resolve(REF_DATA), GBP, RATES_GBP_INFLATION); assertEquals(pv0.getAmount(), 0, TOLERANCE_PV); }
public void test_parSpreadSensitivity_iborIbor() { ResolvedSwap expanded = SWAP_USD_LIBOR_3M_LIBOR_6M_5Y.getProduct().resolve(REF_DATA); PointSensitivities point = SWAP_PRODUCT_PRICER.parSpreadSensitivity(expanded, MULTI_USD).build(); CurrencyParameterSensitivities prAd = MULTI_USD.parameterSensitivity(point); CurrencyParameterSensitivities prFd = FINITE_DIFFERENCE_CALCULATOR.sensitivity( MULTI_USD, p -> CurrencyAmount.of(USD, SWAP_PRODUCT_PRICER.parSpread(expanded, p))); assertTrue(prAd.equalWithTolerance(prFd, TOLERANCE_RATE_DELTA)); }
static ResolvedSwaption sut2() { return ResolvedSwaption.builder() .expiry(EXPIRY.plusHours(1)) .longShort(SHORT) .swaptionSettlement(CASH_SETTLE) .underlying(FixedIborSwapConventions.USD_FIXED_6M_LIBOR_3M .createTrade(LocalDate.of(2014, 6, 10), Tenor.TENOR_10Y, BuySell.BUY, 1d, FIXED_RATE, REF_DATA) .getProduct().resolve(REF_DATA)) .build(); }
private static ResolvedSwap createUnderlyingSwap(LocalDate fixingDate) { FixedIborSwapConvention conv = EUR_EURIBOR_1100_5Y.getTemplate().getConvention(); LocalDate effectiveDate = conv.calculateSpotDateFromTradeDate(fixingDate, REF_DATA); LocalDate maturityDate = effectiveDate.plus(EUR_EURIBOR_1100_5Y.getTemplate().getTenor()); Swap swap = conv.toTrade(fixingDate, effectiveDate, maturityDate, BuySell.BUY, 1d, 1d).getProduct(); return swap.resolve(REF_DATA); }
private static ResolvedSwap createUnderlyingSwap(LocalDate fixingDate) { FixedIborSwapConvention conv = EUR_EURIBOR_1100_5Y.getTemplate().getConvention(); LocalDate effectiveDate = conv.calculateSpotDateFromTradeDate(fixingDate, REF_DATA); LocalDate maturityDate = effectiveDate.plus(EUR_EURIBOR_1100_5Y.getTemplate().getTenor()); Swap swap = conv.toTrade(fixingDate, effectiveDate, maturityDate, BuySell.BUY, 1d, 1d).getProduct(); return swap.resolve(REF_DATA); }
private ResolvedSwap createUnderlyingSwap(LocalDate fixingDate) { FixedIborSwapConvention conv = INDEX.getTemplate().getConvention(); LocalDate effectiveDate = conv.calculateSpotDateFromTradeDate(fixingDate, REF_DATA); LocalDate maturityDate = effectiveDate.plus(INDEX.getTemplate().getTenor()); Swap swap = conv.toTrade(fixingDate, effectiveDate, maturityDate, BuySell.BUY, 1d, 1d).getProduct(); return swap.resolve(REF_DATA); }