Creation of this worksheet was supported by IT Academy program of Information Technology Foundation for Education (HITSA)

Exercises of Lab 16

The aim of the lab is to learn to implement an explicit finite difference method for computing prices of European options depending on two underlying stocks.

From Lecture 15 we know that if the BS market model with constant volatilities hold, then the price of option with payoff function $p(s_1,s_2)$ at time $t$ is given by

$$=u(\frac{\ln(S_1(t))}{\sigma_1},-\rho\frac{\ln(S_1(t))}{\sigma_1}+\frac{\ln(S_2(t))}{\sigma_2},t),$$

where $u$ solves the partial differential equation $$\frac{\partial u}{\partial t}+\frac{1}{2}\frac{\partial^2u}{\partial x_1^2}+\alpha\frac{\partial^2u}{\partial x_2^2}+ \beta\frac{\partial u}{\partial x_1} + \gamma \frac{\partial u}{\partial x_2}-ru=0$$ with final condition $$u(x_1,x_2,T)=p(e^{\sigma_1 x_1},e^{\sigma_2(x_2+\rho x_1)}).$$

An explicit finite difference method for solving this proble corresponds to formulas

$$U_{i,j,k-1}=a_{-1,0}U_{i-1,j,k}+a_{0,0}U_{ijk}+a_{1,0}U_{i+1,j,k}+a_{0,1}U_{i,j+1,k}+a_{0,-1}U_{i,j-1,k},$$

where \begin{align*} a_{-1,0}&=\frac{\Delta t}{2\Delta x_1}\left(\frac{1}{\Delta x_1}-\beta \right),\\ a_{1,0}&=\frac{\Delta t}{2\Delta x_1}\left(\frac{1}{\Delta x_1}+\beta\right),\\ a_{0,-1}&=\frac{\Delta t}{2\Delta x_2}\left(\frac{2\alpha}{\Delta x_2}-\gamma\right),\\ a_{0,1}&=\frac{\Delta t}{2\Delta x_2}\left(\frac{2\alpha}{\Delta x_2}+\gamma\right),\\ a_{0,0}&=1-r\Delta t-\frac{\Delta t}{\Delta x_1^2}-\frac{2\Delta t \cdot \alpha}{\Delta x_2^2}, \end{align*} where $\alpha=\frac{1-\rho^2}{2},\ \beta=\frac{r-D_1-\frac{1}{2}\sigma_1^2}{\sigma_1},\ \gamma=\frac{r-D_2-\frac{1}{2}\sigma_2^2}{\sigma_2}-\rho\beta$

The procedure of using the method is as follows.

  1. Choose artificial boundaries $x_{1,min},x_{1,max},x_{2,min},x_{2,max}$, number of steps $n_1,n_2,m$ in $x_1,x_2$ and $t$ direction and compute step sizes and grid points.
  2. Fill in the values for $U_{ijm},\ i=0,\ldots,n_1,\ j=0,\ldots,n_2$, using the final condition.
  3. For each $k=m,m-1,\ldots,0$
    1. Apply the constant (time independent) boundary condition at $x_1=x_{1,min},x_1=x_{1,max},x_2=x_{2,min},x_2=x_{2,max}$
    2. For each $i=1,\ldots,n_1-1$, $j=1,\ldots,n_2-1$ compute the values $U_{ijk}$ according to the formulas given above.

When using the method it is important to make sure that the coefficient $a_{0,0}$ is non-negative; otherwise the method is unstable.

Exercise 1 Let us consider an European option with payoff function $p(s_1,s_2)=\max(s_1-50,s_2-100,0)$. Assume $r=0.02$, $D_1=D_2=0$ and that underlying stock prices $S_1(t)$ and $S_2(t)$ follow BS market model with volatilities $\sigma_1=0.4$, $\sigma_2=0.6$ and that corresponding brownian motions are correlated with correlation $\rho=0.2$. Let $T=0.5$, $S_1(0)=48$, $S_2(0)=95$. Write a function, that for given values $m,n_1,n_2$ finds an approximate option price at $t=0$ using the finite difference method described above in the case $x_{1,min}=\frac{\ln(S_1(0))}{\sigma_1}-5$, $x_{1,max}=\frac{\ln(S_1(0))}{\sigma_1}+5$, $x_{2,min}=\frac{\ln(S_2(0))}{\sigma_2}-\rho\cdot\frac{\ln(S_1(0))}{\sigma_1} -5$, $x_{2,max}=\frac{\ln(S_2(0))}{\sigma_2}-\rho\cdot\frac{\ln(S_1(0))}{\sigma_1} +5$. Usee this function to compute approximately the option price for $n_1=50,n_2=100$, $m$ should be computed from the stability constraint.

Solution Define the general solver function:

In [ ]:
 

Define a function answer, which solves a concrete equation for given n1 and n2 and returns the approximate option price

In [ ]:
def answer(n1,n2):
In [ ]:
answer(50,100)
Check your results! Answer should be 17.24909728079166

Exercise 2 (problem from the sample final examination)

Consider an European option with payoff $$p(s)=\begin{cases} 0.25\,s,&s<42,\\ 42-\frac{3s}{4},&42\leq s<56,\\ 0,& s\geq 56. \end{cases}$$ and exercise time $T=0.5$. Assume $r=0.05$, $D=0$ and that Black-Scholes market model with the volatility $$\sigma(s,t)=0.4+0.2e^{-t} \sin(s/50)$$ holds. Find the derivative of the option price with respect to time at $t=0.1$ with accuracy $0.01$ by using the central difference approximation to the time derivative if the stock price at $t=0.1$ is 45.

Solution

In [ ]:
 
Check your result! The value of time derivative is approximately 2.34