Пример #1
0
        //-------------------------------------------------------------------------
        public virtual void test_createRateComputation_Monthly()
        {
            InflationRateCalculation         test = InflationRateCalculation.builder().index(GB_HICP).lag(Period.ofMonths(3)).indexCalculationMethod(MONTHLY).firstIndexValue(START_INDEX).build();
            InflationEndMonthRateComputation obs1 = InflationEndMonthRateComputation.of(GB_HICP, START_INDEX, YearMonth.from(DATE_2015_02_05).minusMonths(3));
            InflationEndMonthRateComputation obs2 = InflationEndMonthRateComputation.of(GB_HICP, START_INDEX, YearMonth.from(DATE_2015_03_07).minusMonths(3));
            InflationEndMonthRateComputation obs3 = InflationEndMonthRateComputation.of(GB_HICP, START_INDEX, YearMonth.from(DATE_2015_04_05).minusMonths(3));

            assertEquals(test.createRateComputation(DATE_2015_02_05), obs1);
            assertEquals(test.createRateComputation(DATE_2015_03_07), obs2);
            assertEquals(test.createRateComputation(DATE_2015_04_05), obs3);
        }
Пример #2
0
        public virtual void test_createRateComputation_Interpolated()
        {
            InflationRateCalculation test = InflationRateCalculation.builder().index(CH_CPI).lag(Period.ofMonths(3)).indexCalculationMethod(INTERPOLATED).firstIndexValue(START_INDEX).build();
            double weight1 = 1.0 - 4.0 / 28.0;
            double weight2 = 1.0 - 6.0 / 31.0;
            double weight3 = 1.0 - 4.0 / 30.0;
            InflationEndInterpolatedRateComputation obs1 = InflationEndInterpolatedRateComputation.of(CH_CPI, START_INDEX, YearMonth.from(DATE_2015_02_05).minusMonths(3), weight1);
            InflationEndInterpolatedRateComputation obs2 = InflationEndInterpolatedRateComputation.of(CH_CPI, START_INDEX, YearMonth.from(DATE_2015_03_07).minusMonths(3), weight2);
            InflationEndInterpolatedRateComputation obs3 = InflationEndInterpolatedRateComputation.of(CH_CPI, START_INDEX, YearMonth.from(DATE_2015_04_05).minusMonths(3), weight3);

            assertEquals(test.createRateComputation(DATE_2015_02_05), obs1);
            assertEquals(test.createRateComputation(DATE_2015_03_07), obs2);
            assertEquals(test.createRateComputation(DATE_2015_04_05), obs3);
        }
Пример #3
0
        public virtual void test_createRateComputation_InterpolatedJapan()
        {
            LocalDate date1 = LocalDate.of(2013, 3, 9);
            LocalDate date2 = LocalDate.of(2013, 3, 10);
            LocalDate date3 = LocalDate.of(2013, 3, 11);
            InflationRateCalculation test = InflationRateCalculation.builder().index(JP_CPI_EXF).lag(Period.ofMonths(3)).indexCalculationMethod(INTERPOLATED_JAPAN).firstIndexValue(START_INDEX).build();
            double weight1 = 1.0 - (9.0 + 28.0 - 10.0) / 28.0;
            double weight2 = 1.0;
            double weight3 = 1.0 - 1.0 / 31.0;
            InflationEndInterpolatedRateComputation obs1 = InflationEndInterpolatedRateComputation.of(JP_CPI_EXF, START_INDEX, YearMonth.from(date1).minusMonths(4), weight1);
            InflationEndInterpolatedRateComputation obs2 = InflationEndInterpolatedRateComputation.of(JP_CPI_EXF, START_INDEX, YearMonth.from(date2).minusMonths(3), weight2);
            InflationEndInterpolatedRateComputation obs3 = InflationEndInterpolatedRateComputation.of(JP_CPI_EXF, START_INDEX, YearMonth.from(date3).minusMonths(3), weight3);

            assertEquals(test.createRateComputation(date1), obs1);
            assertEquals(test.createRateComputation(date2), obs2);
            assertEquals(test.createRateComputation(date3), obs3);
        }
Пример #4
0
        public virtual void test_createRateComputation_noFirstIndexValue()
        {
            InflationRateCalculation test = InflationRateCalculation.builder().index(CH_CPI).lag(Period.ofMonths(3)).indexCalculationMethod(INTERPOLATED).build();

            assertThrows(() => test.createRateComputation(DATE_2015_04_05), typeof(System.InvalidOperationException));
        }