Exemple #1
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);
        }
Exemple #2
0
        /// <summary>
        /// Calculates the present value sensitivity of a bill trade with z-spread.
        /// <para>
        /// If the settlement details are provided, the sensitivity is the sum of the underlying product's sensitivity
        /// multiplied by the quantity and the sensitivity of the settlement payment if still due at the valuation date.
        /// If not it is the underlying product's sensitivity 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 sensitivity </returns>
        public virtual PointSensitivities presentValueSensitivityWithZSpread(ResolvedBillTrade trade, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            if (provider.ValuationDate.isAfter(trade.Product.Notional.Date))
            {
                return(PointSensitivities.empty());
            }
            PointSensitivities sensiProduct = productPricer.presentValueSensitivityWithZSpread(trade.Product, provider, zSpread, compoundedRateType, periodsPerYear).multipliedBy(trade.Quantity);

            if (!trade.Settlement.Present)
            {
                return(sensiProduct);
            }
            Payment settlement = trade.Settlement.get();
            RepoCurveDiscountFactors repoDf      = DiscountingBillProductPricer.repoCurveDf(trade.Product, provider);
            PointSensitivities       sensiSettle = presentValueSensitivitySettlement(settlement, repoDf);

            return(sensiProduct.combinedWith(sensiSettle));
        }
Exemple #3
0
 /// <summary>
 /// Creates an instance.
 /// </summary>
 /// <param name="productPricer">  the pricer for <seealso cref="ResolvedBill"/> </param>
 /// <param name="paymentPricer">  the pricer for <seealso cref="Payment"/> </param>
 public DiscountingBillTradePricer(DiscountingBillProductPricer productPricer, DiscountingPaymentPricer paymentPricer)
 {
     this.productPricer = ArgChecker.notNull(productPricer, "productPricer");
     this.paymentPricer = ArgChecker.notNull(paymentPricer, "paymentPricer");
 }