Esempio n. 1
0
        /// <summary>
        /// Calculates the present value of the fixed coupon bond trade with z-spread from the
        /// clean price of the underlying product.
        /// <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>
        /// The z-spread is a parallel shift applied to continuously compounded rates or periodic
        /// compounded rates of the discounting curve.
        /// </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>
        /// <param name="refData">  the reference data used to calculate the settlement date </param>
        /// <param name="cleanPrice">  the clean price </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 of the fixed coupon bond trade </returns>
        public virtual CurrencyAmount presentValueFromCleanPriceWithZSpread(ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider, ReferenceData refData, double cleanPrice, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            ResolvedFixedCouponBond product  = trade.Product;
            LocalDate standardSettlementDate = this.standardSettlementDate(product, provider, refData);
            LocalDate tradeSettlementDate    = settlementDate(trade, provider.ValuationDate);
            Currency  currency = product.Currency;
            RepoCurveDiscountFactors repoDf = DiscountingFixedCouponBondProductPricer.repoCurveDf(product, provider);
            double df         = repoDf.discountFactor(standardSettlementDate);
            double pvStandard = (cleanPrice * product.Notional + productPricer.accruedInterest(product, standardSettlementDate)) * df;

            if (standardSettlementDate.isEqual(tradeSettlementDate))
            {
                return(presentValueFromProductPresentValue(trade, provider, CurrencyAmount.of(currency, pvStandard)));
            }
            // check coupon payment between two settlement dates
            IssuerCurveDiscountFactors issuerDf = DiscountingFixedCouponBondProductPricer.issuerCurveDf(product, provider);
            double pvDiff = 0d;

            if (standardSettlementDate.isAfter(tradeSettlementDate))
            {
                pvDiff = productPricer.presentValueCouponWithZSpread(product, issuerDf, tradeSettlementDate, standardSettlementDate, zSpread, compoundedRateType, periodsPerYear);
            }
            else
            {
                pvDiff = -productPricer.presentValueCouponWithZSpread(product, issuerDf, standardSettlementDate, tradeSettlementDate, zSpread, compoundedRateType, periodsPerYear);
            }
            return(presentValueFromProductPresentValue(trade, provider, CurrencyAmount.of(currency, pvStandard + pvDiff)));
        }
Esempio n. 2
0
        //-------------------------------------------------------------------------
        private CurrencyAmount presentValuePayment(ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider)
        {
            RepoCurveDiscountFactors repoDf = DiscountingFixedCouponBondProductPricer.repoCurveDf(trade.Product, provider);
            Payment upfrontPayment          = this.upfrontPayment(trade);

            return(paymentPricer.presentValue(upfrontPayment, repoDf.DiscountFactors));
        }
Esempio n. 3
0
        private PointSensitivityBuilder presentValueSensitivityPayment(ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider)
        {
            RepoCurveDiscountFactors repoDf = DiscountingFixedCouponBondProductPricer.repoCurveDf(trade.Product, provider);
            Payment upfrontPayment          = this.upfrontPayment(trade);
            PointSensitivityBuilder pt      = paymentPricer.presentValueSensitivity(upfrontPayment, repoDf.DiscountFactors);

            if (pt is ZeroRateSensitivity)
            {
                return(RepoCurveZeroRateSensitivity.of((ZeroRateSensitivity)pt, repoDf.RepoGroup));
            }
            return(pt);    // NoPointSensitivity
        }
Esempio n. 4
0
 /// <summary>
 /// Creates an instance.
 /// </summary>
 /// <param name="productPricer">  the pricer for <seealso cref="ResolvedFixedCouponBond"/> </param>
 /// <param name="paymentPricer">  the pricer for <seealso cref="Payment"/> </param>
 public DiscountingFixedCouponBondTradePricer(DiscountingFixedCouponBondProductPricer productPricer, DiscountingPaymentPricer paymentPricer)
 {
     this.productPricer = ArgChecker.notNull(productPricer, "productPricer");
     this.paymentPricer = ArgChecker.notNull(paymentPricer, "paymentPricer");
 }
 /// <summary>
 /// Creates an instance.
 /// </summary>
 /// <param name="bondPricer">  the pricer for <seealso cref="ResolvedFixedCouponBond"/>. </param>
 public DiscountingBondFutureProductPricer(DiscountingFixedCouponBondProductPricer bondPricer)
 {
     this.bondPricer = ArgChecker.notNull(bondPricer, "bondPricer");
 }