Пример #1
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value of the CMS product.
        /// <para>
        /// The present value of the product is the value on the valuation date.
        /// </para>
        /// <para>
        /// CMS leg and pay leg are typically in the same currency. Thus the present value is expressed as a
        /// single currency amount in most cases.
        ///
        /// </para>
        /// </summary>
        /// <param name="cms">  the CMS product </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="swaptionVolatilities">  the swaption volatilities </param>
        /// <returns> the present value </returns>
        public virtual MultiCurrencyAmount presentValue(ResolvedCms cms, RatesProvider ratesProvider, SabrSwaptionVolatilities swaptionVolatilities)
        {
            CurrencyAmount pvCmsLeg = cmsLegPricer.presentValue(cms.CmsLeg, ratesProvider, swaptionVolatilities);

            if (!cms.PayLeg.Present)
            {
                return(MultiCurrencyAmount.of(pvCmsLeg));
            }
            CurrencyAmount pvPayLeg = payLegPricer.presentValue(cms.PayLeg.get(), ratesProvider);

            return(MultiCurrencyAmount.of(pvCmsLeg).plus(pvPayLeg));
        }
Пример #2
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            CurrencyAmount    computed = LEG_PRICER.presentValue(CAP_LEG, RATES_PROVIDER, VOLATILITIES);
            double            expected = 0d;
            IList <CmsPeriod> cms      = CAP_LEG.CmsPeriods;
            int size = cms.Count;

            for (int i = 0; i < size; ++i)
            {
                expected += PERIOD_PRICER.presentValue(cms[i], RATES_PROVIDER, VOLATILITIES).Amount;
            }
            assertEquals(computed.Currency, EUR);
            assertEquals(computed.Amount, expected, NOTIONAL_VALUE_0 * TOL);
        }
        public virtual void test_presentValue()
        {
            MultiCurrencyAmount pv1   = PRODUCT_PRICER.presentValue(CMS_ONE_LEG, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount pv2   = PRODUCT_PRICER.presentValue(CMS_TWO_LEGS, RATES_PROVIDER, VOLATILITIES);
            CurrencyAmount      pvCms = CMS_LEG_PRICER.presentValue(CMS_LEG, RATES_PROVIDER, VOLATILITIES);
            CurrencyAmount      pvPay = SWAP_LEG_PRICER.presentValue(PAY_LEG, RATES_PROVIDER);

            assertEquals(pv1, MultiCurrencyAmount.of(pvCms));
            assertEquals(pv2, MultiCurrencyAmount.of(pvCms).plus(pvPay));
        }