35
Binomial Tree Option Pricing Author: Brian Bannon

Tree Pricing_Draft

Embed Size (px)

Citation preview

Binomial Tree Option Pricing

Author:Brian Bannon

Contents

1 Introduction 1

2 Theory of Binomial Tree Pricing Models 12.1 Black Scholes Merton Model . . . . . . . . . . . . . . . . . . . . . . . . . . 12.2 Binomial Tree Approximation Model . . . . . . . . . . . . . . . . . . . . . . 32.3 Leisen Reimer Binomial Tree Model . . . . . . . . . . . . . . . . . . . . . . . 52.4 Richardson Extrapolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Methodology of Testing 73.1 Selection of Test Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4 Conclusions 84.1 Summary of Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

5 References 9

6 Appendix 106.1 MatLab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

6.1.1 Assignment 3.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106.1.2 binoTree.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236.1.3 ppInv.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256.1.4 LR BinoTree.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

i

1 Introduction

In this report we are going to look at Binomial Tree option pricing and extensions onto thetree pricing option for plain vanilla options.We will be implementing the Leisen Reimer (LR) Binomial Tree and comparing the pricingresults with normal binomial tree methods along with the standard Black Scholes models tocompare our models. Lastly we will be performing variance reduction techniques to ensurethat the error within these models are reduced to can obtain a value close to the stock’sintrinsic

2 Theory of Binomial Tree Pricing Models

2.1 Black Scholes Merton Model

The Black-Scholes-Merton model is mathematical model used to give a theoretical estimateof the price of a European-style option.Testing over the years have shown that the Black-Scholes Merton model gives good approximations of the observed price and is widely usedwithin industry as an approximation into the price of a given option.This model assumes certain constraints in the market to price options effectively.It assumesthat the market has at least one risky asset called the stock and one risk-less asset calledthe money market, cash or bond.The asset is assumed to have a risk-less rate(risk-free in-terest rate), moves in a geometric Brownian motion(random walk) with drift and assume itsdrift and volatility are constant.Lastly the stock does not pay dividend( For our model inthis report the stock does pay dividends, which is just a trivial extension onto the originalformula).Assumptions on the market have to be made as well. There is to be no arbitrage opportu-nities, it is possible to borrow and lend any amount t the risk free rate,it is possible to buyand sell any amount of stock, and transactions fees and costs do not apply.With these assumptions holding.Then there is a option trading in the market.The option hasa current price now (spot price) and will reach a certain price(strike price) with a certainpay-off at a specified date(Maturity) in the future.The future price of this option is com-pletely determined by current price of the option even though we know nothing about thepath and future stock price of the option.From creating a dynamic hedging position of a longstock position and a short option position a differential equation called the Black-Scholesformula was developed, which governed he price of a option.

∂V

∂t+

1

2σ2S2∂

2V

∂S2+ rS

∂V

∂S− rV = 0 (1)

Where S is the price of the stock,V (S, t) is the price of the derivative as a function of timeand stock price,K is the strike price,r is the risk free rate( expressed in terms of continuouscompounding),σ is the volatility of the returns of the assets.The value for a non-dividend paying call option is:

C(S, t) = N(d1)S −N(d2)Ke−r(T−t) (2)

1

And the price for a put option is

P (S, t) = Ke−r(T−t) − S + C(S, t) = N(−d2)Ke−r(T−t) −N(−d1)S (3)

where

d1 =1

σ√T − t

[ln(S

K) + (r +

σ2

2)(T − t)] (4)

d2 =1

σ√T − t

[ln(S

K) + (r − σ2

2)(T − t)] (5)

As above where T − t is the time to maturity t = now and T = maturity,and N(x) isthe cumulative distribution function of the standard normal distribution.For a European calloption to be in the money, this mean that the spot price of the option at maturity must begreater that the strike price at the current time of writing the option.Thus when it comes tothe maturity date the issuer will exercise the right to buy the option for the strike price andmake a profit from buying the options at a cheaper price than market price.If the spot priceis lower than the strike price the holder will choose the right not to exercise the option.Thepayout for this is written as follows:

callpayoff = max(S −K, 0) =

{S −K, if S > K.

0, if S < K.(6)

For a put option the payout for this is

putpayoff = max(K − S, 0) =

{K − S, if S < K.

0, if S > K.(7)

where the holder will exercise the option if the spot price is lower than the strike price.The Black-Scholes Model has some problems when it comes to look into pricing AmericanOptions. These are options that can be exercised at any point during the time range fromissue to maturity. For this instance the Black-Scholes equation changes into an inequalityand not given an exact approximation.For this report we will be interested in pricing ”plain vanilla” options, which are standardEuropean Call/Put options.These options are constricted to only being exercised on thematurity date given.Even though this report is about Binomial Tree approaches to pricingoptions.It is good to give a strong foundation on which these Tree Approach models are builtoff so confusion does not incur latter on in the report.

2

2.2 Binomial Tree Approximation Model

The binomial tree model is a numerical method for pricing options.The binomial model wasfirst proposed by Cox, Ross and Rubinstein in 1979.Essentially, the model uses a discrete-time (lattice based) model of the varying price over time of the underlying financial instru-ment.This model traces the evolution of the option in discrete-time. This by means of thelattice approach. Thus for a number of times steps between valuation of the option andexpiration date, each of the nodes representing a discrete time step gives a possible price ofthe underlying options at a given point in time.The model is conducted through an iterative process, starting at each of the final expirationdate nodes and working backwards discounting through the tree towards the initial startingnode.The value of the option at each point, or node on the tree is evaluated at each discretepoint.In summary we must generate the tree, calculate the option at each of the final nodesand work backward to find the option value at the preceding point.

To generate the tree, at each point it must be assumed that the option will move up (u)or down(d) by a specific factor per step of the tree.if S is the current price, then the nextfollowing price will be:

Sup = S ∗ u (8)

Sdown = S ∗ d (9)

These up and down factors are calculated using the volatility σ and the time t, measured inyears.

u = eσ√t (10)

d = e−σ√t (11)

u =1

d(12)

S.u.d = S.d.u. = S (13)

The CRR method ensures that the tree is recombinant, i.e. if the underlying asset moves upand then down (u,d), the price will be the same as if it had moved down and then up (d,u),here the two paths merge or recombine. This property reduces the number of tree nodes,and thus accelerates the computation of the option price.

Again as in the Section(2.1), the option values at each point is the options exercisevalue.Max[(Sn −K), 0] for a call option, Max[(K − Sn), 0] for a put option.

3

S0u2

S0u

S0 S0

S0d

S0d2

Fig(1): Graphic representation of the Binomial Tree approach.

Now you obtain the penultimate time step and work backwards to the valuation pointwhere the value of the option can be obtained.To find this value this model used a riskneutrality assumption, that today’s fair price of the a derivative is equal to the expectedvalue of its future payoff discounted by the risk free rate.Thus the option value at a nodeis calculated from the two later nodes one time step on and weighted by their respectiveprobabilities.p is the probability of an up movement and (1− p) is the probability of a downmovement.Thus the binomial tree value is the (probability of moving up)(Option price ofup one step) + (probability of moving down)(Option Price of down one time step)*DiscountFactor.This is shown in Eq(14).

C = e−rtn (pCu + (1− p)Cd) (14)

where the probability of moving up is

p =e(r−q) t

n − du− d

(15)

This is chosen such that the related binomial distribution simulates the geometric BrownianMotion of the underlying stock with parameters r and σ.The binomial model assumes thatmovements in the price follow a binomial distribution; for many trials, this binomial distri-bution approaches the normal distribution assumed by BlackScholes.q is the dividend yieldof the underlying option.This binomial tree approach provides a discrete time approximation to the continuous pro-cess underlying the Black-Scholes model.In European options without dividends the binomialtree method converges to the Black-Scholes Price. We will be looking more into that in thenext section of the report

4

2.3 Leisen Reimer Binomial Tree Model

Leisen and Reimer developed a model with the purpose of improving the rate of convergenceof their binomial tree. As mentioned above most tree models converge to the Black Scholessolution in the limit as the size of the time step ∆t is reduced t zero. But however in binomialtree models the convergence is not smoothThis model converges quadratically in the number of time steps, at least for EuropeanCall and American Call Options. While the binomial tree approach has linear convergence.Therefore the accuracy is much better. Since there are no small oscillations in this model,due to the selection of of odd times steps, compared to no constraints on time step selectionin the normal binomial tree, Richardson extrapolation is easily implemented with this modelto increase the accuracy even more.

d1 =ln( s

k) + (r − q + σ2/2)T

σ√T

(16)

d2 =ln( s

k) + (r − q − σ2/2)T

σ√T

(17)

p = f(d2, N) (18)

p′ = f(d1, N) (19)

u =p′

pe(r−q)∆T (20)

d =1− p′

1− pe(r−q)∆T (21)

Leisen-Reimer developed a method in which the parameters u, d,and p of the binomialtree can be altered in order to get better convergence behaviour.Instead of choosing theparameters p, u and d to get convergence to the normal distribution Leisen-Reimer suggestto use the inversion formulae called the Peizer-Pratt Inversion, see Eq(22).

f(x, n) =1

2+

1

2sign(x)

√1− exp[−(

x

n+ 13

+ 110(n+1)

)2(n+1

6)] (22)

This inversion formulae reverts the standard method and they use the normal approxima-tions to determine the Binomial distribution, and suggest Eq(22) to replace p(the probabilityof going up).

5

2.4 Richardson Extrapolation

In numerical analysis Richardson Extrapolation is a sequence acceleration method, usedto improve the rate of convergence of a sequence.For us in this report as mentioned in theprevious sections Tree approach models do converge to the Black Scholes Price as the numberof time steps tend to infinity.But this convergence can be slow and non-monotonic.Thesetree approaches converge to the normal distribution defined by the Black Scholes model.Ifthe convergence is linear you need to double the steps to get double the accuracy(half theexpected error) but the nodes grow at a rate of N2. The Richardson Extrapolation is a shortcut to this convergence cutting down the execution time.This method improves estimates estimates when the error is known to have a predictableform;

v = f(h) + a1h+ a2h2 + a3h

3 + ..... (23)

here v is assumed to be the true value of the option and f(h) the value returned from the treewith a step size h. Under the assumptions of the technique the accuracy of the estimate f(h)will improve as h tends to zero.as the error term will clearly decrease. Suppose we doublethe steps to half the size.

v = f(h

2) + a1(

h

2)2 + a3(

h

2)3 + ..... (24)

Subtract Eq(23) from twice Eq(24) and get

v = 2f(h

2)− f(h) + a2h

2 + .... (25)

And in doing so cancels the errors in h.Repeated applications of Richardson’s Extrapolationmay be used to combine more estimates in such a way to eliminate higher order terms in theerror expansion.It’s disadvantage is that is can easily be misused and may make estimatesworst.But this is an iterative process and so can be used to eliminator the h2 and improveestimates even more.

6

3 Methodology of Testing

3.1 Selection of Test Cases

For this report we are going to model the Leisen-Reimer Binomial Tree and compare it tothe normal Binomial Tree Approach and compare the convergence of these two approachesover a number of time steps and comment on their rate of convergence to the Black ScholesPrice. This will be all conducted through the programming application of MatLab.We willcreate function files to model the dynamics of both tree approaches and use the in-builtfunction of blsprice for the Black Scholes option price to test the convergence.

To test both these models we will graphically present the results from the models to bestconvey the accuracy of Normal Binomial Tree and the Leisen-Reimer Binomial Tree.To testthe robustness of these computational models we must note their performance and accuracyat critical points in the time line of an option.Thus for example

• An option deep in the money

• An option deep out of the money

• An option where the strike price is equal to the spot price

• An option where it is just slightly above the strike

• An option just slightly below the strike

• To examine the same critical points for a put option

• Examine the models as the number of time steps increase

• Change in fundamental parameters i.e. volatility, expiration time, dividend yield etc.

Note: In our analysis of these tree approaches we only conducted test conditions onEuropean Options to keep things simple for the models. American options tree approachescould be conducted, but was not part of the idea behind this report to introduce the reader tothe use of the Liesen-Reimer binomial tree approach.

In the following section we will present the results from what we have found from ourresearch into binomial tree approaches

7

Results:  

Empirical  Results:  Firstly  we  are  going  to  look  at  a  European  Call  option  at  different  stages  in  the  option  pricing  time  line  and  at  different  number  of  time  steps  to  increase  accuracy.  We  use  a  model  template  for  the  following  results  in  Table  (1)  and  Table  (2),  such  that  we  keep  all  the  variables  constant  and  just  change  the  position  of  the  market  price  with  respect  to  the  strike  price.  In  this  model  r  =  0.02,  T  =  0.5,  vol  =  0.3,  and  q  =  0.05  with  a  times  steps  of  N=199.We  limit  the  time  steps  to  odd  time  steps  to  smooth  the  oscillations  and  it’s  a  part  of  the  constraints    of  the  model.  If  we  used  even  number  of  time  steps  the  normal  Binomial  model  would  produce  a  better  result  closer  to  the  Black  Scholes  Price  

 

  Deep  in  The  money  

Deep  out  of  the  money  

At  the  money  

$1  above  Strike  

$1  below  Strike  

Black  Scholes  Price   5.727109   0.000921   0.682593   1.279708   0.285079  Binomial  Tree  

Price  5.727024   0.000882   0.681658   1.278727   0.285695  

Leisen-­‐Reimer  Tree  Price  

5.727109   0.000921   0.680748   1.279707   0.285079  

Table  (1):  Table  of  the  different  models  at  different  positions  in  the  life  cycle  of  a  call  option  

We  can  see  from  this  table  that  the  Leisen  Reimer  Tree  model  is  closer  to  the  Black  Scholes  price  in  all  of  the  cases  expect  for  at  the  money.  

Next  we  are  going  to  do  the  same  but  for  a  put  option.  

 

  Deep  out  The  money  

Deep  in  of  the  money  

At  the  money  

$1  above  Strike  

$1  below  Strike  

Black  Scholes  Price   0.007908   4.034819   0.815252   0.437057   1.393049  Binomial  Tree  

Price  0.007824   4.034781   0.816178   0.436077   1.393664  

Leisen-­‐Reimer  Tree  Price  

0.007909   4.034820   0.815252   0.437056   1.393048  

Table  (2):  Table  of  the  different  models  at  different  positions  in  the  life  cycle  of  a  put  option  

For  the  put  option  Table  (2)  we  see  that  all  the  values  for  the  Leisen  Reimer  Tree  model  are  close  to  the  Black  Scholes  price  in  all  situations.  I  think  for  Table  (1)  for  at  the  money  it  could  have  been  a  systematic  error  that  may  have  made  the  values  not  in  the  same  range.    

Next  we  will  test  the  convergence  of  the  binomial  model  and  Leisen  Reimer  model  by  increasing  the  number  of  time  steps  of  a  European  Call  option  to  see  which  converges  to  the  Black  Scholes  value  quicker  and  more  accurately.  

 

 

Number  of  Time  Steps     Binomial  Model   LR  Binomial  Model   Black  Scholes  Price  

11   4.757207   4.763223   4.763037  21   4.761255   4.763091   4.763037  51   4.76183   4.763046   4.763037  75   4.762808   4.763041   4.763037  

101   4.762351   4.763039   4.763037  201   4.762874   4.763038   4.763037  401   4.762979   4.763037   4.763037  499   4.762972   4.763037   4.763037  

Table  (3):  Table  of  the  different  models  at  different  time  steps  in  the  life  cycle  of  a  call  option  

We  see  from  Table  (3)  as  you  increase  the  number  of  time  steps  both  tree  models  get  closer  to  the  Black  Scholes  price  which  is  true  from  theoretical  assumptions.  We  can  see  that  the  Leisen  Reimer  Model  reached  the  Black  Scholes  Price  at  around  400  time  steps  while  the  CRR  binomial  tree  after  500  time  steps  has  not  reached  the  Black  Scholes  Value,  proving  that  the  Leisen  Reimer  Model  reduces  execution  time  and  is  more  accurate.  

Next  we  are  going  to  look  at  what  affect  the  time  to  expiry  has  on  these  tree  models,  by  taking  a  European  call  option  and  changing  the  maturity  time    

Time  Range  (Years)   Binomial  Model   LR  Binomial  Model   Black  Scholes  Price  0.25   4.869392   4.86944   4.869439  0.5   4.762822   4.763038   4.763037  1   4.62036   4.620992   4.620991  

1.25   4.571736   4.572024   4.572024  1.5   4.529081   4.530651   4.53065  5   4.103011   4.103961   4.103963  10   3.483733   3.483696   3.483699  20   0.620608   0.622438   0.622438  

Table  (4):  Table  of  the  different  models  at  different  expiry  dates  in  the  life  cycle  of  a  call  option  

If  we  look  at  Table  (4)  we  can  see  that  all  models  price  drop  due  the  extension  of  the  maturity  date.  Also  we  see  that  the  Leisen  Reimer  Model  still  is  the  most  accurate  to  the  Black  Scholes  price  through  this  these  time  ranges.  This  makes  sense  as  the  longer  you  hold  the  option  the  more  the  price  will  go  down.    

 

 

 

 

 

Volatility   Binomial  Model   LR  Binomial  Model   Black  Scholes  Price  

0.1   4.74389   4.74389   4.74389  0.2   4.744428   4.744448   4.744448  0.3   4.762822   4.763038   4.763037  0.4   4.832861   4.832801   4.8328  0.5   4.957288   4.957177   4.957177  

Table  (5):  Table  of  the  different  models  at  different  volatilities  in  the  life  cycle  of  a  call  option  

Lastly  the  volatility,  across  all  models  as  the  volatility  increases  the  price  of  all  the  models  increases.  This  makes  sense  as  the  volatility  increase  the  holder  has  a  greater  chance  of  making  or  losing  money  so  the  price  of  the  option  must  increase.  

If  we  look  at  other  variables  in  the  models  such  as  dividend  yield  and  the  risk  free  rate  of  return  we  get,  increase  the  dividend  yield  the  price  goes  down  and  as  you  decrease  the  risk-­‐free  rate  of  return  the  price  of  the  models  goes  up.  

 

Graphical  Results:  In  this  section  we  are  going  to  look  at  some  graphs  of  the  performance  of  the  models  in  different  positions  and  comment  on  the  output  of  these  graphs.    

 

Fig  (2):  Graph  of  a  call  option  deep  in  the  money  we  can  see  the  LR  Model  and  CRR  model  converge  to  Black  Scholes  Price    

As  we  can  see  here  from  Fig(2)  that  the  deep  in  the  money  call  option  position  where  the  spot  price  is  greater  than  the  strike  shows  that  the  LR  model  converges  quickly  and  accurately  to  the  desired  Black  Scholes  Price.  It  does  not  truly  converge  till  about  400-­‐500  time  steps  in.  As  we  can  see  with  the  CRR  model  the  price  oscillates  around  the  Black  Scholes  price  but  does  not  converge  completely.  

 

Fig  (3):  Graph  of  a  call  option  deep  out  the  money  we  can  see  the  LR  Model  and  CRR  model  converge  to  Black  Scholes  Price    

Fig(3)  show  the  graph  call  option  deep  out  of  the  money  meaning  that  the  current  market  spot  price  is  under  the  strike  price,  and  just  the  holder  will  not  exercise  the  option.  Again  we  see  that  the  LR  model  converges  quicker  than  the  CRR  model,  and  again  the  CRR  oscillates  close  to  but  does  not  converge  with  the  Black  Scholes  Price.  Which  in  this  case  is  close  to  zero  because  the  option  is  out  of  the  money  the  holder  would  pay  zero  for  the  option  as  he  can  buy  it  cheaper  in  the  market  and  thus  will  not  exercise  the  option  to  buy.  

In  Fig  (4)  we  see  a  call  option  at  the  money,  by  far  the  most  interesting  graphical  result  produced  through  this  report  .We  see  that  both  model  now  converge  to  the  Black  Scholes  Price.  Yes  the  LR  model  does  take  less  execution  time  and  converges  quicker,  but  still  both  converge.  Accuracy  was  a  strong  result  of  the  LR  model,  something,  which  overpowered  the  CRR  model.  The  only  theory  I  have  for  this  to  happen  is  that,  because  the  spot  price  is  the  

same  as  the  strike  price,  the  holder  is  just  going  to  buy  the  option  because  it  is  the  market  value  of  the  option.  Thus  this  is  the  lowest  critical  point  at  which  the  holder  will  execute  because  the  option  is  worth  market  value.  

 

Fig  (4):  Graph  of  a  call  option  at  the  money  we  can  see  the  LR  Model  and  CRR  model  converge  to  Black  Scholes  Price    

 

Fig  (5):  Graph  of  a  call  option  at  the  money  we  can  see  the  LR  Model  and  CRR  model  converge  to  Black  Scholes  Price.  With  the  LR  Model  converging  a  lot  quicker  than  the  CRR  

In  Fig  (5)  we  take  a  close  up  of  the  convergence  happening  to  see  if  we  can  get  a  better  picture  from  the  result.    

 

Fig  (6):  Graph  of  a  call  option  very  deep  the  money  we  can  see  the  LR  Model  and  CRR  model  converge  to  Black  Scholes  Price.  This  model  was  model  was  set  with  S  =  30,  K  =20,  r  =  0.05,  T  =  1,  Vol  =  0.3,  q  =  0.05,  and  N=99.  

Fig  (6)  shows  a  European  call  option  very  deep  into  the  money,  more  so  than  Fig  (2).  We  see  if  we  increase  some  of  the  option  fundamental  parameters  such  as  risk  free  rate  and  time  but  mostly  how  deep  in  the  position  the  holder  is  the  CRR  model  shifts  closer  to  the  Black  Scholes  Price.  Bisecting  the  Black  Scholes  Price  line  on  several  occasions.  Showing  during  certain  time  steps  the  CRR  model  does  give  the  Black  Scholes  price.  We  also  see  that  the  period  between  crests  and  troughs  (.  i.e.  Frequency)  is  getting  longer  and  CRR  line  is  smoothing  out.  It  may  look  like  the  CRR  model  will  converge  to  the  Black  Scholes  Price,  but  if  you  increase  the  time  steps  you  see  it  just  oscillates  above  and  below  this  price.    

1 Conclusions

1.1 Summary of Results

In conclusion, this report has presented the reader with hopefully a clear understandingof the topic of Binomial Tree approximations. We have discussed the theory behind thisapproach. Discussed some key mathematical and financial assumptions about the models.

We have presented a way in which to test and model these binomial tree approachesusing the programming application of MatLab.Finally we have presented the results fromour testing to the reader.

From the results, mostly all of the graphical and empirical results had proven the theoret-ical predictions described in the previous sections of this report. The Liesen-Reimer binomialtree approach had out performed the CRR binomial tree approach on several different posi-tions within the option time line .The Liesen-Reimer binomial tree approach had producedmore accurate results, closer to the Black Scholes price and we had presented graphical ev-idence that the Liesen-Reimer binomial tree approach did converge quicker to the desiredreference price. In the graphical results section further investigate would be needed into ”atthe money” option critical points to describe the nature of the CRR behaviour at that point,and also at points which are highly deep in the money. The author had given his suggestionon what this may be but further analysis and investigation in Liesen-Reimer binomial treeapproach methodology would present a clearly picture of why this is happening.

There was some limitations to my analysis. I was not able to present the case of Europeanput options to the reader as through some programming error I believe the results where notoutputting intuitive results for option positions. The code has been provided in this reportso further analysis will be done to correct this error.

Lastly I presented some results in changing the fundamental parameters and what effectthat had on the models results. I presented some cases where I changed what I believed to beimportant variables associated with the approximation price, but a wide number of differentcombinations of parameters could be tried. Unfortunately I did not have time to present aconcise way to present all this information, so I just showed the changes in variables thatthe reader would associate with option pricing.

1

2 References

• Hull, J. C. (2006). Options, futures, and other derivatives. Pearson Education India.

• Hanna A.(2015). Computational Methods in Finance: Companion Notes.Queens Uni-versity Belfast Management School

• Hanna A. (2015). Computational Methods in Finance: Lecture Notes: Tree Ap-proaches, Queens University Belfast Management School.

• Wallner, C.and Uwe, W.Efficient computation of option price sensitivities for optionsof American Style. No.1, CPQF, Working Paper Series,2004

• Wilmott, P. (2013). Paul Wilmott on quantitative finance. John Wiley & Sons.

2

3 Appendix

3.1 MatLab Code

3.1.1 Assignment 3.m

1 %%2 %Assignment 3 Le i sen Reimer (LR) Binomial Tree3

4 S = 14 ;5 K = 9 ;6 r = 0 . 0 2 ;7 T = 0 . 5 ;8 vo l = 0 . 3 ;9 q = 0 . 0 5 ;

10 c a l l p u t = ’ c a l l ’ ; % Enter ”Put” in f o r put money t e s t s11 Option = ’E ’ ;12 N = 199 ;13

14

15

16 LR Price = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N) ;17

18

19

20 BinoTree = binoTree (S , K, r , T, vol , q , ca l l pu t , Option , N) ;21

22 [ Cal l , Put ] = b l s p r i c e (S , K, r , T, vol , q ) ;23

24 [ LR Price , BinoTree , Ca l l ] ’ ;25 s p r i n t f ( ’ Pr iceBlk : \ t%f \nPriceBino : \ t%f \nPriceLR :\ t%f \n ’ , Cal l ,

BinoTree , LR Price )26

27

28 %%29 % Plo t t i ng the opt ion p r i c e s30 a = 1 ; b = 499 ;31 N = [ a : 2 : b ] ;32 P = N∗0 ;33 B = P + b l s p r i c e (S , K, r , T, vol , q ) ;34 LR = N∗0 ;35

36 f o r i =1: l ength (N)37

38 P( i ) = binoTree (S ,K, r ,T, vol , q , ca l l put , Option ,N( i ) ) ;

3

39 LR( i ) = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N( i ) ) ;40

41

42 end43

44 p lo t (N,P, ’−r ’ ,N,B, ’b ’ ,N,LR, ’ g ’ ) ;45 t i t l e ( ’ Black Scholes , Binomial Tree and Le i sen Reimer Binomial Tree

Option Pr i ce ’ )46 x l a b e l ( ’Time Steps ’ )47 y l a b e l ( ’ Option Pr i ce ’ )48 l egend ( ’ Binomial Tree Approx . Pr i ce ’ , ’ Black Scho l e s Pr i ce ’ , ’ Le i sen

Reimer Binomial Tree Approx . Pr i ce ’ , ’ Locat ion ’ , ’ nor theas t ’ )49

50 %%51 %Star t o f t e s t ca s e s ; In the f o l l o w i n g s s e c t i o n s we are going to

look at52 %European c a l l opt ion in or around the money53

54 %Test 155 %Deep in the money56 S = 30 ;57 K = 20 ;58 r = 0 . 0 5 ;59 T = 1 ;60 vo l = 0 . 3 ;61 q = 0 . 0 5 ;62 c a l l p u t = ’ c a l l ’ ;% Enter ”Put” in f o r put money t e s t s63 Option = ’E ’ ;64 N = 999 ;65

66

67

68 LR Price = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N) ;69

70 BinoTree = binoTree (S , K, r , T, vol , q , ca l l pu t , Option , N) ;71

72 [ Cal l , Put ] = b l s p r i c e (S , K, r , T, vol , q ) ;73

74 [ Cal l , BinoTree , LR Price ] ’ ;75 s p r i n t f ( ’ Pr iceBlk : \ t%f \nPriceBino : \ t%f \nPriceLR :\ t%f \n ’ , Cal l ,

BinoTree , LR Price )76

77

78

79 a = 1 ; b = 99 ;

4

80 N = [ a : 2 : b ] ;81 P = N∗0 ;82 B = P + b l s p r i c e (S , K, r , T, vol , q ) ;83 LR = N∗0 ;84

85 f o r i =1: l ength (N)86

87 P( i ) = binoTree (S ,K, r ,T, vol , q , ca l l put , Option ,N( i ) ) ;88 LR( i ) = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N( i ) ) ;89

90

91 end92

93 p lo t (N,P, ’−r ’ ,N,B, ’b ’ ,N,LR, ’ g ’ ) ;94 t i t l e ( ’ Black Scholes , Binomial Tree and Le i sen Reimer Binomial Tree

Option Pr i ce ’ )95 x l a b e l ( ’Time Steps ’ )96 y l a b e l ( ’ Option Pr i ce ’ )97 l egend ( ’ Binomial Tree Approx . Pr i ce ’ , ’ Black Scho l e s Pr i ce ’ , ’ Le i sen

Reimer Binomial Tree Approx . Pr i ce ’ , ’ Locat ion ’ , ’ s outheas t ’ )98

99 %%100 %Test 2101 %Deep out the money102 S = 5 ;103 K = 9 ;104 r = 0 . 0 2 ;105 T = 0 . 5 ;106 vo l = 0 . 3 ;107 q = 0 . 0 5 ;108 c a l l p u t = ’ c a l l ’ ;% Enter ”Put” in f o r put money t e s t s109 Option = ’E ’ ;110 N = 199 ;111

112

113

114 LR Price = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N) ;115

116 BinoTree = binoTree (S , K, r , T, vol , q , ca l l pu t , Option , N) ;117

118 [ Cal l , Put ] = b l s p r i c e (S , K, r , T, vol , q ) ;119

120 [ LR Price , BinoTree , Ca l l ] ’ ;121 s p r i n t f ( ’ Pr iceBlk : \ t%f \nPriceBino : \ t%f \nPriceLR :\ t%f \n ’ , Cal l ,

BinoTree , LR Price )

5

122

123

124

125 a = 1 ; b = 199 ;126 N = [ a : 2 : b ] ;127 P = N∗0 ;128 B = P + b l s p r i c e (S , K, r , T, vol , q ) ;129 LR = N∗0 ;130

131 f o r i =1: l ength (N)132

133 P( i ) = binoTree (S ,K, r ,T, vol , q , ca l l put , Option ,N( i ) ) ;134 LR( i ) = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N( i ) ) ;135

136

137 end138

139 p lo t (N,P, ’−r ’ ,N,B, ’b ’ ,N,LR, ’ g ’ ) ;140 t i t l e ( ’ Black Scholes , Binomial Tree and Le i sen Reimer Binomial Tree

Option Pr i ce ’ )141 x l a b e l ( ’Time Steps ’ )142 y l a b e l ( ’ Option Pr i ce ’ )143 l egend ( ’ Binomial Tree Approx . Pr i ce ’ , ’ Black Scho l e s Pr i ce ’ , ’ Le i sen

Reimer Binomial Tree Approx . Pr i ce ’ , ’ Locat ion ’ , ’ nor theas t ’ )144

145 %%146 %%%Test 3147 %At the money148 S = 9 ;149 K = 9 ;150 r = 0 . 0 2 ;151 T = 0 . 5 ;152 vo l = 0 . 3 ;153 q = 0 . 0 5 ;154 c a l l p u t = ’ c a l l ’ ; % Enter ”Put” in f o r put money t e s t s155 Option = ’E ’ ;156 N = 200 ;157

158

159

160 LR Price = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N) ;161

162 BinoTree = binoTree (S , K, r , T, vol , q , ca l l pu t , Option , N) ;163

164 [ Cal l , Put ] = b l s p r i c e (S , K, r , T, vol , q ) ;

6

165

166 [ LR Price , BinoTree , Ca l l ] ’ ;167

168 s p r i n t f ( ’ Pr iceBlk : \ t%f \nPriceBino : \ t%f \nPriceLR :\ t%f \n ’ , Cal l ,BinoTree , LR Price )

169

170

171 a = 1 ; b = 199 ;172 N = [ a : 2 : b ] ;173 P = N∗0 ;174 B = P + b l s p r i c e (S , K, r , T, vol , q ) ;175 LR = N∗0 ;176

177 f o r i =1: l ength (N)178

179 P( i ) = binoTree (S ,K, r ,T, vol , q , ca l l put , Option ,N( i ) ) ;180 LR( i ) = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N( i ) ) ;181

182

183 end184

185 p lo t (N,P, ’−r ’ ,N,B, ’b ’ ,N,LR, ’ g ’ ) ;186 t i t l e ( ’ Black Scholes , Binomial Tree and Le i sen Reimer Binomial Tree

Option Pr i ce ’ )187 x l a b e l ( ’Time Steps ’ )188 y l a b e l ( ’ Option Pr i ce ’ )189 l egend ( ’ Binomial Tree Approx . Pr i ce ’ , ’ Black Scho l e s Pr i ce ’ , ’ Le i sen

Reimer Binomial Tree Approx . Pr i ce ’ , ’ Locat ion ’ , ’ nor theas t ’ )190

191 %%192 %Test 4193 %Just $1 above the money194 S = 10 ;195 K = 9 ;196 r = 0 . 0 2 ;197 T = 0 . 5 ;198 vo l = 0 . 3 ;199 q = 0 . 0 5 ;200 c a l l p u t = ’ c a l l ’ ;% Enter ”Put” in f o r put money t e s t s201 Option = ’E ’ ;202 N = 199 ;203

204

205

206 LR Price = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N) ;

7

207

208 BinoTree = binoTree (S , K, r , T, vol , q , ca l l pu t , Option , N) ;209

210 [ Cal l , Put ] = b l s p r i c e (S , K, r , T, vol , q ) ;211

212 [ LR Price , BinoTree , Ca l l ] ’ ;213

214 s p r i n t f ( ’ Pr iceBlk : \ t%f \nPriceBino : \ t%f \nPriceLR :\ t%f \n ’ , Cal l ,BinoTree , LR Price )

215

216

217 a = 1 ; b = 199 ;218 N = [ a : 2 : b ] ;219 P = N∗0 ;220 B = P + b l s p r i c e (S , K, r , T, vol , q ) ;221 LR = N∗0 ;222

223 f o r i =1: l ength (N)224

225 P( i ) = binoTree (S ,K, r ,T, vol , q , ca l l put , Option ,N( i ) ) ;226 LR( i ) = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N( i ) ) ;227

228

229 end230

231 p lo t (N,P, ’−r ’ ,N,B, ’b ’ ,N,LR, ’ g ’ ) ;232 t i t l e ( ’ Black Scholes , Binomial Tree and Le i sen Reimer Binomial Tree

Option Pr i ce ’ )233 x l a b e l ( ’Time Steps ’ )234 y l a b e l ( ’ Option Pr i ce ’ )235 l egend ( ’ Binomial Tree Approx . Pr i ce ’ , ’ Black Scho l e s Pr i ce ’ , ’ Le i sen

Reimer Binomial Tree Approx . Pr i ce ’ , ’ Locat ion ’ , ’ nor theas t ’ )236

237 %%238 %Test 5239 %Just $1 below the money240 S = 8 ;241 K = 9 ;242 r = 0 . 0 2 ;243 T = 0 . 5 ;244 vo l = 0 . 3 ;245 q = 0 . 0 5 ;246 c a l l p u t = ’ c a l l ’ ; % Enter ”Put” in f o r put money t e s t s247 Option = ’E ’ ;248 N = 199 ;

8

249

250

251

252 LR Price = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N) ;253

254 BinoTree = binoTree (S , K, r , T, vol , q , ca l l pu t , Option , N) ;255

256 [ Cal l , Put ] = b l s p r i c e (S , K, r , T, vol , q ) ;257

258 [ LR Price , BinoTree , Ca l l ] ’ ;259 s p r i n t f ( ’ Pr iceBlk : \ t%f \nPriceBino : \ t%f \nPriceLR :\ t%f \n ’ , Cal l ,

BinoTree , LR Price )260

261

262

263 a = 1 ; b = 199 ;264 N = [ a : 2 : b ] ;265 P = N∗0 ;266 B = P + b l s p r i c e (S , K, r , T, vol , q ) ;267 LR = N∗0 ;268

269 f o r i =1: l ength (N)270

271 P( i ) = binoTree (S ,K, r ,T, vol , q , ca l l put , Option ,N( i ) ) ;272 LR( i ) = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N( i ) ) ;273

274

275 end276

277 p lo t (N,P, ’−r ’ ,N,B, ’b ’ ,N,LR, ’ g ’ ) ;278 t i t l e ( ’ Black Scholes , Binomial Tree and Le i sen Reimer Binomial Tree

Option Pr i ce ’ )279 x l a b e l ( ’Time Steps ’ )280 y l a b e l ( ’ Option Pr i ce ’ )281 l egend ( ’ Binomial Tree Approx . Pr i ce ’ , ’ Black Scho l e s Pr i ce ’ , ’ Le i sen

Reimer Binomial Tree Approx . Pr i ce ’ , ’ Locat ion ’ , ’ nor theas t ’ )282

283 %%284 %Test 6285 %Deep out o f the money286 S = 15 ;287 K = 9 ;288 r = 0 . 0 2 ;289 T = 0 . 5 ;290 vo l = 0 . 3 ;

9

291 q = 0 . 0 5 ;292 c a l l p u t = ’ put ’ ;293 Option = ’E ’ ;294 N = 199 ;295

296

297

298 LR Price = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N) ;299

300 BinoTree = binoTree (S , K, r , T, vol , q , ca l l pu t , Option , N) ;301

302 [ Cal l , Put ] = b l s p r i c e (S , K, r , T, vol , q ) ;303

304 [ Cal l , BinoTree , LR Price ] ’ ;305 s p r i n t f ( ’ Pr iceBlk : \ t%f \nPriceBino : \ t%f \nPriceLR :\ t%f \n ’ , Put ,

BinoTree , LR Price )306

307

308

309 a = 1 ; b = 199 ;310 N = [ a : 2 : b ] ;311 P = N∗0 ;312 B = P + b l s p r i c e (S , K, r , T, vol , q ) ;313 LR = N∗0 ;314

315 f o r i =1: l ength (N)316

317 P( i ) = binoTree (S ,K, r ,T, vol , q , ca l l put , Option ,N( i ) ) ;318 LR( i ) = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N( i ) ) ;319

320

321 end322

323 p lo t (N,P, ’−r ’ ,N,B, ’b ’ ,N,LR, ’ g ’ ) ;324 t i t l e ( ’ Black Scholes , Binomial Tree and Le i sen Reimer Binomial Tree

Option Pr i ce ’ )325 x l a b e l ( ’Time Steps ’ )326 y l a b e l ( ’ Option Pr i ce ’ )327 l egend ( ’ Binomial Tree Approx . Pr i ce ’ , ’ Black Scho l e s Pr i ce ’ , ’ Le i sen

Reimer Binomial Tree Approx . Pr i ce ’ , ’ Locat ion ’ , ’ nor theas t ’ )328

329 %%330 %Test 7331 %Deep in the money332 S = 5 ;

10

333 K = 9 ;334 r = 0 . 0 2 ;335 T = 0 . 5 ;336 vo l = 0 . 3 ;337 q = 0 . 0 5 ;338 c a l l p u t = ’ put ’ ;% Enter ”Put” in f o r put money t e s t s339 Option = ’E ’ ;340 N = 199 ;341

342

343

344 LR Price = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N) ;345

346 BinoTree = binoTree (S , K, r , T, vol , q , ca l l pu t , Option , N) ;347

348 [ Cal l , Put ] = b l s p r i c e (S , K, r , T, vol , q ) ;349

350 [ LR Price , BinoTree , Ca l l ] ’ ;351 s p r i n t f ( ’ Pr iceBlk : \ t%f \nPriceBino : \ t%f \nPriceLR :\ t%f \n ’ , Put ,

BinoTree , LR Price )352

353

354

355 a = 1 ; b = 199 ;356 N = [ a : 2 : b ] ;357 P = N∗0 ;358 B = P + b l s p r i c e (S , K, r , T, vol , q ) ;359 LR = N∗0 ;360

361 f o r i =1: l ength (N)362

363 P( i ) = binoTree (S ,K, r ,T, vol , q , ca l l put , Option ,N( i ) ) ;364 LR( i ) = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N( i ) ) ;365

366

367 end368

369 p lo t (N,P, ’−r ’ ,N,B, ’b ’ ,N,LR, ’ g ’ ) ;370 t i t l e ( ’ Black Scholes , Binomial Tree and Le i sen Reimer Binomial Tree

Option Pr i ce ’ )371 x l a b e l ( ’Time Steps ’ )372 y l a b e l ( ’ Option Pr i ce ’ )373 l egend ( ’ Binomial Tree Approx . Pr i ce ’ , ’ Black Scho l e s Pr i ce ’ , ’ Le i sen

Reimer Binomial Tree Approx . Pr i ce ’ , ’ Locat ion ’ , ’ nor theas t ’ )374

11

375 %%376 %Test 8377 %At the money378 S = 9 ;379 K = 9 ;380 r = 0 . 0 2 ;381 T = 0 . 5 ;382 vo l = 0 . 3 ;383 q = 0 . 0 5 ;384 c a l l p u t = ’ put ’ ;% Enter ”Put” in f o r put money t e s t s385 Option = ’E ’ ;386 N = 199 ;387

388

389

390 LR Price = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N) ;391

392 BinoTree = binoTree (S , K, r , T, vol , q , ca l l pu t , Option , N) ;393

394 [ Cal l , Put ] = b l s p r i c e (S , K, r , T, vol , q ) ;395

396 [ LR Price , BinoTree , Ca l l ] ’ ;397 s p r i n t f ( ’ Pr iceBlk : \ t%f \nPriceBino : \ t%f \nPriceLR :\ t%f \n ’ , Put ,

BinoTree , LR Price )398

399

400

401 a = 1 ; b = 199 ;402 N = [ a : 2 : b ] ;403 P = N∗0 ;404 B = P + b l s p r i c e (S , K, r , T, vol , q ) ;405 LR = N∗0 ;406

407 f o r i =1: l ength (N)408

409 P( i ) = binoTree (S ,K, r ,T, vol , q , ca l l put , Option ,N( i ) ) ;410 LR( i ) = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N( i ) ) ;411

412

413 end414

415 p lo t (N,P, ’−r ’ ,N,B, ’b ’ ,N,LR, ’ g ’ ) ;416 t i t l e ( ’ Black Scholes , Binomial Tree and Le i sen Reimer Binomial Tree

Option Pr i ce ’ )417 x l a b e l ( ’Time Steps ’ )

12

418 y l a b e l ( ’ Option Pr i ce ’ )419 l egend ( ’ Binomial Tree Approx . Pr i ce ’ , ’ Black Scho l e s Pr i ce ’ , ’ Le i sen

Reimer Binomial Tree Approx . Pr i ce ’ , ’ Locat ion ’ , ’ nor theas t ’ )420

421 %%422 %Test 9423 % $1 Above the money424 S = 10 ;425 K = 9 ;426 r = 0 . 0 2 ;427 T = 0 . 5 ;428 vo l = 0 . 3 ;429 q = 0 . 0 5 ;430 c a l l p u t = ’ put ’ ;% Enter ”Put” in f o r put money t e s t s431 Option = ’E ’ ;432 N = 199 ;433

434

435

436 LR Price = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N) ;437

438 BinoTree = binoTree (S , K, r , T, vol , q , ca l l pu t , Option , N) ;439

440 [ Cal l , Put ] = b l s p r i c e (S , K, r , T, vol , q ) ;441

442 [ LR Price , BinoTree , Ca l l ] ’ ;443 s p r i n t f ( ’ Pr iceBlk : \ t%f \nPriceBino : \ t%f \nPriceLR :\ t%f \n ’ , Put ,

BinoTree , LR Price )444

445

446

447 a = 1 ; b = 199 ;448 N = [ a : 2 : b ] ;449 P = N∗0 ;450 B = P + b l s p r i c e (S , K, r , T, vol , q ) ;451 LR = N∗0 ;452

453 f o r i =1: l ength (N)454

455 P( i ) = binoTree (S ,K, r ,T, vol , q , ca l l put , Option ,N( i ) ) ;456 LR( i ) = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N( i ) ) ;457

458

459 end460

13

461 p lo t (N,P, ’−r ’ ,N,B, ’b ’ ,N,LR, ’ g ’ ) ;462 t i t l e ( ’ Black Scholes , Binomial Tree and Le i sen Reimer Binomial Tree

Option Pr i ce ’ )463 x l a b e l ( ’Time Steps ’ )464 y l a b e l ( ’ Option Pr i ce ’ )465 l egend ( ’ Binomial Tree Approx . Pr i ce ’ , ’ Black Scho l e s Pr i ce ’ , ’ Le i sen

Reimer Binomial Tree Approx . Pr i ce ’ , ’ Locat ion ’ , ’ nor theas t ’ )466

467 %%468 %Test 10469 % $1 below the money470 S = 8 ;471 K = 9 ;472 r = 0 . 0 2 ;473 T = 0 . 5 ;474 vo l = 0 . 3 ;475 q = 0 . 0 5 ;476 c a l l p u t = ’ put ’ ;% Enter ”Put” in f o r put money t e s t s477 Option = ’E ’ ;478 N = 199 ;479

480

481

482 LR Price = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N) ;483

484 BinoTree = binoTree (S , K, r , T, vol , q , ca l l pu t , Option , N) ;485

486 [ Cal l , Put ] = b l s p r i c e (S , K, r , T, vol , q ) ;487

488 [ LR Price , BinoTree , Ca l l ] ’ ;489 s p r i n t f ( ’ Pr iceBlk : \ t%f \nPriceBino : \ t%f \nPriceLR :\ t%f \n ’ , Put ,

BinoTree , LR Price )490

491

492

493 a = 1 ; b = 199 ;494 N = [ a : 2 : b ] ;495 P = N∗0 ;496 B = P + b l s p r i c e (S , K, r , T, vol , q ) ;497 LR = N∗0 ;498

499 f o r i =1: l ength (N)500

501 P( i ) = binoTree (S ,K, r ,T, vol , q , ca l l put , Option ,N( i ) ) ;502 LR( i ) = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N( i ) ) ;

14

503

504

505 end506

507 p lo t (N,P, ’−r ’ ,N,B, ’b ’ ,N,LR, ’ g ’ ) ;508 t i t l e ( ’ Black Scholes , Binomial Tree and Le i sen Reimer Binomial Tree

Option Pr i ce ’ )509 x l a b e l ( ’Time Steps ’ )510 y l a b e l ( ’ Option Pr i ce ’ )511 l egend ( ’ Binomial Tree Approx . Pr i ce ’ , ’ Black Scho l e s Pr i ce ’ , ’ Le i sen

Reimer Binomial Tree Approx . Pr i ce ’ , ’ Locat ion ’ , ’ nor theas t ’ )

15

3.1.2 binoTree.m

1 f unc t i on [ pr i c e , spotTree , p r i c eTree ] = binoTree (S , K, r , T, vol ,q , ca l l pu t , AE, N)

2 %binoTree Option p r i c e us ing binomial t r e e3 % Arguments are spot , s t r i k e , rate , time , vol , y i e ld , c a l l /put

s t r i ng , AE s t r i n g4 % time s t ep s5

6

7 %I n i t i a l i s e v a r i a b l e s8 dt = T / N;9 u = exp ( vo l ∗ s q r t ( dt ) ) ;

10 d = 1 / u ;11 p = ( exp ( ( r−q ) ∗ dt ) − d) / (u − d) ;12 df = exp(−r ∗ dt ) ;13 %c a l l /put switch14

15 i f upper ( c a l l p u t (1 ) )==’C ’16 alpha = 1 ;17 e l s e18 alpha = −1;19 end20

21 %european / american switch22 i f upper (AE(1) )==’A ’23 beta = 1 ;24 e l s e25 beta = 0 ;26 end27 %I n i t i a l i s e and s i z e working v a r i a b l e s28

29 p r i c e = 0 ;30 FF = ze ro s (N+1,N+1) ;31 SS = ze ro s (N+1,N+1) ;32 SS (1 , 1 )=S ;33

34 %Evolve spot p r i c e s forward35 f o r i =2:N+136 SS( i , 1) = SS( i − 1 , 1) ∗ d ;37 f o r j =2: i38 SS( i , j ) = SS( i − 1 , j − 1) ∗ u ;39 end40 end41

16

42 %Set boundary c o n d i t i o n s f o r payo f f43 f o r j =1:1 :N+144 FF(N+1, j )=max( 0 , ( SS(N+1, j ) − K) ∗ alpha ) ;45 end46 f o r i=N:−1:147 f o r j =1: i48 FF( i , j ) = df ∗ (FF( i + 1 , j ) ∗ (1 − p) + FF( i + 1 , j + 1)

∗ p) ;49 i f beta %American50 i f ( SS ( i , j ) − K) ∗ alpha > FF( i , j )51 FF( i , j ) = (SS( i , j ) − K) ∗ alpha ;52 end53 end54 end55 end56

57 p r i c e = FF(1 , 1 ) ;58 spotTree = SS ;59 pr i c eTree = FF;60 end

17

3.1.3 ppInv.m

1 f unc t i on [ y ] = ppInv ( x , n )2 %Returns the Peizer−Pratt In v e r s i on3 %Defined f o r odd va lues o f n only4

5 t = exp (−((x / (n + 1 / 3 + 0 .1 / (n + 1) ) ) ˆ 2) ∗ (n + 1 / 6) ) ;6 y = 0 .5 ∗(1 + s i gn ( x ) ∗ s q r t (1 − t ) ) ;7

8 end

18

3.1.4 LR BinoTree.m

1 f unc t i on [ Pr i ce ] = LR BinoTree ( S , K , r , T, vol , q , ca l l put , N)2 % Binomial t r e e implementation3

4 % I n i t i a l i s e v a r i a b l e s5 dt = T / N;6 d1 = ( log (S/K) + ( r − q + 0.5∗ vo l ˆ2)∗T) /( vo l ∗ s q r t (T) ) ;7 d2 = ( log (S/K) + ( r − q − 0 .5∗ vo l ˆ2)∗T) /( vo l ∗ s q r t (T) ) ;8 p = ppInv ( d2 ,N) ;9 p1 = ppInv ( d1 ,N) ;

10 u = ( p1/p)∗exp ( ( r−q )∗dt ) ;11 d = ((1−p1 ) /(1−p) )∗exp ( ( r−q )∗dt ) ;12 df = exp(−r ∗ dt ) ;13

14 FF = ze ro s (N+1,N+1) ;15 SS = ze ro s (N+1,N+1) ;16

17 %c a l l /put switch18

19 i f upper ( c a l l p u t (1 ) ) ==’C ’20 alpha = 1 ;21 e l s e22 alpha = −1;23 end24

25

26

27 % Evolve Spot p r i c e s foward28 SS (1 , 1 ) = S ;29 % quick note ; ” i ” i s loop counter . From 2 to N+1.30 f o r i =2:N+131 f o r j =2: i32 SS( i , j ) = SS( i −1, j−1)∗u ;33 end34 SS( i , 1 ) = SS( i −1 ,1)∗d ;35 end36

37 % Set boundary c o n d i t i o n s f o r payo f f . j r ep r e s en s increments inv e r t i c a l

38 % space . i i s increments in time .39 f o r j = 1 :N+140 FF(N+1, j ) = max( ( SS( i , j ) − K)∗alpha , 0 ) ;41 end42

19

43 % Discount the opt ion p r i c e back through the t r e e44

45 f o r i = N:−1:146 f o r j =1: i47 FF( i , j ) = df ∗(p∗FF( i +1, j +1) + (1−p)∗FF( i +1, j ) ) ;48 end49 end50

51 Pr i ce = FF(1 , 1 ) ;52

53 end

20