| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Financial Derivatives Toolbox |
| Contents | Index |
| Learn more about Financial Derivatives Toolbox |
treeviewer(Tree)
treeviewer(PriceTree, InstSet)
treeviewer(CFTree, InstSet)
Tree | Tree can be any of the following types of trees. Interest-rate trees:
|
Stock price trees:
Cash flow trees: | |
PriceTree | PriceTree is a Black-Derman-Toy (BDTPriceTree), Black-Karasinski (BKPriceTree), Heath-Jarrow-Morton (HJMPriceTree), Hull-White (HWPriceTree), Cox-Ross-Rubinstein (crrprice), Equal probabilities (eqpprice), or Implied Trinomial tree (ittprice) tree of instrument prices. |
CFTree | CFTree is a tree of swap cash flows. You create cash flow trees when executing the Black-Derman-Toy and Heath-Jarrow-Morton swap functions. (Black-Derman-Toy cash flow trees contain only NaNs.) |
InstSet | (Optional) Variable containing a collection of instruments whose prices or cash flows are contained in a tree. The collection can be created with the function instadd or as a cell array containing the names of the instruments. To display the names of the instruments, the field Name should exist in InstSet. If InstSet is not passed, treeviewer uses default instruments names (numbers) when displaying prices or cash flows. |
treeviewer(Tree) displays an interest rate, stock price, or money-market tree.
treeviewer(PriceTree, InstSet) displays a tree of instrument prices. If you provide the name of an instrument set (InstSet) and you have named the instruments using the field Name, the treeviewer display identifies the instrument being displayed with its name. (See Example 3 for a description.) If you do not provide the optional InstSet argument, the instruments are identified by their sequence number in the instrument set. (See Example 6 for a description.)
treeviewer(CFTree, InstSet) displays a cash flow tree that has been created with swapbybdt or swapbyhjm. If you provide the name of an instrument set (InstSet) containing cash flow names, the treeviewer display identifies the instrument being displayed with its name. (See Example 3 for a description.) If the optional InstSet argument is not present, the instruments are identified by their sequence number in the instrument set. See Example 6 for a description.)
treeviewer price tree diagrams follow the convention that increasing prices appear on the upper branch of a tree and, consequently, decreasing prices appear on the lower branch. Conversely, for interest rate displays, decreasing interest rates appear on the upper branch (prices are rising) and increasing interest rates on the lower branch (prices are falling).
treeviewer provides an interactive display of prices or interest rates. The display is activated by clicking the nodes along the price or interest rate path shown in the left pane when the function is called. For HJM trees you select the endpoints of the path, and treeviewer displays all data from beginning to end. With recombining trees, such as BDT, BK and HW, you must click each node in succession from the beginning (t = 1) to the last node (t = n). Do not include the root node, the node at t = 0. If you do not click the nodes in the proper order, you are reminded with the message
Parent of selected node must be selected.
load deriv.mat treeviewer(HJMTree)
The treeviewer function displays the structure of an HJM tree in the left pane. The tree visualization in the right pane is blank.

To visualize the actual interest-rate tree, go to the Tree Visualization pane and click on Path (the default) and Diagram. Now, select the first path by clicking on the last node (t = 3) of the upper branch.

Note that the entire upper path is highlighted in red.
To complete the process, select a second path by clicking on the last node (t = 3) of another branch. The second path is highlighted in purple. The final display looks like this.

The Tree Visualization pane allows you to select alternative ways to display tree data. For example, if you select Path and Table as your visualization choices, the final display above instead appears in tabular form.

To see a plot of interest rates along the chosen branches, click Path and Plot in the Tree Visualization pane.

Note that with Plot selected, rising interest rates are shown on the upper branch and declining interest rates on the lower.
Finally, if you clicked Node and Children under Tree Visualization, you restrict the data displayed to just the selected parent node and its children.

With Node and Children selected, the choices under Visualization are unavailable.
load deriv.mat treeviewer(BDTTree)
The treeviewer function displays the structure of a BDT tree in the left pane. The tree visualization in the right pane is blank.

To visualize the actual interest-rate tree, go to the Tree Visualization pane and click Path (the default) and Diagram. Now, select the first path by clicking on the first node of the up branch (t = 1). Continue by clicking the down branch at the next node (t = 2). The two figures below show the treeviewer path diagrams for these selections.

Continue clicking all nodes in succession until you reach the end of the branch. Note that the entire path you have selected is highlighted in red.
Select a second path by clicking the first node of the lower branch (t = 1). Continue clicking lower nodes as you did on the first branch. Note that the second branch is highlighted in purple. The final display looks like this.

load deriv.mat [Price, PriceTree] = hjmprice(HJMTree, HJMInstSet); treeviewer(PriceTree, HJMInstSet)

load deriv.mat [Price, PriceTree] = bdtprice(BDTTree, BDTInstSet); treeviewer(PriceTree, BDTInstSet)

load deriv.mat
[Price, PriceTree] = hjmprice(HJMTree, HJMInstSet);
Names = {'Bond1', 'Bond2', 'Option', 'Fixed','Float', 'Cap',...
'Floor', 'Swap'};
treeviewer(PriceTree, Names)

load deriv.mat [Price, PriceTree] = hjmprice(HJMTree, HJMInstSet); treeviewer(PriceTree)

bdttree, bktree, crrtree, eqptreehjmtree, hwtree, instadd, itttreemmktbybdt, mmktbyhjm, swapbybdt, swapbyhjm
![]() | treeshape | trintreepath | ![]() |
View demos and recorded presentations led by industry experts.
Now On Demand
Network with industry peers and learn the latest applications of the leading software product for computational finance.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |