public virtual void pointAndParameterPriceIndex() { double eps = 1.0e-13; LocalDate valuationDate = LocalDate.of(2014, 1, 22); DoubleArray x = DoubleArray.of(0.5, 1.0, 2.0); DoubleArray y = DoubleArray.of(224.2, 262.6, 277.5); CurveInterpolator interp = CurveInterpolators.NATURAL_CUBIC_SPLINE; string curveName = "GB_RPI_CURVE"; InterpolatedNodalCurve interpCurve = InterpolatedNodalCurve.of(Curves.prices(curveName), x, y, interp); ImmutableRatesProvider provider = ImmutableRatesProvider.builder(VAL_DATE).priceIndexCurve(GB_RPI, interpCurve).timeSeries(GB_RPI, LocalDateDoubleTimeSeries.of(date(2013, 11, 30), 200)).build(); double pointSensiValue = 2.5; YearMonth refMonth = YearMonth.from(valuationDate.plusMonths(9)); InflationRateSensitivity pointSensi = InflationRateSensitivity.of(PriceIndexObservation.of(GB_RPI, refMonth), pointSensiValue); CurrencyParameterSensitivities computed = provider.parameterSensitivity(pointSensi.build()); DoubleArray sensiComputed = computed.Sensitivities.get(0).Sensitivity; InflationRateSensitivity pointSensi1 = InflationRateSensitivity.of(PriceIndexObservation.of(GB_RPI, refMonth), 1); DoubleArray sensiExpectedUnit = provider.priceIndexValues(GB_RPI).parameterSensitivity(pointSensi1).Sensitivities.get(0).Sensitivity; assertTrue(sensiComputed.equalWithTolerance(sensiExpectedUnit.multipliedBy(pointSensiValue), eps)); }
//------------------------------------------------------------------------- /// <summary> /// Creates an instance from an index, start index value and reference end month. /// </summary> /// <param name="index"> the index </param> /// <param name="startIndexValue"> the start index value </param> /// <param name="referenceEndMonth"> the reference end month </param> /// <returns> the inflation rate computation </returns> public static InflationEndMonthRateComputation of(PriceIndex index, double startIndexValue, YearMonth referenceEndMonth) { return(new InflationEndMonthRateComputation(startIndexValue, PriceIndexObservation.of(index, referenceEndMonth))); }
//------------------------------------------------------------------------- /// <summary> /// Creates an instance from an index, reference start month and reference end month. /// <para> /// The second start/end observations will be one month later than the start/end month. /// /// </para> /// </summary> /// <param name="index"> the index </param> /// <param name="referenceStartMonth"> the reference start month </param> /// <param name="referenceEndMonth"> the reference end month </param> /// <param name="weight"> the weight </param> /// <returns> the inflation rate computation </returns> public static InflationInterpolatedRateComputation of(PriceIndex index, YearMonth referenceStartMonth, YearMonth referenceEndMonth, double weight) { return(new InflationInterpolatedRateComputation(PriceIndexObservation.of(index, referenceStartMonth), PriceIndexObservation.of(index, referenceStartMonth.plusMonths(1)), PriceIndexObservation.of(index, referenceEndMonth), PriceIndexObservation.of(index, referenceEndMonth.plusMonths(1)), weight)); }
//------------------------------------------------------------------------- /// <summary> /// Creates an instance from an index, reference start month and reference end month. /// </summary> /// <param name="index"> the index </param> /// <param name="referenceStartMonth"> the reference start month </param> /// <param name="referenceEndMonth"> the reference end month </param> /// <returns> the inflation rate computation </returns> public static InflationMonthlyRateComputation of(PriceIndex index, YearMonth referenceStartMonth, YearMonth referenceEndMonth) { return(new InflationMonthlyRateComputation(PriceIndexObservation.of(index, referenceStartMonth), PriceIndexObservation.of(index, referenceEndMonth))); }