/// <summary> /// Computes the present value of the payment with z-spread by discounting. /// <para> /// The present value is zero if the payment date is before the valuation date. /// </para> /// <para> /// The specified discount factors should be for the payment currency, however this is not validated. /// </para> /// <para> /// The z-spread is a parallel shift applied to continuously compounded rates or periodic /// compounded rates of the discounting curve. /// /// </para> /// </summary> /// <param name="payment"> the payment </param> /// <param name="discountFactors"> the discount factors to price against </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 presentValueWithSpread(Payment payment, DiscountFactors discountFactors, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { if (discountFactors.ValuationDate.isAfter(payment.Date)) { return(CurrencyAmount.zero(payment.Currency)); } double df = discountFactors.discountFactorWithSpread(payment.Date, zSpread, compoundedRateType, periodsPerYear); return(payment.Value.multipliedBy(df)); }