public void test_serialization() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); assertSerialization(test); }
public void test_of_bda() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); assertEquals(test.getName(), EUR_USD.toString()); assertEquals(test.getCurrencyPair(), EUR_USD); assertEquals(test.getSpotDateOffset(), PLUS_TWO_DAYS); assertEquals(test.getBusinessDayAdjustment(), BDA_FOLLOW); }
public void test_of_nobda() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS); assertEquals(test.getName(), EUR_USD.toString()); assertEquals(test.getCurrencyPair(), EUR_USD); assertEquals(test.getSpotDateOffset(), PLUS_TWO_DAYS); assertEquals(test.getBusinessDayAdjustment(), BusinessDayAdjustment.of(MODIFIED_FOLLOWING, EUTA_USNY)); }
public void test_toTemplate_badDateOrder() { ImmutableFxSwapConvention base = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); LocalDate tradeDate = LocalDate.of(2015, 5, 5); LocalDate nearDate = date(2015, 4, 5); LocalDate farDate = date(2015, 7, 5); assertThrowsIllegalArg(() -> base.toTrade(tradeDate, nearDate, farDate, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS)); }
public void test_toTrade_dates() { ImmutableFxSwapConvention base = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); LocalDate tradeDate = LocalDate.of(2015, 5, 5); LocalDate nearDate = LocalDate.of(2015, 7, 5); LocalDate nearDateAdj = LocalDate.of(2015, 7, 6); // Adjusted: 5 is Sunday LocalDate farDate = LocalDate.of(2015, 9, 5); LocalDate farDateAdj = LocalDate.of(2015, 9, 7); // Adjusted: 5 is Saturday FxSwapTrade test = base.toTrade(tradeDate, nearDate, farDate, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS); FxSwap expected = FxSwap.ofForwardPoints( CurrencyAmount.of(EUR, NOTIONAL_EUR), FxRate.of(EUR, USD, FX_RATE_NEAR), FX_RATE_PTS, nearDate, farDate, BDA_FOLLOW); assertEquals(test.getInfo().getTradeDate(), Optional.of(tradeDate)); assertEquals(test.getProduct(), expected); ResolvedFxSwap resolvedExpected = ResolvedFxSwap.ofForwardPoints( CurrencyAmount.of(EUR, NOTIONAL_EUR), USD, FX_RATE_NEAR, FX_RATE_PTS, nearDateAdj, farDateAdj); assertEquals(test.getProduct().resolve(REF_DATA), resolvedExpected); }
public void test_toTrade_periods() { ImmutableFxSwapConvention base = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); Period startPeriod = Period.ofMonths(3); Period endPeriod = Period.ofMonths(6); LocalDate tradeDate = LocalDate.of(2015, 5, 5); LocalDate spotDate = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA); LocalDate nearDate = spotDate.plus(startPeriod); LocalDate farDate = spotDate.plus(endPeriod); FxSwapTrade test = base.createTrade(tradeDate, startPeriod, endPeriod, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS, REF_DATA); FxSwap expected = FxSwap.ofForwardPoints( CurrencyAmount.of(EUR, NOTIONAL_EUR), FxRate.of(EUR, USD, FX_RATE_NEAR), FX_RATE_PTS, nearDate, farDate, BDA_FOLLOW); assertEquals(test.getInfo().getTradeDate(), Optional.of(tradeDate)); assertEquals(test.getProduct(), expected); }
public void coverage() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); coverImmutableBean(test); ImmutableFxSwapConvention test2 = ImmutableFxSwapConvention.builder() .name("GBP/USD") .currencyPair(GBP_USD) .spotDateOffset(PLUS_ONE_DAY) .businessDayAdjustment(BDA_MODFOLLOW) .build(); coverBeanEquals(test, test2); }