For purposes of illustration, this section relies on the HJM and BDT models. The HW and BK functions that perform price and sensitivity computations are not explicitly shown here. Functions that use the HW and BK models operate similarly to the BDT model.
The portfolio pricing
functions hjmprice
and bdtprice
calculate the price of any set
of supported instruments, based on an interest-rate tree. The functions
are capable of pricing these instrument types:
Bonds
Bond options
Bond with embedded options
Arbitrary cash flows
Fixed-rate notes
Floating-rate notes
Floating-rate notes with options or embedded options
Caps
Floors
Range Notes
Swaps
Swaptions
For example, the syntax for calling hjmprice
is:
[Price, PriceTree] = hjmprice(HJMTree, InstSet, Options)
Similarly, the calling syntax for bdtprice
is:
[Price,
PriceTree] = bdtprice(BDTTree, InstSet, Options)
Each function requires two input arguments: the interest-rate
tree and the set of instruments, InstSet
. An optional
argument, Options
, further controls the pricing
and the output displayed. (See Derivatives Pricing Options for information about the Options
argument.)
HJMTree
is
the Heath-Jarrow-Morton tree sampling of a forward-rate process, created
using hjmtree
. BDTTree
is the Black-Derman-Toy tree
sampling of an interest-rate process, created using bdttree
. See Building a Tree of Forward Rates to
learn how to create these structures.
InstSet
is the set of instruments to be priced.
This structure represents the set of instruments to be priced independently
using the model.
Options
is
an options structure created with the function derivset
. This structure defines how
the tree is used to find the price of instruments in the portfolio,
and how much additional information is displayed in the command window
when calling the pricing function. If this input argument is not specified
in the call to the pricing function, a default Options structure is
used. The pricing options structure is described in Pricing Options Structure.
The portfolio pricing functions classify the instruments and
call the appropriate instrument-specific pricing function for each
of the instrument types. The HJM instrument-specific pricing
functions are bondbyhjm
, cfbyhjm
, fixedbyhjm
, floatbyhjm
, optbndbyhjm
, rangefloatbyhjm
, swapbyhjm
,
and swaptionbyhjm
. A similarly
named set of functions exists for BDT models. You can also use these
functions directly to calculate the price of sets of instruments of
the same type.
Consider the following example, which uses the portfolio and
interest-rate data in the MAT-file deriv.mat
included
in the toolbox. Load the data into the MATLAB^{®} workspace.
load deriv.mat
Use the MATLAB whos
command
to display a list of the variables loaded from the MAT-file.
whos
Name Size Bytes Class Attributes BDTInstSet 1x1 15956 struct BDTTree 1x1 5138 struct BKInstSet 1x1 15946 struct BKTree 1x1 5904 struct CRRInstSet 1x1 12434 struct CRRTree 1x1 5058 struct EQPInstSet 1x1 12434 struct EQPTree 1x1 5058 struct HJMInstSet 1x1 15948 struct HJMTree 1x1 5838 struct HWInstSet 1x1 15946 struct HWTree 1x1 5904 struct ITTInstSet 1x1 12438 struct ITTTree 1x1 8862 struct ZeroInstSet 1x1 10282 struct ZeroRateSpec 1x1 1580 struct
HJMTree
and HJMInstSet
are
the input arguments required to call the function hjmprice
.
Use the function instdisp
to
examine the set of instruments contained in the variable HJMInstSet
.
instdisp(HJMInstSet) Index Type CouponRate Settle Maturity Period Basis EndMonthRule IssueDate FirstCouponDate LastCouponDate StartDate Face Name Quantity 1 Bond 0.04 01-Jan-2000 01-Jan-2003 1 NaN NaN NaN NaN NaN NaN NaN 4% bond 100 2 Bond 0.04 01-Jan-2000 01-Jan-2004 2 NaN NaN NaN NaN NaN NaN NaN 4% bond 50 Index Type UnderInd OptSpec Strike ExerciseDates AmericanOpt Name Quantity 3 OptBond 2 call 101 01-Jan-2003 NaN Option 101 -50 Index Type CouponRate Settle Maturity FixedReset Basis Principal Name Quantity 4 Fixed 0.04 01-Jan-2000 01-Jan-2003 1 NaN NaN 4% Fixed 80 Index Type Spread Settle Maturity FloatReset Basis Principal Name Quantity 5 Float 20 01-Jan-2000 01-Jan-2003 1 NaN NaN 20BP Float 8 Index Type Strike Settle Maturity CapReset Basis Principal Name Quantity 6 Cap 0.03 01-Jan-2000 01-Jan-2004 1 NaN NaN 3% Cap 30 Index Type Strike Settle Maturity FloorReset Basis Principal Name Quantity 7 Floor 0.03 01-Jan-2000 01-Jan-2004 1 NaN NaN 3% Floor 40 Index Type LegRate Settle Maturity LegReset Basis Principal LegType Name Quantity 8 Swap [0.06 20] 01-Jan-2000 01-Jan-2003 [1 1] NaN NaN [NaN] 6%/20BP Swap 10 Index Type CouponRate Settle Maturity Period Basis ... Name Quantity 1 Bond 0.04 01-Jan-2000 01-Jan-2003 1 NaN ... 4% bond 100 2 Bond 0.04 01-Jan-2000 01-Jan-2004 2 NaN ... 4% bond 50 |
There are eight instruments in this portfolio set: two bonds,
one bond option, one fixed-rate note, one floating-rate note, one
cap, one floor, and one swap. Each instrument has a corresponding
index that identifies the instrument prices in the price vector returned
by hjmprice
.
Now use hjmprice
to calculate
the price of each instrument in the instrument set.
Price = hjmprice(HJMTree, HJMInstSet)
Warning: Not all cash flows are aligned with the tree. Result will be approximated. Price = 98.7159 97.5280 0.0486 98.7159 100.5529 6.2831 0.0486 3.6923
Note The warning shown above appears because some of the cash flows for the second bond do not fall exactly on a tree node. |
Load the MAT-file deriv.mat
into the MATLAB workspace.
load deriv.mat
Use the MATLAB whos
command
to display a list of the variables loaded from the MAT-file.
whos
Name Size Bytes Class Attributes BDTInstSet 1x1 15956 struct BDTTree 1x1 5138 struct BKInstSet 1x1 15946 struct BKTree 1x1 5904 struct CRRInstSet 1x1 12434 struct CRRTree 1x1 5058 struct EQPInstSet 1x1 12434 struct EQPTree 1x1 5058 struct HJMInstSet 1x1 15948 struct HJMTree 1x1 5838 struct HWInstSet 1x1 15946 struct HWTree 1x1 5904 struct ITTInstSet 1x1 12438 struct ITTTree 1x1 8862 struct ZeroInstSet 1x1 10282 struct ZeroRateSpec 1x1 1580 struct
BDTTree
and BDTInstSet
are
the input arguments required to call the function bdtprice
.
Use the function instdisp
to
examine the set of instruments contained in the variable BDTInstSet
.
instdisp(BDTInstSet) Index Type CouponRate Settle Maturity Period Basis EndMonthRule IssueDate FirstCouponDate LastCouponDate StartDate Face Name Quantity 1 Bond 0.1 01-Jan-2000 01-Jan-2003 1 NaN NaN NaN NaN NaN NaN NaN 10% Bond 100 2 Bond 0.1 01-Jan-2000 01-Jan-2004 2 NaN NaN NaN NaN NaN NaN NaN 10% Bond 50 Index Type UnderInd OptSpec Strike ExerciseDates AmericanOpt Name Quantity 3 OptBond 1 call 95 01-Jan-2002 NaN Option 95 -50 Index Type CouponRate Settle Maturity FixedReset Basis Principal Name Quantity 4 Fixed 0.1 01-Jan-2000 01-Jan-2003 1 NaN NaN 10% Fixed 80 Index Type Spread Settle Maturity FloatReset Basis Principal Name Quantity 5 Float 20 01-Jan-2000 01-Jan-2003 1 NaN NaN 20BP Float 8 Index Type Strike Settle Maturity CapReset Basis Principal Name Quantity 6 Cap 0.15 01-Jan-2000 01-Jan-2004 1 NaN NaN 15% Cap 30 Index Type Strike Settle Maturity FloorReset Basis Principal Name Quantity 7 Floor 0.09 01-Jan-2000 01-Jan-2004 1 NaN NaN 9% Floor 40 Index Type LegRate Settle Maturity LegReset Basis Principal LegType Name Quantity 8 Swap [0.15 10] 01-Jan-2000 01-Jan-2003 [1 1] NaN NaN [NaN] 15%/10BP Swap 10 |
There are eight instruments in this portfolio set: two bonds,
one bond option, one fixed-rate note, one floating-rate note, one
cap, one floor, and one swap. Each instrument has a corresponding
index that identifies the instrument prices in the price vector returned
by bdtprice
.
Now use bdtprice
to calculate
the price of each instrument in the instrument set.
Price = bdtprice(BDTTree, BDTInstSet)
Warning: Not all cash flows are aligned with the tree. Result will be approximated. Price = 95.5030 93.9079 1.7657 95.5030 100.4865 1.4863 0.0245 7.4222
The prices in the output vector Price
correspond
to the prices
at observation time zero (tObs = 0)
,
which is defined as the valuation date of the interest-rate tree.
The instrument indexing within Price
is
the same as the indexing within InstSet
.
In the HJM example, the prices in the Price
vector
correspond to the instruments in this order.
InstNames = instget(HJMInstSet, 'FieldName','Name')
InstNames = 4% bond 4% bond Option 101 4% Fixed 20BP Float 3% Cap 3% Floor 6%/20BP Swap
So, in the Price
vector, the fourth element,
98.7159, represents the price of the fourth instrument (4% fixed-rate
note); the sixth element, 6.2831, represents the price of the sixth
instrument (3% cap).
In the BDT example, the prices in the Price
vector
correspond to the instruments in this order.
InstNames = instget(BDTInstSet, 'FieldName','Name')
InstNames = 10% Bond 10% Bond Option 95 10% Fixed 20BP Float 15% Cap 9% Floor 15%/10BP Swap
So, in the Price
vector, the fourth element,
95.5030, represents the price of the fourth instrument (10% fixed-rate
note); the sixth element, 1.4863, represents the price of the sixth
instrument (15% cap).
If you call a pricing function with two output arguments, for example,
[Price, PriceTree] = hjmprice(HJMTree, HJMInstSet)
you generate a price tree along with the price information.
The optional output price tree structure PriceTree
holds
all the pricing information.
HJM Price Tree. In the HJM example, the first field of this structure, FinObj
,
indicates that this structure represents a price tree. The second
field, PBush
, is the tree holding the price of
the instruments in each node of the tree. The third field, AIBush
,
is the tree holding the accrued interest of the instruments in each
node of the tree. Finally, the fourth field, tObs
,
represents the observation time of each level of PBush
and AIBush
,
with units in terms of compounding periods.
In this example, the price tree looks like
PriceTree =
FinObj: 'HJMPriceTree' PBush: {[8x1 double] [8x1x2 double] ...[8x8 double]} AIBush: {[8x1 double] [8x1x2 double] ... [8x8 double]} tObs: [0 1 2 3 4]
Both PBush
and AIBush
are 1
-by-5
cell
arrays, consistent with the five observation times of tObs
.
The data display has been shortened here to fit on a single line.
Using the command-line interface, you can directly examine PriceTree.PBush
,
the field within the PriceTree
structure that contains
the price tree with the price vectors at every state. The first node
represents tObs = 0
, corresponding to the valuation
date.
PriceTree.PBush{1}
ans = 98.7159 97.5280 0.0486 98.7159 100.5529 6.2831 0.0486 3.6923
With this interface, you can observe the prices for all instruments in the portfolio at a specific time.
BDT Price Tree. The BDT output price tree structure PriceTree
holds
all the pricing information. The first field of this structure, FinObj
,
indicates that this structure represents a price tree. The second
field, PTree
, is the tree holding the price of
the instruments in each node of the tree. The third field, AITree
,
is the tree holding the accrued interest of the instruments in each
node of the tree. The fourth field, tObs
, represents
the observation time of each level of PTree
and AITree
,
with units in terms of compounding periods.
You can directly examine the field within the PriceTree
structure,
which contains the price tree with the price vectors at every state.
The first node represents tObs = 0
,
corresponding to the valuation date.
[Price, PriceTree] = bdtprice(BDTTree, BDTInstSet) PriceTree.PTree{1}
ans = 95.5030 93.9079 1.7657 95.5030 100.4865 1.4863 0.0245 7.4222
bdtprice
| bdtsens
| bdttimespec
| bdttree
| bdtvolspec
| bkprice
| bksens
| bktimespec
| bktree
| bkvolspec
| bondbybdt
| bondbybk
| bondbyhjm
| bondbyhw
| bondbyzero
| capbybdt
| capbybk
| capbyblk
| capbyhjm
| capbyhw
| cfbybdt
| cfbybk
| cfbyhjm
| cfbyhw
| cfbyzero
| fixedbybdt
| fixedbybk
| fixedbyhjm
| fixedbyhw
| fixedbyzero
| floatbybdt
| floatbybk
| floatbyhjm
| floatbyhw
| floatbyzero
| floatdiscmargin
| floatmargin
| floorbybdt
| floorbybk
| floorbyblk
| floorbyhjm
| floorbyhw
| hjmprice
| hjmsens
| hjmtimespec
| hjmtree
| hjmvolspec
| hwcalbycap
| hwcalbyfloor
| hwprice
| hwsens
| hwtimespec
| hwtree
| hwvolspec
| instbond
| instcap
| instcf
| instfixed
| instfloat
| instfloor
| instoptbnd
| instoptembnd
| instoptemfloat
| instoptfloat
| instrangefloat
| instswap
| instswaption
| intenvprice
| intenvsens
| intenvset
| mmktbybdt
| mmktbyhjm
| oasbybdt
| oasbybk
| oasbyhjm
| oasbyhw
| optbndbybdt
| optbndbybk
| optbndbyhjm
| optbndbyhw
| optembndbybdt
| optembndbybk
| optembndbyhjm
| optembndbyhw
| optemfloatbybdt
| optemfloatbybk
| optemfloatbyhjm
| optemfloatbyhw
| optfloatbybdt
| optfloatbybk
| optfloatbyhjm
| optfloatbyhw
| rangefloatbybdt
| rangefloatbybk
| rangefloatbyhjm
| rangefloatbyhw
| swapbybdt
| swapbybk
| swapbyhjm
| swapbyhw
| swapbyzero
| swaptionbybdt
| swaptionbybk
| swaptionbyblk
| swaptionbyhjm
| swaptionbyhw