Finance - Maple Programming Help

Home : Support : Online Help : Mathematics : Finance : Lattice Methods : Finance/TreePlot

Finance

 TreePlot
 plot a binomial/trinomial tree

 Calling Sequence TreePlot(tree, opts, plotopts)

Parameters

 tree - binomial or trinomial tree data structure; tree opts - (optional) equation(s) of the form option = value where option is scale; specify options for the TreePlot command plotopts - (optional) options to be passed to the plots[display] command

Options

 • scale = default, exponential, or logarithmic -- This option specifies whether the tree should be plotted using the exponential, logarithmic, or the default scale.

Description

 • The TreePlot command plots the specified binomial/trinomial tree.
 • The tree is displayed using the plots[display] command. All unprocessed arguments are interpreted as plot options and will be passed to the plots[display] command when the final plot data structure is generated.

Examples

 > $\mathrm{with}\left(\mathrm{Finance}\right):$

Construct a Cox-Ross-Rubinstein binomial tree.

 > $\mathrm{S0}≔100$
 ${\mathrm{S0}}{≔}{100}$ (1)
 > $r≔0.05$
 ${r}{≔}{0.05}$ (2)
 > $\mathrm{\sigma }≔0.3$
 ${\mathrm{\sigma }}{≔}{0.3}$ (3)
 > $T≔3.0$
 ${T}{≔}{3.0}$ (4)
 > $N≔20$
 ${N}{≔}{20}$ (5)
 > $\mathrm{Su}≔\mathrm{exp}\left(\mathrm{\sigma }\mathrm{sqrt}\left(\frac{T}{N}\right)\right)$
 ${\mathrm{Su}}{≔}{1.123208700}$ (6)
 > $\mathrm{Sd}≔\mathrm{exp}\left(-\mathrm{\sigma }\mathrm{sqrt}\left(\frac{T}{N}\right)\right)$
 ${\mathrm{Sd}}{≔}{0.8903064939}$ (7)
 > $\mathrm{Pu}≔\frac{\mathrm{exp}\left(\frac{rT}{N}\right)-\mathrm{Sd}}{\mathrm{Su}-\mathrm{Sd}}$
 ${\mathrm{Pu}}{≔}{0.5033086765}$ (8)
 > $\mathrm{Tree}≔\mathrm{BinomialTree}\left(T,N,\mathrm{S0},\mathrm{Su},\mathrm{Pu},\mathrm{Sd}\right)$
 ${\mathrm{Tree}}{:=}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (9)
 > $\mathrm{TreePlot}\left(\mathrm{Tree},\mathrm{thickness}=2,\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true}\right)$
 > $\mathrm{TreePlot}\left(\mathrm{Tree},\mathrm{thickness}=2,\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true},\mathrm{scale}=\mathrm{logarithmic}\right)$

Here is a Jarrow-Rudd tree approximating the same process.

 > $\mathrm{Su}≔\mathrm{exp}\left(\frac{\left(r-\frac{{\mathrm{\sigma }}^{2}}{2}\right)T}{N}+\mathrm{\sigma }\mathrm{sqrt}\left(\frac{T}{N}\right)\right)$
 ${\mathrm{Su}}{≔}{1.124051423}$ (10)
 > $\mathrm{Sd}≔\mathrm{exp}\left(\frac{\left(r-\frac{{\mathrm{\sigma }}^{2}}{2}\right)T}{N}-\mathrm{\sigma }\mathrm{sqrt}\left(\frac{T}{N}\right)\right)$
 ${\mathrm{Sd}}{≔}{0.8909744742}$ (11)
 > $\mathrm{Pu}≔0.5$
 ${\mathrm{Pu}}{≔}{0.5}$ (12)
 > $\mathrm{Tree2}≔\mathrm{BinomialTree}\left(T,N,\mathrm{S0},\mathrm{Su},\mathrm{Pu},\mathrm{Sd}\right)$
 ${\mathrm{Tree2}}{:=}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (13)
 > $\mathrm{TreePlot}\left(\mathrm{Tree2},\mathrm{thickness}=2,\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true}\right)$
 > $\mathrm{TreePlot}\left(\mathrm{Tree2},\mathrm{thickness}=2,\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true},\mathrm{scale}=\mathrm{logarithmic}\right)$

Here is a trinomial tree obtained by combining two steps of the Jarrow-Rudd tree.

 > $\mathrm{Su}≔\mathrm{exp}\left(\frac{\left(r-\frac{{\mathrm{\sigma }}^{2}}{2}\right)\cdot 2T}{N}+2\mathrm{\sigma }\mathrm{sqrt}\left(\frac{T}{N}\right)\right)$
 ${\mathrm{Su}}{≔}{1.263491601}$ (14)
 > $\mathrm{Sd}≔\mathrm{exp}\left(\frac{\left(r-\frac{{\mathrm{\sigma }}^{2}}{2}\right)\cdot 2T}{N}-2\mathrm{\sigma }\mathrm{sqrt}\left(\frac{T}{N}\right)\right)$
 ${\mathrm{Sd}}{≔}{0.7938355137}$ (15)
 > $\mathrm{Pu}≔0.25$
 ${\mathrm{Pu}}{≔}{0.25}$ (16)
 > $\mathrm{Pd}≔0.25$
 ${\mathrm{Pd}}{≔}{0.25}$ (17)
 > $\mathrm{Tree3}≔\mathrm{TrinomialTree}\left(T,\frac{N}{2},\mathrm{S0},\mathrm{Su},\mathrm{Pu},\mathrm{Sd},\mathrm{Pd}\right)$
 ${\mathrm{Tree3}}{:=}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (18)
 > $\mathrm{TreePlot}\left(\mathrm{Tree3},\mathrm{thickness}=2,\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true}\right)$
 > $\mathrm{TreePlot}\left(\mathrm{Tree3},\mathrm{thickness}=2,\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true},\mathrm{scale}=\mathrm{logarithmic}\right)$
 > $\mathrm{plots}\left[\mathrm{display}\right]\left(\mathrm{TreePlot}\left(\mathrm{Tree2},\mathrm{color}=\mathrm{red}\right),\mathrm{TreePlot}\left(\mathrm{Tree3},\mathrm{transparency}=0.3\right),\mathrm{axes}=\mathrm{boxed},\mathrm{thickness}=2,\mathrm{gridlines}\right)$

The following is a tree created for a Cox-Ingersoll-Ross short rate model.

The command to create the plot from the Plotting Guide is

 > $M≔\mathrm{CoxIngersollRossModel}\left(\mathrm{ZeroCurve}\left(0.03\right),0.05,0.5,0.002,0.1\right)$
 ${M}{:=}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (19)
 > $T≔\mathrm{ShortRateTree}\left(M,3,15\right)$
 ${T}{:=}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (20)
 > $\mathrm{TreePlot}\left(T,\mathrm{axes}=\mathrm{boxed},\mathrm{thickness}=3,\mathrm{gridlines}=\mathrm{true},\mathrm{color}=\mathrm{cyan}..\mathrm{blue}\right)$

Compatibility

 • The Finance[TreePlot] command was introduced in Maple 15.