hjmprice
Instrument prices from Heath-Jarrow-Morton interest-rate tree
Description
[
computes arbitrage-free prices for instruments using an interest-rate tree created with
Price
,PriceTree
] = hjmprice(HJMTree
,InstSet
)hjmtree
. All instruments contained in a
financial instrument variable, InstSet
, are priced.
hjmprice
handles instrument types: 'Bond'
,
'CashFlow'
, 'OptBond'
,
'OptEmBond'
, 'OptEmBond'
,
'OptFloat'
, 'OptEmFloat'
,
'Fixed'
, 'Float'
, 'Cap'
,
'Floor'
, 'RangeFloat'
, 'Swap'
.
See instadd
to construct defined types.
Examples
Price the Cap and Float Instruments Contained in an Instrument Set
Load the HJM tree and instruments from the data file
deriv.mat
.
load deriv.mat; HJMSubSet = instselect(HJMInstSet,'Type', {'Float', 'Cap'}); instdisp(HJMSubSet)
Index Type Spread Settle Maturity FloatReset Basis Principal Name Quantity 1 Float 20 01-Jan-2000 01-Jan-2003 1 NaN NaN 20BP Float 8 Index Type Strike Settle Maturity CapReset Basis Principal Name Quantity 2 Cap 0.03 01-Jan-2000 01-Jan-2004 1 NaN NaN 3% Cap 30
Use hjmprice
to price the instruments.
[Price, PriceTree] = hjmprice(HJMTree, HJMSubSet)
Price = 100.5529 6.2831 PriceTree = struct with fields: FinObj: 'HJMPriceTree' PBush: {[2×1 double] [2×1×2 double] [2×2×2 double] [2×4×2 double] [2×8 double]} AIBush: {[2×1 double] [2×1×2 double] [2×2×2 double] [2×4×2 double] [2×8 double]} tObs: [0 1 2 3 4]
You can use treeviewer
to see the prices of these
instruments along the price tree.
Price Multi-Stepped Coupon Bonds
The data for the interest-rate term structure is as follows:
Rates = [0.035; 0.042147; 0.047345; 0.052707]; ValuationDate = 'Jan-1-2010'; StartDates = ValuationDate; EndDates = {'Jan-1-2011'; 'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'}; Compounding = 1;
Create a RateSpec
.
RS = intenvset('ValuationDate', ValuationDate, 'StartDates', StartDates,... 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding)
RS = struct with fields:
FinObj: 'RateSpec'
Compounding: 1
Disc: [4x1 double]
Rates: [4x1 double]
EndTimes: [4x1 double]
StartTimes: [4x1 double]
EndDates: [4x1 double]
StartDates: 734139
ValuationDate: 734139
Basis: 0
EndMonthRule: 1
Create a portfolio of stepped coupon bonds with different maturities.
Settle = '01-Jan-2010'; Maturity = {'01-Jan-2011';'01-Jan-2012';'01-Jan-2013';'01-Jan-2014'}; CouponRate = {{'01-Jan-2011' .042;'01-Jan-2012' .05; '01-Jan-2013' .06; '01-Jan-2014' .07}}; ISet = instbond(CouponRate, Settle, Maturity, 1); instdisp(ISet)
Index Type CouponRate Settle Maturity Period Basis EndMonthRule IssueDate FirstCouponDate LastCouponDate StartDate Face 1 Bond [Cell] 01-Jan-2010 01-Jan-2011 1 0 1 NaN NaN NaN NaN 100 2 Bond [Cell] 01-Jan-2010 01-Jan-2012 1 0 1 NaN NaN NaN NaN 100 3 Bond [Cell] 01-Jan-2010 01-Jan-2013 1 0 1 NaN NaN NaN NaN 100 4 Bond [Cell] 01-Jan-2010 01-Jan-2014 1 0 1 NaN NaN NaN NaN 100
Build the tree with the following data:
Volatility = [.2; .19; .18; .17];
CurveTerm = [ 1; 2; 3; 4];
HJMTimeSpec = hjmtimespec(ValuationDate, EndDates);
HJMVolSpec = hjmvolspec('Proportional', Volatility, CurveTerm, 1e6);
HJMT = hjmtree(HJMVolSpec,RS,HJMTimeSpec)
HJMT = struct with fields:
FinObj: 'HJMFwdTree'
VolSpec: [1x1 struct]
TimeSpec: [1x1 struct]
RateSpec: [1x1 struct]
tObs: [0 1 2 3]
dObs: [734139 734504 734869 735235]
TFwd: {[4x1 double] [3x1 double] [2x1 double] [3]}
CFlowT: {[4x1 double] [3x1 double] [2x1 double] [4]}
FwdTree: {[4x1 double] [3x1x2 double] [2x2x2 double] [1x4x2 double]}
Compute the price of the stepped coupon bonds.
PHJM = hjmprice(HJMT, ISet)
PHJM = 4×1
100.6763
100.7368
100.9266
101.0115
Price a Portfolio of Stepped Callable Bonds and Stepped Vanilla Bonds
The data for the interest-rate term structure is as follows:
Rates = [0.035; 0.042147; 0.047345; 0.052707]; ValuationDate = 'Jan-1-2010'; StartDates = ValuationDate; EndDates = {'Jan-1-2011'; 'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'}; Compounding = 1;
Create a RateSpec
.
RS = intenvset('ValuationDate', ValuationDate, 'StartDates', StartDates,... 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding)
RS = struct with fields:
FinObj: 'RateSpec'
Compounding: 1
Disc: [4x1 double]
Rates: [4x1 double]
EndTimes: [4x1 double]
StartTimes: [4x1 double]
EndDates: [4x1 double]
StartDates: 734139
ValuationDate: 734139
Basis: 0
EndMonthRule: 1
Create an instrument portfolio of three stepped callable bonds and three stepped vanilla bonds and display the instrument portfolio.
Settle = '01-Jan-2010'; Maturity = {'01-Jan-2012';'01-Jan-2013';'01-Jan-2014'}; CouponRate = {{'01-Jan-2011' .042;'01-Jan-2012' .05; '01-Jan-2013' .06; '01-Jan-2014' .07}}; OptSpec='call'; Strike=100; ExerciseDates='01-Jan-2011'; %Callable in one year % Bonds with embedded option ISet = instoptembnd(CouponRate, Settle, Maturity, OptSpec, Strike,... ExerciseDates, 'Period', 1); % Vanilla bonds ISet = instbond(ISet, CouponRate, Settle, Maturity, 1); instdisp(ISet)
Index Type CouponRate Settle Maturity OptSpec Strike ExerciseDates Period Basis EndMonthRule IssueDate FirstCouponDate LastCouponDate StartDate Face AmericanOpt 1 OptEmBond [Cell] 01-Jan-2010 01-Jan-2012 call 100 01-Jan-2011 1 0 1 NaN NaN NaN NaN 100 0 2 OptEmBond [Cell] 01-Jan-2010 01-Jan-2013 call 100 01-Jan-2011 1 0 1 NaN NaN NaN NaN 100 0 3 OptEmBond [Cell] 01-Jan-2010 01-Jan-2014 call 100 01-Jan-2011 1 0 1 NaN NaN NaN NaN 100 0 Index Type CouponRate Settle Maturity Period Basis EndMonthRule IssueDate FirstCouponDate LastCouponDate StartDate Face 4 Bond [Cell] 01-Jan-2010 01-Jan-2012 1 0 1 NaN NaN NaN NaN 100 5 Bond [Cell] 01-Jan-2010 01-Jan-2013 1 0 1 NaN NaN NaN NaN 100 6 Bond [Cell] 01-Jan-2010 01-Jan-2014 1 0 1 NaN NaN NaN NaN 100
Build the tree with the following data:
Volatility = [.2; .19; .18; .17];
CurveTerm = [ 1; 2; 3; 4];
HJMTimeSpec = hjmtimespec(ValuationDate, EndDates);
HJMVolSpec = hjmvolspec('Proportional', Volatility, CurveTerm, 1e6);
HJMT = hjmtree(HJMVolSpec,RS,HJMTimeSpec)
HJMT = struct with fields:
FinObj: 'HJMFwdTree'
VolSpec: [1x1 struct]
TimeSpec: [1x1 struct]
RateSpec: [1x1 struct]
tObs: [0 1 2 3]
dObs: [734139 734504 734869 735235]
TFwd: {[4x1 double] [3x1 double] [2x1 double] [3]}
CFlowT: {[4x1 double] [3x1 double] [2x1 double] [4]}
FwdTree: {[4x1 double] [3x1x2 double] [2x2x2 double] [1x4x2 double]}
Price the instrument set using hjmprice
.
PHJM = hjmprice(HJMT, ISet)
PHJM = 6×1
100.3682
100.1557
99.9232
100.7368
100.9266
101.0115
The first three rows correspond to the price of the stepped callable bonds and the last three rows correspond to the price of the stepped vanilla bonds.
Compute the Price of a Portfolio of Instruments
The data for the interest-rate term structure is as follows:
Rates = [0.035; 0.042147; 0.047345; 0.052707]; ValuationDate = 'Jan-1-2011'; StartDates = ValuationDate; EndDates = {'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'; 'Jan-1-2015'}; Compounding = 1;
Create a RateSpec
.
RS = intenvset('ValuationDate', ValuationDate, 'StartDates',... StartDates, 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding)
RS = struct with fields:
FinObj: 'RateSpec'
Compounding: 1
Disc: [4x1 double]
Rates: [4x1 double]
EndTimes: [4x1 double]
StartTimes: [4x1 double]
EndDates: [4x1 double]
StartDates: 734504
ValuationDate: 734504
Basis: 0
EndMonthRule: 1
Create an instrument portfolio with two range notes and a floating rate note with the following data and display the results:
Spread = 200; Settle = 'Jan-1-2011'; Maturity = 'Jan-1-2014'; % First Range Note RateSched(1).Dates = {'Jan-1-2012'; 'Jan-1-2013' ; 'Jan-1-2014'}; RateSched(1).Rates = [0.045 0.055; 0.0525 0.0675; 0.06 0.08]; % Second Range Note RateSched(2).Dates = {'Jan-1-2012'; 'Jan-1-2013' ; 'Jan-1-2014'}; RateSched(2).Rates = [0.048 0.059; 0.055 0.068 ; 0.07 0.09]; % Create an InstSet InstSet = instadd('RangeFloat', Spread, Settle, Maturity, RateSched); % Add a floating-rate note InstSet = instadd(InstSet, 'Float', Spread, Settle, Maturity); % Display the portfolio instrument instdisp(InstSet)
Index Type Spread Settle Maturity RateSched FloatReset Basis Principal EndMonthRule 1 RangeFloat 200 01-Jan-2011 01-Jan-2014 [Struct] 1 0 100 1 2 RangeFloat 200 01-Jan-2011 01-Jan-2014 [Struct] 1 0 100 1 Index Type Spread Settle Maturity FloatReset Basis Principal EndMonthRule CapRate FloorRate 3 Float 200 01-Jan-2011 01-Jan-2014 1 0 100 1 Inf -Inf
The data to build the tree is as follows:
Volatility = [.2; .19; .18; .17]; CurveTerm = [ 1; 2; 3; 4]; MaTree = {'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'; 'Jan-1-2015'}; HJMTS = hjmtimespec(ValuationDate, MaTree); HJMVS = hjmvolspec('Proportional', Volatility, CurveTerm, 1e6); HJMT = hjmtree(HJMVS, RS, HJMTS)
HJMT = struct with fields:
FinObj: 'HJMFwdTree'
VolSpec: [1x1 struct]
TimeSpec: [1x1 struct]
RateSpec: [1x1 struct]
tObs: [0 1 2 3]
dObs: [734504 734869 735235 735600]
TFwd: {[4x1 double] [3x1 double] [2x1 double] [3]}
CFlowT: {[4x1 double] [3x1 double] [2x1 double] [4]}
FwdTree: {[4x1 double] [3x1x2 double] [2x2x2 double] [1x4x2 double]}
Price the portfolio.
Price = hjmprice(HJMT, InstSet)
Price = 3×1
91.1555
90.6656
105.5147
Create a Float-Float Swap and Price with hjmprice
Use instswap
to create a float-float swap and price the swap with hjmprice
.
RateSpec = intenvset('Rates',.05,'StartDate',today,'EndDate',datemnth(today,60)); IS = instswap([.02 .03],today,datemnth(today,60),[], [], [], [1 1]); VolSpec = hjmvolspec('Constant', .2); TimeSpec = hjmtimespec(today,cfdates(today,datemnth(today,60),1)); HJMTree = hjmtree(VolSpec,RateSpec,TimeSpec); hjmprice(HJMTree,IS)
ans = -4.3220
Price Multiple Swaps with hjmprice
Use instswap
to create multiple swaps and price the swaps with hjmprice
.
RateSpec = intenvset('Rates',.05,'StartDate',today,'EndDate',datemnth(today,60)); IS = instswap([.03 .02],today,datemnth(today,60),[], [], [], [1 1]); IS = instswap(IS,[200 300],today,datemnth(today,60),[], [], [], [0 0]); IS = instswap(IS,[.08 300],today,datemnth(today,60),[], [], [], [1 0]); VolSpec = hjmvolspec('Constant', .2); TimeSpec = hjmtimespec(today,cfdates(today,datemnth(today,60),1)); HJMTree = hjmtree(VolSpec,RateSpec,TimeSpec); hjmprice(HJMTree,IS)
ans = 3×1
4.3220
-4.3220
-0.2701
Input Arguments
HJMTree
— Interest-rate tree structure
structure
Interest-rate tree structure, specified by using hjmtree
.
Data Types: struct
InstSet
— Instrument variable
structure
Instrument variable containing a collection of NINST
instruments,
specified using instadd
. Instruments are categorized by
type; each type can have different data fields. The stored data field is a row vector or
character vector for each instrument.
Data Types: struct
Options
— Derivatives pricing options structure
structure
(Optional) Derivatives pricing options structure, created using derivset
.
Data Types: struct
Output Arguments
Price
— Price for each instrument
vector
Price for each instrument, returned as a
NINST
-by-1
vector. The prices are computed by
backward dynamic programming on the interest-rate tree. If an instrument cannot be
priced, a NaN
is returned in that entry.
Related single-type pricing functions are:
bondbyhjm
— Price a bond from an HJM tree.capbyhjm
— Price a cap from an HJM tree.cfbyhjm
— Price an arbitrary set of cash flows from an HJM tree.fixedbyhjm
— Price a fixed-rate note from an HJM tree.floatbyhjm
— Price a floating-rate note from an HJM tree.floorbyhjm
— Price a floor from an HJM tree.optbndbyhjm
— Price a bond option from an HJM tree.optembndbyhjm
— Price a bond with embedded option by an HJM tree.optfloatbybdt
— Price a floating-rate note with an option from an HJM tree.optemfloatbybdt
— Price a floating-rate note with an embedded option from an HJM tree.rangefloatbyhjm
— Price range floating note using an HJM tree.swapbyhjm
— Price a swap from an HJM tree.swaptionbyhjm
— Price a swaption from an HJM tree.
PriceTree
— Tree structure of instrument prices
structure
Tree structure of instrument prices, returned as a MATLAB® structure of trees containing vectors of instrument prices and accrued
interest, and a vector of observation times for each node. Within
PriceTree
:
PriceTree.PTree
contains the clean prices.PriceTree.AITree
contains the accrued interest.PriceTree.tObs
contains the observation times.
Version History
Introduced before R2006a
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)