public virtual void test_presentValueSensitivityWithZSpread_continuous()
        {
            PointSensitivityBuilder        point    = PRICER.presentValueSensitivityWithZSpread(PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0);
            CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point.build());
            CurrencyParameterSensitivities expected = FD_CAL.sensitivity(PROVIDER, p => PRICER.presentValueWithZSpread(PRODUCT, p, Z_SPREAD, CONTINUOUS, 0));

            assertTrue(computed.equalWithTolerance(expected, 20d * NOTIONAL * EPS));
        }
Пример #2
0
        /// <summary>
        /// Calculates the present value sensitivity of the fixed coupon bond 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 discounting curve.
        /// </para>
        /// <para>
        /// Coupon payments of the underlying product are considered based on the settlement date of the trade.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="provider">  the discounting provider </param>
        /// <param name="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodsPerYear">  the number of periods per year </param>
        /// <returns> the present value curve sensitivity of the trade </returns>
        public virtual PointSensitivities presentValueSensitivityWithZSpread(ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            LocalDate settlementDate             = this.settlementDate(trade, provider.ValuationDate);
            PointSensitivityBuilder sensiProduct = productPricer.presentValueSensitivityWithZSpread(trade.Product, provider, zSpread, compoundedRateType, periodsPerYear, settlementDate);

            return(presentValueSensitivityFromProductPresentValueSensitivity(trade, provider, sensiProduct).build());
        }