public virtual void test_currentCash() { MultiCurrencyAmount cc1 = PRODUCT_PRICER.currentCash(CMS_ONE_LEG, RATES_PROVIDER); MultiCurrencyAmount cc2 = PRODUCT_PRICER.currentCash(CMS_TWO_LEGS, RATES_PROVIDER); assertEquals(cc1, MultiCurrencyAmount.of(CurrencyAmount.zero(EUR))); assertEquals(cc2, MultiCurrencyAmount.of(CurrencyAmount.zero(EUR))); }
public virtual void test_currentCash_onPay() { MultiCurrencyAmount cc1 = TRADE_PRICER.currentCash(CMS_TRADE_PREMIUM, RATES_PROVIDER_ON_PAY); MultiCurrencyAmount cc2 = TRADE_PRICER.currentCash(CMS_TRADE, RATES_PROVIDER_ON_PAY); MultiCurrencyAmount ccProd1 = PRODUCT_PRICER.currentCash(CMS_ONE_LEG, RATES_PROVIDER_ON_PAY); MultiCurrencyAmount ccProd2 = PRODUCT_PRICER.currentCash(CMS_TWO_LEGS, RATES_PROVIDER_ON_PAY); assertEquals(cc1, ccProd1); assertEquals(cc2, ccProd2); }
/// <summary> /// Calculates the current cash of the trade. /// </summary> /// <param name="trade"> the CMS trade </param> /// <param name="ratesProvider"> the rates provider </param> /// <returns> the current cash </returns> public virtual MultiCurrencyAmount currentCash(ResolvedCmsTrade trade, RatesProvider ratesProvider) { MultiCurrencyAmount ccCms = productPricer.currentCash(trade.Product, ratesProvider); if (!trade.Premium.Present) { return(ccCms); } Payment premium = trade.Premium.get(); if (premium.Date.Equals(ratesProvider.ValuationDate)) { ccCms = ccCms.plus(premium.Currency, premium.Amount); } return(ccCms); }