Beispiel #1
0
        public virtual void test_rate_FixedRateComputation()
        {
            FixedRateComputation         ro   = FixedRateComputation.of(0.0123d);
            DispatchingRateComputationFn test = DispatchingRateComputationFn.DEFAULT;

            assertEquals(test.rate(ro, ACCRUAL_START_DATE, ACCRUAL_END_DATE, MOCK_PROV), 0.0123d, 0d);
        }
Beispiel #2
0
        public virtual void test_rate_unknownType()
        {
            RateComputation mockComputation   = mock(typeof(RateComputation));
            DispatchingRateComputationFn test = DispatchingRateComputationFn.DEFAULT;

            assertThrowsIllegalArg(() => test.rate(mockComputation, ACCRUAL_START_DATE, ACCRUAL_END_DATE, MOCK_PROV));
        }
Beispiel #3
0
        public virtual void test_rate_IborRateComputation()
        {
            RateComputationFn <IborRateComputation> mockIbor = mock(typeof(RateComputationFn));
            IborRateComputation ro = IborRateComputation.of(GBP_LIBOR_3M, FIXING_DATE, REF_DATA);

            when(mockIbor.rate(ro, ACCRUAL_START_DATE, ACCRUAL_END_DATE, MOCK_PROV)).thenReturn(0.0123d);
            DispatchingRateComputationFn test = new DispatchingRateComputationFn(mockIbor, MOCK_IBOR_INT_EMPTY, MOCK_IBOR_AVE_EMPTY, MOCK_ON_CPD_EMPTY, MOCK_ON_AVE_EMPTY, MOCK_ON_AVE_DLY_EMPTY, MOCK_INF_MON_EMPTY, MOCK_INF_INT_EMPTY, MOCK_INF_BOND_MON_EMPTY, MOCK_INF_BOND_INT_EMPTY);

            assertEquals(test.rate(ro, ACCRUAL_START_DATE, ACCRUAL_END_DATE, MOCK_PROV), 0.0123d, 0d);
        }
Beispiel #4
0
        public virtual void test_rate_InflationEndInterpolatedRateComputation()
        {
            double mockRate = 223.0d;
            RateComputationFn <InflationEndInterpolatedRateComputation> mockInfInt = mock(typeof(RateComputationFn));
            InflationEndInterpolatedRateComputation ro = InflationEndInterpolatedRateComputation.of(US_CPI_U, 234d, ACCRUAL_END_MONTH, 0.3);

            when(mockInfInt.rate(ro, ACCRUAL_START_DATE, ACCRUAL_END_DATE, MOCK_PROV)).thenReturn(mockRate);
            DispatchingRateComputationFn test = new DispatchingRateComputationFn(MOCK_IBOR_EMPTY, MOCK_IBOR_INT_EMPTY, MOCK_IBOR_AVE_EMPTY, MOCK_ON_CPD_EMPTY, MOCK_ON_AVE_EMPTY, MOCK_ON_AVE_DLY_EMPTY, MOCK_INF_MON_EMPTY, MOCK_INF_INT_EMPTY, MOCK_INF_BOND_MON_EMPTY, mockInfInt);

            assertEquals(test.rate(ro, ACCRUAL_START_DATE, ACCRUAL_END_DATE, MOCK_PROV), mockRate, TOLERANCE_RATE);
        }
Beispiel #5
0
        public virtual void test_rate_OvernightAveragedDailyRateComputation()
        {
            double mockRate = 0.0123d;
            RateComputationFn <OvernightAveragedDailyRateComputation> mockOnAve = mock(typeof(RateComputationFn));
            OvernightAveragedDailyRateComputation ro = OvernightAveragedDailyRateComputation.of(USD_FED_FUND, ACCRUAL_START_DATE, ACCRUAL_END_DATE, REF_DATA);

            when(mockOnAve.rate(ro, ACCRUAL_START_DATE, ACCRUAL_END_DATE, MOCK_PROV)).thenReturn(mockRate);
            DispatchingRateComputationFn test = new DispatchingRateComputationFn(MOCK_IBOR_EMPTY, MOCK_IBOR_INT_EMPTY, MOCK_IBOR_AVE_EMPTY, MOCK_ON_CPD_EMPTY, MOCK_ON_AVE_EMPTY, mockOnAve, MOCK_INF_MON_EMPTY, MOCK_INF_INT_EMPTY, MOCK_INF_BOND_MON_EMPTY, MOCK_INF_BOND_INT_EMPTY);

            assertEquals(test.rate(ro, ACCRUAL_START_DATE, ACCRUAL_END_DATE, MOCK_PROV), mockRate, TOLERANCE_RATE);
        }
Beispiel #6
0
        public virtual void test_rate_IborAverageRateComputation()
        {
            double mockRate = 0.0123d;
            RateComputationFn <IborAveragedRateComputation> mockIborAve = mock(typeof(RateComputationFn));

            LocalDate[] fixingDates            = new LocalDate[] { date(2014, 6, 30), date(2014, 7, 7), date(2014, 7, 14), date(2014, 7, 21) };
            double[]    weights                = new double[] { 0.10d, 0.20d, 0.30d, 0.40d };
            IList <IborAveragedFixing> fixings = new List <IborAveragedFixing>();

            for (int i = 0; i < fixingDates.Length; i++)
            {
                IborAveragedFixing fixing = IborAveragedFixing.builder().observation(IborIndexObservation.of(GBP_LIBOR_3M, fixingDates[i], REF_DATA)).weight(weights[i]).build();
                fixings.Add(fixing);
            }
            IborAveragedRateComputation ro = IborAveragedRateComputation.of(fixings);

            when(mockIborAve.rate(ro, ACCRUAL_START_DATE, ACCRUAL_END_DATE, MOCK_PROV)).thenReturn(mockRate);
            DispatchingRateComputationFn test = new DispatchingRateComputationFn(MOCK_IBOR_EMPTY, MOCK_IBOR_INT_EMPTY, mockIborAve, MOCK_ON_CPD_EMPTY, MOCK_ON_AVE_EMPTY, MOCK_ON_AVE_DLY_EMPTY, MOCK_INF_MON_EMPTY, MOCK_INF_INT_EMPTY, MOCK_INF_BOND_MON_EMPTY, MOCK_INF_BOND_INT_EMPTY);

            assertEquals(test.rate(ro, ACCRUAL_START_DATE, ACCRUAL_END_DATE, MOCK_PROV), mockRate, 0d);
        }