Ejemplo n.º 1
0
        public virtual 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), typeof(MarketDataNotFoundException));
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------
        public virtual 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);
        }
Ejemplo n.º 3
0
        public virtual 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).Date, LocalDate.of(2015, 4, 27));
            assertEquals(((TenorDateParameterMetadata)metadata).Tenor, Tenor.TENOR_3M);
        }
Ejemplo n.º 4
0
        public virtual void test_of_withSpreadAndLabel()
        {
            TermDepositCurveNode test = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD, LABEL);

            assertEquals(test.Label, LABEL);
            assertEquals(test.RateId, QUOTE_ID);
            assertEquals(test.AdditionalSpread, SPREAD);
            assertEquals(test.Template, TEMPLATE);
        }
Ejemplo n.º 5
0
        public virtual void test_of_noSpread()
        {
            TermDepositCurveNode test = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID);

            assertEquals(test.Label, LABEL_AUTO);
            assertEquals(test.RateId, QUOTE_ID);
            assertEquals(test.AdditionalSpread, 0.0d);
            assertEquals(test.Template, TEMPLATE);
        }
Ejemplo n.º 6
0
        public virtual 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.Date, nodeDate);
            assertEquals(metadata.Label, node.Label);
        }
Ejemplo n.º 7
0
        public virtual 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);
        }
Ejemplo n.º 8
0
        public virtual void test_requirements()
        {
            TermDepositCurveNode       test = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            ISet <ObservableId>        set  = test.requirements();
            IEnumerator <ObservableId> itr  = set.GetEnumerator();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(itr.next(), QUOTE_ID);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(itr.hasNext());
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        public virtual void test_serialization()
        {
            TermDepositCurveNode test = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);

            assertSerialization(test);
        }
Ejemplo n.º 11
0
        public virtual void test_metadata_last_fixing()
        {
            TermDepositCurveNode node = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD).withDate(CurveNodeDate.LAST_FIXING);

            assertThrowsWithCause(() => node.metadata(VAL_DATE, REF_DATA), typeof(System.NotSupportedException));
        }