示例#1
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 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);
        }
示例#3
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);
        }
示例#6
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_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);
        }
        //-------------------------------------------------------------------------
        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);
        }
示例#14
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());
 }
示例#15
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();
        }
示例#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());
 }
示例#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);
        }
        //-------------------------------------------------------------------------
        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);
        }
示例#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);
        }
示例#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;
        }
示例#21
0
        /// <summary>
        /// Restricted copy constructor.
        /// </summary>
        /// <param name="beanToCopy">  the bean to copy from </param>
        internal DefaultCurveMetadataBuilder(DefaultCurveMetadata beanToCopy)
        {
            this.curveName_Renamed  = beanToCopy.CurveName;
            this.xValueType_Renamed = beanToCopy.XValueType;
            this.yValueType_Renamed = beanToCopy.YValueType;
//JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method:
            this.info.putAll(beanToCopy.Info);
            this.parameterMetadata_Renamed = beanToCopy.ParameterMetadata.orElse(null);
        }
        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));
        }
示例#23
0
        //-------------------------------------------------------------------------
        public virtual void test_withInfo()
        {
            DefaultCurveMetadata @base = DefaultCurveMetadata.of(CURVE_NAME);

            assertThat(@base.findInfo(CurveInfoType.DAY_COUNT).Present).False;
            DefaultCurveMetadata test = @base.withInfo(CurveInfoType.DAY_COUNT, ACT_360);

            assertThat(@base.findInfo(CurveInfoType.DAY_COUNT).Present).False;
            assertThat(test.findInfo(CurveInfoType.DAY_COUNT).Present).True;
        }
示例#24
0
        public virtual void test_of_CurveName_noMetadata()
        {
            DefaultCurveMetadata test = DefaultCurveMetadata.of(CURVE_NAME);

            assertThat(test.CurveName).isEqualTo(CURVE_NAME);
            assertThat(test.XValueType).isEqualTo(ValueType.UNKNOWN);
            assertThat(test.YValueType).isEqualTo(ValueType.UNKNOWN);
            assertThat(test.Info).isEqualTo(ImmutableMap.of());
            assertThat(test.ParameterMetadata.Present).False;
        }
示例#25
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 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);
	  }
示例#27
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);
        }
示例#28
0
        //-------------------------------------------------------------------------
        public virtual void test_withParameterMetadata()
        {
            DefaultCurveMetadata @base = DefaultCurveMetadata.of(CURVE_NAME);
            DefaultCurveMetadata test  = @base.withParameterMetadata(ParameterMetadata.listOfEmpty(2));

            assertThat(test.ParameterMetadata.Present).True;
            assertThat(test.ParameterMetadata.get()).containsAll(ParameterMetadata.listOfEmpty(2));
            // redo for test coverage
            DefaultCurveMetadata test2 = test.withParameterMetadata(ParameterMetadata.listOfEmpty(3));

            assertThat(test2.ParameterMetadata.Present).True;
            assertThat(test2.ParameterMetadata.get()).containsAll(ParameterMetadata.listOfEmpty(3));
        }
示例#29
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));
        }
示例#30
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());
        }