示例#1
0
        //-------------------------------------------------------------------------
        public virtual void test_marginIndexSensitivity()
        {
            double             notional         = FUTURE.Notional;
            double             accrualFactor    = FUTURE.AccrualFactor;
            PointSensitivities sensiExpected    = PointSensitivities.of(IborRateSensitivity.of(FUTURE.IborRate.Observation, -notional * accrualFactor));
            PointSensitivities priceSensitivity = PRICER.priceSensitivity(FUTURE, new MockRatesProvider());
            PointSensitivities sensiComputed    = PRICER.marginIndexSensitivity(FUTURE, priceSensitivity).normalized();

            assertTrue(sensiComputed.equalWithTolerance(sensiExpected, 1e-5));
        }
示例#2
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValueSensitivity()
        {
            IborIndexRates      mockIbor = mock(typeof(IborIndexRates));
            SimpleRatesProvider prov     = new SimpleRatesProvider();

            prov.IborRates = mockIbor;

            PointSensitivities sensiPrice = PRICER_PRODUCT.priceSensitivity(FUTURE, prov);
            PointSensitivities sensiPresentValueExpected = sensiPrice.multipliedBy(FUTURE.Notional * FUTURE.AccrualFactor * FUTURE_TRADE.Quantity);
            PointSensitivities sensiPresentValueComputed = PRICER_TRADE.presentValueSensitivity(FUTURE_TRADE, prov);

            assertTrue(sensiPresentValueComputed.equalWithTolerance(sensiPresentValueExpected, TOLERANCE_PV_DELTA));
        }
        /// <summary>
        /// Calculates the price sensitivity of the Ibor future option product
        /// based on the price of the underlying future.
        /// <para>
        /// The price sensitivity of the product is the sensitivity of the price to the underlying curves.
        /// The volatility is unchanged for a fixed strike in the sensitivity computation, hence the "StickyStrike" name.
        ///
        /// </para>
        /// </summary>
        /// <param name="futureOption">  the option product </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="volatilities">  the volatilities </param>
        /// <param name="futurePrice">  the price of the underlying future, in decimal form </param>
        /// <returns> the price curve sensitivity of the product </returns>
        public virtual PointSensitivities priceSensitivityRatesStickyStrike(ResolvedIborFutureOption futureOption, RatesProvider ratesProvider, NormalIborFutureOptionVolatilities volatilities, double futurePrice)
        {
            double             delta = deltaStickyStrike(futureOption, ratesProvider, volatilities, futurePrice);
            PointSensitivities futurePriceSensitivity = futurePricer.priceSensitivity(futureOption.UnderlyingFuture, ratesProvider);

            return(futurePriceSensitivity.multipliedBy(delta));
        }
        // ----------     priceSensitivity     ----------
        public virtual void priceSensitivityStickyStrike_from_future_price()
        {
            IborIndexRates      mockIbor = mock(typeof(IborIndexRates));
            SimpleRatesProvider prov     = new SimpleRatesProvider();

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

            double             futurePrice            = 0.9875;
            PointSensitivities futurePriceSensitivity = FUTURE_PRICER.priceSensitivity(OPTION.UnderlyingFuture, prov);
            double             delta = OPTION_PRICER.deltaStickyStrike(OPTION, prov, VOL_SIMPLE_MONEY_PRICE, futurePrice);
            PointSensitivities optionPriceSensitivityExpected = futurePriceSensitivity.multipliedBy(delta);
            PointSensitivities optionPriceSensitivityComputed = OPTION_PRICER.priceSensitivityRatesStickyStrike(OPTION, prov, VOL_SIMPLE_MONEY_PRICE, futurePrice);

            assertTrue(optionPriceSensitivityExpected.equalWithTolerance(optionPriceSensitivityComputed, TOLERANCE_PRICE_DELTA));
        }
示例#5
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates the price sensitivity of the Ibor future product.
 /// <para>
 /// The price sensitivity of the product is the sensitivity of the price to the underlying curves.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesProvider">  the rates provider </param>
 /// <returns> the price curve sensitivity of the product </returns>
 public virtual PointSensitivities priceSensitivity(ResolvedIborFutureTrade trade, RatesProvider ratesProvider)
 {
     return(productPricer.priceSensitivity(trade.Product, ratesProvider));
 }