public virtual void test_presentValueSensitivityRatesStickyModel_stickyStrike()
        {
            SwaptionVolatilities volSabr    = SwaptionSabrRateVolatilityDataSet.getVolatilitiesUsd(VAL_DATE, false);
            double               impliedVol = SWAPTION_PRICER.impliedVolatility(SWAPTION_REC_LONG, RATE_PROVIDER, volSabr);
            SurfaceMetadata      blackMeta  = Surfaces.blackVolatilityByExpiryTenor("CST", VOLS.DayCount);
            SwaptionVolatilities volCst     = BlackSwaptionExpiryTenorVolatilities.of(VOLS.Convention, VOLS.ValuationDateTime, ConstantSurface.of(blackMeta, impliedVol));
            // To obtain a constant volatility surface which create a sticky strike sensitivity
            PointSensitivityBuilder        pointRec    = SWAPTION_PRICER.presentValueSensitivityRatesStickyStrike(SWAPTION_REC_LONG, RATE_PROVIDER, volSabr);
            CurrencyParameterSensitivities computedRec = RATE_PROVIDER.parameterSensitivity(pointRec.build());
            CurrencyParameterSensitivities expectedRec = FD_CAL.sensitivity(RATE_PROVIDER, (p) => SWAPTION_PRICER.presentValue(SWAPTION_REC_LONG, (p), volCst));

            assertTrue(computedRec.equalWithTolerance(expectedRec, NOTIONAL * FD_EPS * 100d));

            PointSensitivityBuilder        pointPay    = SWAPTION_PRICER.presentValueSensitivityRatesStickyStrike(SWAPTION_PAY_SHORT, RATE_PROVIDER, volSabr);
            CurrencyParameterSensitivities computedPay = RATE_PROVIDER.parameterSensitivity(pointPay.build());
            CurrencyParameterSensitivities expectedPay = FD_CAL.sensitivity(RATE_PROVIDER, (p) => SWAPTION_PRICER.presentValue(SWAPTION_PAY_SHORT, (p), volCst));

            assertTrue(computedPay.equalWithTolerance(expectedPay, NOTIONAL * FD_EPS * 100d));
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value sensitivity of the swaption trade to the rate curves.
        /// <para>
        /// The present value sensitivity is computed in a "sticky strike" style, i.e. the sensitivity to the
        /// curve nodes with the volatility at the swaption strike unchanged. This sensitivity does not include a potential
        /// change of volatility due to the implicit change of forward rate or moneyness.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the swaption trade </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="swaptionVolatilities">  the volatilities </param>
        /// <returns> the point sensitivity to the rate curves </returns>
        public virtual PointSensitivities presentValueSensitivityRatesStickyStrike(ResolvedSwaptionTrade trade, RatesProvider ratesProvider, SabrSwaptionVolatilities swaptionVolatilities)
        {
            // product
            ResolvedSwaption        product   = trade.Product;
            PointSensitivityBuilder pointSens = isCash(product) ? cashParYieldPricer.presentValueSensitivityRatesStickyStrike(product, ratesProvider, swaptionVolatilities) : physicalPricer.presentValueSensitivityRatesStickyStrike(product, ratesProvider, swaptionVolatilities);
            // premium
            Payment premium = trade.Premium;
            PointSensitivityBuilder pvcsPremium = paymentPricer.presentValueSensitivity(premium, ratesProvider);

            // total
            return(pointSens.combinedWith(pvcsPremium).build());
        }