public virtual void test_presentValueSensitivity()
        {
            PointSensitivityBuilder pt1   = PRODUCT_PRICER.presentValueSensitivityRates(CMS_ONE_LEG, RATES_PROVIDER, VOLATILITIES);
            PointSensitivityBuilder pt2   = PRODUCT_PRICER.presentValueSensitivityRates(CMS_TWO_LEGS, RATES_PROVIDER, VOLATILITIES);
            PointSensitivityBuilder ptCms = CMS_LEG_PRICER.presentValueSensitivityRates(CMS_LEG, RATES_PROVIDER, VOLATILITIES);
            PointSensitivityBuilder ptPay = SWAP_LEG_PRICER.presentValueSensitivity(PAY_LEG, RATES_PROVIDER);

            assertEquals(pt1, ptCms);
            assertEquals(pt2, ptCms.combinedWith(ptPay));
        }
        public virtual void test_presentValueSensitivity()
        {
            PointSensitivities      pt1     = TRADE_PRICER.presentValueSensitivityRates(CMS_TRADE_PREMIUM, RATES_PROVIDER, VOLATILITIES);
            PointSensitivities      pt2     = TRADE_PRICER.presentValueSensitivityRates(CMS_TRADE, RATES_PROVIDER, VOLATILITIES);
            PointSensitivityBuilder ptProd1 = PRODUCT_PRICER.presentValueSensitivityRates(CMS_ONE_LEG, RATES_PROVIDER, VOLATILITIES);
            PointSensitivityBuilder ptProd2 = PRODUCT_PRICER.presentValueSensitivityRates(CMS_TWO_LEGS, RATES_PROVIDER, VOLATILITIES);
            PointSensitivityBuilder ptPrem  = PREMIUM_PRICER.presentValueSensitivity(PREMIUM, RATES_PROVIDER);

            assertEquals(pt1, ptProd1.combinedWith(ptPrem).build());
            assertEquals(pt2, ptProd2.build());
        }
Example #3
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value curve sensitivity of the CMS 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 CMS trade </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="swaptionVolatilities">  the swaption volatilities </param>
        /// <returns> the present value sensitivity </returns>
        public virtual PointSensitivities presentValueSensitivityRates(ResolvedCmsTrade trade, RatesProvider ratesProvider, SabrSwaptionVolatilities swaptionVolatilities)
        {
            PointSensitivityBuilder pvSensiCms = productPricer.presentValueSensitivityRates(trade.Product, ratesProvider, swaptionVolatilities);

            if (!trade.Premium.Present)
            {
                return(pvSensiCms.build());
            }
            PointSensitivityBuilder pvSensiPremium = paymentPricer.presentValueSensitivity(trade.Premium.get(), ratesProvider);

            return(pvSensiCms.combinedWith(pvSensiPremium).build());
        }