public virtual 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 virtual 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.Info.TradeDate, tradeDate); assertEquals(test.Product, expected); ResolvedFxSwap resolvedExpected = ResolvedFxSwap.ofForwardPoints(CurrencyAmount.of(EUR, NOTIONAL_EUR), USD, FX_RATE_NEAR, FX_RATE_PTS, nearDateAdj, farDateAdj); assertEquals(test.Product.resolve(REF_DATA), resolvedExpected); }