@Test(dataProvider = "calendar") public void test_calendar(ImmutableFxSwapConvention convention, HolidayCalendarId cal) { assertEquals(convention.getSpotDateOffset().getCalendar(), cal); assertEquals(convention.getBusinessDayAdjustment().getCalendar(), cal); }
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)); }
@Override public FxSwapTrade toTrade( TradeInfo tradeInfo, LocalDate startDate, LocalDate endDate, BuySell buySell, double notional, double nearFxRate, double farLegForwardPoints) { Optional<LocalDate> tradeDate = tradeInfo.getTradeDate(); if (tradeDate.isPresent()) { ArgChecker.inOrderOrEqual(tradeDate.get(), startDate, "tradeDate", "startDate"); } double amount1 = BuySell.BUY.normalize(notional); return FxSwapTrade.builder() .info(tradeInfo) .product(FxSwap.ofForwardPoints( CurrencyAmount.of(currencyPair.getBase(), amount1), FxRate.of(currencyPair, nearFxRate), farLegForwardPoints, startDate, endDate, getBusinessDayAdjustment())) .build(); }
public void test_builder() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.builder() .currencyPair(EUR_USD) .name("EUR::USD") .spotDateOffset(PLUS_TWO_DAYS) .businessDayAdjustment(BDA_FOLLOW) .build(); assertEquals(test.getName(), "EUR::USD"); assertEquals(test.getCurrencyPair(), EUR_USD); assertEquals(test.getSpotDateOffset(), PLUS_TWO_DAYS); assertEquals(test.getBusinessDayAdjustment(), BDA_FOLLOW); }
public void test_metadata_end() { FxSwapCurveNode node = FxSwapCurveNode.of(TEMPLATE, QUOTE_ID_PTS); LocalDate valuationDate = LocalDate.of(2015, 1, 22); LocalDate endDate = CONVENTION.getBusinessDayAdjustment() .adjust(CONVENTION.getSpotDateOffset().adjust(valuationDate, REF_DATA).plus(FAR_PERIOD), REF_DATA); ParameterMetadata metadata = node.metadata(valuationDate, REF_DATA); assertEquals(((TenorDateParameterMetadata) metadata).getDate(), endDate); assertEquals(((TenorDateParameterMetadata) metadata).getTenor(), Tenor.of(FAR_PERIOD)); }
public void test_createTrade() { FxSwapTemplate base = FxSwapTemplate.of(NEAR_PERIOD, FAR_PERIOD, CONVENTION); LocalDate tradeDate = LocalDate.of(2015, 10, 29); FxSwapTrade test = base.createTrade(tradeDate, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS, REF_DATA); LocalDate spotDate = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA); LocalDate nearDate = spotDate.plus(NEAR_PERIOD); LocalDate farDate = spotDate.plus(FAR_PERIOD); BusinessDayAdjustment bda = CONVENTION.getBusinessDayAdjustment(); FxSwap expected = FxSwap.ofForwardPoints( CurrencyAmount.of(EUR, NOTIONAL_EUR), FxRate.of(EUR, USD, FX_RATE_NEAR), FX_RATE_PTS, nearDate, farDate, bda); assertEquals(test.getInfo().getTradeDate(), Optional.of(tradeDate)); assertEquals(test.getProduct(), expected); }