//------------------------------------------------------------------------- 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); }
//------------------------------------------------------------------------- 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); }
//------------------------------------------------------------------------- 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 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()); }
/// <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()); }
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()); }