Main Content

CDS

CDS instrument object

Description

Create and price a CDS instrument object for one or more CDS instruments using this workflow:

  1. Use fininstrument to create a CDS instrument object for one or more CDS instruments.

  2. Use defprobcurve to specify a default probability curve for the CDS instrument object.

  3. Use finpricer to specify a Credit pricing method for one or more CDS instruments.

For more information on this workflow, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.

For more information on the available models and pricing methods for a CDS instrument, see Choose Instruments, Models, and Pricers.

Creation

Description

example

CDSobj = fininstrument(InstrumentType,'Maturity',maturity_date,'ContractSpread',contractspread_value) creates a CDS object for one or more CDS instruments by specifying InstrumentType and sets the properties for the required name-value pair arguments Maturity and ContractSpread.

example

CDSobj = fininstrument(___,Name,Value) sets optional properties using additional name-value pairs in addition to the required arguments in the previous syntax. For example, CDSobj = fininstrument("CDS",'Maturity',datetime(2019,1,30),'ContractSpread',200,'Period',4,'Basis',5,'BusinessDayConvention','follow','Name',"cds_instrument") creates a CDS instrument with contract spread of 200. You can specify multiple name-value pair arguments.

Input Arguments

expand all

Instrument type, specified as a string with the value of "CDS", a character vector with the value of 'CDS', an NINST-by-1 string array with values of "CDS", or an NINST-by-1 cell array of character vectors with values of 'CDS'.

Data Types: char | cell | string

Name-Value Arguments

Specify required and optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: CDSobj = fininstrument("CDS",'Maturity',datetime(2019,1,30),'ContractSpread',200,'Period',4,'Basis',5,'BusinessDayConvention',"follow",'Name',"cds_instrument")

Required CDS Name-Value Pair Arguments

expand all

Maturity date, specified as the comma-separated pair consisting of 'Maturity' and a scalar or an NINST-by-1 vector using a datetime array, string array, or date character vectors.

To support existing code, CDS also accepts serial date numbers as inputs, but they are not recommended.

If you use date characters vector or strings, the format must be recognizable by datetime because the Maturity property is stored as a datetime.

Contract spreads expressed in basis points, specified as the comma-separated pair consisting of 'ContractSpread' and a scalar numeric or an NINST-by-1 numeric vector.

Data Types: double

Optional CDS Name-Value Pair Argument

expand all

Premium payments per year, specified as the comma-separated pair consisting of 'Period' and a scalar numeric or an NINST-by-1 numeric vector with values of 1, 2, 3, 4, 6, or 12.

Data Types: double

Day count basis, specified as the comma-separated pair consisting of 'Basis' and a scalar positive integer or an NINST-by-1vector of positive integers using the following values:

  • 0 — actual/actual

  • 1 — 30/360 (SIA)

  • 2 — actual/360

  • 3 — actual/365

  • 4 — 30/360 (PSA)

  • 5 — 30/360 (ISDA)

  • 6 — 30/360 (European)

  • 7 — actual/365 (Japanese)

  • 8 — actual/actual (ICMA)

  • 9 — actual/360 (ICMA)

  • 10 — actual/365 (ICMA)

  • 11 — 30/360E (ICMA)

  • 12 — actual/365 (ISDA)

  • 13 — BUS/252

For more information, see Basis.

Data Types: double

Business day conventions for cash flow dates, specified as the comma-separated pair consisting of 'BusDayConvention' and a scalar string or character vector or an NINST-by-1 cell array of character vectors or string array. The selection for business day convention determines how nonbusiness days are treated. Nonbusiness days are defined as weekends plus any other date that businesses are not open (for example, statutory holidays). Values are:

  • "actual" — Nonbusiness days are effectively ignored. Cash flows that fall on nonbusiness days are assumed to be distributed on the actual date.

  • "follow" — Cash flows that fall on a nonbusiness day are assumed to be distributed on the following business day.

  • "modifiedfollow" — Cash flows that fall on a nonbusiness day are assumed to be distributed on the following business day. However, if the following business day is in a different month, the previous business day is adopted instead.

  • "previous" — Cash flows that fall on a nonbusiness day are assumed to be distributed on the previous business day.

  • "modifiedprevious" — Cash flows that fall on a nonbusiness day are assumed to be distributed on the previous business day. However, if the previous business day is in a different month, the following business day is adopted instead.

Data Types: char | cell | string

Flag for accrued premiums, specified as the comma-separated pair consisting of 'PayAccruedPremium' and a scalar Boolean flag or an NINST-by-1 vector of Boolean flags that are true if accrued premiums are paid upon default and false otherwise.

Data Types: logical

Recovery rate, specified as the comma-separated pair consisting of 'RecoveryRate' and a scalar decimal or an NINST-by-1 vector of decimals from 0 to 1.

Data Types: double

Contract notional value, specified as the comma-separated pair consisting of 'Notional' and a scalar positive integer or an NINST-by-1 vector of positive integers.

Data Types: double

Holidays used in computing business days, specified as the comma-separated pair consisting of 'Holidays' and dates using an NINST-by-1 vector of datetimes, cell array of date character vectors, or date string array. For example:

H = holidays(datetime('today'),datetime(2025,12,15));
CDSobj = fininstrument("CDS",'Maturity',datetime(2025,12,15),'ContractSpread',200,'Holidays',H)

To support existing code, CDS also accepts serial date numbers as inputs, but they are not recommended.

User-defined name for one of more instruments, specified as the comma-separated pair consisting of 'Name' and a scalar string or character vector or an NINST-by-1 cell array of character vectors or string array.

Data Types: char | cell | string

Properties

expand all

Maturity date, returned as a scalar datetime or an NINST-by-1 vector of datetimes.

Data Types: datetime

Contract spreads expressed in basis points, returned as a scalar numeric or an NINST-by-1 numeric vector.

Data Types: double

Premium payments per year, returned as a scalar numeric or an NINST-by-1 numeric vector.

Data Types: double

Day count basis, returned as a scalar positive integer or an NINST-by-1 vector of positive integers.

Data Types: double

Business day conventions for cash flow dates, returned as a scalar string or an NINST-by-1 string array.

Data Types: string

Flag for accrued premiums, returned as a scalar Boolean flag or an NINST-by-1 vector of Boolean flags.

Data Types: logical

Recovery rate, returned as a scalar decimal or an NINST-by-1 vector of decimals.

Data Types: double

Contract notional value, returned as a scalar positive integer or an NINST-by-1 vector of positive integers.

Data Types: double

Holidays used in computing business days, returned as an NINST-by-1 vector of datetimes.

Data Types: datetime

User-defined name for the instrument, returned as a string or an NINST-by-1 string array.

Data Types: string

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(2021,9,15),'ContractSpread',15,'Notional',20000,'Period',4,'Basis',3,'BusinessDayConvention',"follow",'Name',"CDS_instrument")
CDS = 
  CDS with properties:

           ContractSpread: 15
                 Maturity: 15-Sep-2021
                   Period: 4
                    Basis: 3
             RecoveryRate: 0.4000
    BusinessDayConvention: "follow"
                 Holidays: NaT
        PayAccruedPremium: 1
                 Notional: 20000
                     Name: "CDS_instrument"

Create defprobcurve Object

Create a defprobcurve object using defprobcurve.

Settle = datetime(2020,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,'Basis',5)
DefaultProbCurve = 
  defprobcurve with properties:

                  Settle: 20-Sep-2020
                   Basis: 5
                   Dates: [10x1 datetime]
    DefaultProbabilities: [10x1 double]

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2020,9,15);
Type = 'zero';
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;
myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: -1
                Basis: 0
                Dates: [10x1 datetime]
                Rates: [10x1 double]
               Settle: 15-Sep-2020
         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.

outPricer = finpricer("credit",'DefaultProbabilityCurve',DefaultProbCurve,'DiscountCurve',myRC)
outPricer = 
  Credit with properties:

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

Price CDS Instrument

Use price to compute the price for the CDS instrument.

Price = price(outPricer,CDS)
Price = 52.7426

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

Create CDS Instrument Object

Use fininstrument to create a CDS instrument object for three CDS instruments.

CDS = fininstrument("CDS",'Maturity',datetime([2021,9,15 ; 2021,10,15 ; 2021,11,15]),'ContractSpread',15,'Notional',[20000 ; 30000 ; 40000],'Period',4,'Basis',3,'BusinessDayConvention',"follow",'Name',"CDS_instrument")
CDS=3×1 object
  3x1 CDS array with properties:

    ContractSpread
    Maturity
    Period
    Basis
    RecoveryRate
    BusinessDayConvention
    Holidays
    PayAccruedPremium
    Notional
    Name

Create defprobcurve Object

Create a defprobcurve object using defprobcurve.

Settle = datetime(2020,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,'Basis',5)
DefaultProbCurve = 
  defprobcurve with properties:

                  Settle: 20-Sep-2020
                   Basis: 5
                   Dates: [10x1 datetime]
    DefaultProbabilities: [10x1 double]

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2020,9,15);
Type = 'zero';
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;
myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: -1
                Basis: 0
                Dates: [10x1 datetime]
                Rates: [10x1 double]
               Settle: 15-Sep-2020
         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.

outPricer = finpricer("credit",'DefaultProbabilityCurve',DefaultProbCurve,'DiscountCurve',myRC)
outPricer = 
  Credit with properties:

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

Price CDS Instruments

Use price to compute the prices for the CDS instruments.

Price = price(outPricer,CDS)
Price = 3×1

   52.7426
   80.2945
  108.0357

Version History

Introduced in R2020a

expand all