public void test_builder_minSpecified() { ImmutableFraConvention test = ImmutableFraConvention.builder() .index(GBP_LIBOR_3M) .build(); assertEquals(test.getName(), GBP_LIBOR_3M.getName()); assertEquals(test.getIndex(), GBP_LIBOR_3M); assertEquals(test.getCurrency(), GBP); assertEquals(test.getSpotDateOffset(), GBP_LIBOR_3M.getEffectiveDateOffset()); assertEquals(test.getBusinessDayAdjustment(), BDA_MOD_FOLLOW); assertEquals(test.getPaymentDateOffset(), DaysAdjustment.NONE); assertEquals(test.getFixingDateOffset(), GBP_LIBOR_3M.getFixingDateOffset()); assertEquals(test.getDayCount(), GBP_LIBOR_3M.getDayCount()); assertEquals(test.getDiscounting(), ISDA); }
public void test_builder_AUD() { ImmutableFraConvention test = ImmutableFraConvention.of(AUD_INDEX); assertEquals(test.getIndex(), AUD_INDEX); assertEquals(test.getDiscounting(), AFMA); }
@Override public FraTrade createTrade( LocalDate tradeDate, Period periodToStart, Period periodToEnd, BuySell buySell, double notional, double fixedRate, ReferenceData refData) { LocalDate spotValue = calculateSpotDateFromTradeDate(tradeDate, refData); LocalDate startDate = spotValue.plus(periodToStart); LocalDate endDate = spotValue.plus(periodToEnd); DateAdjuster bda = getBusinessDayAdjustment().resolve(refData); // start/end dates are adjusted when FRA trade is created and not adjusted later // payment date is adjusted when FRA trade is created and potentially adjusted again when resolving LocalDate adjustedStart = bda.adjust(startDate); LocalDate adjustedEnd = bda.adjust(endDate); LocalDate adjustedPay = getPaymentDateOffset().adjust(adjustedStart, refData); return toTrade(tradeDate, adjustedStart, adjustedEnd, adjustedPay, buySell, notional, fixedRate); }
public void test_of_index() { ImmutableFraConvention test = ImmutableFraConvention.of(GBP_LIBOR_3M); assertEquals(test.getIndex(), GBP_LIBOR_3M); assertEquals(test.getName(), GBP_LIBOR_3M.getName()); assertEquals(test.getCurrency(), GBP); assertEquals(test.getSpotDateOffset(), GBP_LIBOR_3M.getEffectiveDateOffset()); assertEquals(test.getBusinessDayAdjustment(), BDA_MOD_FOLLOW); assertEquals(test.getPaymentDateOffset(), DaysAdjustment.NONE); assertEquals(test.getFixingDateOffset(), GBP_LIBOR_3M.getFixingDateOffset()); assertEquals(test.getDayCount(), ACT_365F); assertEquals(test.getDiscounting(), ISDA); // ensure other factories match assertEquals(FraConvention.of(GBP_LIBOR_3M), test); assertEquals(FraConventions.of(GBP_LIBOR_3M), test); }
.product(Fra.builder() .buySell(buySell) .currency(getCurrency()) .notional(notional) .startDate(startDate) .endDate(endDate) .paymentDate(AdjustableDate.of(paymentDate, getPaymentDateOffset().getAdjustment())) .fixedRate(fixedRate) .index(index) .fixingDateOffset(getFixingDateOffset()) .dayCount(getDayCount()) .discounting(getDiscounting()) .build()) .build();
/** * Obtains a convention based on the specified index. * <p> * The standard market convention for a FRA is based exclusively on the index. * This creates an instance that contains the index. * The instance is not dereferenced using the {@code FraConvention} name, as such * the result of this method and {@link FraConvention#of(IborIndex)} can differ. * <p> * Use the {@linkplain #builder() builder} for unusual conventions. * * @param index the index, the market convention values are extracted from the index * @return the convention */ public static ImmutableFraConvention of(IborIndex index) { return ImmutableFraConvention.builder() .index(index) .build(); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ImmutableFraConvention beanToCopy) { this.index = beanToCopy.getIndex(); this.name = beanToCopy.name; this.currency = beanToCopy.currency; this.dayCount = beanToCopy.dayCount; this.spotDateOffset = beanToCopy.spotDateOffset; this.businessDayAdjustment = beanToCopy.businessDayAdjustment; this.fixingDateOffset = beanToCopy.fixingDateOffset; this.paymentDateOffset = beanToCopy.paymentDateOffset; this.discounting = beanToCopy.discounting; }
@Override public String toString() { return getName(); }
public void test_builder_noIndex() { assertThrowsIllegalArg(() -> ImmutableFraConvention.builder() .spotDateOffset(NEXT_SAME_BUS_DAY) .build()); }
private static FraConvention createByName(String name) { return IborIndex.extendedEnum().find(name) .map(index -> ImmutableFraConvention.of(index)) .orElse(null); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 100346066: // index return ((ImmutableFraConvention) bean).getIndex(); case 3373707: // name return ((ImmutableFraConvention) bean).name; case 575402001: // currency return ((ImmutableFraConvention) bean).currency; case 1905311443: // dayCount return ((ImmutableFraConvention) bean).dayCount; case 746995843: // spotDateOffset return ((ImmutableFraConvention) bean).spotDateOffset; case -1065319863: // businessDayAdjustment return ((ImmutableFraConvention) bean).businessDayAdjustment; case 873743726: // fixingDateOffset return ((ImmutableFraConvention) bean).fixingDateOffset; case -716438393: // paymentDateOffset return ((ImmutableFraConvention) bean).paymentDateOffset; case -536441087: // discounting return ((ImmutableFraConvention) bean).discounting; } return super.propertyGet(bean, propertyName, quiet); }
public void test_builder_NZD() { ImmutableFraConvention test = ImmutableFraConvention.of(NZD_INDEX); assertEquals(test.getIndex(), NZD_INDEX); assertEquals(test.getDiscounting(), AFMA); }
public void test_serialization() { ImmutableFraConvention test = ImmutableFraConvention.builder() .index(GBP_LIBOR_3M) .build(); assertSerialization(test); }
public void test_builder_allSpecified() { ImmutableFraConvention test = ImmutableFraConvention.builder() .name(GBP_LIBOR_3M.getName()) .index(GBP_LIBOR_3M) .currency(GBP) .spotDateOffset(PLUS_ONE_DAY) .businessDayAdjustment(BDA_FOLLOW) .paymentDateOffset(PLUS_TWO_DAYS) .fixingDateOffset(MINUS_FIVE_DAYS) .dayCount(ACT_360) .discounting(FraDiscountingMethod.NONE) .build(); assertEquals(test.getName(), GBP_LIBOR_3M.getName()); assertEquals(test.getIndex(), GBP_LIBOR_3M); assertEquals(test.getCurrency(), GBP); assertEquals(test.getSpotDateOffset(), PLUS_ONE_DAY); assertEquals(test.getBusinessDayAdjustment(), BDA_FOLLOW); assertEquals(test.getPaymentDateOffset(), PLUS_TWO_DAYS); assertEquals(test.getFixingDateOffset(), MINUS_FIVE_DAYS); assertEquals(test.getDayCount(), ACT_360); assertEquals(test.getDiscounting(), FraDiscountingMethod.NONE); }
public void test_createTrade_period() { FraConvention base = ImmutableFraConvention.builder() .index(GBP_LIBOR_3M) .spotDateOffset(NEXT_SAME_BUS_DAY) .build(); LocalDate tradeDate = LocalDate.of(2015, 5, 5); FraTrade test = base.createTrade(tradeDate, Period.ofMonths(3), 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 test_createTrade_periods() { FraConvention base = ImmutableFraConvention.builder() .index(GBP_LIBOR_3M) .spotDateOffset(NEXT_SAME_BUS_DAY) .build(); LocalDate tradeDate = LocalDate.of(2015, 5, 5); FraTrade test = base.createTrade(tradeDate, Period.ofMonths(3), Period.ofMonths(6), 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 test_toTrade_dates() { FraConvention base = ImmutableFraConvention.builder() .index(GBP_LIBOR_3M) .spotDateOffset(NEXT_SAME_BUS_DAY) .build(); LocalDate tradeDate = LocalDate.of(2015, 5, 5); LocalDate startDate = date(2015, 8, 5); LocalDate endDate = date(2015, 11, 5); LocalDate paymentDate = startDate; FraTrade test = base.toTrade(tradeDate, startDate, endDate, startDate, BUY, NOTIONAL_2M, 0.25d); Fra expected = Fra.builder() .buySell(BUY) .notional(NOTIONAL_2M) .startDate(startDate) .endDate(endDate) .paymentDate(AdjustableDate.of(paymentDate)) .fixedRate(0.25d) .index(GBP_LIBOR_3M) .build(); assertEquals(test.getInfo().getTradeDate(), Optional.of(tradeDate)); assertEquals(test.getProduct(), expected); }
public void coverage() { ImmutableFraConvention test = ImmutableFraConvention.builder() .index(GBP_LIBOR_3M) .build(); coverImmutableBean(test); ImmutableFraConvention test2 = ImmutableFraConvention.builder() .index(GBP_LIBOR_3M) .name("Test") .currency(USD) .spotDateOffset(PLUS_ONE_DAY) .businessDayAdjustment(BDA_FOLLOW) .paymentDateOffset(PLUS_TWO_DAYS) .fixingDateOffset(MINUS_FIVE_DAYS) .dayCount(ACT_360) .discounting(FraDiscountingMethod.NONE) .build(); coverBeanEquals(test, test2); coverPrivateConstructor(FraConventions.class); coverPrivateConstructor(FraConventionLookup.class); }
public void test_createTrade_periods_adjust_payOffset() { FraConvention base = ImmutableFraConvention.builder() .index(GBP_LIBOR_3M) .spotDateOffset(NEXT_SAME_BUS_DAY) .paymentDateOffset(PLUS_TWO_DAYS) .build(); LocalDate tradeDate = LocalDate.of(2016, 8, 11); FraTrade test = base.createTrade(tradeDate, Period.ofMonths(1), Period.ofMonths(4), BUY, NOTIONAL_2M, 0.25d, REF_DATA); Fra expected = Fra.builder() .buySell(BUY) .notional(NOTIONAL_2M) .startDate(date(2016, 9, 12)) .endDate(date(2016, 12, 12)) .paymentDate(AdjustableDate.of(date(2016, 9, 14), PLUS_TWO_DAYS.getAdjustment())) .fixedRate(0.25d) .index(GBP_LIBOR_3M) .build(); assertEquals(test.getInfo().getTradeDate(), Optional.of(tradeDate)); assertEquals(test.getProduct(), expected); }