//-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            CurrencyAmount computed = PRICER.presentValue(PRODUCT, PROVIDER);
            CurrencyAmount expected = PRICER_NOMINAL.presentValue(PRODUCT.NominalPayment, DSC_FACTORS_ISSUER);
            int            size     = PRODUCT.PeriodicPayments.size();
            double         pvCupon  = 0d;

            for (int i = 2; i < size; ++i)
            {
                FixedCouponBondPaymentPeriod payment = PRODUCT.PeriodicPayments.get(i);
                pvCupon += PRICER_COUPON.presentValue(payment, IssuerCurveDiscountFactors.of(DSC_FACTORS_ISSUER, GROUP_ISSUER));
            }
            expected = expected.plus(pvCupon);
            assertEquals(computed.Currency, EUR);
            assertEquals(computed.Amount, expected.Amount, NOTIONAL * TOL);
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value of the fixed coupon bond trade.
        /// <para>
        /// The present value of the trade is the value on the valuation date.
        /// The result is expressed using the payment currency of the bond.
        /// </para>
        /// <para>
        /// Coupon payments of the underlying product are considered based on the settlement date of the trade.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="provider">  the discounting provider </param>
        /// <returns> the present value of the fixed coupon bond trade </returns>
        public virtual CurrencyAmount presentValue(ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider)
        {
            LocalDate      settlementDate = this.settlementDate(trade, provider.ValuationDate);
            CurrencyAmount pvProduct      = productPricer.presentValue(trade.Product, provider, settlementDate);

            return(presentValueFromProductPresentValue(trade, provider, pvProduct));
        }