Main Content

price

Compute price for credit derivative instrument with Credit pricer

Description

example

[Price,PriceResult] = price(inpPricer,inpInstrument) computes the instrument price and related pricing information based on the pricing object inpPricer and the instrument object inpInstrument.

Examples

collapse all

This example shows the workflow to price a CDS instrument when you use a defprobcurve model and a Credit pricing method.

Create CDS Instrument Object

Use fininstrument to create a CDS instrument object.

CDS = fininstrument("cds",'Maturity',datetime(2027,9,20),'ContractSpread', 50,'Name',"CDS_instrument")
CDS = 
  CDS with properties:

           ContractSpread: 50
                 Maturity: 20-Sep-2027
                   Period: 4
                    Basis: 2
             RecoveryRate: 0.4000
    BusinessDayConvention: "actual"
                 Holidays: NaT
        PayAccruedPremium: 1
                 Notional: 10000000
                     Name: "CDS_instrument"

Create defprobcurve Object

Create a defprobcurve object using defprobcurve.

Settle = datetime(2017, 9, 20);
DefProbTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])];
DefaultProbabilities = [0.005 0.007 0.01 0.015 0.026 0.04 0.077 0.093 0.15 0.20]';
ProbDates = Settle + DefProbTimes;
DefaultProbCurve = defprobcurve(Settle,ProbDates,DefaultProbabilities)
DefaultProbCurve = 
  defprobcurve with properties:

                  Settle: 20-Sep-2017
                   Basis: 2
                   Dates: [10x1 datetime]
    DefaultProbabilities: [10x1 double]

Create ratecurve Object

Create a ratecurve object using ratecurve.

ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])];
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;
ZeroCurve = ratecurve("zero",Settle,ZeroDates,ZeroRates)
ZeroCurve = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: -1
                Basis: 0
                Dates: [10x1 datetime]
                Rates: [10x1 double]
               Settle: 20-Sep-2017
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Create Credit Pricer Object

Use finpricer to create a Credit pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

CDSpricer = finpricer("credit",'DiscountCurve',ZeroCurve,'DefaultProbabilityCurve',DefaultProbCurve)
CDSpricer = 
  Credit with properties:

              DiscountCurve: [1x1 ratecurve]
                   TimeStep: 10
    DefaultProbabilityCurve: [1x1 defprobcurve]

Price CDS Instrument

Use price to compute the price for the CDS instrument.

outPrice = price(CDSpricer, CDS)
outPrice = 6.9363e+04

Input Arguments

collapse all

Pricer object, specified as a scalar Credit pricer object. Use finpricer to create the Credit pricer object.

Data Types: object

Instrument object, specified as a scalar CDS instrument object. Use fininstrument to create the CDS instrument object.

Data Types: object

Output Arguments

collapse all

Instrument price, returned as a numeric.

Price result, returned as a PriceResult object. The object has the following fields:

  • PriceResult.Results — Table of results that includes the CDS price and accrued premium

  • PriceResult.PricerData — Structure that includes the premium leg payment dates, times, and cash flows

Introduced in R2020a