示例#1
0
        public virtual void test_withName()
        {
            RatesCurveGroupDefinition test        = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addDiscountCurve(CURVE_DEFN1, GBP).build();
            RatesCurveGroupDefinition expected    = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("NewName")).addDiscountCurve(CURVE_DEFN1, GBP).build();
            RatesCurveGroupDefinition withNewName = test.withName(CurveGroupName.of("NewName"));

            assertEquals(withNewName, expected);
        }
示例#2
0
        public virtual void test_builder4()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_NAME1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).build();

            assertEquals(test.Name, CurveGroupName.of("Test"));
            assertEquals(test.Entries, ImmutableList.of(ENTRY3));
            assertEquals(test.findEntry(CurveName.of("Test")), ENTRY3);
            assertEquals(test.findEntry(CurveName.of("Test2")), null);
            assertEquals(test.findEntry(CurveName.of("Rubbish")), null);
        }
示例#3
0
        public virtual void test_builder3()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addDiscountCurve(CURVE_NAME1, GBP).addForwardCurve(CURVE_NAME1, GBP_SONIA).addForwardCurve(CURVE_NAME1, GBP_LIBOR_1W).addForwardCurve(CURVE_NAME2, GBP_LIBOR_1M, GBP_LIBOR_3M).build();

            assertEquals(test.Name, CurveGroupName.of("Test"));
            assertEquals(test.Entries, ImmutableList.of(ENTRY1, ENTRY2));
            assertEquals(test.findEntry(CurveName.of("Test")), ENTRY1);
            assertEquals(test.findEntry(CurveName.of("Test2")), ENTRY2);
            assertEquals(test.findEntry(CurveName.of("Rubbish")), null);
        }
示例#4
0
        //-------------------------------------------------------------------------
        public virtual void test_of_String()
        {
            CurveId test = CurveId.of("Group", "Name");

            assertEquals(test.CurveGroupName, CurveGroupName.of("Group"));
            assertEquals(test.CurveName, CurveName.of("Name"));
            assertEquals(test.ObservableSource, ObservableSource.NONE);
            assertEquals(test.MarketDataType, typeof(Curve));
            assertEquals(test.MarketDataName, CurveName.of("Name"));
            assertEquals(test.ToString(), "CurveId:Group/Name");
        }
示例#5
0
        public virtual void test_of_TypesSource()
        {
            CurveId test = CurveId.of(CurveGroupName.of("Group"), CurveName.of("Name"), OBS_SOURCE);

            assertEquals(test.CurveGroupName, CurveGroupName.of("Group"));
            assertEquals(test.CurveName, CurveName.of("Name"));
            assertEquals(test.ObservableSource, OBS_SOURCE);
            assertEquals(test.MarketDataType, typeof(Curve));
            assertEquals(test.MarketDataName, CurveName.of("Name"));
            assertEquals(test.ToString(), "CurveId:Group/Name/Vendor");
        }
示例#6
0
        public virtual void test_builder_seasonality()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addSeasonality(CURVE_NAME_I, SEASONALITY_ADDITIVE_DEF).build();

            assertEquals(test.Name, CurveGroupName.of("Test"));
            assertEquals(test.Entries, ImmutableList.of(ENTRY3));
            assertEquals(test.findEntry(CurveName.of("Test")), ENTRY3);
            assertEquals(test.findEntry(CurveName.of("Test2")), null);
            assertEquals(test.findEntry(CurveName.of("Rubbish")), null);
            assertEquals(test.findCurveDefinition(CurveName.of("Test")), CURVE_DEFN1);
            assertEquals(test.findCurveDefinition(CurveName.of("Test2")), null);
            assertEquals(test.findCurveDefinition(CurveName.of("Rubbish")), null);
            ImmutableMap <CurveName, SeasonalityDefinition> seasonMap = test.SeasonalityDefinitions;

            assertTrue(seasonMap.size() == 1);
            assertEquals(seasonMap.get(CURVE_NAME_I), SEASONALITY_ADDITIVE_DEF);
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance used to obtain a curve group by name.
 /// </summary>
 /// <param name="groupName">  the curve group name </param>
 /// <returns> the identifier </returns>
 public static LegalEntityCurveGroupId of(string groupName)
 {
     return(new LegalEntityCurveGroupId(CurveGroupName.of(groupName), ObservableSource.NONE));
 }
示例#8
0
        public virtual void test_serialization()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addDiscountCurve(CURVE_DEFN1, GBP).build();

            assertSerialization(test);
        }
示例#9
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addDiscountCurve(CURVE_DEFN1, GBP).build();

            coverImmutableBean(test);
            RatesCurveGroupDefinition test2 = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test2")).addForwardCurve(CURVE_DEFN2, GBP_LIBOR_1M).build();

            coverBeanEquals(test, test2);
        }
        public virtual void test_ofCurves_duplicateCurveName()
        {
            RatesCurveGroupDefinition definition = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("group")).addForwardCurve(IBOR_NAME, USD_LIBOR_1M, USD_LIBOR_2M).build();
            RatesCurveGroup           group      = RatesCurveGroup.ofCurves(definition, IBOR_CURVE, IBOR_CURVE);

            assertThat(group.findForwardCurve(USD_LIBOR_1M)).hasValue(IBOR_CURVE);
            assertThat(group.findForwardCurve(USD_LIBOR_2M)).hasValue(IBOR_CURVE);
        }
示例#11
0
        public virtual void test_bind_after_last_fixing()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addForwardCurve(CURVE_DEFN_I, GB_RPI).addSeasonality(CURVE_NAME_I, SEASONALITY_ADDITIVE_DEF).build();
            LocalDate valuationDate        = LocalDate.of(2015, 10, 15);
            LocalDate lastFixingDate       = LocalDate.of(2015, 10, 31);
            LocalDate otherFixingDate      = LocalDate.of(2015, 9, 30);
            LocalDate other2FixingDate     = LocalDate.of(2015, 8, 31);
            double    lastFixingValue      = 234.56;
            IDictionary <Index, LocalDateDoubleTimeSeries> map = ImmutableMap.of(GB_RPI, LocalDateDoubleTimeSeries.builder().put(lastFixingDate, lastFixingValue).put(otherFixingDate, lastFixingValue - 1.0).put(other2FixingDate, lastFixingValue - 2.0).build());
            RatesCurveGroupDefinition testBound = test.bindTimeSeries(valuationDate, map);
            IList <CurveDefinition>   list      = testBound.CurveDefinitions;

            assertEquals(list.Count, 2);
            assertTrue(list[0] is InterpolatedNodalCurveDefinition);
            assertTrue(list[1] is InflationNodalCurveDefinition);
            InflationNodalCurveDefinition seasonDef = (InflationNodalCurveDefinition)list[1];

            assertEquals(seasonDef.CurveWithoutFixingDefinition, CURVE_DEFN_I);
            assertEquals(seasonDef.LastFixingMonth, YearMonth.from(otherFixingDate));
            assertEquals(seasonDef.LastFixingValue, lastFixingValue - 1.0);
            assertEquals(seasonDef.Name, CURVE_NAME_I);
            assertEquals(seasonDef.SeasonalityDefinition, SEASONALITY_ADDITIVE_DEF);
            assertEquals(seasonDef.YValueType, ValueType.PRICE_INDEX);
        }
示例#12
0
        //-------------------------------------------------------------------------
        public virtual void test_tradesInitialGuesses()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).build();

            MarketData marketData = ImmutableMarketData.of(date(2015, 6, 30), ImmutableMap.of(GBP_LIBOR_1M_ID, 0.5d, GBP_LIBOR_3M_ID, 1.5d));
            Trade      trade1     = NODE1.trade(1d, marketData, REF_DATA);
            Trade      trade2     = NODE2.trade(1d, marketData, REF_DATA);

            assertEquals(test.TotalParameterCount, 2);
            assertEquals(test.resolvedTrades(marketData, REF_DATA), ImmutableList.of(trade1, trade2));
            assertEquals(test.initialGuesses(marketData), ImmutableList.of(0.5d, 1.5d));
        }
示例#13
0
        //-------------------------------------------------------------------------
        public virtual void test_metadata()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).build();

            LocalDate     valuationDate = date(2015, 6, 30);
            CurveMetadata meta          = CURVE_DEFN1.metadata(valuationDate, REF_DATA);

            assertEquals(test.metadata(valuationDate, REF_DATA), ImmutableList.of(meta));
        }
示例#14
0
        //-------------------------------------------------------------------------
        public virtual void test_filtered()
        {
            DummyFraCurveNode node1 = DummyFraCurveNode.of(Period.ofDays(5), GBP_LIBOR_1M, GBP_LIBOR_1M_ID);
            DummyFraCurveNode node2 = DummyFraCurveNode.of(Period.ofDays(10), GBP_LIBOR_1M, GBP_LIBOR_1M_ID);
            DummyFraCurveNode node3 = DummyFraCurveNode.of(Period.ofDays(11), GBP_LIBOR_1M, GBP_LIBOR_1M_ID, DROP_THIS_2D);
            ImmutableList <DummyFraCurveNode> nodes = ImmutableList.of(node1, node2, node3);
            LocalDate valuationDate = date(2015, 6, 30);

            InterpolatedNodalCurveDefinition curveDefn = InterpolatedNodalCurveDefinition.builder().name(CURVE_NAME1).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_365F).nodes(nodes).interpolator(CurveInterpolators.LINEAR).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build();
            RatesCurveGroupDefinition        test      = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(curveDefn, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).build();
            RatesCurveGroupDefinition        expected  = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(curveDefn.filtered(valuationDate, REF_DATA), GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).build();

            assertEquals(test.filtered(valuationDate, REF_DATA), expected);
        }
示例#15
0
 public virtual void test_missingEntries()
 {
     assertThrowsIllegalArg(() => RatesCurveGroupDefinition.of(CurveGroupName.of("group"), ImmutableList.of(ENTRY1), ImmutableList.of(CURVE_DEFN1, CURVE_DEFN2)), "An entry must be provided .* \\[Test2\\]");
 }
示例#16
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance used to obtain a curve group by name.
 /// </summary>
 /// <param name="groupName">  the curve group name </param>
 /// <returns> the identifier </returns>
 public static RatesCurveGroupId of(string groupName)
 {
     return(new RatesCurveGroupId(CurveGroupName.of(groupName), ObservableSource.NONE));
 }
示例#17
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance used to obtain a curve by name.
 /// </summary>
 /// <param name="groupName">  the curve group name </param>
 /// <param name="curveName">  the curve name </param>
 /// <returns> the identifier </returns>
 public static CurveId of(string groupName, string curveName)
 {
     return(new CurveId(CurveGroupName.of(groupName), CurveName.of(curveName), ObservableSource.NONE));
 }
示例#18
0
        public virtual void test_bind_no_seasonality()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addForwardCurve(CURVE_DEFN_I, GB_RPI).build();
            LocalDate valuationDate        = LocalDate.of(2015, 11, 10);
            LocalDate lastFixingDate       = LocalDate.of(2015, 10, 31);
            LocalDate otherFixingDate      = LocalDate.of(2015, 9, 30);
            double    lastFixingValue      = 234.56;
            IDictionary <Index, LocalDateDoubleTimeSeries> map = ImmutableMap.of(GB_RPI, LocalDateDoubleTimeSeries.builder().put(lastFixingDate, 234.56).put(otherFixingDate, lastFixingValue - 1).build());
            RatesCurveGroupDefinition testBound = test.bindTimeSeries(valuationDate, map);
            IList <CurveDefinition>   list      = testBound.CurveDefinitions;

            assertEquals(list.Count, 2);
            assertTrue(list[0] is InterpolatedNodalCurveDefinition);
            assertTrue(list[1] is InflationNodalCurveDefinition);
            InflationNodalCurveDefinition seasonDef = (InflationNodalCurveDefinition)list[1];

            assertEquals(seasonDef.CurveWithoutFixingDefinition, CURVE_DEFN_I);
            assertEquals(seasonDef.LastFixingMonth, YearMonth.from(lastFixingDate));
            assertEquals(seasonDef.LastFixingValue, lastFixingValue);
            assertEquals(seasonDef.Name, CURVE_NAME_I);
            assertEquals(seasonDef.YValueType, ValueType.PRICE_INDEX);
            // Check the default
            assertTrue(seasonDef.SeasonalityDefinition.SeasonalityMonthOnMonth.equalWithTolerance(DoubleArray.filled(12, 1d), 1.0E-10));
            assertEquals(seasonDef.SeasonalityDefinition.AdjustmentType, ShiftType.SCALED);
        }
        public virtual void test_ofCurves()
        {
            RatesCurveGroupDefinition definition = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("group")).addCurve(DISCOUNT_NAME, GBP, GBP_LIBOR_1M).addForwardCurve(IBOR_NAME, USD_LIBOR_1M, USD_LIBOR_2M).addForwardCurve(OVERNIGHT_NAME, EUR_EONIA).build();
            RatesCurveGroup           group      = RatesCurveGroup.ofCurves(definition, DISCOUNT_CURVE, OVERNIGHT_CURVE, IBOR_CURVE);

            assertThat(group.findDiscountCurve(GBP)).hasValue(DISCOUNT_CURVE);
            assertThat(group.findForwardCurve(USD_LIBOR_1M)).hasValue(IBOR_CURVE);
            assertThat(group.findForwardCurve(USD_LIBOR_2M)).hasValue(IBOR_CURVE);
            assertThat(group.findForwardCurve(EUR_EONIA)).hasValue(OVERNIGHT_CURVE);
        }
示例#20
0
        public virtual void test_combinedWith_differentCurveNames()
        {
            RatesCurveGroupDefinition base1    = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addForwardCurve(CURVE_DEFN_I, GB_RPI).build();
            RatesCurveGroupDefinition base2    = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("TestX")).addForwardCurve(CURVE_DEFN2, GBP_LIBOR_6M).build();
            RatesCurveGroupDefinition expected = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addForwardCurve(CURVE_DEFN_I, GB_RPI).addForwardCurve(CURVE_DEFN2, GBP_LIBOR_6M).build();

            assertEquals(base1.combinedWith(base2), expected);
        }
示例#21
0
        public virtual void test_combinedWith_sameCurveNamesClash()
        {
            RatesCurveGroupDefinition base1 = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addForwardCurve(CURVE_DEFN_I, GB_RPI).build();
            RatesCurveGroupDefinition base2 = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("TestX")).addCurve(CURVE_DEFN1B, GBP, GBP_LIBOR_6M).build();

            assertThrowsIllegalArg(() => base1.combinedWith(base2));
        }
        public virtual void coverage()
        {
            CurveGroupName test = CurveGroupName.of("Foo");

            assertEquals(test.ToString(), "Foo");
        }