public virtual void test_trade_noMarketData()
        {
            FraCurveNode node          = FraCurveNode.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));
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FraCurveNode test = FraCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);

            coverImmutableBean(test);
            FraCurveNode test2 = FraCurveNode.of(FraTemplate.of(Period.ofMonths(1), GBP_LIBOR_6M), QuoteId.of(StandardId.of("OG-Ticker", "Deposit2")));

            coverBeanEquals(test, test2);
        }
        public virtual void test_metadata_fixed()
        {
            LocalDate              nodeDate = VAL_DATE.plusMonths(1);
            FraCurveNode           node     = FraCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD).withDate(CurveNodeDate.of(nodeDate));
            DatedParameterMetadata metadata = node.metadata(VAL_DATE, REF_DATA);

            assertEquals(metadata.Date, nodeDate);
            assertEquals(metadata.Label, node.Label);
        }
        public virtual void test_of_withSpreadAndLabel()
        {
            FraCurveNode test = FraCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD, LABEL);

            assertEquals(test.Label, LABEL);
            assertEquals(test.RateId, QUOTE_ID);
            assertEquals(test.AdditionalSpread, SPREAD);
            assertEquals(test.Template, TEMPLATE);
        }
        public virtual void test_of_noSpread()
        {
            FraCurveNode test = FraCurveNode.of(TEMPLATE, QUOTE_ID);

            assertEquals(test.Label, LABEL_AUTO);
            assertEquals(test.RateId, QUOTE_ID);
            assertEquals(test.AdditionalSpread, 0.0d);
            assertEquals(test.Template, TEMPLATE);
        }
        public virtual void test_builder_defaults()
        {
            FraCurveNode test = FraCurveNode.builder().label(LABEL).template(TEMPLATE).rateId(QUOTE_ID).additionalSpread(SPREAD).build();

            assertEquals(test.Label, LABEL);
            assertEquals(test.RateId, QUOTE_ID);
            assertEquals(test.AdditionalSpread, SPREAD);
            assertEquals(test.Template, TEMPLATE);
            assertEquals(test.Date, CurveNodeDate.END);
        }
        public virtual void test_metadata_end()
        {
            FraCurveNode      node          = FraCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            LocalDate         valuationDate = LocalDate.of(2015, 1, 22);
            LocalDate         endDate       = OFFSET.adjust(valuationDate, REF_DATA).plus(PERIOD_TO_START).plusMonths(3);
            ParameterMetadata metadata      = node.metadata(valuationDate, REF_DATA);

            assertEquals(((TenorDateParameterMetadata)metadata).Date, endDate);
            assertEquals(((TenorDateParameterMetadata)metadata).Tenor, TENOR_5M);
        }
        public virtual void test_requirements()
        {
            FraCurveNode               test = FraCurveNode.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());
        }
        public virtual void test_metadata_last_fixing()
        {
            FraCurveNode           node          = FraCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD).withDate(CurveNodeDate.LAST_FIXING);
            LocalDate              valuationDate = LocalDate.of(2015, 1, 22);
            ImmutableMarketData    marketData    = ImmutableMarketData.builder(valuationDate).addValue(QUOTE_ID, 0.0d).build();
            FraTrade               trade         = node.trade(1d, marketData, REF_DATA);
            ResolvedFra            resolved      = trade.Product.resolve(REF_DATA);
            LocalDate              fixingDate    = ((IborRateComputation)(resolved.FloatingRate)).FixingDate;
            DatedParameterMetadata metadata      = node.metadata(valuationDate, REF_DATA);

            assertEquals(((TenorDateParameterMetadata)metadata).Date, fixingDate);
            assertEquals(((TenorDateParameterMetadata)metadata).Tenor, TENOR_5M);
        }
Ejemplo n.º 10
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         FraCurveNode other = (FraCurveNode)obj;
         return(JodaBeanUtils.equal(template, other.template) && JodaBeanUtils.equal(rateId, other.rateId) && JodaBeanUtils.equal(additionalSpread, other.additionalSpread) && JodaBeanUtils.equal(label, other.label) && JodaBeanUtils.equal(date_Renamed, other.date_Renamed) && JodaBeanUtils.equal(dateOrder, other.dateOrder));
     }
     return(false);
 }
        public virtual void test_initialGuess()
        {
            FraCurveNode node       = FraCurveNode.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);
            double approximateMaturity = TEMPLATE.PeriodToEnd.toTotalMonths() / 12.0d;
            double df = Math.Exp(-approximateMaturity * rate);

            assertEquals(node.initialGuess(marketData, ValueType.DISCOUNT_FACTOR), df);
            assertEquals(node.initialGuess(marketData, ValueType.PRICE_INDEX), 0d);
        }
        public virtual void test_trade()
        {
            FraCurveNode        node              = FraCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            LocalDate           valuationDate     = LocalDate.of(2015, 1, 22);
            double              rate              = 0.035;
            ImmutableMarketData marketData        = ImmutableMarketData.builder(valuationDate).addValue(QUOTE_ID, rate).build();
            FraTrade            trade             = node.trade(1d, marketData, REF_DATA);
            LocalDate           startDateExpected = BDA_MOD_FOLLOW.adjust(OFFSET.adjust(valuationDate, REF_DATA).plus(PERIOD_TO_START), REF_DATA);
            LocalDate           endDateExpected   = BDA_MOD_FOLLOW.adjust(OFFSET.adjust(valuationDate, REF_DATA).plus(PERIOD_TO_END), REF_DATA);
            Fra       productExpected             = Fra.builder().buySell(BuySell.SELL).currency(GBP).dayCount(ACT_365F).startDate(startDateExpected).endDate(endDateExpected).paymentDate(AdjustableDate.of(startDateExpected)).notional(1.0d).index(GBP_LIBOR_3M).fixedRate(rate + SPREAD).build();
            TradeInfo tradeInfoExpected           = TradeInfo.builder().tradeDate(valuationDate).build();

            assertEquals(trade.Product, productExpected);
            assertEquals(trade.Info, tradeInfoExpected);
        }
        public virtual void test_serialization()
        {
            FraCurveNode test = FraCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);

            assertSerialization(test);
        }