Exemplo n.º 1
0
        public virtual PointSensitivityBuilder rateSensitivity(InflationEndInterpolatedRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider)
        {
            PriceIndexValues        values = provider.priceIndexValues(computation.Index);
            PointSensitivityBuilder sensi  = endSensitivity(computation, values);

            return(sensi.multipliedBy(1d / computation.StartIndexValue));
        }
        //-------------------------------------------------------------------------
        public virtual double rate(InflationInterpolatedRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider)
        {
            PriceIndexValues values     = provider.priceIndexValues(computation.Index);
            double           indexStart = interpolateStart(computation, values);
            double           indexEnd   = interpolateEnd(computation, values);

            return(indexEnd / indexStart - 1d);
        }
        //-------------------------------------------------------------------------
        public virtual double rate(InflationEndMonthRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider)
        {
            PriceIndexValues values     = provider.priceIndexValues(computation.Index);
            double           indexStart = computation.StartIndexValue;
            double           indexEnd   = values.value(computation.EndObservation);

            return(indexEnd / indexStart - 1);
        }
        public virtual PointSensitivityBuilder rateSensitivity(InflationInterpolatedRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider)
        {
            PriceIndexValues        values        = provider.priceIndexValues(computation.Index);
            double                  indexStart    = interpolateStart(computation, values);
            double                  indexEnd      = interpolateEnd(computation, values);
            double                  indexStartInv = 1d / indexStart;
            PointSensitivityBuilder sensi1        = startSensitivity(computation, values).multipliedBy(-indexEnd * indexStartInv * indexStartInv);
            PointSensitivityBuilder sensi2        = endSensitivity(computation, values).multipliedBy(indexStartInv);

            return(sensi1.combinedWith(sensi2));
        }
        public virtual double explainRate(InflationEndMonthRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider, ExplainMapBuilder builder)
        {
            PriceIndexValues values   = provider.priceIndexValues(computation.Index);
            double           indexEnd = values.value(computation.EndObservation);

            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, indexEnd));
            double rate = this.rate(computation, startDate, endDate, provider);

            builder.put(ExplainKey.COMBINED_RATE, rate);
            return(rate);
        }
Exemplo n.º 6
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));
        }
        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);
        }
        // interpolate the observations at the end
        private PointSensitivityBuilder endSensitivity(InflationInterpolatedRateComputation computation, PriceIndexValues values)
        {
            double weight = computation.Weight;
            PointSensitivityBuilder sensi1 = values.valuePointSensitivity(computation.EndObservation).multipliedBy(weight);
            PointSensitivityBuilder sensi2 = values.valuePointSensitivity(computation.EndSecondObservation).multipliedBy(1d - weight);

            return(sensi1.combinedWith(sensi2));
        }
        // 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);
        }
        public virtual PointSensitivityBuilder rateSensitivity(InflationEndMonthRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider)
        {
            PriceIndexValues values = provider.priceIndexValues(computation.Index);

            return(values.valuePointSensitivity(computation.EndObservation).multipliedBy(1d / computation.StartIndexValue));
        }