public virtual void test_currencyExposure()
        {
            MultiCurrencyAmount     computed1 = PRODUCT_PRICER.currencyExposure(CMS_ONE_LEG, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount     computed2 = PRODUCT_PRICER.currencyExposure(CMS_TWO_LEGS, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount     pv1       = PRODUCT_PRICER.presentValue(CMS_ONE_LEG, RATES_PROVIDER, VOLATILITIES);
            PointSensitivityBuilder pt1       = PRODUCT_PRICER.presentValueSensitivityRates(CMS_ONE_LEG, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount     expected1 = RATES_PROVIDER.currencyExposure(pt1.build()).plus(pv1);
            MultiCurrencyAmount     pv2       = PRODUCT_PRICER.presentValue(CMS_TWO_LEGS, RATES_PROVIDER, VOLATILITIES);
            PointSensitivityBuilder pt2       = PRODUCT_PRICER.presentValueSensitivityRates(CMS_TWO_LEGS, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount     expected2 = RATES_PROVIDER.currencyExposure(pt2.build()).plus(pv2);

            assertEquals(computed1.getAmount(EUR).Amount, expected1.getAmount(EUR).Amount, NOTIONAL_VALUE * TOL);
            assertEquals(computed2.getAmount(EUR).Amount, expected2.getAmount(EUR).Amount, NOTIONAL_VALUE * TOL);
        }
コード例 #2
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the currency exposure of the trade.
        /// </summary>
        /// <param name="trade">  the CMS trade </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="swaptionVolatilities">  the swaption volatilities </param>
        /// <returns> the currency exposure </returns>
        public virtual MultiCurrencyAmount currencyExposure(ResolvedCmsTrade trade, RatesProvider ratesProvider, SabrSwaptionVolatilities swaptionVolatilities)
        {
            MultiCurrencyAmount ceCms = productPricer.currencyExposure(trade.Product, ratesProvider, swaptionVolatilities);

            if (!trade.Premium.Present)
            {
                return(ceCms);
            }
            CurrencyAmount pvPremium = paymentPricer.presentValue(trade.Premium.get(), ratesProvider);

            return(ceCms.plus(pvPremium));
        }