Financial Derivatives Toolbox | ![]() ![]() |
Using BDT Trees in MATLAB
When working with the BDT model, the Financial Derivatives Toolbox uses trees to represent interest rates, prices, etc. At the highest level, these trees contain several MATLAB structures. The structures encapsulate information needed to interpret completely the information contained in a tree.
Because BDT trees are essentially MATLAB structures, you can examine their contents manually, just as you can for HJM trees. Consider this example, which uses the data in the MAT-file deriv.mat
included in the toolbox.
Load the data into the MATLAB workspace.
Display the list of the variables loaded from the MAT-file.
whos
Name Size Bytes Class
BDTInstSet 1x1 22708 struct array BDTTree 1x1 5522 struct array HJMInstSet 1x1 22700 struct array HJMTree 1x1 6318 struct array ZeroInstSet 1x1 14442 struct array ZeroRateSpec 1x1 1580 struct array
Structure of a BDT Tree
You can now examine in some detail the contents of the BDTTree structure.
BDTTree BDTTree = FinObj: 'BDTFwdTree' VolSpec: [1x1 struct] TimeSpec: [1x1 struct] RateSpec: [1x1 struct] tObs: [0 1 2 3] TFwd: {[4x1 double] [3x1 double] [2x1 double] [3]} CFlowT: {[4x1 double] [3x1 double] [2x1 double] [4]} FwdTree: {1x4 cell}
FwdTree
contains the actual rate tree. It is represented in MATLAB as a cell array with each cell array element containing a tree level.
The other fields contain other information relevant to interpreting the values in FwdTree
. The most important of these are VolSpec
, TimeSpec
, and RateSpec
, which contain the volatility, rate structure, and time structure information respectively.
Look at the RateSpec
structure used in generating this tree to see where these values originate. Arrange the values in a single array.
[BDTTree.RateSpec.StartTimes BDTTree.RateSpec.EndTimes... BDTTree.RateSpec.Rates] ans = 0 1.0000 0.1000 0 2.0000 0.1100 0 3.0000 0.1200 0 4.0000 0.1250
Look at the rates in FwdTree
. The first node represents the valuation date, tObs = 0
. The second node represents tObs = 1
. Examine the rates at the second, third and fourth nodes.
The second node represents the first observation time, tObs = 1
. This node contains a total of two states, one representing the branch going up (1.0979
) and the other representing the branch going down (1.1432
).
Note The convention in this document is to display prices going up on the upper branch. Consequently, when displaying rates, rates are falling on the upper branch and increasing on the lower. |
The third node represents the second observation time, tObs = 2
. This node contains a total of three states, one representing the branch going up (1.0976
), one representing the branch in the middle (1.1377
) and the other representing the branch going down (1.1942
).
The fourth node represents the third observation time, tObs = 3
. This node contains a total of four states, one representing the branch going up (1.0872
), two representing the branches in the middle (1.1183
and 1.1606
) and the other representing the branch going down (1.2179
).
Verifying Results with treepath
The function treepath
isolates a specific node by specifying the path to the node as a vector of branches taken to reach that node. As an example, consider the node reached by starting from the root node, taking the branch up, then the branch down, and finally another branch down. Given that the tree has only two branches per node, branches going up correspond to a 1, and branches going down correspond to a 2. The path up-down-down becomes the vector [1 2 2]
.
treepath
returns the short rates for all the nodes touched by the path specified in the input argument, the first one corresponding to the root node, and the last one corresponding to the target node.
Graphical View of Interest Rate Tree
The function treeviewer
provides a graphical view of the path of interest rates specified in BDTTree
. For example, load the file deriv.mat
. Here is a treeviewer
representation of the rates along several branches of BDTTree
.
A previous example used treepath
to find the path of interest rates taking the first branch up and then two branches down the rate tree.
The treeviewer
function displays the same information obtained by clicking along the sequence of nodes, as shown next.
![]() | Black-Derman-Toy Model (BDT) | Pricing and Sensitivity from BDT | ![]() |