public virtual void test_forecastValue_unknownType() { SwapPaymentEvent mockPaymentEvent = mock(typeof(SwapPaymentEvent)); DispatchingSwapPaymentEventPricer test = DispatchingSwapPaymentEventPricer.DEFAULT; assertThrowsIllegalArg(() => test.forecastValue(mockPaymentEvent, MOCK_PROV)); }
//------------------------------------------------------------------------- public virtual void test_presentValueSensitivity_unknownType() { SwapPaymentEvent mockPaymentEvent = mock(typeof(SwapPaymentEvent)); DispatchingSwapPaymentEventPricer test = DispatchingSwapPaymentEventPricer.DEFAULT; assertThrowsIllegalArg(() => test.presentValueSensitivity(mockPaymentEvent, MOCK_PROV)); }
public virtual void test_currencyExposure_unknownType() { SwapPaymentEvent mockPaymentEvent = mock(typeof(SwapPaymentEvent)); DispatchingSwapPaymentEventPricer test = DispatchingSwapPaymentEventPricer.DEFAULT; assertThrowsIllegalArg(() => test.currencyExposure(mockPaymentEvent, MOCK_PROV)); }
//------------------------------------------------------------------------- public virtual void test_cashFlowEquivalentAndSensitivity() { ResolvedSwap swap = ResolvedSwap.of(IBOR_LEG, FIXED_LEG); ImmutableMap <Payment, PointSensitivityBuilder> computedFull = CashFlowEquivalentCalculator.cashFlowEquivalentAndSensitivitySwap(swap, PROVIDER); ImmutableList <Payment> keyComputedFull = computedFull.Keys.asList(); ImmutableList <PointSensitivityBuilder> valueComputedFull = computedFull.values().asList(); ImmutableMap <Payment, PointSensitivityBuilder> computedIborLeg = CashFlowEquivalentCalculator.cashFlowEquivalentAndSensitivityIborLeg(IBOR_LEG, PROVIDER); ImmutableMap <Payment, PointSensitivityBuilder> computedFixedLeg = CashFlowEquivalentCalculator.cashFlowEquivalentAndSensitivityFixedLeg(FIXED_LEG, PROVIDER); assertEquals(computedFixedLeg.Keys.asList(), keyComputedFull.subList(0, 2)); assertEquals(computedIborLeg.Keys.asList(), keyComputedFull.subList(2, 6)); assertEquals(computedFixedLeg.values().asList(), valueComputedFull.subList(0, 2)); assertEquals(computedIborLeg.values().asList(), valueComputedFull.subList(2, 6)); double eps = 1.0e-7; RatesFiniteDifferenceSensitivityCalculator calc = new RatesFiniteDifferenceSensitivityCalculator(eps); int size = keyComputedFull.size(); for (int i = 0; i < size; ++i) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int index = i; int index = i; CurrencyParameterSensitivities expected = calc.sensitivity(PROVIDER, p => ((NotionalExchange)CashFlowEquivalentCalculator.cashFlowEquivalentSwap(swap, p).PaymentEvents.get(index)).PaymentAmount); SwapPaymentEvent @event = CashFlowEquivalentCalculator.cashFlowEquivalentSwap(swap, PROVIDER).PaymentEvents.get(index); PointSensitivityBuilder point = computedFull.get(((NotionalExchange)@event).Payment); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point.build()); assertTrue(computed.equalWithTolerance(expected, eps * NOTIONAL)); } }