예제 #1
0
        public virtual void test_presentValue_zspread()
        {
            CurrencyAmount pvComputed = PRICER.presentValueWithZSpread(BILL, PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0);
            double         pvExpected = DSC_FACTORS_ISSUER.discountFactor(MATURITY_DATE) * NOTIONAL.Amount * Math.Exp(-Z_SPREAD * DSC_FACTORS_ISSUER.relativeYearFraction(MATURITY_DATE));

            assertEquals(pvComputed.Currency, EUR);
            assertEquals(pvComputed.Amount, pvExpected, TOLERANCE_PV);
        }
예제 #2
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValueZSpread_settle_before_val()
        {
            CurrencyAmount pvComputed = PRICER_TRADE.presentValueWithZSpread(BILL_TRADE_SETTLE_BEFORE_VAL, PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0);
            CurrencyAmount pvExpected = PRICER_PRODUCT.presentValueWithZSpread(BILL_PRODUCT.resolve(REF_DATA), PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0).multipliedBy(QUANTITY);

            assertEquals(pvComputed.Currency, EUR);
            assertEquals(pvComputed.Amount, pvExpected.Amount, TOLERANCE_PV);
            MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposureWithZSpread(BILL_TRADE_SETTLE_BEFORE_VAL, PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0);

            assertEquals(ceComputed.Currencies.size(), 1);
            assertTrue(ceComputed.contains(EUR));
            assertEquals(ceComputed.getAmount(EUR).Amount, pvExpected.Amount, TOLERANCE_PV);
        }
예제 #3
0
        /// <summary>
        /// Calculates the present value of a bill trade with z-spread.
        /// <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>
        /// <para>
        /// The z-spread is a parallel shift applied to continuously compounded rates or periodic compounded rates of
        /// the issuer discounting curve. The z-spread is applied only on the legal entity curve, not on the repo curve used
        /// for the settlement amount.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="provider">  the discounting provider </param>
        /// <param name="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodsPerYear">  the number of periods per year </param>
        /// <returns> the present value </returns>
        public virtual CurrencyAmount presentValueWithZSpread(ResolvedBillTrade trade, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            if (provider.ValuationDate.isAfter(trade.Product.Notional.Date))
            {
                return(CurrencyAmount.of(trade.Product.Currency, 0.0d));
            }
            CurrencyAmount pvProduct = productPricer.presentValueWithZSpread(trade.Product, provider, zSpread, compoundedRateType, periodsPerYear).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);
        }