/** * Obtains a template based on the specified period and index. * <p> * The period from the spot date to the start date is specified. * The period from the spot date to the end date will be the period to start * plus the tenor of the index. * <p> * For example, a '2 x 5' FRA has a period to the start date of 2 months. * The index will be a 3 month index, such as 'USD-LIBOR-3M'. * The period to the end date will be the period to the start date plus the index tenor. * * @param periodToStart the period between the spot date and the start date * @param index the index that defines the market convention * @return the template */ public static FraTemplate of(Period periodToStart, IborIndex index) { return of(periodToStart, periodToStart.plus(index.getTenor().getPeriod()), FraConvention.of(index)); }
private static CurveNode curveFraCurveNode( String conventionStr, String timeStr, String label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order) { Matcher matcher = FRA_TIME_REGEX.matcher(timeStr.toUpperCase(Locale.ENGLISH)); if (!matcher.matches()) { throw new IllegalArgumentException(Messages.format("Invalid time format for FRA: {}", timeStr)); } Period periodToStart = Period.parse("P" + matcher.group(1) + "M"); Period periodToEnd = Period.parse("P" + matcher.group(2) + "M"); FraConvention convention = FraConvention.of(conventionStr); FraTemplate template = FraTemplate.of(periodToStart, periodToEnd, convention); return FraCurveNode.builder() .template(template) .rateId(quoteId) .additionalSpread(spread) .label(label) .date(date) .dateOrder(order) .build(); }
public void test_serialization() { FraTemplate test = FraTemplate.of(Period.ofMonths(2), GBP_LIBOR_3M); assertSerialization(test); }
public void test_of_PeriodIndex() { FraTemplate test = FraTemplate.of(Period.ofMonths(2), GBP_LIBOR_3M); assertEquals(test.getPeriodToStart(), Period.ofMonths(2)); assertEquals(test.getPeriodToEnd(), Period.ofMonths(5)); // defaulted assertEquals(test.getConvention(), FRA_GBP_LIBOR_3M); }
public void test_of_PeriodPeriodConvention() { FraTemplate test = FraTemplate.of(Period.ofMonths(2), Period.ofMonths(4), FRA_GBP_LIBOR_3M); assertEquals(test.getPeriodToStart(), Period.ofMonths(2)); assertEquals(test.getPeriodToEnd(), Period.ofMonths(4)); assertEquals(test.getConvention(), FRA_GBP_LIBOR_3M); }
public void test_createTrade() { FraTemplate base = FraTemplate.of(Period.ofMonths(3), Period.ofMonths(6), FRA_GBP_LIBOR_3M); LocalDate tradeDate = LocalDate.of(2015, 5, 4); // trade date is a holiday! FraTrade test = base.createTrade(tradeDate, BUY, NOTIONAL_2M, 0.25d, REF_DATA); Fra expected = Fra.builder() .buySell(BUY) .notional(NOTIONAL_2M) .startDate(date(2015, 8, 5)) .endDate(date(2015, 11, 5)) .fixedRate(0.25d) .index(GBP_LIBOR_3M) .build(); assertEquals(test.getInfo().getTradeDate(), Optional.of(tradeDate)); assertEquals(test.getProduct(), expected); }
public void coverage() { FraCurveNode test = FraCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD); coverImmutableBean(test); FraCurveNode test2 = FraCurveNode.of( FraTemplate.of(Period.ofMonths(1), GBP_LIBOR_6M), QuoteId.of(StandardId.of("OG-Ticker", "Deposit2"))); coverBeanEquals(test, test2); }
public void test_createTrade_paymentOffset() { FraConvention convention = ((ImmutableFraConvention) FRA_GBP_LIBOR_3M).toBuilder() .paymentDateOffset(PLUS_TWO_DAYS) .build(); FraTemplate base = FraTemplate.of(Period.ofMonths(3), Period.ofMonths(6), convention); LocalDate tradeDate = LocalDate.of(2015, 5, 4); // trade date is a holiday! FraTrade test = base.createTrade(tradeDate, BUY, NOTIONAL_2M, 0.25d, REF_DATA); Fra expected = Fra.builder() .buySell(BUY) .notional(NOTIONAL_2M) .startDate(date(2015, 8, 5)) .endDate(date(2015, 11, 5)) .paymentDate(AdjustableDate.of(date(2015, 8, 7), PLUS_TWO_DAYS.getAdjustment())) .fixedRate(0.25d) .index(GBP_LIBOR_3M) .build(); assertEquals(test.getInfo().getTradeDate(), Optional.of(tradeDate)); assertEquals(test.getProduct(), expected); }
QuoteId.of(StandardId.of(SCHEME, fwd3IdValues[0]))); for (int i = 0; i < fwd3FraTenors.length; i++) { fwd3Nodes[i + 1] = FraCurveNode.of(FraTemplate.of(fwd3FraTenors[i], EUR_EURIBOR_3M), QuoteId.of(StandardId.of(SCHEME, fwd3IdValues[i + 1]))); QuoteId.of(StandardId.of(SCHEME, fwd6IdValues[0]))); for (int i = 0; i < fwd6FraTenors.length; i++) { fwd6Nodes[i + 1] = FraCurveNode.of(FraTemplate.of(fwd6FraTenors[i], EUR_EURIBOR_6M), QuoteId.of(StandardId.of(SCHEME, fwd6IdValues[i + 1])));