예제 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_createParameterSensitivity()
        {
            InterpolatedNodalCurve test = InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES, INTERPOLATOR);

            assertThat(test.createParameterSensitivity(DoubleArray.of(2d, 3d, 4d))).isEqualTo(UnitParameterSensitivity.of(CURVE_NAME, DoubleArray.of(2d, 3d, 4d)));
            assertThat(test.createParameterSensitivity(Currency.GBP, DoubleArray.of(2d, 3d, 4d))).isEqualTo(CurrencyParameterSensitivity.of(CURVE_NAME, Currency.GBP, DoubleArray.of(2d, 3d, 4d)));
        }
예제 #2
0
        public virtual void test_withValuesXy_badSize()
        {
            InterpolatedNodalCurve @base = InterpolatedNodalCurve.of(METADATA, XVALUES, YVALUES, INTERPOLATOR);

            assertThrowsIllegalArg(() => @base.withValues(DoubleArray.EMPTY, DoubleArray.EMPTY));
            assertThrowsIllegalArg(() => @base.withValues(DoubleArray.of(1d, 3d, 5d), DoubleArray.of(4d, 6d)));
        }
        //-------------------------------------------------------------------------
        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);
        }
예제 #4
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            InterpolatedNodalCurve test = InterpolatedNodalCurve.of(METADATA, XVALUES, YVALUES, INTERPOLATOR);

            coverImmutableBean(test);
            InterpolatedNodalCurve test2 = InterpolatedNodalCurve.builder().metadata(METADATA_ENTRIES).xValues(XVALUES2).yValues(YVALUES_BUMPED).extrapolatorLeft(CurveExtrapolators.LOG_LINEAR).interpolator(CurveInterpolators.DOUBLE_QUADRATIC).extrapolatorRight(CurveExtrapolators.LOG_LINEAR).build();

            coverBeanEquals(test, test2);
        }
예제 #5
0
        public virtual void test_of_extrapolators()
        {
            InterpolatedNodalCurve test = InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES, INTERPOLATOR, LINEAR_EXTRAPOLATOR, LINEAR_EXTRAPOLATOR);

            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ExtrapolatorLeft.Name).isEqualTo(LINEAR_EXTRAPOLATOR.Name);
            assertThat(test.Interpolator.Name).isEqualTo(INTERPOLATOR.Name);
            assertThat(test.ExtrapolatorRight.Name).isEqualTo(LINEAR_EXTRAPOLATOR.Name);
        }
        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));
        }
예제 #7
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));
        }
예제 #8
0
 public virtual void test_of_invalid()
 {
     // not enough nodes
     assertThrowsIllegalArg(() => InterpolatedNodalCurve.of(METADATA, DoubleArray.of(1d), DoubleArray.of(1d), INTERPOLATOR));
     // x node size != y node size
     assertThrowsIllegalArg(() => InterpolatedNodalCurve.of(METADATA, XVALUES, DoubleArray.of(1d, 3d), INTERPOLATOR));
     // parameter metadata size != node size
     assertThrowsIllegalArg(() => InterpolatedNodalCurve.of(METADATA_ENTRIES, DoubleArray.of(1d, 3d), DoubleArray.of(1d, 3d), INTERPOLATOR));
     // x not in order
     assertThrowsIllegalArg(() => InterpolatedNodalCurve.of(METADATA, DoubleArray.of(2d, 1d), DoubleArray.of(2d, 3d), INTERPOLATOR));
 }
예제 #9
0
        //-------------------------------------------------------------------------
        public virtual void test_withValuesXy()
        {
            InterpolatedNodalCurve @base = InterpolatedNodalCurve.of(METADATA, XVALUES, YVALUES, INTERPOLATOR);
            InterpolatedNodalCurve test  = @base.withValues(XVALUES2, YVALUES_BUMPED);

            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ParameterCount).isEqualTo(SIZE);
            assertThat(test.Metadata).isEqualTo(METADATA);
            assertThat(test.XValues).isEqualTo(XVALUES2);
            assertThat(test.YValues).isEqualTo(YVALUES_BUMPED);
        }
	  //-------------------------------------------------------------------------
	  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);
	  }
        public virtual void test_firstDerivative()
        {
            InterpolatedNodalCurve curve = InterpolatedNodalCurve.of(METADATA, DoubleArray.of(0, 1), DoubleArray.of(2, 2.5), CurveInterpolators.LINEAR);

            Curve absoluteShiftedCurve = ParallelShiftedCurve.absolute(curve, 1);
            Curve relativeShiftedCurve = ParallelShiftedCurve.relative(curve, 0.2);

            assertThat(curve.firstDerivative(0.1)).isEqualTo(0.5);
            assertThat(absoluteShiftedCurve.firstDerivative(0.1)).isEqualTo(0.5);
            assertThat(relativeShiftedCurve.firstDerivative(0.1)).isEqualTo(0.5 * 1.2);
        }
예제 #12
0
        public virtual void test_of_noCurveMetadata()
        {
            InterpolatedNodalCurve test = InterpolatedNodalCurve.of(METADATA_NOPARAM, XVALUES, YVALUES, INTERPOLATOR);

            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ParameterCount).isEqualTo(SIZE);
            assertThat(test.getParameter(0)).isEqualTo(YVALUES.get(0));
            assertThat(test.getParameter(1)).isEqualTo(YVALUES.get(1));
            assertThat(test.getParameterMetadata(0)).isEqualTo(SimpleCurveParameterMetadata.of(ValueType.YEAR_FRACTION, XVALUES.get(0)));
            assertThat(test.getParameterMetadata(1)).isEqualTo(SimpleCurveParameterMetadata.of(ValueType.YEAR_FRACTION, XVALUES.get(1)));
        }
예제 #13
0
        public virtual void test_withNode_atEnd_withoutMetadata()
        {
            InterpolatedNodalCurve     @base = InterpolatedNodalCurve.of(METADATA, XVALUES, YVALUES, INTERPOLATOR);
            LabelDateParameterMetadata item  = LabelDateParameterMetadata.of(date(2015, 6, 30), TNR_1Y);
            InterpolatedNodalCurve     test  = @base.withNode(0.5d, 4d, item);

            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ParameterCount).isEqualTo(SIZE + 1);
            assertThat(test.Metadata).isEqualTo(METADATA);
            assertThat(test.XValues).isEqualTo(DoubleArray.of(0.5d, 1d, 2d, 3d));
            assertThat(test.YValues).isEqualTo(DoubleArray.of(4d, 5d, 7d, 8d));
        }
        public virtual void test_relative()
        {
            CurveParallelShifts test = CurveParallelShifts.relative(0.1d, 0.2d, 0.4d);

            Curve baseCurve = InterpolatedNodalCurve.of(Curves.zeroRates("curve", DayCounts.ACT_365F), DoubleArray.of(1, 2, 3), DoubleArray.of(5, 6, 7), CurveInterpolators.LOG_LINEAR);

            MarketDataBox <Curve> shiftedCurveBox = test.applyTo(MarketDataBox.ofSingleValue(baseCurve), REF_DATA);

            assertEquals(shiftedCurveBox.getValue(0), ParallelShiftedCurve.relative(baseCurve, 0.1d));
            assertEquals(shiftedCurveBox.getValue(1), ParallelShiftedCurve.relative(baseCurve, 0.2d));
            assertEquals(shiftedCurveBox.getValue(2), ParallelShiftedCurve.relative(baseCurve, 0.4d));
        }
        //-------------------------------------------------------------------------
        public virtual void test_yValueParameterSensitivity()
        {
            InterpolatedNodalCurve curve = InterpolatedNodalCurve.of(METADATA, DoubleArray.of(0, 1), DoubleArray.of(2, 2.5), CurveInterpolators.LINEAR);

            Curve absoluteShiftedCurve = ParallelShiftedCurve.absolute(curve, 1);
            Curve relativeShiftedCurve = ParallelShiftedCurve.relative(curve, 0.2);

            UnitParameterSensitivity expected = curve.yValueParameterSensitivity(0.1);

            assertThat(absoluteShiftedCurve.yValueParameterSensitivity(0.1)).isEqualTo(expected);
            assertThat(relativeShiftedCurve.yValueParameterSensitivity(0.1)).isEqualTo(expected);
        }
예제 #16
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         InterpolatedNodalCurve other = (InterpolatedNodalCurve)obj;
         return(JodaBeanUtils.equal(metadata, other.metadata) && JodaBeanUtils.equal(xValues, other.xValues) && JodaBeanUtils.equal(yValues, other.yValues) && JodaBeanUtils.equal(interpolator, other.interpolator) && JodaBeanUtils.equal(extrapolatorLeft, other.extrapolatorLeft) && JodaBeanUtils.equal(extrapolatorRight, other.extrapolatorRight));
     }
     return(false);
 }
예제 #17
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));
        }
예제 #18
0
        //-------------------------------------------------------------------------
        public virtual void test_lookup()
        {
            InterpolatedNodalCurve test   = InterpolatedNodalCurve.of(METADATA, XVALUES, YVALUES, INTERPOLATOR);
            BoundCurveInterpolator interp = INTERPOLATOR.bind(XVALUES, YVALUES, FLAT_EXTRAPOLATOR, FLAT_EXTRAPOLATOR);

            assertThat(test.yValue(XVALUES.get(0))).isEqualTo(YVALUES.get(0));
            assertThat(test.yValue(XVALUES.get(1))).isEqualTo(YVALUES.get(1));
            assertThat(test.yValue(XVALUES.get(2))).isEqualTo(YVALUES.get(2));
            assertThat(test.yValue(10d)).isEqualTo(interp.interpolate(10d));

            assertThat(test.yValueParameterSensitivity(10d).MarketDataName).isEqualTo(CURVE_NAME);
            assertThat(test.yValueParameterSensitivity(10d).Sensitivity).isEqualTo(interp.parameterSensitivity(10d));
            assertThat(test.firstDerivative(10d)).isEqualTo(interp.firstDerivative(10d));
        }
예제 #19
0
        public virtual void test_withNode_replace_withMetadata()
        {
            InterpolatedNodalCurve     @base = InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES, INTERPOLATOR);
            LabelDateParameterMetadata item  = LabelDateParameterMetadata.of(date(2015, 6, 30), TNR_1Y);
            InterpolatedNodalCurve     test  = @base.withNode(2d, 4d, item);
            IList <ParameterMetadata>  list  = new List <ParameterMetadata>(METADATA_ENTRIES.ParameterMetadata.get());

            list[1] = item;
            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ParameterCount).isEqualTo(SIZE);
            assertThat(test.Metadata).isEqualTo(METADATA.withParameterMetadata(list));
            assertThat(test.XValues).isEqualTo(DoubleArray.of(1d, 2d, 3d));
            assertThat(test.YValues).isEqualTo(DoubleArray.of(5d, 4d, 8d));
        }
예제 #20
0
        //-------------------------------------------------------------------------
        public virtual void test_withNode_atStart_withMetadata()
        {
            InterpolatedNodalCurve     @base = InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES, INTERPOLATOR);
            LabelDateParameterMetadata item  = LabelDateParameterMetadata.of(date(2015, 6, 30), TNR_1Y);
            InterpolatedNodalCurve     test  = @base.withNode(0.5d, 4d, item);
            IList <ParameterMetadata>  list  = new List <ParameterMetadata>();

            list.Add(item);
            ((IList <ParameterMetadata>)list).AddRange(ParameterMetadata.listOfEmpty(SIZE));
            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ParameterCount).isEqualTo(SIZE + 1);
            assertThat(test.Metadata).isEqualTo(METADATA_ENTRIES.withParameterMetadata(list));
            assertThat(test.XValues).isEqualTo(DoubleArray.of(0.5d, 1d, 2d, 3d));
            assertThat(test.YValues).isEqualTo(DoubleArray.of(4d, 5d, 7d, 8d));
        }
예제 #21
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));
        }
예제 #22
0
        //-------------------------------------------------------------------------
        public virtual void test_of_CurveMetadata()
        {
            InterpolatedNodalCurve test = InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES, INTERPOLATOR);

            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ParameterCount).isEqualTo(SIZE);
            assertThat(test.getParameter(0)).isEqualTo(YVALUES.get(0));
            assertThat(test.getParameter(1)).isEqualTo(YVALUES.get(1));
            assertThat(test.getParameterMetadata(0)).isSameAs(METADATA_ENTRIES.ParameterMetadata.get().get(0));
            assertThat(test.getParameterMetadata(1)).isSameAs(METADATA_ENTRIES.ParameterMetadata.get().get(1));
            assertThat(test.withParameter(0, 2d)).isEqualTo(InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES.with(0, 2d), INTERPOLATOR));
            assertThat(test.withPerturbation((i, v, m) => v - 2d)).isEqualTo(InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES_BUMPED, INTERPOLATOR));
            assertThat(test.ExtrapolatorLeft.Name).isEqualTo(FLAT_EXTRAPOLATOR.Name);
            assertThat(test.Interpolator.Name).isEqualTo(INTERPOLATOR.Name);
            assertThat(test.ExtrapolatorRight.Name).isEqualTo(FLAT_EXTRAPOLATOR.Name);
            assertThat(test.Metadata).isEqualTo(METADATA_ENTRIES);
            assertThat(test.XValues).isEqualTo(XVALUES);
            assertThat(test.YValues).isEqualTo(YVALUES);
        }
        public virtual void parameter_sensitivity_additive()
        {
            InflationNodalCurve curve = InflationNodalCurve.of(CURVE_NOFIX, VAL_DATE_2, LAST_FIX_MONTH_2, LAST_FIX_VALUE, SEASONALITY_ADDITIVE_DEF);
            double shift = 1.0E-2;

            for (int i = 1; i < TEST_MONTHS.Length; i++)
            {
                double nbMonths = YearMonth.from(VAL_DATE_2).until(TEST_MONTHS[i], MONTHS);
                UnitParameterSensitivity psComputed = curve.yValueParameterSensitivity(nbMonths);
                for (int j = 0; j < TIMES.size(); j++)
                {
                    double[] valuePM = new double[2];
                    for (int pm = 0; pm < 2; pm++)
                    {
                        DoubleArray            shiftedValues   = VALUES.with(j, VALUES.get(j) + (1 - 2 * pm) * shift);
                        InterpolatedNodalCurve intCurveShifted = InterpolatedNodalCurve.of(METADATA, TIMES, shiftedValues, INTERPOLATOR);
                        InflationNodalCurve    seaCurveShifted = InflationNodalCurve.of(intCurveShifted, VAL_DATE_2, LAST_FIX_MONTH_2, LAST_FIX_VALUE, SEASONALITY_ADDITIVE_DEF);
                        valuePM[pm] = seaCurveShifted.yValue(nbMonths);
                    }
                    assertEquals(psComputed.Sensitivity.get(j), (valuePM[0] - valuePM[1]) / (2 * shift), TOLERANCE_DELTA);
                }
            }
        }
예제 #24
0
        //-------------------------------------------------------------------------
        public NodalCurve curve(LocalDate valuationDate, CurveMetadata metadata, DoubleArray parameters)
        {
            DoubleArray nodeTimes = buildNodeTimes(valuationDate, metadata);

            return(InterpolatedNodalCurve.builder().metadata(metadata).xValues(nodeTimes).yValues(parameters).extrapolatorLeft(extrapolatorLeft).interpolator(interpolator).extrapolatorRight(extrapolatorRight).build());
        }
예제 #25
0
 /// <summary>
 /// Creates an interpolated curve with metadata.
 /// </summary>
 /// <param name="metadata">  the curve metadata </param>
 /// <param name="xValues">  the x-values </param>
 /// <param name="yValues">  the y-values </param>
 /// <param name="interpolator">  the interpolator </param>
 /// <param name="extrapolatorLeft">  the extrapolator for extrapolating off the left-hand end of the curve </param>
 /// <param name="extrapolatorRight">  the extrapolator for extrapolating off the right-hand end of the curve </param>
 /// <returns> the curve </returns>
 public static InterpolatedNodalCurve of(CurveMetadata metadata, DoubleArray xValues, DoubleArray yValues, CurveInterpolator interpolator, CurveExtrapolator extrapolatorLeft, CurveExtrapolator extrapolatorRight)
 {
     return(InterpolatedNodalCurve.builder().metadata(metadata).xValues(xValues).yValues(yValues).interpolator(interpolator).extrapolatorLeft(extrapolatorLeft).extrapolatorRight(extrapolatorRight).build());
 }
예제 #26
0
        private readonly IList <ParameterMetadata> parameterMetadata;  // derived, not a property

        //-------------------------------------------------------------------------
        /// <summary>
        /// Creates an interpolated curve with metadata.
        /// </summary>
        /// <param name="metadata">  the curve metadata </param>
        /// <param name="xValues">  the x-values </param>
        /// <param name="yValues">  the y-values </param>
        /// <param name="interpolator">  the interpolator </param>
        /// <returns> the curve </returns>
        public static InterpolatedNodalCurve of(CurveMetadata metadata, DoubleArray xValues, DoubleArray yValues, CurveInterpolator interpolator)
        {
            return(InterpolatedNodalCurve.builder().metadata(metadata).xValues(xValues).yValues(yValues).interpolator(interpolator).build());
        }
예제 #27
0
        /// <summary>
        /// Creates the ISDA compliant curve.
        /// <para>
        /// The parameter metadata is not stored in the metadata of the curve.
        ///
        /// </para>
        /// </summary>
        /// <param name="yearFractions">  the year fraction values </param>
        /// <param name="zeroRates">  the zero rate values </param>
        /// <returns> the curve </returns>
        public InterpolatedNodalCurve curve(DoubleArray yearFractions, DoubleArray zeroRates)
        {
            CurveMetadata baseMetadata = Curves.zeroRates(name, dayCount);

            return(InterpolatedNodalCurve.of(baseMetadata, yearFractions, zeroRates, CurveInterpolators.PRODUCT_LINEAR, CurveExtrapolators.FLAT, CurveExtrapolators.PRODUCT_LINEAR));
        }
예제 #28
0
        public virtual void test_withMetadata_badSize()
        {
            InterpolatedNodalCurve @base = InterpolatedNodalCurve.of(METADATA, XVALUES, YVALUES, INTERPOLATOR);

            assertThrowsIllegalArg(() => @base.withMetadata(METADATA_ENTRIES2));
        }
예제 #29
0
        public virtual void test_serialization()
        {
            InterpolatedNodalCurve test = InterpolatedNodalCurve.of(METADATA, XVALUES, YVALUES, INTERPOLATOR);

            assertSerialization(test);
        }