public void test_metadata_end() { TermDepositCurveNode node = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD); LocalDate valuationDate = LocalDate.of(2015, 1, 22); ParameterMetadata metadata = node.metadata(valuationDate, REF_DATA); assertEquals(((TenorDateParameterMetadata) metadata).getDate(), LocalDate.of(2015, 4, 27)); assertEquals(((TenorDateParameterMetadata) metadata).getTenor(), Tenor.TENOR_3M); }
public void test_requirements() { TermDepositCurveNode test = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD); Set<ObservableId> set = test.requirements(); Iterator<ObservableId> itr = set.iterator(); assertEquals(itr.next(), QUOTE_ID); assertFalse(itr.hasNext()); }
// ------------------------------------------------------------------------- public void coverage() { TermDepositCurveNode test = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD); coverImmutableBean(test); TermDepositCurveNode test2 = TermDepositCurveNode.of( TermDepositTemplate.of(Period.ofMonths(1), CONVENTION), QuoteId.of(StandardId.of("OG-Ticker", "Deposit2"))); coverBeanEquals(test, test2); }
public void test_metadata_fixed() { LocalDate nodeDate = VAL_DATE.plusMonths(1); TermDepositCurveNode node = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD).withDate(CurveNodeDate.of(nodeDate)); LocalDate valuationDate = LocalDate.of(2015, 1, 22); DatedParameterMetadata metadata = node.metadata(valuationDate, REF_DATA); assertEquals(metadata.getDate(), nodeDate); assertEquals(metadata.getLabel(), node.getLabel()); }
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); }
public void test_of_noSpread() { TermDepositCurveNode test = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID); assertEquals(test.getLabel(), LABEL_AUTO); assertEquals(test.getRateId(), QUOTE_ID); assertEquals(test.getAdditionalSpread(), 0.0d); assertEquals(test.getTemplate(), TEMPLATE); }
public void test_of_withSpreadAndLabel() { TermDepositCurveNode test = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD, LABEL); assertEquals(test.getLabel(), LABEL); assertEquals(test.getRateId(), QUOTE_ID); assertEquals(test.getAdditionalSpread(), SPREAD); assertEquals(test.getTemplate(), TEMPLATE); }
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); }
public void test_builder_defaults() { TermDepositCurveNode test = TermDepositCurveNode.builder() .label(LABEL) .template(TEMPLATE) .rateId(QUOTE_ID) .additionalSpread(SPREAD) .build(); assertEquals(test.getLabel(), LABEL); assertEquals(test.getRateId(), QUOTE_ID); assertEquals(test.getAdditionalSpread(), SPREAD); assertEquals(test.getTemplate(), TEMPLATE); assertEquals(test.getDate(), CurveNodeDate.END); }
public void test_serialization() { TermDepositCurveNode test = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD); assertSerialization(test); }
public void test_metadata_last_fixing() { TermDepositCurveNode node = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD).withDate(CurveNodeDate.LAST_FIXING); assertThrowsWithCause( () -> node.metadata(VAL_DATE, REF_DATA), UnsupportedOperationException.class); }
public void test_trade_noMarketData() { TermDepositCurveNode node = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD); LocalDate valuationDate = LocalDate.of(2015, 1, 22); MarketData marketData = MarketData.empty(valuationDate); assertThrows(() -> node.trade(1d, marketData, REF_DATA), MarketDataNotFoundException.class); }