public virtual void test_rate() { SimpleRatesProvider prov = new SimpleRatesProvider(); LocalDateDoubleTimeSeries timeSeries = LocalDateDoubleTimeSeries.of(FIXING_DATE, RATE); IborIndexRates mockIbor = new TestingIborIndexRates(GBP_LIBOR_3M, FIXING_DATE, LocalDateDoubleTimeSeries.empty(), timeSeries); prov.IborRates = mockIbor; ForwardIborRateComputationFn obsFn = ForwardIborRateComputationFn.DEFAULT; assertEquals(obsFn.rate(GBP_LIBOR_3M_COMP, ACCRUAL_START_DATE, ACCRUAL_END_DATE, prov), RATE); // explain ExplainMapBuilder builder = ExplainMap.builder(); assertEquals(obsFn.explainRate(GBP_LIBOR_3M_COMP, ACCRUAL_START_DATE, ACCRUAL_END_DATE, prov, builder), RATE); ExplainMap built = builder.build(); assertEquals(built.get(ExplainKey.OBSERVATIONS).Present, true); assertEquals(built.get(ExplainKey.OBSERVATIONS).get().size(), 1); assertEquals(built.get(ExplainKey.OBSERVATIONS).get().get(0).get(ExplainKey.FIXING_DATE), FIXING_DATE); assertEquals(built.get(ExplainKey.OBSERVATIONS).get().get(0).get(ExplainKey.INDEX), GBP_LIBOR_3M); assertEquals(built.get(ExplainKey.OBSERVATIONS).get().get(0).get(ExplainKey.INDEX_VALUE), RATE); assertEquals(built.get(ExplainKey.OBSERVATIONS).get().get(0).get(ExplainKey.FROM_FIXING_SERIES), true); assertEquals(built.get(ExplainKey.OBSERVATIONS).get().get(0).get(ExplainKey.FORWARD_RATE_START_DATE), FORWARD_START_DATE); assertEquals(built.get(ExplainKey.OBSERVATIONS).get().get(0).get(ExplainKey.FORWARD_RATE_END_DATE), FORWARD_END_DATE); assertEquals(built.get(ExplainKey.COMBINED_RATE), RATE); }
public virtual void test_rateSensitivity() { IborIndexRates mockIbor = mock(typeof(IborIndexRates)); SimpleRatesProvider prov = new SimpleRatesProvider(); prov.IborRates = mockIbor; when(mockIbor.ratePointSensitivity(GBP_LIBOR_3M_COMP.Observation)).thenReturn(SENSITIVITY); ForwardIborRateComputationFn obsFn = ForwardIborRateComputationFn.DEFAULT; assertEquals(obsFn.rateSensitivity(GBP_LIBOR_3M_COMP, ACCRUAL_START_DATE, ACCRUAL_END_DATE, prov), SENSITIVITY); }