CDS
instrument object
Create and price aCDS
instrument object for one or more CDS instruments using this workflow:
Usefininstrument
to create aCDS
instrument object for one or more CDS instruments.
Usedefprobcurve
to specify a default probability curve for theCDS
instrument object.
Usefinpricer
to specify aCredit
pricing method for one or moreCDS
instruments.
For more information on this workflow, seeGet Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.
For more information on the available models and pricing methods for aCDS
instrument, seeChoose Instruments, Models, and Pricers.
creates aCDSobj
= fininstrument(InstrumentType
,'Maturity
',maturity_date,'ContractSpread
',contractspread_value)CDS
object for one or more CDS instruments by specifyingInstrumentType
and sets thepropertiesfor the required name-value pair argumentsMaturity
andContractSpread
.
sets optionalpropertiesusing 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 aCDS
instrument with contract spread of 200. You can specify multiple name-value pair arguments.
InstrumentType
—Instrument type"CDS"
|string array with values of"CDS"
|character vector with value'CDS'
|cell array of character vectors with values of'CDS'
Instrument type, specified as a string with the value of"CDS"
, a character vector with the value of'CDS'
, anNINST
-by-1
string array with values of"CDS"
, or anNINST
-by-1
cell array of character vectors with values of'CDS'
.
Data Types:char
|cell
|string
CDS
Name-Value Pair Arguments
Specify required and optional comma-separated pairs ofName,Value
arguments.Name
is the argument name andValue
is the corresponding value.Name
must appear inside quotes. You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN
.
CDSobj = fininstrument("CDS",'Maturity',datetime(2019,1,30),'ContractSpread',200,'Period',4,'Basis',5,'BusinessDayConvention',"follow",'Name',"cds_instrument")
CDS
Name-Value Pair Arguments
Maturity
—Maturity dateMaturity date, specified as the comma-separated pair consisting of'Maturity'
and a scalar datetime, serial date number, date character vector, date string or anNINST
-by-1
vector of datetimes, serial date numbers, cell array of date character vectors, or date string array.
If you use date characters vector or date strings, the format must be recognizable bydatetime
because theMaturity
property is stored as a datetime.
Data Types:char
|cell
|double
|string
|datetime
ContractSpread
—Contract spreads expressed in basis pointsContract spreads expressed in basis points, specified as the comma-separated pair consisting of'ContractSpread'
and a scalar numeric or anNINST
-by-1
数字矢量tor.
Data Types:double
CDS
Name-Value Pair Argument
Period
—Premium payments per year4
(default) |scalar numeric with value of1
,2
,3
,4
,6
,12
|数字矢量tor with values of1
,2
,3
,4
,6
,12
Premium payments per year, specified as the comma-separated pair consisting of'Period'
and a scalar numeric or anNINST
-by-1
数字矢量tor with values of1
,2
,3
,4
,6
, or12
.
Data Types:double
Basis
—Day count basis0
(actual/actual)(default) |scalar of positive integers of the set[1...13]
|vector of positive integers of the set[1...13]
Day count basis, specified as the comma-separated pair consisting of'Basis'
and a scalar positive integer or anNINST
-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, seeBasis.
Data Types:double
BusinessDayConvention
—Business day convention for cash flow dates"actual"
(default) |string|string array|character vector|cell array of character vectorsBusiness day conventions for cash flow dates, specified as the comma-separated pair consisting of'BusDayConvention'
and a scalar string or character vector or anNINST
-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
PayAccruedPremium
—为应计费用true
(default) |scalar value oftrue
orfalse
|vector with values oftrue
orfalse
为应计费用, specified as the comma-separated pair consisting of'PayAccruedPremium'
and a scalar Boolean flag or anNINST
-by-1
vector of Boolean flags that aretrue
if accrued premiums are paid upon default andfalse
otherwise.
Data Types:logical
RecoveryRate
—Recovery rate0.4
(default) |scalar decimal|vector of decimalsRecovery rate, specified as the comma-separated pair consisting of'RecoveryRate'
and a scalar decimal or anNINST
-by-1
vector of decimals from0
to1
.
Data Types:double
Notional
—Contract notional value100
(default) |scalar positive integer|vector of positive integersContract notional value, specified as the comma-separated pair consisting of'Notional'
and a scalar positive integer or anNINST
-by-1
vector of positive integers.
Data Types:double
Holidays
—Holidays used in computing business daysNaT
(default) |datetimes|cell array of character vectors|date string array|serial date numbersHolidays used in computing business days, specified as the comma-separated pair consisting of'Holidays'
and dates using anNINST
-by-1
vector of datetimes, serial date numbers, 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)
Data Types:double
|cell
|datetime
|string
Name
—User-defined name for instrument" "
(default) |string|string array|character vector|cell array of character vectorsUser-defined name for one of more instruments, specified as the comma-separated pair consisting of'Name'
and a scalar string or character vector or anNINST
-by-1
cell array of character vectors or string array.
Data Types:char
|cell
|string
Maturity
—Maturity dateMaturity date, returned as a scalar datetime or anNINST
-by-1
vector of datetimes.
Data Types:datetime
ContractSpread
—Contract spreads expressed in basis pointsContract spreads expressed in basis points, returned as a scalar numeric or anNINST
-by-1
数字矢量tor.
Data Types:double
Period
—Premium payments per year4
(default) |scalar numeric with value of1
,2
,3
,4
,6
or12
|数字矢量tor with values of1
,2
,3
,4
,6
or12
Premium payments per year, returned as a scalar numeric or anNINST
-by-1
数字矢量tor.
Data Types:double
Basis
—Day count basis0
(actual/actual)(default) |scalar positive integers of the set[1...13]
|vector of positive integers of the set[1...13]
Day count basis, returned as a scalar positive integer or anNINST
-by-1
vector of positive integers.
Data Types:double
BusinessDayConvention
—Business day convention for cash flow dates"actual"
(default) |string|string arrayBusiness day conventions for cash flow dates, returned as a scalar string or anNINST
-by-1
string array.
Data Types:string
PayAccruedPremium
—为应计费用true
(default) |scalar valuetrue
orfalse
|vector of valuestrue
orfalse
为应计费用, returned as a scalar Boolean flag or anNINST
-by-1
vector of Boolean flags.
Data Types:logical
RecoveryRate
—Recovery rate0.4
(default) |scalar decimal|vector of decimalsRecovery rate, returned as a scalar decimal or anNINST
-by-1
vector of decimals.
Data Types:double
Notional
—Contract notional value100
(default) |scalar positive integer|vector of positive integersContract notional value, returned as a scalar positive integer or anNINST
-by-1
vector of positive integers.
Data Types:double
Holidays
—Holidays used in computing business daysNaT
(default) |datetimesHolidays used in computing business days, returned as anNINST
-by-1
vector of datetimes.
Data Types:datetime
Name
—User-defined name for instrument" "
(default) |string|string arrayUser-defined name for the instrument, returned as a string or anNINST
-by-1
string array.
Data Types:string
This example shows the workflow to price aCDS
instrument when you use adefprobcurve
model and aCredit
pricing method.
CreateCDS
Instrument Object
Usefininstrument
to create aCDS
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"
Createdefprobcurve
Object
Create adefprobcurve
object usingdefprobcurve
.
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]
Createratecurve
Object
Create aratecurve
object usingratecurve
.
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"
CreateCredit
Pricer Object
Usefinpricer
to create aCredit
pricer object and use theratecurve
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]
PriceCDS
Instrument
Useprice
to compute the price for theCDS
instrument.
Price = price(outPricer,CDS)
Price = 52.7426
This example shows the workflow to price multipleCDS
当你使用工具defprobcurve
model and aCredit
pricing method.
CreateCDS
Instrument Object
Usefininstrument
to create aCDS
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 object3x1 CDS array with properties: ContractSpread Maturity Period Basis RecoveryRate BusinessDayConvention Holidays PayAccruedPremium Notional Name
Createdefprobcurve
Object
Create adefprobcurve
object usingdefprobcurve
.
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]
Createratecurve
Object
Create aratecurve
object usingratecurve
.
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"
CreateCredit
Pricer Object
Usefinpricer
to create aCredit
pricer object and use theratecurve
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]
PriceCDS
Instruments
Useprice
to compute the prices for theCDS
instruments.
Price = price(outPricer,CDS)
Price =3×152.7426 80.2945 108.0357
You have a modified version of this example. Do you want to open this example with your edits?
You clicked a link that corresponds to this MATLAB command:
运行该命令通过输入MATLAB逗号nd Window. Web browsers do not support MATLAB commands.
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:.
Selectweb siteYou can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.