コード例 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_priceIndexValues()
        {
            LocalDateDoubleTimeSeries ts   = LocalDateDoubleTimeSeries.of(VAL_DATE, 0.62d);
            ImmutableRatesProvider    test = ImmutableRatesProvider.builder(VAL_DATE).priceIndexCurve(GB_RPI, GBPRI_CURVE).timeSeries(GB_RPI, ts).build();

            assertEquals(test.priceIndexValues(GB_RPI).Index, GB_RPI);
            assertEquals(test.priceIndexValues(GB_RPI).Fixings, ts);
            assertEquals(test.PriceIndices, ImmutableSet.of(GB_RPI));
            assertEquals(test.TimeSeriesIndices, ImmutableSet.of(GB_RPI));
        }
        public virtual void merge_content_2()
        {
            ImmutableRatesProvider test1  = ImmutableRatesProvider.builder(VAL_DATE).discountCurve(GBP, DISCOUNT_CURVE_GBP).timeSeries(GBP_USD_WM, TS).build();
            ImmutableRatesProvider test2  = ImmutableRatesProvider.builder(VAL_DATE).discountCurve(USD, DISCOUNT_CURVE_USD).iborIndexCurve(USD_LIBOR_3M, USD_LIBOR_CURVE).overnightIndexCurve(USD_FED_FUND, FED_FUND_CURVE).priceIndexCurve(GB_RPI, GBPRI_CURVE).timeSeries(GB_RPI, TS).build();
            ImmutableRatesProvider merged = ImmutableRatesProvider.combined(FX_MATRIX, test1, test2);

            assertEquals(merged.ValuationDate, VAL_DATE);
            assertEquals(merged.discountFactors(USD), DiscountFactors.of(USD, VAL_DATE, DISCOUNT_CURVE_USD));
            assertEquals(merged.discountFactors(GBP), DiscountFactors.of(GBP, VAL_DATE, DISCOUNT_CURVE_GBP));
            assertEquals(merged.iborIndexRates(USD_LIBOR_3M), IborIndexRates.of(USD_LIBOR_3M, VAL_DATE, USD_LIBOR_CURVE));
            assertEquals(merged.overnightIndexRates(USD_FED_FUND), OvernightIndexRates.of(USD_FED_FUND, VAL_DATE, FED_FUND_CURVE));
            assertEquals(merged.priceIndexValues(GB_RPI), PriceIndexValues.of(GB_RPI, VAL_DATE, GBPRI_CURVE, TS));
            assertEquals(merged.timeSeries(GBP_USD_WM), TS);
            assertEquals(merged.FxRateProvider, FX_MATRIX);
        }
        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));
        }
コード例 #4
0
        public virtual void test_priceIndexValues_notKnown()
        {
            ImmutableRatesProvider test = ImmutableRatesProvider.builder(VAL_DATE).build();

            assertThrowsIllegalArg(() => test.priceIndexValues(GB_RPI));
        }