Exemple #1
0
        public virtual void test_currencyExposure()
        {
            MultiCurrencyAmount     computed1 = PRODUCT_PRICER.currencyExposure(CMS_ONE_LEG, RATES_PROVIDER);
            MultiCurrencyAmount     computed2 = PRODUCT_PRICER.currencyExposure(CMS_TWO_LEGS, RATES_PROVIDER);
            MultiCurrencyAmount     pv1       = PRODUCT_PRICER.presentValue(CMS_ONE_LEG, RATES_PROVIDER);
            PointSensitivityBuilder pt1       = PRODUCT_PRICER.presentValueSensitivity(CMS_ONE_LEG, RATES_PROVIDER);
            MultiCurrencyAmount     expected1 = RATES_PROVIDER.currencyExposure(pt1.build()).plus(pv1);
            MultiCurrencyAmount     pv2       = PRODUCT_PRICER.presentValue(CMS_TWO_LEGS, RATES_PROVIDER);
            PointSensitivityBuilder pt2       = PRODUCT_PRICER.presentValueSensitivity(CMS_TWO_LEGS, RATES_PROVIDER);
            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);
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the currency exposure of the trade.
        /// </summary>
        /// <param name="trade">  the CMS trade </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <returns> the currency exposure </returns>
        public virtual MultiCurrencyAmount currencyExposure(ResolvedCmsTrade trade, RatesProvider ratesProvider)
        {
            MultiCurrencyAmount ceCms = productPricer.currencyExposure(trade.Product, ratesProvider);

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

            return(ceCms.plus(pvPremium));
        }