Пример #1
0
 public void test_initialGuess() {
   TermDepositCurveNode node = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
   double rate = 0.035;
   MarketData marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();
   assertEquals(node.initialGuess(marketData, ValueType.ZERO_RATE), rate);
   assertEquals(node.initialGuess(marketData, ValueType.FORWARD_RATE), rate);
   assertEquals(
       node.initialGuess(marketData, ValueType.DISCOUNT_FACTOR), Math.exp(-rate * 0.25), 1.0e-12);
 }
Пример #2
0
 public 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.getProduct(), depositExpected);
   assertEquals(trade.getInfo(), tradeInfoExpected);
 }