LatticePrice - Maple Help

Finance

 LatticePrice
 return the net present value of the given instruments computed using a binomial or trinomial tree

 Calling Sequence LatticePrice(instrument, model, discountrate, opts)

Parameters

 instrument - one-asset option, swaption, cap, floor, or collar data structure; financial instrument model - binomial or trinomial tree; tree approximation for the underlying stochastic process discountrate - non-negative constant or a yield term structure; discount rate opts - equations of the form option = value where option is one of referencedate or daycounter; specify options for the LatticePrice command

Options

 • daycounter =  a string containing a date specification in a format recognized by ParseDate or a Date data structure -- This option specifies a day counter or day counting convention.
 • referencedate =  a string containing a date specification in a format recognized by ParseDate or a Date data structure -- This option specifies the reference date, that is, the date when the discount factor is 1. By default this is set to the global evaluation date.

Description

 • The LatticePrice command computes the net present value of the specified financial instrument using the specified lattice approximation for the underlying stochastic process.
 • The parameter instrument is a financial instrument to be valued. At the present the following instruments are supported:
 – a one-asset option of the American, Bermudan, or European type (see AmericanOption, BermudanOption, or EuropeanOption)
 – a swaption of the American, Bermudan, or European type (see AmericanSwaption, BermudanSwaption, or EuropeanSwaption)
 – interest rate cap, floor, or collar (see Cap, Floor, or Collar)
 • The parameter model is a binomial or trinomial tree.
 • The parameter discountrate is the discount rate. It can be either a non-negative constant or a yield term structure. In the former case the reference date and the day count convention for the underlying term structure can be provided using the options daycounter and referencedate.
 • Note that all internal computations are performed at the hardware precision.

Examples

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

Set the global evaluation date to January 3, 2006.

 > $\mathrm{SetEvaluationDate}\left("January 3, 2006"\right):$
 > $\mathrm{Settings}\left(\mathrm{daycounter}=\mathrm{Thirty360European}\right):$

Construct a binomial tree approximating a Black-Scholes process with an initial value of 100, a risk-free rate of 10%, and constant volatility of 40%. Assume that no dividend is paid. Build the tree by subdividing the time period 0..0.6 into 1000 equal time steps.

 > $T≔\mathrm{BlackScholesBinomialTree}\left(100,0.1,0.,0.4,0.6,1000\right):$

Consider an American put option with a strike price of 100 that matures in 6 months.

 > $P≔S↦\mathrm{max}\left(100-S,0\right)$
 ${P}{≔}{S}{↦}{\mathrm{max}}{}\left({100}{-}{S}{,}{0}\right)$ (1)
 > $\mathrm{A1}≔\mathrm{AmericanOption}\left(P,0,0.5\right):$
 > $\mathrm{Maturity}≔\mathrm{AdvanceDate}\left(\mathrm{EvaluationDate}\left(\right),6,\mathrm{Months},\mathrm{output}=\mathrm{formatted}\right)$
 ${\mathrm{Maturity}}{≔}{"July 3, 2006"}$ (2)
 > $\mathrm{YearFraction}\left(\mathrm{Maturity}\right)$
 ${0.5000000000}$ (3)
 > $\mathrm{A2}≔\mathrm{AmericanOption}\left(P,\mathrm{EvaluationDate}\left(\right),\mathrm{Maturity}\right):$

Calculate the price of this option using the tree constructed above. Use the risk-free rate as the discount rate.

 > $\mathrm{LatticePrice}\left(\mathrm{A1},T,0.1\right)$
 ${9.220859736}$ (4)
 > $\mathrm{LatticePrice}\left(\mathrm{A2},T,0.1\right)$
 ${9.220859736}$ (5)

The next set of examples will demonstrate how to price American-style swaptions using Hull-White trinomial trees.

 > $\mathrm{SetEvaluationDate}\left("November 17, 2006"\right):$
 > $\mathrm{EvaluationDate}\left(\right)$
 ${"November 17, 2006"}$ (6)
 > $\mathrm{nominalamt}≔1000.0$
 ${\mathrm{nominalamt}}{≔}{1000.0}$ (7)
 > $\mathrm{fixing_days}≔2$
 ${\mathrm{fixing_days}}{≔}{2}$ (8)
 > $\mathrm{start}≔\mathrm{AdvanceDate}\left(1,\mathrm{Years},\mathrm{EURIBOR}\right)$
 ${\mathrm{start}}{≔}{"November 17, 2007"}$ (9)
 > $\mathrm{maturity}≔\mathrm{AdvanceDate}\left(\mathrm{start},5,\mathrm{Years},\mathrm{EURIBOR}\right)$
 ${\mathrm{maturity}}{≔}{"November 17, 2012"}$ (10)
 > $\mathrm{discount_curve}≔\mathrm{ForwardCurve}\left(0.04875825,'\mathrm{daycounter}'=\mathrm{Actual365Fixed}\right)$
 ${\mathrm{discount_curve}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (11)
 > $\mathrm{fixed_schedule}≔\mathrm{Schedule}\left(\mathrm{start},\mathrm{maturity},\mathrm{Annual},'\mathrm{convention}'=\mathrm{Unadjusted},'\mathrm{calendar}'=\mathrm{EURIBOR}\right)$
 ${\mathrm{fixed_schedule}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (12)
 > $\mathrm{floating_schedule}≔\mathrm{Schedule}\left(\mathrm{start},\mathrm{maturity},\mathrm{Semiannual},'\mathrm{convention}'=\mathrm{ModifiedFollowing},'\mathrm{calendar}'=\mathrm{EURIBOR}\right)$
 ${\mathrm{floating_schedule}}{≔}{\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{benchmark}≔\mathrm{BenchmarkRate}\left(6,\mathrm{Months},\mathrm{EURIBOR},0.04875825\right)$
 ${\mathrm{benchmark}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (14)

Construct an interest rate swap receiving the fixed-rate payments in exchange for the floating-rate payments.

 > $\mathrm{swap}≔\mathrm{InterestRateSwap}\left(\mathrm{nominalamt},0.,\mathrm{fixed_schedule},\mathrm{benchmark},\mathrm{floating_schedule},0.\right)$
 ${\mathrm{swap}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (15)

Compute the at-the-money rate for this interest rate swap.

 > $\mathrm{atm_rate}≔\mathrm{FairRate}\left(\mathrm{swap},\mathrm{discount_curve}\right)$
 ${\mathrm{atm_rate}}{≔}{0.04996048632}$ (16)

Construct three swaps.

 > $\mathrm{itm_swap}≔\mathrm{InterestRateSwap}\left(\mathrm{nominalamt},0.8\mathrm{atm_rate},\mathrm{fixed_schedule},\mathrm{benchmark},\mathrm{floating_schedule},0.\right)$
 ${\mathrm{itm_swap}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (17)
 > $\mathrm{atm_swap}≔\mathrm{InterestRateSwap}\left(\mathrm{nominalamt},1.0\mathrm{atm_rate},\mathrm{fixed_schedule},\mathrm{benchmark},\mathrm{floating_schedule},0.\right)$
 ${\mathrm{atm_swap}}{≔}{\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{otm_swap}≔\mathrm{InterestRateSwap}\left(\mathrm{nominalamt},1.2\mathrm{atm_rate},\mathrm{fixed_schedule},\mathrm{benchmark},\mathrm{floating_schedule},0.\right)$
 ${\mathrm{otm_swap}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (19)

Here are cash flows for the paying leg of our interest rate swap.

 > $\mathrm{cash_flows}≔\mathrm{CashFlows}\left(\mathrm{itm_swap},\mathrm{paying}\right)$
 ${\mathrm{cash_flows}}{≔}\left[{\mathrm{39.96838906 on \text{'}November 17, 2008\text{'}}}{,}{\mathrm{39.96838906 on \text{'}November 17, 2009\text{'}}}{,}{\mathrm{39.96838906 on \text{'}November 17, 2010\text{'}}}{,}{\mathrm{39.96838906 on \text{'}November 17, 2011\text{'}}}{,}{\mathrm{39.96838906 on \text{'}November 19, 2012\text{'}}}\right]$ (20)

Here are cash flows for the receiving leg of our interest rate swap.

 > $\mathrm{CashFlows}\left(\mathrm{itm_swap},\mathrm{receiving}\right)$
 $\left[{\mathrm{24.67872558 on \text{'}May 19, 2008\text{'}}}{,}{\mathrm{24.40119905 on \text{'}November 17, 2008\text{'}}}{,}{\mathrm{24.81751704 on \text{'}May 18, 2009\text{'}}}{,}{\mathrm{24.53995292 on \text{'}November 17, 2009\text{'}}}{,}{\mathrm{24.67872558 on \text{'}May 17, 2010\text{'}}}{,}{\mathrm{24.67872558 on \text{'}November 17, 2010\text{'}}}{,}{\mathrm{24.67872558 on \text{'}May 17, 2011\text{'}}}{,}{\mathrm{24.67872558 on \text{'}November 17, 2011\text{'}}}{,}{\mathrm{24.67872558 on \text{'}May 17, 2012\text{'}}}{,}{\mathrm{24.95632730 on \text{'}November 19, 2012\text{'}}}\right]$ (21)

These are the days when coupon payments are scheduled to occur.

 > $\mathrm{dates}≔\mathrm{map}\left(t↦t\left[\mathrm{date}\right],\mathrm{cash_flows}\right)$
 ${\mathrm{dates}}{≔}\left[{\mathrm{date}}{,}{\mathrm{date}}{,}{\mathrm{date}}{,}{\mathrm{date}}{,}{\mathrm{date}}\right]$ (22)
 > $\mathrm{itm_swaption}≔\mathrm{AmericanSwaption}\left(\mathrm{itm_swap},\mathrm{AdvanceDate}\left(\mathrm{start},1,\mathrm{Days},\mathrm{EURIBOR}\right),\mathrm{AdvanceDate}\left(\mathrm{dates}\left[-2\right],1,\mathrm{Days},\mathrm{EURIBOR}\right)\right)$
 ${\mathrm{itm_swaption}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (23)
 > $\mathrm{atm_swaption}≔\mathrm{AmericanSwaption}\left(\mathrm{atm_swap},\mathrm{AdvanceDate}\left(\mathrm{start},1,\mathrm{Days},\mathrm{EURIBOR}\right),\mathrm{AdvanceDate}\left(\mathrm{dates}\left[-2\right],1,\mathrm{Days},\mathrm{EURIBOR}\right)\right)$
 ${\mathrm{atm_swaption}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (24)
 > $\mathrm{otm_swaption}≔\mathrm{AmericanSwaption}\left(\mathrm{otm_swap},\mathrm{AdvanceDate}\left(\mathrm{start},1,\mathrm{Days},\mathrm{EURIBOR}\right),\mathrm{AdvanceDate}\left(\mathrm{dates}\left[-2\right],1,\mathrm{Days},\mathrm{EURIBOR}\right)\right)$
 ${\mathrm{otm_swaption}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (25)

Price these swaptions using the Hull-White trinomial tree.

 > $a≔0.048696$
 ${a}{≔}{0.048696}$ (26)
 > $\mathrm{\sigma }≔0.0058904$
 ${\mathrm{\sigma }}{≔}{0.0058904}$ (27)
 > $\mathrm{model}≔\mathrm{HullWhiteModel}\left(\mathrm{discount_curve},a,\mathrm{\sigma }\right)$
 ${\mathrm{model}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (28)
 > $\mathrm{time_grid}≔\mathrm{TimeGrid}\left(\mathrm{YearFraction}\left(\mathrm{maturity}\right)+0.5,100\right)$
 ${\mathrm{time_grid}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (29)
 > $\mathrm{short_rate_tree}≔\mathrm{ShortRateTree}\left(\mathrm{model},\mathrm{time_grid}\right)$
 ${\mathrm{short_rate_tree}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (30)

Price your swaptions using the tree constructed above.

 > $\mathrm{LatticePrice}\left(\mathrm{itm_swaption},\mathrm{short_rate_tree},\mathrm{discount_curve}\right)$
 ${54.62494411}$ (31)
 > $\mathrm{LatticePrice}\left(\mathrm{atm_swaption},\mathrm{short_rate_tree},\mathrm{discount_curve}\right)$
 ${29.46563575}$ (32)
 > $\mathrm{LatticePrice}\left(\mathrm{otm_swaption},\mathrm{short_rate_tree},\mathrm{discount_curve}\right)$
 ${15.16495357}$ (33)

Compatibility

 • The Finance[LatticePrice] command was introduced in Maple 15.
 • For more information on Maple 15 changes, see Updates in Maple 15.