Example #1
0
        public virtual void test_currentCash()
        {
            CurrencyAmount computed = PRICER.currentCash(TRADE_SETTLED, RATES_PROVIDER_ON_PAY);
            CurrencyAmount expected = PRODUCT_PRICER.currentCash(RPRODUCT, RATES_PROVIDER_ON_PAY, SETTLEMENT_BEFORE);

            assertEquals(computed.Amount, expected.Amount, NOTIONAL * QUANTITY * TOL);
        }
Example #2
0
        /// <summary>
        /// Calculates the current cash of the bond trade.
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="ratesProvider">  the rates provider, used to determine price index values </param>
        /// <returns> the current cash </returns>
        public virtual CurrencyAmount currentCash(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider)
        {
            LocalDate      valuationDate  = ratesProvider.ValuationDate;
            LocalDate      settlementDate = this.settlementDate(trade, valuationDate);
            CurrencyAmount cashProduct    = productPricer.currentCash(trade.Product, ratesProvider, settlementDate);

            if (!trade.Settlement.Present)
            {
                return(cashProduct);
            }
            BondPaymentPeriod settlePeriod = trade.Settlement.get().Payment;
            double            cashSettle   = settlePeriod.PaymentDate.isEqual(valuationDate) ? netAmount(trade, ratesProvider).Amount : 0d;

            return(cashProduct.plus(cashSettle));
        }