コード例 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_withSensitivity()
        {
            IborFutureOptionSensitivity @base    = IborFutureOptionSensitivity.of(NAME, 12d, date(2015, 8, 28), 0.98, 0.99, GBP, 32d);
            IborFutureOptionSensitivity expected = IborFutureOptionSensitivity.of(NAME, 12d, date(2015, 8, 28), 0.98, 0.99, GBP, 20d);
            IborFutureOptionSensitivity test     = @base.withSensitivity(20d);

            assertEquals(test, expected);
        }
        // ----------     present value normal vol sensitivity     ----------

        public virtual void presentvalue_normalVolSensitivity_from_env()
        {
            IborIndexRates      mockIbor = mock(typeof(IborIndexRates));
            SimpleRatesProvider prov     = new SimpleRatesProvider();

            prov.IborRates = mockIbor;
            when(mockIbor.rate(OPTION.UnderlyingFuture.IborRate.Observation)).thenReturn(RATE);

            IborFutureOptionSensitivity psProduct  = OPTION_PRODUCT_PRICER.priceSensitivityModelParamsVolatility(OPTION, prov, VOL_SIMPLE_MONEY_PRICE);
            IborFutureOptionSensitivity psExpected = psProduct.withSensitivity(psProduct.Sensitivity * OPTION_PRODUCT_PRICER.marginIndex(OPTION, 1) * OPTION_QUANTITY);
            IborFutureOptionSensitivity psComputed = OPTION_TRADE_PRICER.presentValueSensitivityModelParamsVolatility(FUTURE_OPTION_TRADE, prov, VOL_SIMPLE_MONEY_PRICE);

            assertTrue(psExpected.compareKey(psComputed) == 0);
            assertEquals(psComputed.Sensitivity, psExpected.Sensitivity, TOLERANCE_PV_DELTA);
        }