CDS
CDS
instrument object
Description
Create and price a credit default swap (CDS
) instrument
object for one or more CDS instruments using this workflow:
Use
fininstrument
to create aCDS
instrument object for one or more CDS instruments.Use
defprobcurve
to specify a default probability curve for theCDS
instrument object.Use
finpricer
to specify aCredit
pricing method for one or moreCDS
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
Syntax
Description
creates a CDSobj
= fininstrument(InstrumentType
,'Maturity
',maturity_date,'ContractSpread
',contractspread_value)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
.
sets optional properties using additional
name-value pairs in addition to the required arguments in the previous
syntax. For example, CDSobj
= fininstrument(___,Name,Value
)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
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
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
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-1
vector 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
Output Arguments
CDS instrument, returned as a CDS
object.
Properties
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
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: [10×1 datetime] DefaultProbabilities: [10×1 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: [10×1 datetime] Rates: [10×1 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: [1×1 ratecurve] TimeStep: 10 DefaultProbabilityCurve: [1×1 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 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: [10×1 datetime] DefaultProbabilities: [10×1 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: [10×1 datetime] Rates: [10×1 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: [1×1 ratecurve] TimeStep: 10 DefaultProbabilityCurve: [1×1 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
More About
A credit default swap (CDS) is a derivative that allows investors to hedge against credit default or speculate on an entity's creditworthiness.
A CDS) involves a protection buyer, who seeks protection against credit risk, and a protection seller, who provides that protection for regular premium payments. The contract specifies the reference entity whose credit risk is covered. If a credit event like a default or significant downgrade occurs, the seller must pay the buyer the difference between the debt's face value and recovery value. Settlement can occur through physical delivery, where the buyer exchanges the defaulted debt for its face value, or cash settlement, where the seller pays the buyer the difference in cash.
Version History
Introduced in R2020aAlthough CDS
supports serial date numbers,
datetime
values are recommended instead. The
datetime
data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.
To convert serial date numbers or text to datetime
values, use the datetime
function. For example:
t = datetime(738427.656845093,"ConvertFrom","datenum"); y = year(t)
y = 2021
There are no plans to remove support for serial date number inputs.
See Also
Functions
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)