Products & Services Solutions Academia Support User Community Company

Learn more about Financial Derivatives Toolbox   

Graphical Representation of Trees

Introduction

You can use the function treeviewer to display a graphical representation of a tree, allowing you to examine interactively the prices and rates on the nodes of the tree until maturity. To get started with this process, first load the data file deriv.mat included in this toolbox.

load deriv.mat

For information on the use of treeviewer to observe interest rate movement, see Observing Interest Rates. For information on using treeviewer to observe the movement of prices, see Observing Instrument Prices.

Observing Interest Rates

If you provide the name of an interest rate tree to the treeviewer function, it displays a graphical view of the path of interest rates. For example, here is the treeviewer representation of all the rates along both the up and down branches of HJMTree.

treeviewer(HJMTree)

treeviewer diagram of the HJM interest rate tree

The example in Isolating a Specific Node for a CRRTree used bushpath to find the path of forward rates along an HJM tree by taking the first branch up and then two branches down the rate tree.

FRates = bushpath(HJMTree.FwdTree, [1 2 2])

FRates =

    1.0356
    1.0364
    1.0526
    1.0674

With the treeviewer function you can display the identical information by clicking along the same sequence of nodes, as shown next.

treeviewer diagram showing same rates as bushpath

Next is a treeviewer representation of interest rates along several branches of BDTTree.

treeviewer(BDTTree)

treeviewer diagram of BDT interest rate tree

The example in Isolating a Specific Node for a CRRTree used treepath to find the path of interest rates taking the first branch up and then two branches down the rate tree.

FRates = treepath(BDTTree.FwdTree, [1 2 2])

FRates =

    1.1000
    1.0979
    1.1377
    1.1606

You can display the identical information by clicking along the same sequence of nodes, as shown next.

treeviewer diagram showing same rates as treepath

Observing Instrument Prices

To use treeviewer to display a tree of instrument prices, provide the name of an instrument set along with the name of a price tree in your call to treeviewer, for example:

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

With treeviewer you select each instrument individually in the instrument portfolio for display.

treeviewer diagram showing all instruments in the HJM instrument set

You can use an analogous process to view instrument prices based on the BDT interest rate tree included in deriv.mat.

load deriv.mat
[BDTPrice, BDTPriceTree] = bdtprice(BDTTree, BDTInstSet);
treeviewer(BDTPriceTree, BDTInstSet)

treeviewer diagram showing all instruments in the BDT instrument set

Valuation Date Prices

You can use treeviewer instrument-by-instrument to observe instrument prices through time. For the first 4% bond in the HJM instrument portfolio, treeviewer indicates a valuation date price of 98.72, the same value obtained by accessing the PriceTree structure directly.

treeviewer diagram showing detail at first node

As a further example, look at the sixth instrument in the price vector, the 3% cap. At the valuation date, its value obtained directly from the structure is 6.2831. Use treeviewer on this instrument to confirm this price.

treeviewer diagram showing first value to be 6.28

Additional Observation Times

The second node represents the first-rate observation time, tObs = 1. This node displays two states, one representing the branch going up and the other one representing the branch going down.

Examine the prices of the node corresponding to the up branch.

PriceTree.PBush{2}(:,:,1)

ans =

  100.1563
   99.7309
    0.1007
  100.1563
  100.3782
    3.2594
    0.1007
    3.5597

As before, you can use treeviewer, this time to examine the price for the 4% bond on the up branch. treeviewer displays a price of 100.2 for the first node of the up branch, as expected.

treeviewer diagram showing value of 100.2 for t = 1 on the upper branch

Now examine the corresponding down branch.

PriceTree.PBush{2}(:,:,2)

ans =

   96.3041
   94.1986
         0
   96.3041
  100.3671
    8.6342
         0
   -0.3923

Use treeviewer once again, now to observe the price of the 4% bond on the down branch. The displayed price of 96.3 conforms to the price obtained from direct access of the PriceTree structure. You may continue this process as far along the price tree as you want.

treeviewer diagram showing value of 96.3 for t = 1 on the lower branch

  


Free Interactive Computational Finance CD

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