public void test_collectIndices() { OvernightAveragedDailyRateComputation test = OvernightAveragedDailyRateComputation.of(USD_FED_FUND, date(2016, 2, 24), date(2016, 3, 24), REF_DATA); ImmutableSet.Builder<Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(USD_FED_FUND)); }
return OvernightAveragedRateComputation.of(index, startDate, endDate, rateCutOffDays, referenceData); case AVERAGED_DAILY: return OvernightAveragedDailyRateComputation.of(index, startDate, endDate, referenceData); default: throw new IllegalArgumentException(Messages.format("unsupported Overnight accrual method, {}", accrualMethod));
public void test_rate_OvernightAveragedDailyRateComputation() { double mockRate = 0.0123d; RateComputationFn<OvernightAveragedDailyRateComputation> mockOnAve = mock(RateComputationFn.class); 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_BRL_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); }
public void test_serialization() { OvernightAveragedDailyRateComputation test = OvernightAveragedDailyRateComputation.of(USD_FED_FUND, date(2016, 2, 24), date(2016, 3, 24), REF_DATA); assertSerialization(test); }
public void test_of_badDateOrder() { assertThrowsIllegalArg(() -> OvernightAveragedDailyRateComputation.of( USD_FED_FUND, date(2016, 2, 24), date(2016, 2, 24), REF_DATA)); assertThrowsIllegalArg(() -> OvernightAveragedDailyRateComputation.of( USD_FED_FUND, date(2016, 2, 25), date(2016, 2, 24), REF_DATA)); }
public void coverage() { OvernightAveragedDailyRateComputation test = OvernightAveragedDailyRateComputation.of(USD_FED_FUND, date(2016, 2, 24), date(2016, 3, 24), REF_DATA); coverImmutableBean(test); OvernightAveragedDailyRateComputation test2 = OvernightAveragedDailyRateComputation.of(GBP_SONIA, date(2014, 6, 3), date(2014, 7, 3), REF_DATA); coverBeanEquals(test, test2); }
public void test_after_regression() { LocalDate startDate = date(2018, 3, 1); LocalDate endDate = date(2018, 3, 31); OvernightAveragedDailyRateComputation cmp = OvernightAveragedDailyRateComputation.of( USD_FED_FUND, startDate, endDate, REF_DATA); ImmutableRatesProvider rates = getRatesProvider(date(2018, 4, 28)); double computed = FUNCTION.rate(cmp, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, rates); double expected = 0.0150612903225806; assertEquals(computed, expected, TOL); assertEquals(FUNCTION.rateSensitivity(cmp, startDate, endDate, rates), PointSensitivityBuilder.none()); }
public void test_of_noRateCutoff() { OvernightAveragedDailyRateComputation test = OvernightAveragedDailyRateComputation.of( USD_FED_FUND, date(2016, 2, 24), date(2016, 3, 24), REF_DATA); assertEquals(test.getStartDate(), date(2016, 2, 24)); assertEquals(test.getEndDate(), date(2016, 3, 24)); assertEquals(test.getIndex(), USD_FED_FUND); assertEquals(test.getFixingCalendar(), USD_FED_FUND.getFixingCalendar().resolve(REF_DATA)); }
public void test_observeOn() { OvernightAveragedDailyRateComputation test = OvernightAveragedDailyRateComputation.of(USD_FED_FUND, date(2016, 2, 24), date(2016, 3, 24), REF_DATA); assertEquals(test.observeOn(date(2016, 2, 24)), OvernightIndexObservation.of(USD_FED_FUND, date(2016, 2, 24), REF_DATA)); }
public void test_calculate() { OvernightAveragedDailyRateComputation test = OvernightAveragedDailyRateComputation.of(USD_FED_FUND, date(2016, 2, 24), date(2016, 3, 24), REF_DATA); assertEquals( test.calculateEffectiveFromFixing(date(2016, 2, 24)), USD_FED_FUND.calculateEffectiveFromFixing(date(2016, 2, 24), REF_DATA)); assertEquals( test.calculateFixingFromEffective(date(2016, 2, 24)), USD_FED_FUND.calculateFixingFromEffective(date(2016, 2, 24), REF_DATA)); assertEquals( test.calculatePublicationFromFixing(date(2016, 2, 24)), USD_FED_FUND.calculatePublicationFromFixing(date(2016, 2, 24), REF_DATA)); assertEquals( test.calculateMaturityFromFixing(date(2016, 2, 24)), USD_FED_FUND.calculateMaturityFromFixing(date(2016, 2, 24), REF_DATA)); assertEquals( test.calculateMaturityFromEffective(date(2016, 2, 24)), USD_FED_FUND.calculateMaturityFromEffective(date(2016, 2, 24), REF_DATA)); }
public void test_before() { LocalDate startDate = date(2018, 2, 1); LocalDate endDate = date(2018, 2, 28); OvernightAveragedDailyRateComputation cmp = OvernightAveragedDailyRateComputation.of( USD_FED_FUND, startDate, endDate, REF_DATA); ImmutableRatesProvider rates = getRatesProvider(date(2018, 1, 24));
public void test_between() { LocalDate startDate = date(2018, 3, 1); LocalDate endDate = date(2018, 3, 31); OvernightAveragedDailyRateComputation cmp = OvernightAveragedDailyRateComputation.of( USD_FED_FUND, startDate, endDate, REF_DATA); ImmutableRatesProvider rates = getRatesProvider(date(2018, 3, 14));
OvernightAveragedRateComputation.of(USD_FED_FUND, ACCRUAL_START_DATE, ACCRUAL_END_DATE, 0, REF_DATA); OvernightAveragedDailyRateComputation onAvgDly = OvernightAveragedDailyRateComputation.of(USD_FED_FUND, ACCRUAL_START_DATE, ACCRUAL_END_DATE, REF_DATA); InflationMonthlyRateComputation inflationMonthly = InflationMonthlyRateComputation.of(US_CPI_U, ACCRUAL_START_MONTH, ACCRUAL_END_MONTH);