treeviewer

Tree information

Description

example

treeviewer(Tree)displays an interest rate tree, stock price tree, or money-market tree.

example

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 fieldName,treeviewerdisplay identifies the instrument being displayed with its name. (SeeExample 3for a description.) If you do not provide the optionalInstSetinput argument, the instruments are identified by their sequence number in the instrument set. (SeeExample 6for a description.)

example

treeviewer(CFTree,InstSet)displays a cash flow tree that has been created withswapbybdtorswapbyhjm. If you provide the name of an instrument set (InstSet) containing cash flow names, thetreeviewerdisplay identifies the instrument being displayed with its name. (SeeExample 3for a description.) If the optionalInstSetargument is not present, the instruments are identified by their sequence number in the instrument set. SeeExample 6for a description.)

Examples

Display an HJM Interest-Rate Tree

loadderiv.mattreeviewer(HJMTree)

Thetreeviewer功能显示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 theTree Visualizationpane and clickPath(the default) andDiagram. Now, select the first path by clicking the last node (t = 3) of the upper branch.

The entire upper path is highlighted in red.

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

Alternative Forms of Display

TheTree Visualizationpane allows you to select alternative ways to display tree data. For example, if you selectPathandTableas your visualization choices, the final display above instead appears in tabular form.

To see a plot of interest rates along the chosen branches, clickPathandPlotin theTree Visualizationpane.

WithPlotselected, rising interest rates are shown on the upper branch and declining interest rates on the lower.

Finally, if you clickedNode and ChildrenunderTree Visualization, you restrict the data displayed to just the selected parent node and its children.

WithNode and Childrenselected, the choices underVisualizationare unavailable.

Display a BDT Interest-Rate Tree

load deriv.mat treeviewer(BDTTree)

Thetreeviewer功能显示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 theTree Visualizationpane and clickPath(the default) andDiagram. Now, select the first path by clicking 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. 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. The second branch is highlighted in purple. The final display looks like this.

Display an HJM Price Tree for Named Instruments

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

Display a BDT Price Tree for Named Instruments

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

Display an HJM Price Tree with Renamed Instruments

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

Display an HJM Price Tree Using Default Instrument Names (Numbers)

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

Input Arguments

collapse all

Interest-rate tree, stock price tree, or money-market tree, specified using the associated tree function.

Interest-rate trees:

  • Black-Derman-Toy (BDTTree) obtained frombdttree

  • Black-Karasinski (BKTree) obtained frombktree

  • Heath-Jarrow-Morton (HJMTree) obtained fromhjmtree

  • Hull-White (HWTree) obtained fromhwtree

  • Cox-Ingersoll-Ross (CIRTree) obtained fromcirtree

Money market trees:

  • Black-Derman-Toy (BDTMMktTree) obtained frommmktbybdtfor a money-market tree from a BDT interest-rate tree.

  • Heath-Jarrow-Morton (HJMMMktTree) obtained frommmktbyhjmfor a money-market tree from an HJM interest-rate tree.

    Note

    Money market trees cannot be created from BK or HW interest-rate trees.

Stock price trees:

  • Cox-Ross-Rubinstein (CRRTree) obtained fromcrrtree

  • Implied Trinomial tree (ITTTree) obtained fromitttree

  • Standard Trinomial tree (STTTree) obtained fromstttree

  • Leisen-Reimer stock tree (LRTree) obtained fromlrtree

  • Equal probabilities (EQPTree) obtained fromeqptree

Cash flow trees:

  • Black-Derman-Toy (BDTCFTree) obtained as output from the swap functionswapbybdt

  • Heath-Jarrow-Morton (HJMCFTree) obtained as output from the swap functionswapbyhjm

    Note

    For the functionswapbybdt, which uses a recombining binomial tree, this structure contains onlyNaNs because cash flows cannot be accurately calculated at every tree node for floating-rate notes.

Data Types:struct

Tree structure of instrument prices, specified as:

  • Black-Derman-Toy (BDTPriceTree) obtained from the portfolio functionbdtpriceor the individual functions, such asbondbybdt,capbybdt, and so on.

  • Black-Karasinski (BKPriceTree) obtained from the portfolio functionbkpriceor the individual functions, such asbondbybk,capbybk, and so on.

  • Cox-Ingersoll-Ross (CIRPriceTree) obtained from the portfolio functioncirpriceor the individual functions, such asbondbycir,capbycir, and so on.

  • Heath-Jarrow-Morton (HJMPriceTree) obtained from the portfolio functionhjmpriceor the individual functions, such asbondbyhjm,capbyhjm, and so on.

  • Hull-White (HWPriceTree) obtained from the portfolio functionhwpriceor the individual functions, such asbondbyhw,capbyhw, and so on.

  • Leisen-Reimer (LRPriceTree) obtained from the individual functionoptstockbylr.

  • Cox-Ross-Rubinstein (CRRPriceTree) obtained from the portfolio functioncrrpriceor the individual functions, such asasianbycrr,barrierbycrr, and so on.

  • Equal probabilities (EQPPriceTree) obtained from the portfolio functioneqppriceor the individual functions, such asasianbyeqp,barrierbyeqp, and so on.

  • Implied Trinomial tree (ITTPriceTree) obtained from the portfolio functionittpriceor the individual functions, such asasianbyitt,barrierbyitt, and so on.

  • Standard trinomial tree (STTPriceTree) obtained from the portfolio functionsttpriceor the individual functions, such asasianbystt,barrierbystt, and so on.

Data Types:struct

CFTreeis a tree of swap cash flows, specified when you create cash flow trees by executing the Black-Derman-Toy (obtained as output from the swap functionswapbybdt) and Heath-Jarrow-Morton (swapbyhjm) swap functions. (Black-Derman-Toy cash flow trees contain onlyNaNs.)

Data Types:struct

(Optional) Variable containing a collection of instruments whose prices or cash flows are contained in a tree, specified usinginstadd. To display the names of the instruments, the fieldNameshould exist inInstSet. IfInstSetis not passed,treevieweruses default instruments names (numbers) when displaying prices or cash flows.

Data Types:struct

More About

collapse all

Treeviewer Conventions

treeviewerprice tree diagrams follow the convention that increasing prices appear on the upper branch of a tree and, so, decreasing prices appear on the lower branch.

Conversely, for interest rate displays,decreasinginterest rates appear on the upper branch (prices are rising) andincreasinginterest rates on the lower branch (prices are falling).

Using Treeviewer

treeviewerprovides an interactive display of prices or interest rates.

Thetreeviewerdisplay 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, andtreeviewerdisplays all data from beginning to end.

  • With recombining trees, such as BDT, BK, HW, and CIR you must clickeachnode in succession from the beginning (t = 1) to the last node (t = n). Do not include theroot node,node att = 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.

Note

TheHelp按钮是不available fortreeviewerin MATLAB Online.

Introduced before R2006a