public virtual void of_construction_multiplicative_2() { InflationNodalCurve curveComputed = InflationNodalCurve.of(CURVE_NOFIX, VAL_DATE_2, LAST_FIX_MONTH_2, LAST_FIX_VALUE, SEASONALITY_MULTIPLICATIVE_DEF); assertEquals(curveComputed.Underlying.XValues.get(0), NB_MONTHS_2, TOLERANCE_TIME); assertEquals(curveComputed.Underlying.YValues.get(0), LAST_FIX_VALUE, TOLERANCE_TIME); assertEquals(curveComputed.yValue(NB_MONTHS_2), LAST_FIX_VALUE, TOLERANCE_TIME); }
public virtual void of_construction_additive_1() { InflationNodalCurve curveComputed = InflationNodalCurve.of(CURVE_NOFIX, VAL_DATE_1, LAST_FIX_MONTH_1, LAST_FIX_VALUE, SEASONALITY_ADDITIVE_DEF); assertEquals(curveComputed.Underlying.XValues.get(0), NB_MONTHS_1, TOLERANCE_TIME); assertEquals(curveComputed.Underlying.YValues.get(0), LAST_FIX_VALUE, TOLERANCE_TIME); assertEquals(curveComputed.yValue(NB_MONTHS_1), LAST_FIX_VALUE, TOLERANCE_TIME); }
//------------------------------------------------------------------------- public virtual void coverage() { InflationNodalCurve test = InflationNodalCurve.of(CURVE_NOFIX, VAL_DATE_1, LAST_FIX_MONTH_1, LAST_FIX_VALUE, SEASONALITY_MULTIPLICATIVE_DEF); coverImmutableBean(test); InflationNodalCurve test2 = InflationNodalCurve.of(CURVE2_NOFIX, VAL_DATE_2, LAST_FIX_MONTH_2, LAST_FIX_VALUE + 1.0d, SEASONALITY_ADDITIVE_DEF); 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 override bool Equals(object obj) { if (obj == this) { return(true); } if (obj != null && obj.GetType() == this.GetType()) { InflationNodalCurve other = (InflationNodalCurve)obj; return(JodaBeanUtils.equal(underlying, other.underlying) && JodaBeanUtils.equal(seasonality, other.seasonality) && JodaBeanUtils.equal(adjustmentType, other.adjustmentType)); } return(false); }
public virtual void value_multiplicative() { InflationNodalCurve curveComputed = InflationNodalCurve.of(CURVE_NOFIX, VAL_DATE_2, LAST_FIX_MONTH_2, LAST_FIX_VALUE, SEASONALITY_MULTIPLICATIVE_DEF); for (int i = 1; i < TEST_MONTHS.Length; i++) { double nbMonths = YearMonth.from(VAL_DATE_2).until(TEST_MONTHS[i], MONTHS); double valueComputed = curveComputed.yValue(nbMonths); int x = (int)((nbMonths + 12) % 12); double valueNoAdj = EXTENDED_CURVE_2.yValue(nbMonths); double adj = SEASONALITY_MULTIPLICATIVE_COMP_2.get(x); double valueExpected = valueNoAdj * adj; assertEquals(valueExpected, valueComputed, TOLERANCE_VALUE); } }
public virtual void value_additive() { InflationNodalCurve curveComputed = InflationNodalCurve.of(CURVE_NOFIX, VAL_DATE_2, LAST_FIX_MONTH_2, LAST_FIX_VALUE, SEASONALITY_ADDITIVE_DEF); for (int i = 1; i < TEST_MONTHS.Length; i++) { double nbMonths = YearMonth.from(VAL_DATE_2).until(TEST_MONTHS[i], MONTHS); double valueComputed = curveComputed.yValue(nbMonths); int x = (int)((nbMonths + 12) % 12); double valueNoAdj = EXTENDED_CURVE_2.yValue(nbMonths); DoubleArray seasonalityAdditiveCompounded = seasonalityCompounded(VAL_DATE_2, LAST_FIX_MONTH_2, SEASONALITY_ADDITIVE, (v, a) => v + a); double adj = seasonalityAdditiveCompounded.get(x); double valueExpected = valueNoAdj + adj; assertEquals(valueExpected, valueComputed, TOLERANCE_VALUE); } }
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); } } }
public virtual void test_serialization() { InflationNodalCurve test = InflationNodalCurve.of(CURVE_NOFIX, VAL_DATE_1, LAST_FIX_MONTH_1, LAST_FIX_VALUE, SEASONALITY_MULTIPLICATIVE_DEF); assertSerialization(test); }
public NodalCurve curve(LocalDate valuationDate, CurveMetadata metadata, DoubleArray parameters) { NodalCurve curveWithoutFixing = curveWithoutFixingDefinition.curve(valuationDate, metadata, parameters); return(InflationNodalCurve.of(curveWithoutFixing, valuationDate, lastFixingMonth, lastFixingValue, seasonalityDefinition)); }