//------------------------------------------------------------------------- /// <summary> /// Calculates the present value sensitivity of the Ibor future trade. /// <para> /// The present value sensitivity of the trade is the sensitivity of the present value to /// the underlying curves. /// /// </para> /// </summary> /// <param name="trade"> the trade </param> /// <param name="ratesProvider"> the rates provider </param> /// <returns> the present value curve sensitivity of the trade </returns> public virtual PointSensitivities presentValueSensitivity(ResolvedIborFutureTrade trade, RatesProvider ratesProvider) { ResolvedIborFuture product = trade.Product; PointSensitivities priceSensi = productPricer.priceSensitivity(product, ratesProvider); PointSensitivities marginIndexSensi = productPricer.marginIndexSensitivity(product, priceSensi); return(marginIndexSensi.multipliedBy(trade.Quantity)); }
//------------------------------------------------------------------------- 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)); }