@Override public TermDepositTrade toTrade( LocalDate tradeDate, LocalDate startDate, LocalDate endDate, BuySell buySell, double notional, double rate) { ArgChecker.inOrderOrEqual(tradeDate, startDate, "tradeDate", "startDate"); return TermDepositTrade.builder() .tradeInfo(TradeInfo.builder().tradeDate(tradeDate).build()) .product( TermDeposit.builder() .buySell(buySell) .currency(currency) .notional(notional) .startDate(startDate) .endDate(endDate) .businessDayAdjustment(businessDayAdjustment) .rate(rate) .dayCount(dayCount) .build()) .build(); }
public void test_toTrade() { IborFixingDepositConvention convention = ImmutableIborFixingDepositConvention.builder() .businessDayAdjustment(BDA_MOD_FOLLOW) .currency(EUR) .dayCount(ACT_365F) .fixingDateOffset(FIXING_ADJ) .index(EUR_LIBOR_3M) .spotDateOffset(SPOT_ADJ) .build(); LocalDate tradeDate = LocalDate.of(2015, 1, 22); Period depositPeriod = Period.ofMonths(3); double notional = 1d; double fixedRate = 0.045; IborFixingDepositTrade trade = convention.toTrade(tradeDate, depositPeriod, BUY, notional, fixedRate); LocalDate startExpected = SPOT_ADJ.adjust(tradeDate); LocalDate endExpected = startExpected.plus(depositPeriod); IborFixingDeposit productExpected = IborFixingDeposit.builder() .businessDayAdjustment(BDA_MOD_FOLLOW) .buySell(BUY) .currency(EUR) .dayCount(ACT_365F) .startDate(startExpected) .endDate(endExpected) .fixedRate(fixedRate) .fixingDateOffset(FIXING_ADJ) .index(EUR_LIBOR_3M) .notional(notional) .build(); TradeInfo tradeInfoExpected = TradeInfo.builder().tradeDate(tradeDate).build(); assertEquals(trade.getProduct(), productExpected); assertEquals(trade.getTradeInfo(), tradeInfoExpected); }
public void test_serialization() { FxSingleTrade test = FxSingleTrade.builder() .tradeInfo(TradeInfo.builder().tradeDate(date(2014, 6, 30)).build()) .product(FWD1) .build(); assertSerialization(test); }
// ------------------------------------------------------------------------- public void coverage() { FxSingleTrade test = FxSingleTrade.builder() .tradeInfo(TradeInfo.builder().tradeDate(date(2014, 6, 30)).build()) .product(FWD1) .build(); coverImmutableBean(test); FxSingleTrade test2 = FxSingleTrade.builder().product(FWD2).build(); coverBeanEquals(test, test2); }
/** Test {@link TermDepositTrade}. */ @Test public class TermDepositTradeTest { private static final TermDeposit DEPOSIT = TermDeposit.builder() .buySell(BuySell.BUY) .currency(GBP) .notional(100000000d) .startDate(LocalDate.of(2015, 1, 19)) .endDate(LocalDate.of(2015, 7, 19)) .businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO)) .dayCount(ACT_365F) .rate(0.0250) .build(); private static final TradeInfo TRADE_INFO = TradeInfo.builder().tradeDate(date(2014, 6, 30)).build(); // ------------------------------------------------------------------------- public void test_builder() { TermDepositTrade test = TermDepositTrade.builder().product(DEPOSIT).tradeInfo(TRADE_INFO).build(); assertEquals(test.getProduct(), DEPOSIT); assertEquals(test.getTradeInfo(), TRADE_INFO); } // ------------------------------------------------------------------------- public void coverage() { TermDepositTrade test1 = TermDepositTrade.builder().product(DEPOSIT).tradeInfo(TRADE_INFO).build(); coverImmutableBean(test1); TermDepositTrade test2 = TermDepositTrade.builder().product(DEPOSIT).build(); coverBeanEquals(test1, test2); } public void test_serialization() { TermDepositTrade test = TermDepositTrade.builder().product(DEPOSIT).tradeInfo(TRADE_INFO).build(); assertSerialization(test); } }