// interpolate the observations at the end
        private double interpolateEnd(InflationInterpolatedRateComputation computation, PriceIndexValues values)
        {
            double weight      = computation.Weight;
            double indexValue1 = values.value(computation.EndObservation);
            double indexValue2 = values.value(computation.EndSecondObservation);

            return(weight * indexValue1 + (1d - weight) * indexValue2);
        }
Пример #2
0
        //-------------------------------------------------------------------------
        public virtual double rate(InflationMonthlyRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider)
        {
            PriceIndex       index      = computation.Index;
            PriceIndexValues values     = provider.priceIndexValues(index);
            double           indexStart = values.value(computation.StartObservation);
            double           indexEnd   = values.value(computation.EndObservation);

            return(indexEnd / indexStart - 1d);
        }
Пример #3
0
        public virtual PointSensitivityBuilder rateSensitivity(InflationMonthlyRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider)
        {
            PriceIndex              index         = computation.Index;
            PriceIndexValues        values        = provider.priceIndexValues(index);
            double                  indexStart    = values.value(computation.StartObservation);
            double                  indexEnd      = values.value(computation.EndObservation);
            double                  indexStartInv = 1d / indexStart;
            PointSensitivityBuilder sensi1        = values.valuePointSensitivity(computation.StartObservation).multipliedBy(-indexEnd * indexStartInv * indexStartInv);
            PointSensitivityBuilder sensi2        = values.valuePointSensitivity(computation.EndObservation).multipliedBy(indexStartInv);

            return(sensi1.combinedWith(sensi2));
        }
Пример #4
0
        public virtual double explainRate(InflationMonthlyRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider, ExplainMapBuilder builder)
        {
            PriceIndex       index      = computation.Index;
            PriceIndexValues values     = provider.priceIndexValues(index);
            double           indexStart = values.value(computation.StartObservation);
            double           indexEnd   = values.value(computation.EndObservation);

            builder.addListEntry(ExplainKey.OBSERVATIONS, child => child.put(ExplainKey.ENTRY_TYPE, "InflationObservation").put(ExplainKey.FIXING_DATE, computation.StartObservation.FixingMonth.atEndOfMonth()).put(ExplainKey.INDEX, index).put(ExplainKey.INDEX_VALUE, indexStart));
            builder.addListEntry(ExplainKey.OBSERVATIONS, child => child.put(ExplainKey.ENTRY_TYPE, "InflationObservation").put(ExplainKey.FIXING_DATE, computation.EndObservation.FixingMonth.atEndOfMonth()).put(ExplainKey.INDEX, index).put(ExplainKey.INDEX_VALUE, indexEnd));
            double rate = this.rate(computation, startDate, endDate, provider);

            builder.put(ExplainKey.COMBINED_RATE, rate);
            return(rate);
        }
        public virtual double explainRate(InflationInterpolatedRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider, ExplainMapBuilder builder)
        {
            PriceIndexValues values = provider.priceIndexValues(computation.Index);
            double           w1     = computation.Weight;
            double           w2     = 1d - w1;

            builder.addListEntry(ExplainKey.OBSERVATIONS, child => child.put(ExplainKey.ENTRY_TYPE, "InflationObservation").put(ExplainKey.FIXING_DATE, computation.StartObservation.FixingMonth.atEndOfMonth()).put(ExplainKey.INDEX, computation.Index).put(ExplainKey.INDEX_VALUE, values.value(computation.StartObservation)).put(ExplainKey.WEIGHT, w1));
            builder.addListEntry(ExplainKey.OBSERVATIONS, child => child.put(ExplainKey.ENTRY_TYPE, "InflationObservation").put(ExplainKey.FIXING_DATE, computation.StartSecondObservation.FixingMonth.atEndOfMonth()).put(ExplainKey.INDEX, computation.Index).put(ExplainKey.INDEX_VALUE, values.value(computation.StartSecondObservation)).put(ExplainKey.WEIGHT, w2));
            builder.addListEntry(ExplainKey.OBSERVATIONS, child => child.put(ExplainKey.ENTRY_TYPE, "InflationObservation").put(ExplainKey.FIXING_DATE, computation.EndObservation.FixingMonth.atEndOfMonth()).put(ExplainKey.INDEX, computation.Index).put(ExplainKey.INDEX_VALUE, values.value(computation.EndObservation)).put(ExplainKey.WEIGHT, w1));
            builder.addListEntry(ExplainKey.OBSERVATIONS, child => child.put(ExplainKey.ENTRY_TYPE, "InflationObservation").put(ExplainKey.FIXING_DATE, computation.EndSecondObservation.FixingMonth.atEndOfMonth()).put(ExplainKey.INDEX, computation.Index).put(ExplainKey.INDEX_VALUE, values.value(computation.EndSecondObservation)).put(ExplainKey.WEIGHT, w2));
            double rate = this.rate(computation, startDate, endDate, provider);

            builder.put(ExplainKey.COMBINED_RATE, rate);
            return(rate);
        }