Esempio n. 1
0
        public virtual void test_priceSensitivityWithZSpread_continuous()
        {
            PointSensitivities             point    = FUTURE_PRICER.priceSensitivityWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0);
            CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point);
            CurrencyParameterSensitivities expected = FD_CAL.sensitivity(PROVIDER, (p) => CurrencyAmount.of(USD, FUTURE_PRICER.priceWithZSpread(FUTURE_PRODUCT, (p), Z_SPREAD, CONTINUOUS, 0)));

            assertTrue(computed.equalWithTolerance(expected, EPS * 10.0));
        }
        /// <summary>
        /// Calculates the present value sensitivity of the bond future trade with z-spread.
        /// <para>
        /// The present value sensitivity of the trade is the sensitivity of the present value to
        /// the underlying curves.
        /// </para>
        /// <para>
        /// The z-spread is a parallel shift applied to continuously compounded rates or periodic compounded rates
        /// of the issuer discounting curve.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="discountingProvider">  the discounting provider </param>
        /// <param name="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodPerYear">  the number of periods per year </param>
        /// <returns> the present value curve sensitivity of the trade </returns>
        public PointSensitivities presentValueSensitivityWithZSpread(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider, double zSpread, CompoundedRateType compoundedRateType, int periodPerYear)
        {
            ResolvedBondFuture product          = trade.Product;
            PointSensitivities priceSensi       = productPricer.priceSensitivityWithZSpread(product, discountingProvider, zSpread, compoundedRateType, periodPerYear);
            PointSensitivities marginIndexSensi = productPricer.marginIndexSensitivity(product, priceSensi);

            return(marginIndexSensi.multipliedBy(trade.Quantity));
        }