//-------------------------------------------------------------------------
        public virtual void test_metadata()
        {
            InterpolatedNodalCurveDefinition test     = InterpolatedNodalCurveDefinition.builder().name(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_365F).nodes(NODES).interpolator(CurveInterpolators.LINEAR).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build();
            DefaultCurveMetadata             expected = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_365F).parameterMetadata(NODES.get(0).metadata(VAL_DATE, REF_DATA), NODES.get(1).metadata(VAL_DATE, REF_DATA)).build();

            assertEquals(test.metadata(VAL_DATE, REF_DATA), expected);
        }
Esempio n. 2
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            coverImmutableBean(COMBINED_CURVE);
            CombinedCurve test = CombinedCurve.of(ConstantCurve.of(DefaultCurveMetadata.builder().curveName("name1").xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).build(), 1d), ConstantCurve.of(DefaultCurveMetadata.builder().curveName("name2").xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).build(), 2d));

            coverBeanEquals(COMBINED_CURVE, test);
        }
        public virtual void prices_curveNameParams()
        {
            CurveMetadata test     = Curves.prices(CURVE_NAME, PARAMS);
            CurveMetadata expected = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.MONTHS).yValueType(ValueType.PRICE_INDEX).parameterMetadata(PARAMS).build();

            assertEquals(test, expected);
        }
Esempio n. 4
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ParameterizedFunctionalCurve test1 = ParameterizedFunctionalCurve.of(METADATA, PARAMETERS, VALUE_FUNCTION, DERIVATIVE_FUNCTION, SENSITIVITY_FUNCTION);

            coverImmutableBean(test1);

            DoubleArray   @params  = DoubleArray.of(1.2);
            CurveMetadata metadata = DefaultCurveMetadata.builder().curveName("test").yValueType(ValueType.DISCOUNT_FACTOR).xValueType(ValueType.YEAR_FRACTION).build();

            System.Func <DoubleArray, double, double> value = (DoubleArray t, double?u) =>
            {
                return(t.get(0) * u);
            };
            System.Func <DoubleArray, double, double> deriv = (DoubleArray t, double?u) =>
            {
                return(t.get(0));
            };
            System.Func <DoubleArray, double, DoubleArray> sensi = (DoubleArray t, double?u) =>
            {
                return(DoubleArray.of(u));
            };
            ParameterizedFunctionalCurve test2 = ParameterizedFunctionalCurve.of(metadata, @params, value, deriv, sensi);

            coverBeanEquals(test1, test2);
        }
        //-------------------------------------------------------------------------
        public virtual void test_metadata()
        {
            ParameterizedFunctionalCurveDefinition test = ParameterizedFunctionalCurveDefinition.builder().dayCount(ACT_365F).valueFunction(VALUE_FUNCTION).derivativeFunction(DERIVATIVE_FUNCTION).sensitivityFunction(SENSITIVITY_FUNCTION).initialGuess(INITIAL_PARAMS).name(CURVE_NAME).nodes(NODES).parameterMetadata(PARAM_METADATA).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).build();
            DefaultCurveMetadata expected = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_365F).parameterMetadata(PARAM_METADATA).build();

            assertEquals(test.metadata(VAL_DATE, REF_DATA), expected);
        }
        public virtual void discountFactors_curveName()
        {
            CurveMetadata test     = Curves.discountFactors(CURVE_NAME, ACT_360);
            CurveMetadata expected = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.DISCOUNT_FACTOR).dayCount(ACT_360).build();

            assertEquals(test, expected);
        }
Esempio n. 7
0
        //-------------------------------------------------------------------------
        public CurveMetadata metadata(LocalDate valuationDate, ReferenceData refData)
        {
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IList <DatedParameterMetadata> nodeMetadata = nodes.Select(node => node.metadata(valuationDate, refData)).collect(toImmutableList());

            return(DefaultCurveMetadata.builder().curveName(name).xValueType(xValueType).yValueType(yValueType).dayCount(dayCount).parameterMetadata(nodeMetadata).build());
        }
        public virtual void zeroRates_curveName()
        {
            CurveMetadata test     = Curves.zeroRates(CURVE_NAME, ACT_360);
            CurveMetadata expected = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_360).build();

            assertEquals(test, expected);
        }
        public virtual void forwardRates_curveNameParams()
        {
            CurveMetadata test     = Curves.forwardRates(CURVE_NAME, ACT_360, PARAMS);
            CurveMetadata expected = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.FORWARD_RATE).dayCount(ACT_360).parameterMetadata(PARAMS).build();

            assertEquals(test, expected);
        }
        public virtual void sabrParameterByExpiry_curveNameParams()
        {
            CurveMetadata test     = Curves.sabrParameterByExpiry(CURVE_NAME, ACT_365F, ValueType.SABR_NU, PARAMS);
            CurveMetadata expected = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.SABR_NU).dayCount(ACT_365F).parameterMetadata(PARAMS).build();

            assertEquals(test, expected);
        }
        //-------------------------------------------------------------------------
        public virtual void recoveryRates_string()
        {
            CurveMetadata test     = Curves.recoveryRates(NAME, ACT_360);
            CurveMetadata expected = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.RECOVERY_RATE).dayCount(ACT_360).build();

            assertEquals(test, expected);
        }
        public virtual void blackVolatilityByExpiry_curveNameParams()
        {
            CurveMetadata test     = Curves.blackVolatilityByExpiry(CURVE_NAME, ACT_360, PARAMS);
            CurveMetadata expected = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.BLACK_VOLATILITY).dayCount(ACT_360).parameterMetadata(PARAMS).build();

            assertEquals(test, expected);
        }
        //-------------------------------------------------------------------------
        public virtual void prices_string()
        {
            CurveMetadata test     = Curves.prices(NAME);
            CurveMetadata expected = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.MONTHS).yValueType(ValueType.PRICE_INDEX).build();

            assertEquals(test, expected);
        }
        //-------------------------------------------------------------------------
        public virtual void test_curve()
        {
            InterpolatedNodalCurveDefinition test     = InterpolatedNodalCurveDefinition.builder().name(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_365F).nodes(NODES).interpolator(CurveInterpolators.LINEAR).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build();
            DefaultCurveMetadata             metadata = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_365F).parameterMetadata(NODES.get(0).metadata(VAL_DATE, REF_DATA), NODES.get(1).metadata(VAL_DATE, REF_DATA)).build();
            InterpolatedNodalCurve           expected = InterpolatedNodalCurve.builder().metadata(metadata).xValues(DoubleArray.of(ACT_365F.yearFraction(VAL_DATE, DATE1), ACT_365F.yearFraction(VAL_DATE, DATE2))).yValues(DoubleArray.of(1d, 1.5d)).interpolator(CurveInterpolators.LINEAR).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build();

            assertEquals(test.curve(VAL_DATE, metadata, DoubleArray.of(1d, 1.5d)), expected);
        }
Esempio n. 15
0
 /// <summary>
 /// Creates metadata for a curve providing a SABR parameter.
 /// <para>
 /// The x-values represent time to expiry year fractions as defined by the specified day count.
 ///
 /// </para>
 /// </summary>
 /// <param name="name">  the curve name </param>
 /// <param name="dayCount">  the day count </param>
 /// <param name="yType">  the y-value type, which must be one of the four SABR values </param>
 /// <param name="parameterMetadata">  the parameter metadata </param>
 /// <returns> the curve metadata </returns>
 public static CurveMetadata sabrParameterByExpiry <T1>(CurveName name, DayCount dayCount, ValueType yType, IList <T1> parameterMetadata) where T1 : com.opengamma.strata.market.param.ParameterMetadata
 {
     if (!yType.Equals(ValueType.SABR_ALPHA) && !yType.Equals(ValueType.SABR_BETA) && !yType.Equals(ValueType.SABR_RHO) && !yType.Equals(ValueType.SABR_NU))
     {
         throw new System.ArgumentException("SABR y-value type must be SabrAlpha, SabrBeta, SabrRho or SabrNu");
     }
     return(DefaultCurveMetadata.builder().curveName(name).xValueType(ValueType.YEAR_FRACTION).yValueType(yType).dayCount(dayCount).parameterMetadata(parameterMetadata).build());
 }
Esempio n. 16
0
 /// <summary>
 /// Creates metadata for a curve providing a SABR parameter.
 /// <para>
 /// The x-values represent time to expiry year fractions as defined by the specified day count.
 ///
 /// </para>
 /// </summary>
 /// <param name="name">  the curve name </param>
 /// <param name="dayCount">  the day count </param>
 /// <param name="yType">  the y-value type, which must be one of the four SABR values </param>
 /// <returns> the curve metadata </returns>
 public static CurveMetadata sabrParameterByExpiry(CurveName name, DayCount dayCount, ValueType yType)
 {
     if (!yType.Equals(ValueType.SABR_ALPHA) && !yType.Equals(ValueType.SABR_BETA) && !yType.Equals(ValueType.SABR_RHO) && !yType.Equals(ValueType.SABR_NU))
     {
         throw new System.ArgumentException("SABR y-value type must be SabrAlpha, SabrBeta, SabrRho or SabrNu");
     }
     return(DefaultCurveMetadata.builder().curveName(name).xValueType(ValueType.YEAR_FRACTION).yValueType(yType).dayCount(dayCount).build());
 }
Esempio n. 17
0
        public virtual void test_withMetadata()
        {
            ParameterizedFunctionalCurve @base    = ParameterizedFunctionalCurve.of(METADATA, PARAMETERS, VALUE_FUNCTION, DERIVATIVE_FUNCTION, SENSITIVITY_FUNCTION);
            CurveMetadata metadata                = DefaultCurveMetadata.builder().curveName("test").yValueType(ValueType.DISCOUNT_FACTOR).xValueType(ValueType.YEAR_FRACTION).build();
            ParameterizedFunctionalCurve expected = ParameterizedFunctionalCurve.of(metadata, PARAMETERS, VALUE_FUNCTION, DERIVATIVE_FUNCTION, SENSITIVITY_FUNCTION);

            assertEquals(@base.withMetadata(metadata), expected);
        }
Esempio n. 18
0
        static ParameterizedFunctionalCurveTest()
        {
            TenorParameterMetadata param1 = TenorParameterMetadata.of(Tenor.TENOR_1Y);
            TenorParameterMetadata param2 = TenorParameterMetadata.of(Tenor.TENOR_5Y);
            TenorParameterMetadata param3 = TenorParameterMetadata.of(Tenor.TENOR_10Y);

            METADATA = DefaultCurveMetadata.builder().curveName("test").yValueType(ValueType.DISCOUNT_FACTOR).xValueType(ValueType.YEAR_FRACTION).parameterMetadata(param1, param2, param3).build();
        }
Esempio n. 19
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            DefaultCurveMetadata test = DefaultCurveMetadata.of(CURVE_NAME);

            coverImmutableBean(test);
            DefaultCurveMetadata test2 = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.DISCOUNT_FACTOR).dayCount(ACT_360).jacobian(JACOBIAN_DATA).parameterMetadata(ParameterMetadata.empty()).build();

            coverBeanEquals(test, test2);
        }
Esempio n. 20
0
        public virtual void test_builder3()
        {
            DefaultCurveMetadata test = DefaultCurveMetadata.builder().curveName(CURVE_NAME).parameterMetadata(ImmutableList.of(ParameterMetadata.empty())).clearParameterMetadata().build();

            assertThat(test.CurveName).isEqualTo(CURVE_NAME);
            assertThat(test.XValueType).isEqualTo(ValueType.UNKNOWN);
            assertThat(test.YValueType).isEqualTo(ValueType.UNKNOWN);
            assertThat(test.ParameterMetadata.Present).False;
        }
Esempio n. 21
0
        //-------------------------------------------------------------------------
        public virtual void test_underlyingCurves()
        {
            CurveMetadata          metadata = DefaultCurveMetadata.builder().curveName("newCurve").xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).parameterMetadata(PARAM_METADATA_SPREAD).build();
            InterpolatedNodalCurve newCurve = InterpolatedNodalCurve.of(metadata, XVALUES_SPREAD, YVALUES_SPREAD, NATURAL_CUBIC_SPLINE, LINEAR, LINEAR);

            assertEquals(COMBINED_CURVE.withUnderlyingCurve(0, newCurve), CombinedCurve.of(newCurve, SPREAD_CURVE, COMBINED_CURVE.Metadata));
            assertEquals(COMBINED_CURVE.withUnderlyingCurve(1, newCurve), CombinedCurve.of(BASE_CURVE, newCurve, COMBINED_CURVE.Metadata));
            assertEquals(COMBINED_CURVE.split(), ImmutableList.of(BASE_CURVE, SPREAD_CURVE));
            assertThrowsIllegalArg(() => COMBINED_CURVE.withUnderlyingCurve(2, newCurve));
        }
        public virtual void underlyingCurve()
        {
            assertEquals(ADD_FIXED_CURVE.split(), ImmutableList.of(FIXED_CURVE, SPREAD_CURVE));
            CurveMetadata          metadata = DefaultCurveMetadata.builder().curveName(CurveName.of("newCurve")).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_365F).parameterMetadata(PARAM_METADATA_SPREAD).build();
            InterpolatedNodalCurve newCurve = InterpolatedNodalCurve.of(metadata, XVALUES_SPREAD, YVALUES_SPREAD, INTERPOLATOR);

            assertEquals(ADD_FIXED_CURVE.withUnderlyingCurve(0, newCurve), AddFixedCurve.of(newCurve, SPREAD_CURVE));
            assertEquals(ADD_FIXED_CURVE.withUnderlyingCurve(1, newCurve), AddFixedCurve.of(FIXED_CURVE, newCurve));
            assertThrowsIllegalArg(() => ADD_FIXED_CURVE.withUnderlyingCurve(2, newCurve));
        }
	  //-------------------------------------------------------------------------
	  public virtual void test_curve()
	  {
		InflationNodalCurveDefinition test = new InflationNodalCurveDefinition(UNDERLYING_DEF, LAST_FIX_MONTH, LAST_FIX_VALUE, SEASONALITY_DEF);
		DefaultCurveMetadata metadata = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.PRICE_INDEX).dayCount(ACT_365F).parameterMetadata(NODES.get(0).metadata(VAL_DATE, REF_DATA), NODES.get(1).metadata(VAL_DATE, REF_DATA)).build();
		LocalDate date0 = NODES.get(0).date(VAL_DATE, REF_DATA);
		LocalDate date1 = NODES.get(1).date(VAL_DATE, REF_DATA);
		DoubleArray param = DoubleArray.of(250.0d, 260.0d);
		InterpolatedNodalCurve expectedUnderlying = InterpolatedNodalCurve.builder().metadata(metadata).xValues(DoubleArray.of(ACT_365F.yearFraction(VAL_DATE, date0), ACT_365F.yearFraction(VAL_DATE, date1))).yValues(param).interpolator(CurveInterpolators.LOG_LINEAR).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build();
		InflationNodalCurve expected = InflationNodalCurve.of(expectedUnderlying, VAL_DATE, LAST_FIX_MONTH, LAST_FIX_VALUE, SEASONALITY_DEF);
		assertEquals(test.curve(VAL_DATE, metadata, param), expected);
	  }
Esempio n. 24
0
        //-------------------------------------------------------------------------
        public virtual void test_withMetadata()
        {
            IList <ParameterMetadata> combinedParamMeta = new List <ParameterMetadata>();

            ((IList <ParameterMetadata>)combinedParamMeta).AddRange(PARAM_METADATA_BASE);
            ((IList <ParameterMetadata>)combinedParamMeta).AddRange(PARAM_METADATA_SPREAD);
            CurveMetadata newMetadata = DefaultCurveMetadata.builder().curveName("newName").xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).parameterMetadata(combinedParamMeta).build();
            CombinedCurve computed    = COMBINED_CURVE.withMetadata(newMetadata);
            CombinedCurve expected    = CombinedCurve.of(BASE_CURVE, SPREAD_CURVE, newMetadata);

            assertEquals(computed, expected);
        }
Esempio n. 25
0
        public virtual void test_dayCount()
        {
            CurveMetadata          baseMetadata      = DefaultCurveMetadata.builder().curveName(BASE_NAME).xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).build();
            CurveMetadata          spreadMetadata    = DefaultCurveMetadata.builder().curveName(SPREAD_NAME).xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(DayCounts.ACT_360).build();
            InterpolatedNodalCurve baseCurve         = InterpolatedNodalCurve.of(baseMetadata, XVALUES_BASE, YVALUES_BASE, NATURAL_CUBIC_SPLINE, LINEAR, LINEAR);
            InterpolatedNodalCurve spreadCurve       = InterpolatedNodalCurve.of(spreadMetadata, XVALUES_SPREAD, YVALUES_SPREAD, PCHIP, LINEAR, LINEAR);
            CurveMetadata          combinedMetadata1 = DefaultCurveMetadata.builder().curveName("CombinedCurve").xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(DayCounts.ACT_360).build();

            assertThrowsIllegalArg(() => CombinedCurve.of(baseCurve, spreadCurve, combinedMetadata1));
            CurveMetadata combinedMetadata2 = DefaultCurveMetadata.builder().curveName("CombinedCurve").xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).build();

            assertThrowsIllegalArg(() => CombinedCurve.of(baseCurve, spreadCurve, combinedMetadata2));
        }
Esempio n. 26
0
        public virtual void test_builder4()
        {
            DefaultCurveMetadata test = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.DISCOUNT_FACTOR).parameterMetadata(ParameterMetadata.empty()).parameterMetadata(ParameterMetadata.empty()).build();

            assertThat(test.CurveName).isEqualTo(CURVE_NAME);
            assertThat(test.XValueType).isEqualTo(ValueType.YEAR_FRACTION);
            assertThat(test.YValueType).isEqualTo(ValueType.DISCOUNT_FACTOR);
            assertThrowsIllegalArg(() => test.getInfo(CurveInfoType.DAY_COUNT));
            assertThat(test.findInfo(CurveInfoType.DAY_COUNT)).isEqualTo(null);
            assertThat(test.findInfo(CurveInfoType.JACOBIAN)).isEqualTo(null);
            assertThat(test.findInfo(CurveInfoType.of("Rubbish"))).isEqualTo(null);
            assertThat(test.ParameterMetadata.Present).True;
            assertThat(test.ParameterMetadata.get()).containsExactly(ParameterMetadata.empty());
        }
Esempio n. 27
0
        public virtual void test_builder1()
        {
            DefaultCurveMetadata test = DefaultCurveMetadata.builder().curveName(CURVE_NAME.ToString()).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.DISCOUNT_FACTOR).dayCount(ACT_360).jacobian(JACOBIAN_DATA).addInfo(CurveInfoType.DAY_COUNT, null).parameterMetadata(ImmutableList.of(ParameterMetadata.empty())).build();

            assertThat(test.CurveName).isEqualTo(CURVE_NAME);
            assertThat(test.XValueType).isEqualTo(ValueType.YEAR_FRACTION);
            assertThat(test.YValueType).isEqualTo(ValueType.DISCOUNT_FACTOR);
            assertThat(test.findInfo(CurveInfoType.DAY_COUNT)).Empty;
            assertThat(test.getInfo(CurveInfoType.JACOBIAN)).isEqualTo(JACOBIAN_DATA);
            assertThat(test.findInfo(CurveInfoType.JACOBIAN)).isEqualTo(JACOBIAN_DATA);
            assertThat(test.findInfo(CurveInfoType.of("Rubbish"))).isEqualTo(null);
            assertThat(test.ParameterMetadata.Present).True;
            assertThat(test.ParameterMetadata.get()).containsExactly(ParameterMetadata.empty());
        }
Esempio n. 28
0
        /// <summary>
        /// Creates a curve as the sum of a base curve and a spread curve.
        /// <para>
        /// The metadata of the combined curve will be created form the base curve and spread curve.
        ///
        /// </para>
        /// </summary>
        /// <param name="baseCurve">  the base curve </param>
        /// <param name="spreadCurve">  the spread curve </param>
        /// <returns> the combined curve </returns>
        public static CombinedCurve of(Curve baseCurve, Curve spreadCurve)
        {
            CurveMetadata baseMetadata   = baseCurve.Metadata;
            CurveMetadata spreadMetadata = spreadCurve.Metadata;

            IList <ParameterMetadata> paramMeta = Stream.concat(IntStream.range(0, baseCurve.ParameterCount).mapToObj(i => baseCurve.getParameterMetadata(i)), IntStream.range(0, spreadCurve.ParameterCount).mapToObj(i => spreadCurve.getParameterMetadata(i))).collect(toImmutableList());

            DefaultCurveMetadataBuilder metadataBuilder = DefaultCurveMetadata.builder().curveName(baseCurve.Name.Name + "+" + spreadMetadata.CurveName.Name).xValueType(baseMetadata.XValueType).yValueType(baseMetadata.YValueType).parameterMetadata(paramMeta);

            if (baseMetadata.findInfo(CurveInfoType.DAY_COUNT).Present)
            {
                metadataBuilder.addInfo(CurveInfoType.DAY_COUNT, baseMetadata.getInfo(CurveInfoType.DAY_COUNT));
            }

            return(of(baseCurve, spreadCurve, metadataBuilder.build()));
        }
Esempio n. 29
0
        public virtual void test_of_noMetadata()
        {
            IList <ParameterMetadata> combinedParamMeta = new List <ParameterMetadata>();

            ((IList <ParameterMetadata>)combinedParamMeta).AddRange(PARAM_METADATA_BASE);
            ((IList <ParameterMetadata>)combinedParamMeta).AddRange(PARAM_METADATA_SPREAD);
            CurveMetadata expectedMetadata = DefaultCurveMetadata.builder().curveName(BASE_NAME + "+" + SPREAD_NAME).xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).parameterMetadata(combinedParamMeta).build();

            assertEquals(COMBINED_CURVE.BaseCurve, BASE_CURVE);
            assertEquals(COMBINED_CURVE.SpreadCurve, SPREAD_CURVE);
            assertEquals(COMBINED_CURVE.Metadata, expectedMetadata);
            assertEquals(COMBINED_CURVE.Name, expectedMetadata.CurveName);
            assertEquals(COMBINED_CURVE.ParameterCount, BASE_CURVE.ParameterCount + SPREAD_CURVE.ParameterCount);
            assertEquals(COMBINED_CURVE.getParameter(1), BASE_CURVE.getParameter(1));
            assertEquals(COMBINED_CURVE.getParameter(6), SPREAD_CURVE.getParameter(3));
            assertEquals(COMBINED_CURVE.getParameterMetadata(0), BASE_CURVE.getParameterMetadata(0));
            assertEquals(COMBINED_CURVE.getParameterMetadata(4), SPREAD_CURVE.getParameterMetadata(1));
        }
Esempio n. 30
0
        public virtual void test_of()
        {
            CurveMetadata          baseMetadata     = DefaultCurveMetadata.builder().curveName(BASE_NAME).xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).build();
            CurveMetadata          spreadMetadata   = DefaultCurveMetadata.builder().curveName(SPREAD_NAME).xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).build();
            InterpolatedNodalCurve baseCurve        = InterpolatedNodalCurve.of(baseMetadata, XVALUES_BASE, YVALUES_BASE, NATURAL_CUBIC_SPLINE, LINEAR, LINEAR);
            InterpolatedNodalCurve spreadCurve      = InterpolatedNodalCurve.of(spreadMetadata, XVALUES_SPREAD, YVALUES_SPREAD, PCHIP, LINEAR, LINEAR);
            CurveMetadata          combinedMetadata = DefaultCurveMetadata.builder().curveName("CombinedCurve").xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).build();
            CombinedCurve          test             = CombinedCurve.of(baseCurve, spreadCurve, combinedMetadata);

            assertEquals(test.BaseCurve, baseCurve);
            assertEquals(test.SpreadCurve, spreadCurve);
            assertEquals(test.Metadata, combinedMetadata);
            assertEquals(test.Name, combinedMetadata.CurveName);
            assertEquals(test.ParameterCount, baseCurve.ParameterCount + spreadCurve.ParameterCount);
            assertEquals(test.getParameter(1), baseCurve.getParameter(1));
            assertEquals(test.getParameter(6), spreadCurve.getParameter(3));
            assertEquals(test.getParameterMetadata(2), baseCurve.getParameterMetadata(2));
            assertEquals(test.getParameterMetadata(5), spreadCurve.getParameterMetadata(2));
        }