irbootstrap
Description
creates a data structure for storing interest-rate term structure data. The
outCurve
= irbootstrap(BootInstruments
,Settle
)outCurve
output is a ratecurve
object.
specifies options using one or more name-value pair arguments in addition to any of the
input argument combinations in the previous syntax. For example, outCurve
= irbootstrap(___,Name,Value
)OutCurve =
irbootstrap(Settle,BootInstruments,'Type',"zero",'Compounding',2,'Basis',5,'InterpMethod',"cubic")
bootstraps a zero curve from BootInstruments
.
Examples
Bootstrap ratecurve
Object from Market Data
Define Deposit and Swap Parameters
Settle = datetime(2018,3,21);
DepRates = [.0050769 .0054934 .0061432 .0072388 .0093263]';
DepTimes = [1 2 3 6 12]';
DepDates = datemnth(Settle,DepTimes);
nDeposits = length(DepTimes);
SwapRates = [.0112597 0;.0128489 0;.0138917 0;.0146135 0;.0151175 0;...
.0155184 0;.0158536 0;.0161435 0];
SwapTimes = (2:9)';
SwapDates = datemnth(Settle,12*SwapTimes);
nSwaps = length(SwapTimes);
nInst = nDeposits + nSwaps;
Create a Vector of Market Swap Instruments
Use fininstrument
to create a vector of market Deposit
and Swap
instrument objects.
BootInstruments(nInst,1) = fininstrument.FinInstrument; for ii=1:length(DepDates) BootInstruments(ii) = fininstrument("deposit",'Maturity',DepDates(ii),'Rate',DepRates(ii)); end for ii=1:length(SwapDates) BootInstruments(ii+nDeposits) = fininstrument("swap",'Maturity',SwapDates(ii),'LegRate',[SwapRates(ii) 0]); end
Create ratecurve
Object for Zero-Rate Curve
Use irbootstrap
to create a ratecurve
object for the zero-rate curve.
ZeroCurve = irbootstrap(BootInstruments,Settle)
ZeroCurve = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 0 Dates: [13x1 datetime] Rates: [13x1 double] Settle: 21-Mar-2018 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
Create Zero Curve Using DiscountCurve
Input
This example shows how to create a ratecurve
object using irbootstrap
with Deposit
and Swap
instruments and a DiscountCurve
for discounting cash flows.
Settle = datetime(2021,4,15); crvDates = Settle + [calmonths([1 2 3 6]) calyears([1 2 3 5 7 10 20 30])]'; crvRates = [0.0004 0.0004 0.0005 0.0006 0.0008 0.0018 0.0037 0.0088 0.013 0.0165 0.022 0.0233]'; DiscountCurve = ratecurve("zero",Settle,crvDates,crvRates); DepRates = [0.002 0.0021 0.0023 0.0024 .0028]'; DepDates = Settle + calmonths([1 2 3 6 12]'); SwapRates = [0.0041 0;0.0057 0;0.017 0;0.0193 0;0.024 0;0.027 0]; SwapTimes = [2 3 5 10 20 30]'; SwapDates = datemnth(Settle,12*SwapTimes); BootInstruments = [fininstrument("deposit","Maturity",DepDates,"Rate",DepRates); ... fininstrument("swap","Maturity",SwapDates,"LegRate",SwapRates)]; ZeroCurve = irbootstrap(BootInstruments,Settle,'DiscountCurve',DiscountCurve)
ZeroCurve = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 0 Dates: [11x1 datetime] Rates: [11x1 double] Settle: 15-Apr-2021 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
Bootstrap ratecurve
Object from BootInstruments
for OIS Futures and Overnight Indexed Swaps
Create a BootInstruments
variable as an input argument to irbootstrap
to create a ratecurve
object. The BootInstruments
variable has OISFuture
instrument objects for one-month SOFR Futures and three-month SOFR Futures, and an OvernightIndexedSwap
instrument object.
Create Instruments
Use fininstrument
to create an OISFuture
instrument object for one-month SOFR Futures.
Settle = datetime(2021,3,4); HFDates = datetime(2021,3,1) + caldays(0:3)'; HistFixing = timetable(HFDates,[0.02;0.04;0.04;0.02]); % Data from the following: https://www.cmegroup.com/trading/interest-rates/stir/one-month-sofr_quotes_globex.html Prices_1M = [99.97 99.96 99.95]'; Maturity_1M = lbusdate(2021,[3 4 5]',[],[],'datetime'); StartDate_1M = fbusdate(2021,[3 4 5]',[],[],'datetime'); FutInstruments_1M = fininstrument("OISFuture","Maturity",Maturity_1M ,"QuotedPrice",Prices_1M,"StartDate",StartDate_1M,"Method","Average",... 'HistoricalFixing',HistFixing,'Name',"1MonthSOFRFuture")
FutInstruments_1M=3×1 OISFuture array with properties:
QuotedPrice
Method
Basis
StartDate
Maturity
Notional
BusinessDayConvention
Holidays
ProjectionCurve
HistoricalFixing
Name
Use fininstrument
to create an OISFuture
instrument object for three-month SOFR Futures.
% Data from the following: https://www.cmegroup.com/trading/interest-rates/stir/three-month-sofr_quotes_globex.html Prices_3M = [99.92 99.895 99.84 99.74]'; Dates_3M_Maturity = thirdwednesday([6 9 12 3]',[2021 2021 2021 2022]','datetime'); Dates_3M_Start = thirdwednesday([3 6 9 12]',2021,'datetime'); FutInstruments_3M = fininstrument("OISFuture","Maturity",Dates_3M_Maturity,... "QuotedPrice",Prices_3M,"StartDate",Dates_3M_Start,'HistoricalFixing',HistFixing,'Name',"3MonthSOFRFuture");
Use fininstrument
to create an OvernightIndexedSwap
instrument object.
SOFRSwapRates = [.0023 0;.0064 0;.013 0;.017 0;.0175 0]; SOFRSwapTimes = [3 5 10 20 30]; SOFRSwapDates = datemnth(Settle,12*SOFRSwapTimes)'; SOFRSwapInstruments = fininstrument("OvernightIndexedSwap","Maturity",SOFRSwapDates,"LegRate",SOFRSwapRates,'Name',"overnight_swap_instrument")
SOFRSwapInstruments=5×1 OvernightIndexedSwap array with properties:
LegRate
LegType
Reset
Basis
Notional
HistoricalFixing
ResetOffset
PaymentDelay
ProjectionCurve
BusinessDayConvention
Holidays
EndMonthRule
DaycountAdjustedCashFlow
StartDate
Maturity
Name
Define BootInstruments
for the three types of instruments.
BootInstruments = [FutInstruments_1M;FutInstruments_3M;SOFRSwapInstruments]
BootInstruments=12×1 heterogeneous FinInstrument (OISFuture, OvernightIndexedSwap) array with properties:
Name
Create ratecurve
Object
Use irbootstrap
to create a ratecurve
object.
SOFRCurve = irbootstrap(BootInstruments,Settle)
SOFRCurve = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 0 Dates: [12x1 datetime] Rates: [12x1 double] Settle: 04-Mar-2021 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
Bootstrap ratecurve
Object from STIRFuture
, Deposit
, and Swap
BootInstruments
Create BootInstruments
for multiple Deposit,
STIRFuture
, and Swap
instruments and then use irbootstrap
to create and display a ratecurve
object.
Create Instruments
Use fininstrument
to create a Deposit
instrument object.
Settle = datetime(2021,6,15); DepRates = [0.0016 0.0017 .00175]'; DepDates = Settle + calmonths([1 2 3]'); Deposits = fininstrument("Deposit","Maturity",DepDates,"Rate",DepRates,'Name',"deposit_instrument")
Deposits=3×1 Deposit array with properties:
Rate
Period
Basis
Maturity
Principal
BusinessDayConvention
Holidays
Name
Use fininstrument
to create a STIRFuture
instrument object.
FutureRates = [0.002 0.0025 0.0035]'; FutMat = [datetime(2021,9,15) datetime(2021,12,15) datetime(2022,3,16)]'; FutEndDates = [datetime(2021,12,15) datetime(2022,3,15) datetime(2022,6,15)]'; Futures = fininstrument("STIRFuture","Maturity",FutMat,"RateEndDate",FutEndDates,"QuotedPrice",100 - 100*FutureRates,'Name',"stir_future_instrument")
Futures=3×1 STIRFuture array with properties:
QuotedPrice
Basis
RateEndDate
Maturity
Notional
BusinessDayConvention
Holidays
ProjectionCurve
Name
Use fininstrument
to create a Swap
instrument object.
SwapRates = [.0063 0;.0108 0;.013 0;.015 0;0.017 0;.018 0;0.019 0]; SwapTimes = [2 5 7 10 15 20 30]'; SwapDates = datemnth(Settle,12*SwapTimes); Swaps = fininstrument("Swap","Maturity",SwapDates,"LegRate",SwapRates,'Name',"swap_instrument")
Swaps=7×1 Swap array with properties:
LegRate
LegType
Reset
Basis
Notional
LatestFloatingRate
ResetOffset
DaycountAdjustedCashFlow
ProjectionCurve
BusinessDayConvention
Holidays
EndMonthRule
StartDate
Maturity
Name
Define BootInstruments
for the three instruments.
BootInstruments = [Deposits;Futures;Swaps];
Create ratecurve
Object Using irbootstrap
Use irbootstrap
to create a ratecurve
object.
ConvexityAdj = (1:3)'/10000; ZeroCurve = irbootstrap(BootInstruments,Settle,'ConvexityAdjustment',ConvexityAdj,'InterpMethod','pchip')
ZeroCurve = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 0 Dates: [13x1 datetime] Rates: [13x1 double] Settle: 15-Jun-2021 InterpMethod: "pchip" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
Plot Bootstrapped Curve
PlottingDates = Settle + calmonths(1:360); plot(PlottingDates,zerorates(ZeroCurve,PlottingDates)) xlabel('Maturity (Years)') ylabel('Zero Rate') title('Bootstrapped Curve')
Input Arguments
BootInstruments
— Collection of instruments
array of instrument objects
Collection of instruments, specified as an array of instrument objects. The
collection of instruments can include Deposit
, Swap
, FRA
, STIRFuture
, OISFuture
, and OvernightIndexedSwap
instruments.
Data Types: object
Settle
— Settlement date
datetime scalar | string scalar | date character vector
Settlement date, specified as a scalar datetime, string, or date character vector.
To support existing code, irbootstrap
also
accepts serial date numbers as inputs, but they are not recommended.
Name-Value Arguments
Specify 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: OutCurve =
irbootstrap(Settle,BootInstruments,'Type',"zero",'Compounding',2,'Basis',5,'InterpMethod',"cubic")
Type
— Type of interest-rate curve
"zero"
(default) | string with value "discount"
, "forward"
, or "zero"
| character vector with value 'discount'
,
'forward'
, or 'zero'
Type of interest-rate curve, specified as the comma-separated pair consisting of
'Type'
and a scalar string or character vector.
Note
When you use irbootstrap
, the value you specify for
Type
can impact the curve construction because it affects the
type of data that is interpolated on (that is, forward rates, zero rates, or
discount factors) during the bootstrapping process.
Data Types: char
| string
Compounding
— Compounding frequency
Compounding
for the ratecurve
object (default) | possible values include: –1
, 0
, 1
, 2
, 3
,
4
, 6
, 12
.
Compounding frequency, specified as the comma-separated pair consisting of
'Compounding'
and a scalar numeric using the supported values:
–1
, 0
, 1
,
2
, 3
, 4
,
6
, or 12
.
Data Types: double
Basis
— Day-count basis
0
(actual/actual) (default) | integer from 0
to 13
Day-count basis, specified as the comma-separated pair consisting of
'Basis'
and a scalar integer.
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
InterpMethod
— Interpolation method
"linear"
(default) | string with value "linear"
, "cubic"
, "next"
, "previous"
, "pchip"
, "v5cubic"
, "makima"
,
or "spline"
| character vector with value 'linear'
,
'cubic'
, 'next'
,
'previous'
, 'pchip'
,
'v5cubic'
, 'makima'
, or
'spline'
Interpolation method, specified as the comma-separated pair consisting of
'InterpMethod'
and a scalar string or character vector using a
supported value. For more information on interpolation methods, see interp1
.
Data Types: char
| string
ShortExtrapMethod
— Extrapolation method for data before first data
"next"
(default) | string with value "linear"
, "next"
, "previous"
, "pchip"
, "cubic"
,"v5cubic"
,
"makima"
, or "spline"
| character vector with value 'linear'
,
'next'
, 'previous'
,
'pchip'
, 'cubic'
,'v5cubic'
,
'makima'
, or 'spline'
Extrapolation method for data before first data, specified as the comma-separated
pair consisting of 'ShortExtrapMethod'
and a scalar string or
character vector using a supported value. For more information on interpolation
methods, see interp1
.
Data Types: char
| string
LongExtrapMethod
— Extrapolation method for data after last data
"previous"
(default) | string with value "linear"
, "next"
, "previous"
, "pchip"
, "cubic"
,"v5cubic"
,
"makima"
, or "spline"
| character vector with value 'linear'
,
'next'
, 'previous'
,
'pchip'
, 'cubic'
,'v5cubic'
,
'makima'
, or 'spline'
Extrapolation method for data after last data, specified as the comma-separated
pair consisting of 'LongExtrapMethod'
and a scalar string or
character vector using a supported value. For more information on interpolation
methods, see interp1
.
Data Types: char
| string
DiscountCurve
— ratecurve
object for discounting cash flows
ratecurve.empty
(default) | scalar ratecurve
object
ratecurve
object for discounting cash flows, specified as the
comma-separated pair consisting of 'DiscountCurve'
and the name of
a previously created ratecurve
object.
Data Types: object
ConvexityAdjustment
— Convexity adjustment for STIRFuture
instrument
0
(default) | numeric vector
Convexity adjustment for one or more STIRFuture
instruments, specified as the comma-separated pair consisting of
'ConvexityAdjustment'
and an
NFutures
-by-1
vector of numeric values.
Note
You can only use ConvexityAdjustment
when using
irbootstrap
with a STIRFuture
instrument. Also, the length of the ConvexityAdjustment
vector
must match the number of STIRFuture
instruments.
Data Types: double
Output Arguments
outCurve
— Rate curve
ratecurve
object
Rate curve, returned as a ratecurve
object. The object has the
following properties:
Type
Settle
Compounding
Basis
Dates
Rates
InterpMethod
ShortExtrapMethod
LongExtrapMethod
Version History
Introduced in R2020aR2022b: Serial date numbers not recommended
Although irbootstrap
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.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)