Beispiel #1
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            CurrencyAmount pvComputed = PRICER.presentValue(BILL, PROVIDER);
            double         pvExpected = DSC_FACTORS_ISSUER.discountFactor(MATURITY_DATE) * NOTIONAL.Amount;

            assertEquals(pvComputed.Currency, EUR);
            assertEquals(pvComputed.Amount, pvExpected, TOLERANCE_PV);
        }
Beispiel #2
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue_settle_before_val()
        {
            CurrencyAmount pvComputed = PRICER_TRADE.presentValue(BILL_TRADE_SETTLE_BEFORE_VAL, PROVIDER);
            CurrencyAmount pvExpected = PRICER_PRODUCT.presentValue(BILL_PRODUCT.resolve(REF_DATA), PROVIDER).multipliedBy(QUANTITY);

            assertEquals(pvComputed.Currency, EUR);
            assertEquals(pvComputed.Amount, pvExpected.Amount, TOLERANCE_PV);
            MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposure(BILL_TRADE_SETTLE_BEFORE_VAL, PROVIDER);

            assertEquals(ceComputed.Currencies.size(), 1);
            assertTrue(ceComputed.contains(EUR));
            assertEquals(ceComputed.getAmount(EUR).Amount, pvExpected.Amount, TOLERANCE_PV);
            CurrencyAmount cashComputed = PRICER_TRADE.currentCash(BILL_TRADE_SETTLE_BEFORE_VAL, VAL_DATE);

            assertEquals(cashComputed.Currency, EUR);
            assertEquals(cashComputed.Amount, 0, TOLERANCE_PV);
        }
Beispiel #3
0
        /// <summary>
        /// Calculates the present value of a bill trade.
        /// <para>
        /// If the settlement details are provided, the present value is the sum of the underlying product's present value
        /// multiplied by the quantity and the present value of the settlement payment if still due at the valuation date.
        /// If not it is the underlying product's present value multiplied by the quantity.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="provider">  the discounting provider </param>
        /// <returns> the present value </returns>
        public virtual CurrencyAmount presentValue(ResolvedBillTrade trade, LegalEntityDiscountingProvider provider)
        {
            if (provider.ValuationDate.isAfter(trade.Product.Notional.Date))
            {
                return(CurrencyAmount.of(trade.Product.Currency, 0.0d));
            }
            CurrencyAmount pvProduct = productPricer.presentValue(trade.Product, provider).multipliedBy(trade.Quantity);

            if (trade.Settlement.Present)
            {
                RepoCurveDiscountFactors repoDf   = DiscountingBillProductPricer.repoCurveDf(trade.Product, provider);
                CurrencyAmount           pvSettle = paymentPricer.presentValue(trade.Settlement.get(), repoDf.DiscountFactors);
                return(pvProduct.plus(pvSettle));
            }
            return(pvProduct);
        }