// calculates present value for one scenario internal CurrencyAmount presentValue(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, PriceType priceType, ReferenceData refData) { return(tradePricer.presentValue(trade, ratesProvider, priceType, refData)); }
// internal price computation with specified coupon rate internal virtual double price(ResolvedCdsTrade trade, CreditRatesProvider ratesProvider, double fractionalSpread, PriceType priceType, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return(productPricer.price(trade.Product, ratesProvider, fractionalSpread, settlementDate, priceType, refData)); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the price of the underlying product, which is the present value per unit notional. /// <para> /// This method can calculate the clean or dirty price, see <seealso cref="PriceType"/>. /// If calculating the clean price, the accrued interest is calculated based on the step-in date. /// </para> /// <para> /// This is coherent to <seealso cref="#presentValueOnSettle(ResolvedCdsTrade, CreditRatesProvider, PriceType, ReferenceData)"/>. /// /// </para> /// </summary> /// <param name="trade"> the trade </param> /// <param name="ratesProvider"> the rates provider </param> /// <param name="priceType"> the price type </param> /// <param name="refData"> the reference data </param> /// <returns> the price </returns> public virtual double price(ResolvedCdsTrade trade, CreditRatesProvider ratesProvider, PriceType priceType, ReferenceData refData) { return(price(trade, ratesProvider, trade.Product.FixedRate, priceType, refData)); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the risky PV01 of the underlying product. /// <para> /// RPV01 is defined as minus of the present value sensitivity to coupon rate. /// </para> /// <para> /// This is computed based on the settlement date rather than the valuation date. /// /// </para> /// </summary> /// <param name="trade"> the trade </param> /// <param name="ratesProvider"> the rates provider </param> /// <param name="priceType"> the price type </param> /// <param name="refData"> the reference date </param> /// <returns> the RPV01 </returns> public virtual CurrencyAmount rpv01OnSettle(ResolvedCdsTrade trade, CreditRatesProvider ratesProvider, PriceType priceType, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return(productPricer.rpv01(trade.Product, ratesProvider, settlementDate, priceType, refData)); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the present value of the trade. /// <para> /// The present value of the product is based on the valuation date. /// </para> /// <para> /// This method can calculate the clean or dirty present value, see <seealso cref="PriceType"/>. /// If calculating the clean value, the accrued interest is calculated based on the step-in date. /// /// </para> /// </summary> /// <param name="trade"> the trade </param> /// <param name="ratesProvider"> the rates provider </param> /// <param name="priceType"> the price type </param> /// <param name="refData"> the reference data </param> /// <returns> the price </returns> public virtual CurrencyAmount presentValue(ResolvedCdsTrade trade, CreditRatesProvider ratesProvider, PriceType priceType, ReferenceData refData) { CurrencyAmount pvProduct = productPricer.presentValue(trade.Product, ratesProvider, ratesProvider.ValuationDate, priceType, refData); if (!trade.UpfrontFee.Present) { return(pvProduct); } Payment upfront = trade.UpfrontFee.get(); CurrencyAmount pvUpfront = upfrontPricer.presentValue(upfront, ratesProvider.discountFactors(upfront.Currency).toDiscountFactors()); return(pvProduct.plus(pvUpfront)); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the price of the underlying product, which is the present value per unit notional. /// <para> /// This method can calculate the clean or dirty price, see <seealso cref="PriceType"/>. /// If calculating the clean price, the accrued interest is calculated based on the step-in date. /// </para> /// <para> /// This is coherent to <seealso cref="#presentValueOnSettle(ResolvedCdsIndexTrade, CreditRatesProvider, PriceType, ReferenceData)"/>. /// /// </para> /// </summary> /// <param name="trade"> the trade </param> /// <param name="ratesProvider"> the rates provider </param> /// <param name="priceType"> the price type </param> /// <param name="refData"> the reference data </param> /// <returns> the price </returns> public virtual double price(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, PriceType priceType, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return(productPricer.price(trade.Product, ratesProvider, settlementDate, priceType, refData)); }