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)); }
public virtual void test_presentValue() { MultiCurrencyAmount pv1 = TRADE_PRICER.presentValue(CMS_TRADE_PREMIUM, RATES_PROVIDER, VOLATILITIES); MultiCurrencyAmount pv2 = TRADE_PRICER.presentValue(CMS_TRADE, RATES_PROVIDER, VOLATILITIES); MultiCurrencyAmount pvProd1 = PRODUCT_PRICER.presentValue(CMS_ONE_LEG, RATES_PROVIDER, VOLATILITIES); MultiCurrencyAmount pvProd2 = PRODUCT_PRICER.presentValue(CMS_TWO_LEGS, RATES_PROVIDER, VOLATILITIES); CurrencyAmount pvPrem = PREMIUM_PRICER.presentValue(PREMIUM, RATES_PROVIDER); assertEquals(pv1, pvProd1.plus(pvPrem)); assertEquals(pv2, pvProd2); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the present value of the CMS trade. /// <para> /// The present value of the trade is the value on the valuation date. /// /// </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 </returns> public virtual MultiCurrencyAmount presentValue(ResolvedCmsTrade trade, RatesProvider ratesProvider, SabrSwaptionVolatilities swaptionVolatilities) { MultiCurrencyAmount pvCms = productPricer.presentValue(trade.Product, ratesProvider, swaptionVolatilities); if (!trade.Premium.Present) { return(pvCms); } CurrencyAmount pvPremium = paymentPricer.presentValue(trade.Premium.get(), ratesProvider); return(pvCms.plus(pvPremium)); }