//-------------------------------------------------------------------------
        public TermDepositTrade toTrade(TradeInfo tradeInfo, LocalDate startDate, LocalDate endDate, BuySell buySell, double notional, double rate)
        {
            Optional <LocalDate> tradeDate = tradeInfo.TradeDate;

            if (tradeDate.Present)
            {
                ArgChecker.inOrderOrEqual(tradeDate.get(), startDate, "tradeDate", "startDate");
            }
            return(TermDepositTrade.builder().info(tradeInfo).product(TermDeposit.builder().buySell(buySell).currency(currency).notional(notional).startDate(startDate).endDate(endDate).businessDayAdjustment(businessDayAdjustment).rate(rate).dayCount(dayCount).build()).build());
        }
Esempio n. 2
0
        public virtual void test_trade()
        {
            TermDepositCurveNode node          = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            double           rate              = 0.035;
            MarketData       marketData        = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();
            TermDepositTrade trade             = node.trade(1d, marketData, REF_DATA);
            LocalDate        startDateExpected = PLUS_TWO_DAYS.adjust(VAL_DATE, REF_DATA);
            LocalDate        endDateExpected   = startDateExpected.plus(DEPOSIT_PERIOD);
            TermDeposit      depositExpected   = TermDeposit.builder().buySell(BuySell.BUY).currency(EUR).dayCount(ACT_360).startDate(startDateExpected).endDate(endDateExpected).notional(1.0d).businessDayAdjustment(BDA_MOD_FOLLOW).rate(rate + SPREAD).build();
            TradeInfo        tradeInfoExpected = TradeInfo.builder().tradeDate(VAL_DATE).build();

            assertEquals(trade.Product, depositExpected);
            assertEquals(trade.Info, tradeInfoExpected);
        }
Esempio n. 3
0
        public virtual void test_createTrade()
        {
            TermDepositTemplate template       = TermDepositTemplate.of(DEPOSIT_PERIOD, CONVENTION);
            LocalDate           tradeDate      = LocalDate.of(2015, 1, 23);
            BuySell             buy            = BuySell.BUY;
            double           notional          = 2_000_000d;
            double           rate              = 0.0125;
            TermDepositTrade trade             = template.createTrade(tradeDate, buy, notional, rate, REF_DATA);
            TradeInfo        tradeInfoExpected = TradeInfo.of(tradeDate);
            LocalDate        startDateExpected = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA);
            LocalDate        endDateExpected   = startDateExpected.plus(DEPOSIT_PERIOD);
            TermDeposit      productExpected   = TermDeposit.builder().buySell(buy).currency(EUR).notional(notional).businessDayAdjustment(BDA_MOD_FOLLOW).startDate(startDateExpected).endDate(endDateExpected).rate(rate).dayCount(ACT_360).build();

            assertEquals(trade.Info, tradeInfoExpected);
            assertEquals(trade.Product, productExpected);
        }
Esempio n. 4
0
        //-------------------------------------------------------------------------
        public virtual void test_toTrade()
        {
            TermDepositConvention convention     = ImmutableTermDepositConvention.builder().name("EUR-Dep").businessDayAdjustment(BDA_MOD_FOLLOW).currency(EUR).dayCount(ACT_360).spotDateOffset(PLUS_TWO_DAYS).build();
            LocalDate             tradeDate      = LocalDate.of(2015, 1, 22);
            Period           period3M            = Period.ofMonths(3);
            BuySell          buy                 = BuySell.BUY;
            double           notional            = 2_000_000d;
            double           rate                = 0.0125;
            TermDepositTrade trade               = convention.createTrade(tradeDate, period3M, buy, notional, rate, REF_DATA);
            LocalDate        startDateExpected   = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA);
            LocalDate        endDateExpected     = startDateExpected.plus(period3M);
            TermDeposit      termDepositExpected = TermDeposit.builder().buySell(buy).currency(EUR).notional(notional).startDate(startDateExpected).endDate(endDateExpected).businessDayAdjustment(BDA_MOD_FOLLOW).rate(rate).dayCount(ACT_360).build();
            TradeInfo        tradeInfoExpected   = TradeInfo.of(tradeDate);

            assertEquals(trade.Product, termDepositExpected);
            assertEquals(trade.Info, tradeInfoExpected);
        }
        //-----------------------------------------------------------------------
        // create a TermDeposit trade
        private static Trade createTrade1()
        {
            TermDeposit td = TermDeposit.builder().buySell(BuySell.BUY).startDate(LocalDate.of(2014, 9, 12)).endDate(LocalDate.of(2014, 12, 12)).businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, HolidayCalendarIds.GBLO)).currency(Currency.USD).notional(10_000_000).dayCount(DayCounts.THIRTY_360_ISDA).rate(0.003).build();

            return(TermDepositTrade.builder().product(td).info(TradeInfo.builder().id(StandardId.of("example", "1")).addAttribute(AttributeType.DESCRIPTION, "Deposit 10M at 3%").counterparty(StandardId.of("example", "A")).settlementDate(LocalDate.of(2014, 12, 16)).build()).build());
        }