// ------------------------------------------------------------------------- public void test_toTrade_tenor() { ThreeLegBasisSwapConvention base = ImmutableThreeLegBasisSwapConvention.of(NAME, FIXED, IBOR6M, IBOR12M); LocalDate tradeDate = LocalDate.of(2015, 5, 5); LocalDate startDate = date(2015, 5, 7); LocalDate endDate = date(2025, 5, 7); SwapTrade test = base.createTrade(tradeDate, TENOR_10Y, BUY, NOTIONAL_2M, 0.25d, REF_DATA); Swap expected = Swap.of( FIXED.toLeg(startDate, endDate, PAY, NOTIONAL_2M, 0.25d), IBOR6M.toLeg(startDate, endDate, PAY, NOTIONAL_2M), IBOR12M.toLeg(startDate, endDate, RECEIVE, NOTIONAL_2M)); assertEquals(test.getInfo().getTradeDate(), Optional.of(tradeDate)); assertEquals(test.getProduct(), expected); }
// ----------------------------------------------------------------------- // create a vanilla fixed vs libor 3m swap private static Trade createVanillaFixedVsLibor3mSwap() { NotionalSchedule notional = NotionalSchedule.of(Currency.USD, 100_000_000); SwapLeg payLeg = RateCalculationSwapLeg.builder() .payReceive(PayReceive.PAY) .accrualSchedule( PeriodicSchedule.builder() .startDate(LocalDate.of(2014, 9, 12)) .endDate(LocalDate.of(2021, 9, 12)) .frequency(Frequency.P6M) .businessDayAdjustment( BusinessDayAdjustment.of(MODIFIED_FOLLOWING, HolidayCalendarIds.USNY)) .build()) .paymentSchedule( PaymentSchedule.builder() .paymentFrequency(Frequency.P6M) .paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(notional) .calculation(FixedRateCalculation.of(0.015, DayCounts.THIRTY_U_360)) .build(); SwapLeg receiveLeg = RateCalculationSwapLeg.builder() .payReceive(PayReceive.RECEIVE) .accrualSchedule( PeriodicSchedule.builder() .startDate(LocalDate.of(2014, 9, 12)) .endDate(LocalDate.of(2021, 9, 12)) .frequency(Frequency.P3M) .businessDayAdjustment( BusinessDayAdjustment.of(MODIFIED_FOLLOWING, HolidayCalendarIds.USNY)) .build()) .paymentSchedule( PaymentSchedule.builder() .paymentFrequency(Frequency.P3M) .paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(notional) .calculation(IborRateCalculation.of(IborIndices.USD_LIBOR_3M)) .build(); return SwapTrade.builder() .product(Swap.of(payLeg, receiveLeg)) .info( TradeInfo.builder() .addAttribute(TradeAttributeType.DESCRIPTION, "Fixed vs Libor 3m") .counterparty(StandardId.of("example", "A")) .settlementDate(LocalDate.of(2014, 9, 12)) .build()) .build(); }
@Override public DatedCurveParameterMetadata metadata(LocalDate valuationDate) { SwapTrade trade = template.toTrade(valuationDate, BuySell.BUY, 1, 1, 0); return TenorCurveNodeMetadata.of(trade.getProduct().getEndDate(), template.getTenor(), label); }