SlideShare a Scribd company logo
1 of 23
Download to read offline
Options pricing using Lattice models • October 2019 • with C++ code snippets
Options pricing
using Lattice models in C++
QUASAR CHUNAWALA
quasar.chunawala@gmail.com
October 2019
Abstract
This is a short essay on using lattice methods to price European and American style
options.
1. BINOMIAL TREES
1.1. Introduction.
Binomial trees are useful for pricing a variety of European and American-style derivatives.
The primary practical use of the Binomial model was and still is for pricing American-style
options.
1.2. Pricing a European call option on a binomial tree.
Consider a stock with initial price S0, which follows a binomial process. During a time
period ∆t, the price per share of this stock will be one of two possible values, it can go up
to S0u or down to S0d. Consider a European call option that confers on its owner the right,
but not the obligation to buy one share of stock at time one for the strike price K. The
European call option pays (St − K)+
at time t.
We assume that the markets are complete. In a complete market, every derivative
security can be replicated by trading in the stock and money market asset.
Suppose we begin with an initial wealth X0 and buy ∆ shares of a stock at price S0 at
time zero, leaving us with a cash postion X0 − ∆S0. The value of our portfolio of stock and
the money market account at time one is :
X1 = ∆S1 + er∆t
(X0 − ∆S0) = X0er∆t
+ ∆(S1 − S0er∆t
)
We want to find X0 and ∆ so, that X1(u) = Cu and X1(d) = Cd. Note here, that Cu and
Cd are given quantities, the amounts that the derivative security will pay off depending
upon the outcome of the coin tosses. At time zero, we know what the two values Cu and
Cd are; we don’t know which of these two possibilities will be realized. Replication of the
derivative security thus requires that :
1
Options pricing using Lattice models • October 2019 • with C++ code snippets
Figure 1: A binomial tree with N=4 timesteps
e−r∆t
Cu = X0 + ∆(S0ue−r∆t
− S0)
e−r∆t
Cd = X0 + ∆(S0de−r∆t
− S0)
One way to solve these two equations in two unknowns is to multiply the first by a
number ˜p and the second by ˜q = 1 − ˜p and then add them to get
e−r∆t
(˜pCu + ˜qCd) = X0 + ∆((˜pS0u + ˜qS0d)e−r∆t
− S0)
If we choose ˜p so that the ∆ term in the above equation is zero, that is :
S0 = e−r∆t
(˜pS0u + ˜qS0d)
we obtain the simple formula for X0,
X0 = e−r∆t
(˜pCu + ˜qCd)
We can solve for ˜p and ˜q as follows:
S0 = e−r∆t
(˜pS0u + ˜qS0d)
er∆t
= (˜pu + (1 − ˜p)d)
er∆t
= ˜p(u − d) + d
˜p =
er∆t
− d
u − d
˜q =
u − er∆t
u − d
2
Options pricing using Lattice models • October 2019 • with C++ code snippets
We can solve for ∆ simply by subtracting the portfolio values at time one -
∆ =
Cu − Cd
S0u − S0d
Thus, we have replicated the option payoff.
The numbers ˜p and ˜q are both positive because of the no-arbitrage condition and they
sum to one. For this reason, we can regard them as up and down probabilities. They are
not the actual probabilities, which I shall p and q, but rather the risk-neutral probabilities.
Under the actual probabilities, the average rate of growth of a stock is typically strictly
greater than the rate of growth of an investment in the money market; otherwise no one
would want to incur the risk associated with investing in the stock. Thus, p and q = 1 − p
should satisfy
S0 < e−r∆t
(pS0u + qS0d)
whereas ˜p and ˜q satisfy
S0 = e−r∆t
(˜pS0u + ˜qS0d)
If the average rate of growth of the stock were exactly the same as the rate of growth
of the money market investment, then investors must be neutral about risk - they do
not require compensation for assuming it, nor are they willing to pay extra for it. This
is simply not the case, and hence ˜p and ˜q cannot be the actual probabilities. They are
only numbers which assist us in the solution of the two equations in the two unknowns
(∆, X0). They assist us by making the term multiplying the unknown ∆ drop out. If we
want to construct a portfolio whose value at time one is V1, then its value at time zero,
must be given by the formula above, so that its mean rate of growth under risk-neutral
probabilities is the rate of growth of the money market investment. The formula is called
the risk-neutral pricing formula.
1.3. Matching moments of the binomial and lognormal distributions.
Consider a time period ∆t in the continuous time Black Scholes world. Suppose the stock
price process governed by following SDE :
dS = mSdt + σSdz
where m and σ are known constants - the mean rate of growth of the stock and the
volatility of the stock price respectively. The simplest choice is a constant volatility.
From Ito’s formula, we know that, if S(t) is any stochastic process, then the process
f(S(t), t) is given by the expansion :
df =
∂f
∂t
+ mS
∂f
∂S
+
1
2
σ2
S2 ∂2
f
∂S2
dt + σS
∂f
∂S
dz
If we let f(S) = log S then we obtain the following Wiener process :
3
Options pricing using Lattice models • October 2019 • with C++ code snippets
∂f
∂t
= 0
∂f
∂S
=
1
S
∂2
f
∂S2
= −
1
S2
=⇒ d(ln S) = (m −
1
2
σ2
)dt + σdz
=⇒ ln(
ST
S0
) = (m −
1
2
σ2
)T + σZ(0, T)
=⇒ ST = S0 exp[(m − σ2
/2)T + σ
√
TZ(0, 1)]
Thus, log ST is normally distributed.
log ST ∼ N(log S0 + (m − σ2
/2)T, σT)
We can now calculate the moments of the lognormal distribution around 0. We need
to calculate the mean and variance. Since, log ST is normally distributed, we can use the
moment generating function of the normal distribution to help calculate expections.
The MGF of a normal random variable Z is given by,
E(etZ
) =
+∞
−∞
etz 1
√
2π
e−z2
/2
dz
= et2
/2 1
√
2π
+∞
−∞
e−(z−t)2
/2
dz
= et2
/2
The MGF of X = ν + σZ by completing the square as above is MX(t) = eνt+σ2
t2
/2
. Let
the random variable Y = eX
= eν+σZ
. Then E(Y n
) = E(enX
) = eνn+σ2
n2
/2
.
Therefore, in particular,
E[ST ] = S0e(ν+σ2
/2)∆t
= S0e(m−σ2
/2+σ2
/2)∆t
= S0em∆t
E[S2
T ] = S0e(2ν+2σ2
)∆t
= S0e(2m−σ2
+2σ2
)∆t
= S0e(2m+σ2
)∆t
For the underlying price at the end of the period to have the same mean and variance
in both the binomial model and the Black Scholes models, the following two identities
must hold where the first and second moments are matched.
4
Options pricing using Lattice models • October 2019 • with C++ code snippets
pu + (1 − p)d = er∆t
pu2
+ (1 − p)d2
= e(2r+σ2
)∆t
Solving the first equation for the probability p, we obtain :
p =
er∆t
− d
u − d
1.4. CRR Binomial Tree.
Cox, Ross, Rubinstein in their original model assume the identity ud = 1, so that u = 1/d.
Substituting u = 1/d and the value of the risk neutral probability p into the second
equation we get :
p(u2
− d2
) + d2
= e(2r+σ2
)∆t
(er∆t
− d)(u + d) + d2
= e(2r+σ2
)∆t
er∆t
(u + d) − du − d2
+ d2
= e(2r+σ2
)∆t
er∆t
(u + d) − du = e(2r+σ2
)∆t
er∆t
(d2
+ 1) − d = e(2r+σ2
)∆t
d
(d2
+ 1) − d(e−r∆t
+ e(r+σ2
)∆t
) = 0
d2
− 2Ad + 1 = 0
where A = 1
2 (e−r∆t
+ e(r+σ2
)∆t
).
The solutions of this quadratic equation are:
u = A + A2 − 1
d = A − A2 − 1
If we linearize the above solution using the series expansion ex
= 1 + x + x2
2! + . . ., we
obtain -
A =
1
2
[(1 − r∆t) + (1 + r∆t + σ2
∆t)]
= 1 +
1
2
σ2
∆t
A2
=
1
4
[(1 − 2r∆t) + (1 + 2r∆t + 2σ2
∆t) + 2(1 + σ2
∆t)]
= 1 + σ2
∆t
u = 1 + σ
√
∆t +
1
2
σ2
∆t
d = 1 − σ
√
∆t +
1
2
σ2
∆t
5
Options pricing using Lattice models • October 2019 • with C++ code snippets
Terms of higher orders can be added without violating the relations since they become
infinitesimally small as ∆t approached 0. Thus, the more common form is
u = eσ
√
∆t
d = e−σ
√
∆t
The CRR has traditionally been the most widely used version of the binomial model.
[1]
1.5. CRR Binomial Tree implementation.
The following is an implementation of the CRR model on a European option.
#include<iostream>
#include <iostream>
#include <array>
class CRRBinomialTree
{
private:
double p;
std::array<std::array<double, 200>, 200> S;
std::array<std::array<double, 200>, 200> C;
double u;
double d;
double T;
int N;
double sigma;
double dt;
double r;
double s_0;
double K;
char optionType;
double q;
public:
CRRBinomialTree(double vol, double expiry, int numOfTimeSteps,
double spot, double strike, double rate, double div, char optType);
double pv();
double payOff(double s_t);
};
// CRRBinomialTree.cpp : Computes the value of a European
// option using backwards induction in a CRR Binomial tree
#include<iostream>
#include "CRRBinomialTree.h"
#include<cmath>
CRRBinomialTree::CRRBinomialTree(double vol, double expiry, int numOfTimeSteps,
6
Options pricing using Lattice models • October 2019 • with C++ code snippets
double spot, double strike, double rate, double div, char optType)
{
N = numOfTimeSteps;
T = expiry;
dt = T / N;
r = rate;
q = div;
sigma = vol;
u = exp(sigma * sqrt(dt));
d = 1 / u;
double a = exp((r - q) * dt);
p = (a - d) / (u - d);
s_0 = spot;
K = strike;
optionType = optType;
S = {0.0};
C = {0.0};
//compute the stock prices at each node
//initialize call prices
for (int i = 0; i <= N; ++i)
{
for (int j = 0; j <= i; ++j)
{
S[i][j] = s_0 * pow(u, j) * pow(d, i - j);
C[i][j] = 0.0;
}
}
}
double CRRBinomialTree::payOff(double S_t)
{
if (optionType == 'C')
return std::max(S_t - K, 0.0);
if (optionType == 'P')
return std::max(K - S_t, 0.0);
}
double CRRBinomialTree::pv()
{
double df = 0.0;
//compute terminal payoffs
for (int j = N; j >= 0; --j)
{
C[N][j] = payOff(S[N][j]);
}
//work backwards
7
Options pricing using Lattice models • October 2019 • with C++ code snippets
for (int i = N - 1; i >= 0; --i)
{
for (int j = i; j >= 0; --j)
{
df = exp(-r * dt);
C[i][j] = df * (p * C[i + 1][j + 1] + (1 - p) * C[i + 1][j]);
}
}
return C[0][0];
}
#include<iostream>
#include "CRRBinomialTree.h"
int main()
{
CRRBinomialTree *europeanCall, *europeanPut;
europeanCall = new CRRBinomialTree(0.10, 1.0, 100, 100.0, 100.0, 0.05, 0.0, 'C');
europeanPut = new CRRBinomialTree(0.10, 1.0, 100, 100.0, 100.0, 0.05, 0.0, 'P');
double V_0=0.0;
V_0 = europeanCall->pv();
std::cout << "nCall value = " << V_0;
V_0 = europeanPut->pv();
std::cout << "nPut value = " << V_0;
return 0;
}
1.6. Early exercise of American options on non-dividend paying stocks.
Consider the following two portfolios at time t:
Portfolio A: One European Call option c, Ke−r(T −t)
cash.
Portfolio B: One share of stock worth St
In portfolio A, the cash will grow to K at time T. If ST > K, the option will be exercised
at maturity, and the portfolio A is worth ST . If ST < K, the call option expires worthless
and the portfolio is worth K. Hence, at time T, the portfolio is worth
max(ST , K)
Portfolio B is worth ST at time T. Hence, portfolio A is always worth as much as, and
can be worth more than the portfolio B at maturity.
max(ST , K) ≥ ST
In the absence of arbitrage opportunities, this must also be true today.
8
Options pricing using Lattice models • October 2019 • with C++ code snippets
c + Ke−r(T −t)
≥ St
c ≥ St − Ke−r(T −t)
≥ (St − K)
So, the European call c is always worth more than its intrinsic at expiry. Because
the owner of an American call has all the exercise opportunities open to the owner of a
corresponding European call, we must have C ≥ c. Given r > 0, C > St − K. This means
that C is always greater than the option’s intrinsic value prior to maturity.
Hence, it is never optimal to exercise American call options on non-dividend paying
stocks.
2. TRINOMIAL TREES
Trinomial trees are used more in practice then binomial trees, since they allow for 3
states: up, down and middle moves. We can price both European and American options
with trinomial trees.
2.1. CRR Trinomial tree.
The CRR has a symmetric tree structure where,
u = eλσ
√
∆t
(1)
d = e−λσ
√
∆t
(2)
ud = m2
= 1 (3)
The necessary and sufficient condition for the tree to recombine is ud = m2
.
We can compute the option value in a trinomial tree as the discounted expectation in
a risk-neutral world by computing:
Ci,j = e−r∆t
(puCi+1,j+1 + pmCi+1,j + pdCi+1,j−1) (4)
As before, we match the first two moments of the trinomial and lognormal distributions.
puu + (1 − pu − pd) + pdd = em∆t
(5)
puu2
+ (1 − pu − pd) + pdd2
= e(2m+σ2
)∆t
(6)
If we take the first order approximations of the power series of ex
, we can solve for
pu, pm, pd as follows. Let k = λσ
√
∆t. The first moment yields :
puek
+ (1 − pu − pd) + pde−k
= er∆t
pu(1 + k + k2
/2) + (1 − pu − pd) + pd(1 − k + k2
/2) = (1 + r∆t)
pu(k + k2
/2) + pd(−k + k2
/2) = r∆t
(7)
9
Options pricing using Lattice models • October 2019 • with C++ code snippets
The second moment yields:
pue2k
+ (1 − pu − pd) + pde−2k
= e(2r+σ2
)∆t
2λσ
√
∆t(pu − pd) = 2r∆t + σ2
∆t
pu(1 + 2k + 2k2
) + (1 − pu − pd) + pd(1 − 2k + 2k2
) = (1 + 2r∆t + σ2
∆t)
pu(2k + 2k2
) + pd(−2k + 2k2
) = 2r∆t + σ2
∆t
(8)
Plugging in the value of r∆t from equation 7 into 8, we obtain:
pu(2k + 2k2
) + pd(−2k + 2k2
) = 2r∆t + σ2
∆t
pu(2k + 2k2
) + pd(−2k + 2k2
) = pu(2k + k2
) + pd(−2k + k2
) + σ2
∆t
(pu + pd)k2
= σ2
∆t
(1 − pm)λ2
σ2
∆t = σ2
∆t
1 − pm =
1
λ2
pm = 1 −
1
λ2
(9)
Multiplying the left and right hand sides of the equation 9 by (−k + k2
/2),
pu + pd =
σ2
∆t
k2
pu(−k + k2
/2) + pd(−k + k2
/2) =
σ2
∆t
λ2σ2∆t
(−k + k2
/2)
pu(−k + k2
/2) + pd(−k + k2
/2) =
1
λ2
(−k + k2
/2)
(10)
I now solve equations 7 and 10 simultaneously.
pu(2k) = r∆t −
1
λ2
(−k + k2
/2)
pu(2λσ
√
∆t) = r∆t +
λσ
√
∆t
λ2
−
λ2
σ2
∆t
2λ2
pu(2λσ) ≈ r
√
∆t +
σ
λ
pu =
1
2λ2
+
1
2
r
λσ
√
∆t
(11)
Since pu and pd should add up to 1/λ2
,
pd =
1
2λ2
−
1
2
r
λσ
√
∆t (12)
It has been found that the value of λ that produces the best convergence rate is:
λ =
3
2
10
Options pricing using Lattice models • October 2019 • with C++ code snippets
2.2. CRR Trinomial Tree implementation.
The following code implements an American CRR trinomial tree with λ = 3/2. Suppose
we use a trinomial tree to price an at-the-money (ATM) American call option on a stock
priced at 50 dollars, strike price of 50, volatility of 20 percent, risk-free rate of 6 percent,
annual dividend yield of 3 percent and time to maturity = 1 year. Thus, S = 50, K = 50,
σ = 0.20, r = 0.06, q = 0.03 and T = 1.
//CRRTrinomialTree.h
#include <iostream>
#include <array>
class CRRTrinomialTree
{
private:
double p_u,p_d,p_m;
std::array<std::array<double, 250>, 250> S;
std::array<std::array<double, 250>, 250> C;
double u;
double d;
double T;
int N;
double sigma;
double dt;
double r;
double s_0;
double K;
char optionType;
double q;
double drift;
public:
CRRTrinomialTree(double vol, double expiry, int numOfTimeSteps,
double spot, double strike, double rate, double div, char optType);
double pv();
double payOff(double s_t);
void printTree();
int x(int i, int j);
int y(int i, int j);
};
// CRRTrinomialTree.cpp : Computes the value of a American option
// using backwards induction in a CRR Trinomial tree
#include<iostream>
#include "CRRTrinomialTree.h"
#include <cmath>
#include <iomanip>
CRRTrinomialTree::CRRTrinomialTree(double vol, double expiry, int numOfTimeSteps,
11
Options pricing using Lattice models • October 2019 • with C++ code snippets
double spot, double strike, double rate, double div, char optType)
{
N = numOfTimeSteps;
T = expiry;
dt = T / N;
r = rate;
q = div;
sigma = vol;
drift = (r - q - pow(sigma, 2.0) / 2.0);
const double lambda = sqrt(3.0 / 2.0);
u = exp(lambda * sigma * sqrt(dt));
d = 1 / u;
p_u = (1 / (2 * pow(lambda, 2))) +
(1 / 2) * (drift / (lambda * sigma)) * sqrt(dt);
p_d = (1 / (2 * pow(lambda, 2))) -
(1 / 2) * (drift / (lambda * sigma)) * sqrt(dt);
p_m = 1 - (1 / pow(lambda, 2));
s_0 = spot;
K = strike;
optionType = optType;
S = { 0.0 };
C = { 0.0 };
//compute the stock prices at each node
//initialize call prices
for (int i = 0; i <= N; ++i)
{
for (int j = -i; j <= i; ++j)
{
S[x(i,j)][y(i,j)] = s_0 * pow(u, j);
C[x(i,j)][y(i,j)] = 0.0;
}
}
}
int CRRTrinomialTree::x(int i, int j)
{
return (i + j);
}
int CRRTrinomialTree::y(int i, int j)
{
return i;
}
void CRRTrinomialTree::printTree()
{
std::cout << "nStock price tree";
std::cout << std::setprecision(5);
12
Options pricing using Lattice models • October 2019 • with C++ code snippets
for(int i = 2*N; i>=0;--i)
{
std::cout << "nn";
for (int j = 0; j <= N; ++j)
{
std::cout << "t" << S[i][j];
}
}
std::cout << "nnCall price tree";
for (int i = 2 * N; i >= 0; --i)
{
std::cout << "nn";
for (int j = 0; j <= N; ++j)
{
std::cout << "t" << C[i][j];
}
}
}
double CRRTrinomialTree::payOff(double S_t)
{
if (optionType == 'C')
return std::max(S_t - K, 0.0);
if (optionType == 'P')
return std::max(K - S_t, 0.0);
}
double CRRTrinomialTree::pv()
{
double df = 0.0;
int h = 0;
//compute terminal payoffs
for (int j = N; j >= -N; --j)
{
C[x(N,j)][y(N,j)] = payOff(S[x(N,j)][y(N,j)]);
}
//work backwards
for (int i = N - 1; i >= 0; --i)
{
for (int j = i; j >= -i; --j)
{
df = exp(-r * dt);
double v_u = C[x(i + 1, j + 1)][y(i + 1, j + 1)];
double v_m = C[x(i + 1, j)][y(i + 1, j)];
double v_d = C[x(i + 1, j - 1)][y(i + 1, j - 1)];
13
Options pricing using Lattice models • October 2019 • with C++ code snippets
double discountedExpectation = df * (p_u * v_u
+ p_m * v_m + p_d * v_d);
C[x(i,j)][y(i,j)] = std::max(discountedExpectation,
payOff(S[x(i,j)][y(i,j)]));
}
}
return C[0][0];
}
// testCRRTrinomialTree.cpp
#include<iostream>
#include "CRRTrinomialTree.h"
int main()
{
CRRTrinomialTree* americanCall;
americanCall = new CRRTrinomialTree(0.20, 1, 4, 50, 50, 0.06, 0.03, 'C');
double V_0 = americanCall->pv();
std::cout << "nPut value = " << V_0;
americanCall->printTree();
return 0;
}
The American call price and tree are printed as shown below:
Call value = 4.22538
Stock price tree
0 0 0 0 81.607
0 0 0 0 72.2
0 0 0 72.2 63.878
0 0 0 63.878 56.515
0 0 63.878 56.515 50
0 0 56.515 50 44.236
0 56.515 50 44.236 39.137
0 50 44.236 39.137 34.626
50 44.236 39.137 34.626 30.634
Call price tree
14
Options pricing using Lattice models • October 2019 • with C++ code snippets
0 0 0 0 31.607
0 0 0 0 22.2
0 0 0 22.226 13.878
0 0 0 13.986 6.5145
0 0 14.09 6.6962 0
0 0 7.494 2.1392 0
0 8.0402 2.9013 0 0
0 3.6442 0.70244 0 0
4.2254 1.1834 0 0 0
3. FINITE DIFFERENCE METHODS
Numerical methods known as finite difference methods are used for pricing derivatives
by approximating the diffusion process that the derivative must follow. Finite difference
methods schemes are used to numerically solve PDEs. They are particular useful for
valuation, when a closed-form analytical solution does not exist. By discretizing the
continuous time PDE, the derivative security must follow, it is possible approximate the
evolution of the derivative prices and therefore the PV of the contract.
3.1. The Black Scholes PDE.
Consider an underlying asset with price x. The underlying price evolves according to:
dx = µxdt + σxdz (13)
Consider a derivative contract whose value C depends on the asset price x at time t,
and can be thought of as a function C(t, x) of the random asset price x and time t. Using
Ito’s lemma, the function of a stochastic variable follows the process :
dC =
∂C
∂t
+ µx
∂C
∂x
+
1
2
σ2
x2 ∂2
C
∂x2
dt + σx
∂C
∂x
dz (14)
In the same way as for the asset-pricing model in equation 13, the process for C(t, x)
has two components - the drift component and a volatility component. The drift term is
deterministic, involving the drift and volatility parameters of the asset price process and
the partials of C with respect to x and t. Fundamentally, the source of randomness dz in
the asset-price process in equation 13 is the same as that in the derivative-price process
in equation 14.
It should therefore be possible to eliminate the source of randomness to create a
riskless portfolio Π akin to a money market asset. Construct a portfolio Π by shorting the
derivative C and buying ∂C
∂x units of the underlying.
15
Options pricing using Lattice models • October 2019 • with C++ code snippets
Π = −C +
∂C
∂x
x (15)
The change in the value of the portfolio over the time period dt is the differential,
dΠ = −dC +
∂C
∂x
dx (16)
Subsituting for dC and dx in equation 16 and using equations 13 and 14,
dΠ = −
∂C
∂t
+ µx
∂C
∂x
+
1
2
σ2
x2 ∂2
C
∂x2
dt − σx
∂C
∂x
dz +
∂C
∂x
(µxdt + σxdz) (17)
Simplifying we obtain,
dΠ =
∂C
∂t
+
1
2
σ2
x2 ∂2
C
∂x2
dt (18)
Finally, the rate of return on the riskless portfolio is:
dΠ
Π
=
∂C
∂t + 1
2 σ2
x2 ∂2
C
∂x2 dt
−C + ∂C
∂x x
= rdt (19)
The derivative C(t, x) price must therefore be the solution of the partial differential
equation,
∂C
∂t
(t, x) + rx
∂C
∂x
(t, x) +
1
2
σ2
x2 ∂2
C
∂x2
(t, x) = rC(t, x) (20)
3.2. Difference operators.
The principle of the finite difference method is to approximate the derivatives in partial
differential equations by a linear combination of the function values.
The derivative of a function at the point x can be approximated as:
Forward difference divided by h:
∆h[f](x)
h
=
f(x + h) − f(x)
h
(21)
Backward difference divided by h:
h[f](x)
h
=
f(x) − f(x − h)
h
(22)
Central difference divided by h:
δh[f](x)
h
=
f(x + h/2) − f(x − h/2)
h
(23)
In an analogous way, one can obtain finite difference approximations to higher order
derivatives and differential operators.
16
Options pricing using Lattice models • October 2019 • with C++ code snippets
The second order central difference:
f (x) ≈
δ2
h[f](x)
h
=
f (x + h/2) − f (x − h/2)
h
=
f(x+h)−f(x)
h − f(x)−f(x−h)
h
h
=
f(x + h) − 2f(x) + f(x − h)
h2
(24)
The second order forward difference:
f (x) ≈
∆2
h[f](x)
h
=
f (x + h) − f (x)
h
=
f(x+2h)−f(x+h)
h − f(x+h)−f(x)
h
h
=
f(x + 2h) − 2f(x + h) + f(x)
h2
(25)
The second order backward difference:
f (x) ≈
2
h[f](x)
h
=
f (x) − f (x − h)
h
=
f(x)−f(x−h)
h − f(x−h)−f(x−2h)
h
h
=
f(x) − 2f(x − h) + f(x − 2h)
h2
(26)
Mixed partial derivatives can be obtained as follows. Taking the central difference of
the x and y variables, we could obtain, for example:
∂2
u
∂x∂y i,j
=
∂
∂x
∂u
∂y
≈
(∂u
∂y )i+1,j − (∂u
∂y )i−1,j
2∆x
=
ui+1,j+1−ui+1j−1
2∆y −
ui−1,j+1−ui−1j−1
2∆y
2∆x
=
ui+1,j+1 − ui+1,j−1 − ui−1,j+1 + ui−1,j−1
4∆x∆y
(27)
3.3. Explicit finite difference scheme.
Consider the Black Scholes PDE:
∂C
∂t
+ rS
∂C
∂S
+
1
2
σ2
S2 ∂2
C
∂S2
= rC (28)
subject to the payoff condition C(t, ST ) = max(ST − K)+
.
We can simply this PDE by substituting it with finite differences. First, let’s substitute
x = log S, so that ∂C
∂S = ∂C
∂x · ∂x
∂S = 1
S
∂C
∂x and ∂2
C
∂S2 = − 1
S2
∂C
∂x + 1
S2
∂2
C
∂x2 .
∂C
∂t
+ ν
∂C
∂x
+
1
2
σ2 ∂2
C
∂x2
= rC (29)
We imagine time and space divided up into discrete intervals (∆t and ∆x), this is the
finite difference grid or lattice.
To obtain the explicit finite difference method we approximate the equation 29 using a
forward difference for ∂C/∂t and central differences for ∂C/∂x and ∂2
C/∂x2
. Denote by
Ci,j = C(ti, xj)
Therefore,
∂C
∂t t=ti
=
Ci+1,j − Ci,j
∆t
(30)
17
Options pricing using Lattice models • October 2019 • with C++ code snippets
∂C
∂x x=xj
=
Ci+1,j+1 − Ci+1,j−1
2∆x
(31)
∂2
C
∂x2
x=xj
=
Ci+1,j+1 − 2Ci+1,j + Ci+1,j−1
∆x2
(32)
Figure 2: Stencils for grid points for explicit and implicit finite difference schemes in
solving a PDE that is first order in t and second order in x
Substituting these values in the equation 29 we obtain,
Ci+1,j − Ci,j
∆t
+r
Ci+1,j+1 − Ci+1,j−1
2∆x
+
1
2
σ2 Ci+1,j+1 − 2Ci+1,j + Ci+1,j−1
∆x2
= rCi,j (33)
Multiplying throughout by 2∆x2
∆t,
2r(∆x)2
∆tCi,j = 2(∆x)2
(Ci+1,j − Ci,j) + r∆x∆t(Ci+1,j+1 − Ci+1,j−1)
+ σ2
∆t(Ci+1,j+1 − 2Ci+1,j + Ci+1,j−1)
=⇒ Ci,j(2∆x2
)(1 + r∆t) = (r∆x∆t + σ2
∆t)Ci+1,j+1 + (2∆x2
− 2σ2
∆t)Ci+1,j
+ (σ2
∆t − r∆x∆t)Ci+1,j−1
=⇒ Ci,j =
1
1 + r∆t
∆t
r
2∆x
+
σ2
2∆x2
Ci+1,j+1 + 1 −
σ2
∆x2
∆t Ci+1,j
+
1
2
σ2
∆x2
−
r
∆x
∆t Ci+1,j−1
(34)
The coefficients of Ci+1,j+1, Ci+1,j and Ci+1,j−1 can be thought of as the trinomial
probabilities. (1 + r∆t) is the discounting factor.
Therefore the explicit finite difference method is equivalent of approximating the Black
Scholes diffusion process by a discrete trinomial process, where,
18
Options pricing using Lattice models • October 2019 • with C++ code snippets
Ci,j =
1
1 + r∆t
(puCi+1,j+1 + pmCi + 1, j + pdCi+1,j−1) (35)
pu = ∆t
r
2∆x
+
σ2
2∆x2
(36)
pm = 1 −
σ2
∆x2
∆t (37)
pd =
1
2
σ2
∆x2
−
r
∆x
∆t (38)
3.4. Explicit finite difference implementation.
We create a rectangular grid or lattice by adding extra nodes to a trinomial tree, so that
we have 2M + 1, M >= N at every time step i instead of just 2i + 1.
However, at time step i, given all option values at i + 1, we cannot compute the bottom
and top option values (Ci,−M and Ci,M ) using discounted expectations, since this would
require knowing option values Ci+1,−M−1 and Ci+1,M+1 which we do not have. With no
additional information we can only compute the region indicated by the dashed branches
using discounted expectations.
In order to be able to compute the remainder of the grid we must add the extra
boundary conditions which determine the behavior of the option price as a function asset
price for high and low values of the asset price xj.
For example, for a European call option we have the following Neumann boundary
conditions (the delta for deep ITM calls is 1, whereas for deep OTM calls is 0):
∂C
∂S
(t, S) = 1 for large S (39)
∂C
∂S
(t, S) = 0 for small S (40)
In terms of the grid, the conditions 39 and 40 become:
Ci,M − Ci,M−1
Si,M − Si,M−1
= 1 for large S (41)
Ci,−M+1 − Ci,−M
Si,−M+1 − Si,−M
= 0 for small S (42)
I price a one-year ATM European call option with S = 100, K = 100, T = 1 year, r = 0.06,
δ = 0.03, M = 3, N = 3, ∆x = 0.02.
// ExplicitFDMGrid.h
#include <iostream>
#include <array>
class ExplicitFDMGrid
{
19
Options pricing using Lattice models • October 2019 • with C++ code snippets
private:
double p_u, p_d, p_m;
std::array<std::array<double, 250>, 250> S;
std::array<std::array<double, 250>, 250> C;
double T;
long M;
long N;
double sigma;
double dt;
double r;
double s_0;
double K;
char optionType;
double q;
double drift;
double dx;
public:
ExplicitFDMGrid(double vol, double expiry, long N_, long M_,
double spot, double strike, double rate, double div, char optType, double dx);
double pv();
double payOff(double s_t);
void printTree();
int row(int i, int j);
int col(int i, int j);
};
// ExplicitFDMGrid.cpp : Computes the value of a European option
// the explicit finite difference method
#include<iostream>
#include "ExplicitFDMGrid.h"
#include <cmath>
#include <iomanip>
ExplicitFDMGrid::ExplicitFDMGrid(double vol, double expiry, long N_, long M_,
double spot, double strike, double rate, double div, char optType, double deltax)
{
N = N_; M = M_;
T = expiry;
dt = T / N;
r = rate;
q = div;
sigma = vol;
dx = deltax;
drift = (r - q - pow(sigma, 2.0) / 2.0);
p_u = 0.50 * dt * (pow((sigma/dx),2)+(drift/dx));
p_m = 1 - dt * (pow((sigma / dx), 2));
p_d = 0.50 * dt * (pow((sigma / dx), 2) - (drift / dx));
s_0 = spot;
K = strike;
20
Options pricing using Lattice models • October 2019 • with C++ code snippets
optionType = optType;
S = { 0.0 };
C = { 0.0 };
std::cout << "np_u = " << p_u;
std::cout << "np_m = " << p_m;
std::cout << "np_d = " << p_d;
//initialize the asset prices at maturity
//these apply to every time step
for (int j = -M; j <= M; ++j)
{
for (int i = 0; i <= N; ++i)
{
S[row(i, j)][col(i, j)] = s_0 * exp(j * dx);
}
}
//initialize the option values at maturity
for (int j = -M; j <= M; ++j)
{
C[row(N, j)][col(N, j)] = payOff(S[row(N, j)][col(N, j)]);
}
}
int ExplicitFDMGrid::row(int i, int j)
{
return (M+j);
}
int ExplicitFDMGrid::col(int i, int j)
{
return i;
}
void ExplicitFDMGrid::printTree()
{
std::cout << "nStock price tree";
std::cout << std::setprecision(8);
for (int j = 2 * M; j >= 0; --j)
{
std::cout << "nn";
for (int i = 0; i <= N; ++i)
{
std::cout << "t" << S[j][i];
}
}
21
Options pricing using Lattice models • October 2019 • with C++ code snippets
std::cout << "nnCall price tree";
for(int j = 2 * M; j >= 0; --j)
{
std::cout << "nn";
for (int i = 0; i <= N; ++i)
{
std::cout << "t" << C[j][i];
}
}
}
double ExplicitFDMGrid::payOff(double S_t)
{
if (optionType == 'C')
return std::max(S_t - K, 0.0);
if (optionType == 'P')
return std::max(K - S_t, 0.0);
}
double ExplicitFDMGrid::pv()
{
double df = 0.0;
//work backwards
for (int i = N - 1; i >= 0; --i)
{
for (int j = M - 1; j >= -M+1; --j)
{
df = exp(-r * dt);
double v_u = C[row(i + 1, j + 1)][col(i + 1, j + 1)];
double v_m = C[row(i + 1, j)][col(i + 1, j)];
double v_d = C[row(i + 1, j - 1)][col(i + 1, j - 1)];
C[row(i,j)][col(i,j)] = (p_u * v_u
+ p_m * v_m + p_d * v_d);
}
//Neumann boundary conditions
if (optionType == 'C')
{
C[row(i, M)][col(i, M)] = C[row(i, M - 1)][col(i, M - 1)] +
(S[row(i, M)][col(i, M)] - S[row(i, M - 1)][col(i, M - 1)]);
C[row(i, -M)][col(i, -M)] = C[row(i, -M + 1)][col(i, -M + 1)];
}
else if (optionType == 'P')
{
C[row(i, M)][col(i, M)] = C[row(i, M - 1)][col(i, M - 1)];
22
Options pricing using Lattice models • October 2019 • with C++ code snippets
C[row(i, -M)][col(i, -M)] = C[row(i, -M + 1)][col(i, -M + 1)] +
(S[row(i, -M)][col(i, -M)] - S[row(i, -M + 1)][col(i, -M + 1)]);
}
}
return C[row(0,0)][col(0,0)];
}
// test explicit FDM grid
#include<iostream>
#include "ExplicitFDMGrid.h"
int main()
{
ExplicitFDMGrid* g;
g = new ExplicitFDMGrid(0.20, 1, 3, 3, 100, 100, 0.06,0.03,'C',0.2);
double V_0 = g->pv();
std::cout << "nOption value = " << V_0;
g->printTree();
return 0;
}
REFERENCES
[1] Mark Rubinstein John Cox, Stephen Ross. Option pricing: A simplified approach.
Journal of Financial Economics, 1979.
23

More Related Content

What's hot

Introduction to Cost Accounting
Introduction to Cost AccountingIntroduction to Cost Accounting
Introduction to Cost AccountingDr. Sushil Bansode
 
Strategic cost management devika rajagopal
Strategic cost management devika rajagopalStrategic cost management devika rajagopal
Strategic cost management devika rajagopalDevika Rajagopal
 
International Logistics - Customs, Transportation And Intermediaries
International Logistics  -  Customs, Transportation And IntermediariesInternational Logistics  -  Customs, Transportation And Intermediaries
International Logistics - Customs, Transportation And IntermediariesBhupesh Shah
 
Managing the Transfer Pricing Lifecycle
Managing the Transfer Pricing LifecycleManaging the Transfer Pricing Lifecycle
Managing the Transfer Pricing LifecycleJuan Carlos Ceballos
 
Introduction to cost accounting
Introduction to cost accountingIntroduction to cost accounting
Introduction to cost accountingSyed Mahmood Ali
 
DEFINITION AND INTRODUCTION OF EXPORT MARKETING
DEFINITION AND INTRODUCTION OF EXPORT MARKETINGDEFINITION AND INTRODUCTION OF EXPORT MARKETING
DEFINITION AND INTRODUCTION OF EXPORT MARKETINGAman Dwivedi
 
Customs Classification
Customs ClassificationCustoms Classification
Customs Classificationtasjhesselink
 
Cargo documentation
Cargo documentationCargo documentation
Cargo documentationmanzoor mba
 
Learning Series - Derivative
Learning Series - DerivativeLearning Series - Derivative
Learning Series - DerivativeHDFC securities
 
Strategic Financial Management.pdf
Strategic Financial Management.pdfStrategic Financial Management.pdf
Strategic Financial Management.pdfIbrahimMuye
 

What's hot (20)

Custom valuation
Custom valuationCustom valuation
Custom valuation
 
Options, caps, floors
Options, caps, floorsOptions, caps, floors
Options, caps, floors
 
Introduction to Cost Accounting
Introduction to Cost AccountingIntroduction to Cost Accounting
Introduction to Cost Accounting
 
Transfer pricing
Transfer pricingTransfer pricing
Transfer pricing
 
Strategic cost management devika rajagopal
Strategic cost management devika rajagopalStrategic cost management devika rajagopal
Strategic cost management devika rajagopal
 
International Logistics - Customs, Transportation And Intermediaries
International Logistics  -  Customs, Transportation And IntermediariesInternational Logistics  -  Customs, Transportation And Intermediaries
International Logistics - Customs, Transportation And Intermediaries
 
Managing the Transfer Pricing Lifecycle
Managing the Transfer Pricing LifecycleManaging the Transfer Pricing Lifecycle
Managing the Transfer Pricing Lifecycle
 
Introduction to cost accounting
Introduction to cost accountingIntroduction to cost accounting
Introduction to cost accounting
 
Cost accounting
Cost accountingCost accounting
Cost accounting
 
DEFINITION AND INTRODUCTION OF EXPORT MARKETING
DEFINITION AND INTRODUCTION OF EXPORT MARKETINGDEFINITION AND INTRODUCTION OF EXPORT MARKETING
DEFINITION AND INTRODUCTION OF EXPORT MARKETING
 
Investment and speculation
Investment and speculationInvestment and speculation
Investment and speculation
 
Cost accounting
Cost accountingCost accounting
Cost accounting
 
Customs Classification
Customs ClassificationCustoms Classification
Customs Classification
 
Cargo documentation
Cargo documentationCargo documentation
Cargo documentation
 
break even analysis
break even analysisbreak even analysis
break even analysis
 
Derivatives
DerivativesDerivatives
Derivatives
 
Learning Series - Derivative
Learning Series - DerivativeLearning Series - Derivative
Learning Series - Derivative
 
Strategic Financial Management.pdf
Strategic Financial Management.pdfStrategic Financial Management.pdf
Strategic Financial Management.pdf
 
Cost control
Cost controlCost control
Cost control
 
Contract Costing
Contract CostingContract Costing
Contract Costing
 

Similar to Options pricing using Lattice models

Uncertain Volatility Models
Uncertain Volatility ModelsUncertain Volatility Models
Uncertain Volatility ModelsSwati Mital
 
BB_11_Futures & Options_Hull_Chap_12.pptx
BB_11_Futures & Options_Hull_Chap_12.pptxBB_11_Futures & Options_Hull_Chap_12.pptx
BB_11_Futures & Options_Hull_Chap_12.pptxIbrahimKhatatbeh5
 
Remark on variance swaps pricing
Remark on variance swaps pricingRemark on variance swaps pricing
Remark on variance swaps pricingIlya Gikhman
 
Remark on variance swaps pricing new
Remark on variance swaps pricing newRemark on variance swaps pricing new
Remark on variance swaps pricing newIlya Gikhman
 
BB_12_Futures & Options_Hull_Chap_13.pptx
BB_12_Futures & Options_Hull_Chap_13.pptxBB_12_Futures & Options_Hull_Chap_13.pptx
BB_12_Futures & Options_Hull_Chap_13.pptxIbrahimKhatatbeh5
 
The comparative study of finite difference method and monte carlo method for ...
The comparative study of finite difference method and monte carlo method for ...The comparative study of finite difference method and monte carlo method for ...
The comparative study of finite difference method and monte carlo method for ...Alexander Decker
 
11.the comparative study of finite difference method and monte carlo method f...
11.the comparative study of finite difference method and monte carlo method f...11.the comparative study of finite difference method and monte carlo method f...
11.the comparative study of finite difference method and monte carlo method f...Alexander Decker
 
Options pricing and hedging
Options pricing and hedgingOptions pricing and hedging
Options pricing and hedgingIlya Gikhman
 
Derivatives pricing and Malliavin Calculus
Derivatives pricing and Malliavin CalculusDerivatives pricing and Malliavin Calculus
Derivatives pricing and Malliavin CalculusHugo Delatte
 
Black-Scholes overview
Black-Scholes overviewBlack-Scholes overview
Black-Scholes overviewInon Sharony
 
Option pricing model
Option pricing modelOption pricing model
Option pricing modelVishal Jain
 
Options pricing ( calculation of option premium)
Options pricing ( calculation of option premium)Options pricing ( calculation of option premium)
Options pricing ( calculation of option premium)Ameya Ranadive
 
The convenience yield implied by quadratic volatility smiles presentation [...
The convenience yield implied by quadratic volatility smiles   presentation [...The convenience yield implied by quadratic volatility smiles   presentation [...
The convenience yield implied by quadratic volatility smiles presentation [...yigalbt
 
Value of options presentation
Value of options presentationValue of options presentation
Value of options presentationTrevor Ruwa
 
Modeling an Asset Price
Modeling an Asset PriceModeling an Asset Price
Modeling an Asset PriceAdnan Kuhait
 
портфель English
портфель Englishпортфель English
портфель EnglishIlya Gikhman
 
Black scholes pricing consept
Black scholes pricing conseptBlack scholes pricing consept
Black scholes pricing conseptIlya Gikhman
 

Similar to Options pricing using Lattice models (20)

Uncertain Volatility Models
Uncertain Volatility ModelsUncertain Volatility Models
Uncertain Volatility Models
 
presentation
presentationpresentation
presentation
 
DP_M4_L2.pdf
DP_M4_L2.pdfDP_M4_L2.pdf
DP_M4_L2.pdf
 
BB_11_Futures & Options_Hull_Chap_12.pptx
BB_11_Futures & Options_Hull_Chap_12.pptxBB_11_Futures & Options_Hull_Chap_12.pptx
BB_11_Futures & Options_Hull_Chap_12.pptx
 
Remark on variance swaps pricing
Remark on variance swaps pricingRemark on variance swaps pricing
Remark on variance swaps pricing
 
Remark on variance swaps pricing new
Remark on variance swaps pricing newRemark on variance swaps pricing new
Remark on variance swaps pricing new
 
BB_12_Futures & Options_Hull_Chap_13.pptx
BB_12_Futures & Options_Hull_Chap_13.pptxBB_12_Futures & Options_Hull_Chap_13.pptx
BB_12_Futures & Options_Hull_Chap_13.pptx
 
The comparative study of finite difference method and monte carlo method for ...
The comparative study of finite difference method and monte carlo method for ...The comparative study of finite difference method and monte carlo method for ...
The comparative study of finite difference method and monte carlo method for ...
 
11.the comparative study of finite difference method and monte carlo method f...
11.the comparative study of finite difference method and monte carlo method f...11.the comparative study of finite difference method and monte carlo method f...
11.the comparative study of finite difference method and monte carlo method f...
 
Options pricing and hedging
Options pricing and hedgingOptions pricing and hedging
Options pricing and hedging
 
Derivatives pricing and Malliavin Calculus
Derivatives pricing and Malliavin CalculusDerivatives pricing and Malliavin Calculus
Derivatives pricing and Malliavin Calculus
 
Black-Scholes overview
Black-Scholes overviewBlack-Scholes overview
Black-Scholes overview
 
Option pricing model
Option pricing modelOption pricing model
Option pricing model
 
Options pricing ( calculation of option premium)
Options pricing ( calculation of option premium)Options pricing ( calculation of option premium)
Options pricing ( calculation of option premium)
 
Black-Schole Model.pptx
Black-Schole Model.pptxBlack-Schole Model.pptx
Black-Schole Model.pptx
 
The convenience yield implied by quadratic volatility smiles presentation [...
The convenience yield implied by quadratic volatility smiles   presentation [...The convenience yield implied by quadratic volatility smiles   presentation [...
The convenience yield implied by quadratic volatility smiles presentation [...
 
Value of options presentation
Value of options presentationValue of options presentation
Value of options presentation
 
Modeling an Asset Price
Modeling an Asset PriceModeling an Asset Price
Modeling an Asset Price
 
портфель English
портфель Englishпортфель English
портфель English
 
Black scholes pricing consept
Black scholes pricing conseptBlack scholes pricing consept
Black scholes pricing consept
 

More from Quasar Chunawala

Systems of linear algebraic equations i
Systems of linear algebraic equations iSystems of linear algebraic equations i
Systems of linear algebraic equations iQuasar Chunawala
 
Investigation of functions
Investigation of functionsInvestigation of functions
Investigation of functionsQuasar Chunawala
 
On building FX Volatility surface - The Vanna Volga method
On building FX Volatility surface - The Vanna Volga methodOn building FX Volatility surface - The Vanna Volga method
On building FX Volatility surface - The Vanna Volga methodQuasar Chunawala
 
Interpolation techniques - Background and implementation
Interpolation techniques - Background and implementationInterpolation techniques - Background and implementation
Interpolation techniques - Background and implementationQuasar Chunawala
 

More from Quasar Chunawala (8)

Resume
ResumeResume
Resume
 
Systems of linear algebraic equations i
Systems of linear algebraic equations iSystems of linear algebraic equations i
Systems of linear algebraic equations i
 
Vector Addition
Vector AdditionVector Addition
Vector Addition
 
Recursive squaring
Recursive squaringRecursive squaring
Recursive squaring
 
Investigation of functions
Investigation of functionsInvestigation of functions
Investigation of functions
 
Vector spaces
Vector spacesVector spaces
Vector spaces
 
On building FX Volatility surface - The Vanna Volga method
On building FX Volatility surface - The Vanna Volga methodOn building FX Volatility surface - The Vanna Volga method
On building FX Volatility surface - The Vanna Volga method
 
Interpolation techniques - Background and implementation
Interpolation techniques - Background and implementationInterpolation techniques - Background and implementation
Interpolation techniques - Background and implementation
 

Recently uploaded

Call Girls Alandi Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Alandi Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Alandi Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Alandi Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verifiedConnaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 
Zoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdfZoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdfSumit Kumar yadav
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learninglevieagacer
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPirithiRaju
 
Conjugation, transduction and transformation
Conjugation, transduction and transformationConjugation, transduction and transformation
Conjugation, transduction and transformationAreesha Ahmad
 
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...Monika Rani
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfrohankumarsinghrore1
 
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRLKochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRLkantirani197
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryAlex Henderson
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)Areesha Ahmad
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)Areesha Ahmad
 
IDENTIFICATION OF THE LIVING- forensic medicine
IDENTIFICATION OF THE LIVING- forensic medicineIDENTIFICATION OF THE LIVING- forensic medicine
IDENTIFICATION OF THE LIVING- forensic medicinesherlingomez2
 
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...chandars293
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksSérgio Sacani
 
Factory Acceptance Test( FAT).pptx .
Factory Acceptance Test( FAT).pptx       .Factory Acceptance Test( FAT).pptx       .
Factory Acceptance Test( FAT).pptx .Poonam Aher Patil
 
PSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptxPSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptxSuji236384
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsSérgio Sacani
 
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...dkNET
 

Recently uploaded (20)

Call Girls Alandi Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Alandi Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Alandi Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Alandi Call Me 7737669865 Budget Friendly No Advance Booking
 
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verifiedConnaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
 
Zoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdfZoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdf
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learning
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
Conjugation, transduction and transformation
Conjugation, transduction and transformationConjugation, transduction and transformation
Conjugation, transduction and transformation
 
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdf
 
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRLKochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 
IDENTIFICATION OF THE LIVING- forensic medicine
IDENTIFICATION OF THE LIVING- forensic medicineIDENTIFICATION OF THE LIVING- forensic medicine
IDENTIFICATION OF THE LIVING- forensic medicine
 
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
Factory Acceptance Test( FAT).pptx .
Factory Acceptance Test( FAT).pptx       .Factory Acceptance Test( FAT).pptx       .
Factory Acceptance Test( FAT).pptx .
 
PSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptxPSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptx
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
 
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...
 
Clean In Place(CIP).pptx .
Clean In Place(CIP).pptx                 .Clean In Place(CIP).pptx                 .
Clean In Place(CIP).pptx .
 

Options pricing using Lattice models

  • 1. Options pricing using Lattice models • October 2019 • with C++ code snippets Options pricing using Lattice models in C++ QUASAR CHUNAWALA quasar.chunawala@gmail.com October 2019 Abstract This is a short essay on using lattice methods to price European and American style options. 1. BINOMIAL TREES 1.1. Introduction. Binomial trees are useful for pricing a variety of European and American-style derivatives. The primary practical use of the Binomial model was and still is for pricing American-style options. 1.2. Pricing a European call option on a binomial tree. Consider a stock with initial price S0, which follows a binomial process. During a time period ∆t, the price per share of this stock will be one of two possible values, it can go up to S0u or down to S0d. Consider a European call option that confers on its owner the right, but not the obligation to buy one share of stock at time one for the strike price K. The European call option pays (St − K)+ at time t. We assume that the markets are complete. In a complete market, every derivative security can be replicated by trading in the stock and money market asset. Suppose we begin with an initial wealth X0 and buy ∆ shares of a stock at price S0 at time zero, leaving us with a cash postion X0 − ∆S0. The value of our portfolio of stock and the money market account at time one is : X1 = ∆S1 + er∆t (X0 − ∆S0) = X0er∆t + ∆(S1 − S0er∆t ) We want to find X0 and ∆ so, that X1(u) = Cu and X1(d) = Cd. Note here, that Cu and Cd are given quantities, the amounts that the derivative security will pay off depending upon the outcome of the coin tosses. At time zero, we know what the two values Cu and Cd are; we don’t know which of these two possibilities will be realized. Replication of the derivative security thus requires that : 1
  • 2. Options pricing using Lattice models • October 2019 • with C++ code snippets Figure 1: A binomial tree with N=4 timesteps e−r∆t Cu = X0 + ∆(S0ue−r∆t − S0) e−r∆t Cd = X0 + ∆(S0de−r∆t − S0) One way to solve these two equations in two unknowns is to multiply the first by a number ˜p and the second by ˜q = 1 − ˜p and then add them to get e−r∆t (˜pCu + ˜qCd) = X0 + ∆((˜pS0u + ˜qS0d)e−r∆t − S0) If we choose ˜p so that the ∆ term in the above equation is zero, that is : S0 = e−r∆t (˜pS0u + ˜qS0d) we obtain the simple formula for X0, X0 = e−r∆t (˜pCu + ˜qCd) We can solve for ˜p and ˜q as follows: S0 = e−r∆t (˜pS0u + ˜qS0d) er∆t = (˜pu + (1 − ˜p)d) er∆t = ˜p(u − d) + d ˜p = er∆t − d u − d ˜q = u − er∆t u − d 2
  • 3. Options pricing using Lattice models • October 2019 • with C++ code snippets We can solve for ∆ simply by subtracting the portfolio values at time one - ∆ = Cu − Cd S0u − S0d Thus, we have replicated the option payoff. The numbers ˜p and ˜q are both positive because of the no-arbitrage condition and they sum to one. For this reason, we can regard them as up and down probabilities. They are not the actual probabilities, which I shall p and q, but rather the risk-neutral probabilities. Under the actual probabilities, the average rate of growth of a stock is typically strictly greater than the rate of growth of an investment in the money market; otherwise no one would want to incur the risk associated with investing in the stock. Thus, p and q = 1 − p should satisfy S0 < e−r∆t (pS0u + qS0d) whereas ˜p and ˜q satisfy S0 = e−r∆t (˜pS0u + ˜qS0d) If the average rate of growth of the stock were exactly the same as the rate of growth of the money market investment, then investors must be neutral about risk - they do not require compensation for assuming it, nor are they willing to pay extra for it. This is simply not the case, and hence ˜p and ˜q cannot be the actual probabilities. They are only numbers which assist us in the solution of the two equations in the two unknowns (∆, X0). They assist us by making the term multiplying the unknown ∆ drop out. If we want to construct a portfolio whose value at time one is V1, then its value at time zero, must be given by the formula above, so that its mean rate of growth under risk-neutral probabilities is the rate of growth of the money market investment. The formula is called the risk-neutral pricing formula. 1.3. Matching moments of the binomial and lognormal distributions. Consider a time period ∆t in the continuous time Black Scholes world. Suppose the stock price process governed by following SDE : dS = mSdt + σSdz where m and σ are known constants - the mean rate of growth of the stock and the volatility of the stock price respectively. The simplest choice is a constant volatility. From Ito’s formula, we know that, if S(t) is any stochastic process, then the process f(S(t), t) is given by the expansion : df = ∂f ∂t + mS ∂f ∂S + 1 2 σ2 S2 ∂2 f ∂S2 dt + σS ∂f ∂S dz If we let f(S) = log S then we obtain the following Wiener process : 3
  • 4. Options pricing using Lattice models • October 2019 • with C++ code snippets ∂f ∂t = 0 ∂f ∂S = 1 S ∂2 f ∂S2 = − 1 S2 =⇒ d(ln S) = (m − 1 2 σ2 )dt + σdz =⇒ ln( ST S0 ) = (m − 1 2 σ2 )T + σZ(0, T) =⇒ ST = S0 exp[(m − σ2 /2)T + σ √ TZ(0, 1)] Thus, log ST is normally distributed. log ST ∼ N(log S0 + (m − σ2 /2)T, σT) We can now calculate the moments of the lognormal distribution around 0. We need to calculate the mean and variance. Since, log ST is normally distributed, we can use the moment generating function of the normal distribution to help calculate expections. The MGF of a normal random variable Z is given by, E(etZ ) = +∞ −∞ etz 1 √ 2π e−z2 /2 dz = et2 /2 1 √ 2π +∞ −∞ e−(z−t)2 /2 dz = et2 /2 The MGF of X = ν + σZ by completing the square as above is MX(t) = eνt+σ2 t2 /2 . Let the random variable Y = eX = eν+σZ . Then E(Y n ) = E(enX ) = eνn+σ2 n2 /2 . Therefore, in particular, E[ST ] = S0e(ν+σ2 /2)∆t = S0e(m−σ2 /2+σ2 /2)∆t = S0em∆t E[S2 T ] = S0e(2ν+2σ2 )∆t = S0e(2m−σ2 +2σ2 )∆t = S0e(2m+σ2 )∆t For the underlying price at the end of the period to have the same mean and variance in both the binomial model and the Black Scholes models, the following two identities must hold where the first and second moments are matched. 4
  • 5. Options pricing using Lattice models • October 2019 • with C++ code snippets pu + (1 − p)d = er∆t pu2 + (1 − p)d2 = e(2r+σ2 )∆t Solving the first equation for the probability p, we obtain : p = er∆t − d u − d 1.4. CRR Binomial Tree. Cox, Ross, Rubinstein in their original model assume the identity ud = 1, so that u = 1/d. Substituting u = 1/d and the value of the risk neutral probability p into the second equation we get : p(u2 − d2 ) + d2 = e(2r+σ2 )∆t (er∆t − d)(u + d) + d2 = e(2r+σ2 )∆t er∆t (u + d) − du − d2 + d2 = e(2r+σ2 )∆t er∆t (u + d) − du = e(2r+σ2 )∆t er∆t (d2 + 1) − d = e(2r+σ2 )∆t d (d2 + 1) − d(e−r∆t + e(r+σ2 )∆t ) = 0 d2 − 2Ad + 1 = 0 where A = 1 2 (e−r∆t + e(r+σ2 )∆t ). The solutions of this quadratic equation are: u = A + A2 − 1 d = A − A2 − 1 If we linearize the above solution using the series expansion ex = 1 + x + x2 2! + . . ., we obtain - A = 1 2 [(1 − r∆t) + (1 + r∆t + σ2 ∆t)] = 1 + 1 2 σ2 ∆t A2 = 1 4 [(1 − 2r∆t) + (1 + 2r∆t + 2σ2 ∆t) + 2(1 + σ2 ∆t)] = 1 + σ2 ∆t u = 1 + σ √ ∆t + 1 2 σ2 ∆t d = 1 − σ √ ∆t + 1 2 σ2 ∆t 5
  • 6. Options pricing using Lattice models • October 2019 • with C++ code snippets Terms of higher orders can be added without violating the relations since they become infinitesimally small as ∆t approached 0. Thus, the more common form is u = eσ √ ∆t d = e−σ √ ∆t The CRR has traditionally been the most widely used version of the binomial model. [1] 1.5. CRR Binomial Tree implementation. The following is an implementation of the CRR model on a European option. #include<iostream> #include <iostream> #include <array> class CRRBinomialTree { private: double p; std::array<std::array<double, 200>, 200> S; std::array<std::array<double, 200>, 200> C; double u; double d; double T; int N; double sigma; double dt; double r; double s_0; double K; char optionType; double q; public: CRRBinomialTree(double vol, double expiry, int numOfTimeSteps, double spot, double strike, double rate, double div, char optType); double pv(); double payOff(double s_t); }; // CRRBinomialTree.cpp : Computes the value of a European // option using backwards induction in a CRR Binomial tree #include<iostream> #include "CRRBinomialTree.h" #include<cmath> CRRBinomialTree::CRRBinomialTree(double vol, double expiry, int numOfTimeSteps, 6
  • 7. Options pricing using Lattice models • October 2019 • with C++ code snippets double spot, double strike, double rate, double div, char optType) { N = numOfTimeSteps; T = expiry; dt = T / N; r = rate; q = div; sigma = vol; u = exp(sigma * sqrt(dt)); d = 1 / u; double a = exp((r - q) * dt); p = (a - d) / (u - d); s_0 = spot; K = strike; optionType = optType; S = {0.0}; C = {0.0}; //compute the stock prices at each node //initialize call prices for (int i = 0; i <= N; ++i) { for (int j = 0; j <= i; ++j) { S[i][j] = s_0 * pow(u, j) * pow(d, i - j); C[i][j] = 0.0; } } } double CRRBinomialTree::payOff(double S_t) { if (optionType == 'C') return std::max(S_t - K, 0.0); if (optionType == 'P') return std::max(K - S_t, 0.0); } double CRRBinomialTree::pv() { double df = 0.0; //compute terminal payoffs for (int j = N; j >= 0; --j) { C[N][j] = payOff(S[N][j]); } //work backwards 7
  • 8. Options pricing using Lattice models • October 2019 • with C++ code snippets for (int i = N - 1; i >= 0; --i) { for (int j = i; j >= 0; --j) { df = exp(-r * dt); C[i][j] = df * (p * C[i + 1][j + 1] + (1 - p) * C[i + 1][j]); } } return C[0][0]; } #include<iostream> #include "CRRBinomialTree.h" int main() { CRRBinomialTree *europeanCall, *europeanPut; europeanCall = new CRRBinomialTree(0.10, 1.0, 100, 100.0, 100.0, 0.05, 0.0, 'C'); europeanPut = new CRRBinomialTree(0.10, 1.0, 100, 100.0, 100.0, 0.05, 0.0, 'P'); double V_0=0.0; V_0 = europeanCall->pv(); std::cout << "nCall value = " << V_0; V_0 = europeanPut->pv(); std::cout << "nPut value = " << V_0; return 0; } 1.6. Early exercise of American options on non-dividend paying stocks. Consider the following two portfolios at time t: Portfolio A: One European Call option c, Ke−r(T −t) cash. Portfolio B: One share of stock worth St In portfolio A, the cash will grow to K at time T. If ST > K, the option will be exercised at maturity, and the portfolio A is worth ST . If ST < K, the call option expires worthless and the portfolio is worth K. Hence, at time T, the portfolio is worth max(ST , K) Portfolio B is worth ST at time T. Hence, portfolio A is always worth as much as, and can be worth more than the portfolio B at maturity. max(ST , K) ≥ ST In the absence of arbitrage opportunities, this must also be true today. 8
  • 9. Options pricing using Lattice models • October 2019 • with C++ code snippets c + Ke−r(T −t) ≥ St c ≥ St − Ke−r(T −t) ≥ (St − K) So, the European call c is always worth more than its intrinsic at expiry. Because the owner of an American call has all the exercise opportunities open to the owner of a corresponding European call, we must have C ≥ c. Given r > 0, C > St − K. This means that C is always greater than the option’s intrinsic value prior to maturity. Hence, it is never optimal to exercise American call options on non-dividend paying stocks. 2. TRINOMIAL TREES Trinomial trees are used more in practice then binomial trees, since they allow for 3 states: up, down and middle moves. We can price both European and American options with trinomial trees. 2.1. CRR Trinomial tree. The CRR has a symmetric tree structure where, u = eλσ √ ∆t (1) d = e−λσ √ ∆t (2) ud = m2 = 1 (3) The necessary and sufficient condition for the tree to recombine is ud = m2 . We can compute the option value in a trinomial tree as the discounted expectation in a risk-neutral world by computing: Ci,j = e−r∆t (puCi+1,j+1 + pmCi+1,j + pdCi+1,j−1) (4) As before, we match the first two moments of the trinomial and lognormal distributions. puu + (1 − pu − pd) + pdd = em∆t (5) puu2 + (1 − pu − pd) + pdd2 = e(2m+σ2 )∆t (6) If we take the first order approximations of the power series of ex , we can solve for pu, pm, pd as follows. Let k = λσ √ ∆t. The first moment yields : puek + (1 − pu − pd) + pde−k = er∆t pu(1 + k + k2 /2) + (1 − pu − pd) + pd(1 − k + k2 /2) = (1 + r∆t) pu(k + k2 /2) + pd(−k + k2 /2) = r∆t (7) 9
  • 10. Options pricing using Lattice models • October 2019 • with C++ code snippets The second moment yields: pue2k + (1 − pu − pd) + pde−2k = e(2r+σ2 )∆t 2λσ √ ∆t(pu − pd) = 2r∆t + σ2 ∆t pu(1 + 2k + 2k2 ) + (1 − pu − pd) + pd(1 − 2k + 2k2 ) = (1 + 2r∆t + σ2 ∆t) pu(2k + 2k2 ) + pd(−2k + 2k2 ) = 2r∆t + σ2 ∆t (8) Plugging in the value of r∆t from equation 7 into 8, we obtain: pu(2k + 2k2 ) + pd(−2k + 2k2 ) = 2r∆t + σ2 ∆t pu(2k + 2k2 ) + pd(−2k + 2k2 ) = pu(2k + k2 ) + pd(−2k + k2 ) + σ2 ∆t (pu + pd)k2 = σ2 ∆t (1 − pm)λ2 σ2 ∆t = σ2 ∆t 1 − pm = 1 λ2 pm = 1 − 1 λ2 (9) Multiplying the left and right hand sides of the equation 9 by (−k + k2 /2), pu + pd = σ2 ∆t k2 pu(−k + k2 /2) + pd(−k + k2 /2) = σ2 ∆t λ2σ2∆t (−k + k2 /2) pu(−k + k2 /2) + pd(−k + k2 /2) = 1 λ2 (−k + k2 /2) (10) I now solve equations 7 and 10 simultaneously. pu(2k) = r∆t − 1 λ2 (−k + k2 /2) pu(2λσ √ ∆t) = r∆t + λσ √ ∆t λ2 − λ2 σ2 ∆t 2λ2 pu(2λσ) ≈ r √ ∆t + σ λ pu = 1 2λ2 + 1 2 r λσ √ ∆t (11) Since pu and pd should add up to 1/λ2 , pd = 1 2λ2 − 1 2 r λσ √ ∆t (12) It has been found that the value of λ that produces the best convergence rate is: λ = 3 2 10
  • 11. Options pricing using Lattice models • October 2019 • with C++ code snippets 2.2. CRR Trinomial Tree implementation. The following code implements an American CRR trinomial tree with λ = 3/2. Suppose we use a trinomial tree to price an at-the-money (ATM) American call option on a stock priced at 50 dollars, strike price of 50, volatility of 20 percent, risk-free rate of 6 percent, annual dividend yield of 3 percent and time to maturity = 1 year. Thus, S = 50, K = 50, σ = 0.20, r = 0.06, q = 0.03 and T = 1. //CRRTrinomialTree.h #include <iostream> #include <array> class CRRTrinomialTree { private: double p_u,p_d,p_m; std::array<std::array<double, 250>, 250> S; std::array<std::array<double, 250>, 250> C; double u; double d; double T; int N; double sigma; double dt; double r; double s_0; double K; char optionType; double q; double drift; public: CRRTrinomialTree(double vol, double expiry, int numOfTimeSteps, double spot, double strike, double rate, double div, char optType); double pv(); double payOff(double s_t); void printTree(); int x(int i, int j); int y(int i, int j); }; // CRRTrinomialTree.cpp : Computes the value of a American option // using backwards induction in a CRR Trinomial tree #include<iostream> #include "CRRTrinomialTree.h" #include <cmath> #include <iomanip> CRRTrinomialTree::CRRTrinomialTree(double vol, double expiry, int numOfTimeSteps, 11
  • 12. Options pricing using Lattice models • October 2019 • with C++ code snippets double spot, double strike, double rate, double div, char optType) { N = numOfTimeSteps; T = expiry; dt = T / N; r = rate; q = div; sigma = vol; drift = (r - q - pow(sigma, 2.0) / 2.0); const double lambda = sqrt(3.0 / 2.0); u = exp(lambda * sigma * sqrt(dt)); d = 1 / u; p_u = (1 / (2 * pow(lambda, 2))) + (1 / 2) * (drift / (lambda * sigma)) * sqrt(dt); p_d = (1 / (2 * pow(lambda, 2))) - (1 / 2) * (drift / (lambda * sigma)) * sqrt(dt); p_m = 1 - (1 / pow(lambda, 2)); s_0 = spot; K = strike; optionType = optType; S = { 0.0 }; C = { 0.0 }; //compute the stock prices at each node //initialize call prices for (int i = 0; i <= N; ++i) { for (int j = -i; j <= i; ++j) { S[x(i,j)][y(i,j)] = s_0 * pow(u, j); C[x(i,j)][y(i,j)] = 0.0; } } } int CRRTrinomialTree::x(int i, int j) { return (i + j); } int CRRTrinomialTree::y(int i, int j) { return i; } void CRRTrinomialTree::printTree() { std::cout << "nStock price tree"; std::cout << std::setprecision(5); 12
  • 13. Options pricing using Lattice models • October 2019 • with C++ code snippets for(int i = 2*N; i>=0;--i) { std::cout << "nn"; for (int j = 0; j <= N; ++j) { std::cout << "t" << S[i][j]; } } std::cout << "nnCall price tree"; for (int i = 2 * N; i >= 0; --i) { std::cout << "nn"; for (int j = 0; j <= N; ++j) { std::cout << "t" << C[i][j]; } } } double CRRTrinomialTree::payOff(double S_t) { if (optionType == 'C') return std::max(S_t - K, 0.0); if (optionType == 'P') return std::max(K - S_t, 0.0); } double CRRTrinomialTree::pv() { double df = 0.0; int h = 0; //compute terminal payoffs for (int j = N; j >= -N; --j) { C[x(N,j)][y(N,j)] = payOff(S[x(N,j)][y(N,j)]); } //work backwards for (int i = N - 1; i >= 0; --i) { for (int j = i; j >= -i; --j) { df = exp(-r * dt); double v_u = C[x(i + 1, j + 1)][y(i + 1, j + 1)]; double v_m = C[x(i + 1, j)][y(i + 1, j)]; double v_d = C[x(i + 1, j - 1)][y(i + 1, j - 1)]; 13
  • 14. Options pricing using Lattice models • October 2019 • with C++ code snippets double discountedExpectation = df * (p_u * v_u + p_m * v_m + p_d * v_d); C[x(i,j)][y(i,j)] = std::max(discountedExpectation, payOff(S[x(i,j)][y(i,j)])); } } return C[0][0]; } // testCRRTrinomialTree.cpp #include<iostream> #include "CRRTrinomialTree.h" int main() { CRRTrinomialTree* americanCall; americanCall = new CRRTrinomialTree(0.20, 1, 4, 50, 50, 0.06, 0.03, 'C'); double V_0 = americanCall->pv(); std::cout << "nPut value = " << V_0; americanCall->printTree(); return 0; } The American call price and tree are printed as shown below: Call value = 4.22538 Stock price tree 0 0 0 0 81.607 0 0 0 0 72.2 0 0 0 72.2 63.878 0 0 0 63.878 56.515 0 0 63.878 56.515 50 0 0 56.515 50 44.236 0 56.515 50 44.236 39.137 0 50 44.236 39.137 34.626 50 44.236 39.137 34.626 30.634 Call price tree 14
  • 15. Options pricing using Lattice models • October 2019 • with C++ code snippets 0 0 0 0 31.607 0 0 0 0 22.2 0 0 0 22.226 13.878 0 0 0 13.986 6.5145 0 0 14.09 6.6962 0 0 0 7.494 2.1392 0 0 8.0402 2.9013 0 0 0 3.6442 0.70244 0 0 4.2254 1.1834 0 0 0 3. FINITE DIFFERENCE METHODS Numerical methods known as finite difference methods are used for pricing derivatives by approximating the diffusion process that the derivative must follow. Finite difference methods schemes are used to numerically solve PDEs. They are particular useful for valuation, when a closed-form analytical solution does not exist. By discretizing the continuous time PDE, the derivative security must follow, it is possible approximate the evolution of the derivative prices and therefore the PV of the contract. 3.1. The Black Scholes PDE. Consider an underlying asset with price x. The underlying price evolves according to: dx = µxdt + σxdz (13) Consider a derivative contract whose value C depends on the asset price x at time t, and can be thought of as a function C(t, x) of the random asset price x and time t. Using Ito’s lemma, the function of a stochastic variable follows the process : dC = ∂C ∂t + µx ∂C ∂x + 1 2 σ2 x2 ∂2 C ∂x2 dt + σx ∂C ∂x dz (14) In the same way as for the asset-pricing model in equation 13, the process for C(t, x) has two components - the drift component and a volatility component. The drift term is deterministic, involving the drift and volatility parameters of the asset price process and the partials of C with respect to x and t. Fundamentally, the source of randomness dz in the asset-price process in equation 13 is the same as that in the derivative-price process in equation 14. It should therefore be possible to eliminate the source of randomness to create a riskless portfolio Π akin to a money market asset. Construct a portfolio Π by shorting the derivative C and buying ∂C ∂x units of the underlying. 15
  • 16. Options pricing using Lattice models • October 2019 • with C++ code snippets Π = −C + ∂C ∂x x (15) The change in the value of the portfolio over the time period dt is the differential, dΠ = −dC + ∂C ∂x dx (16) Subsituting for dC and dx in equation 16 and using equations 13 and 14, dΠ = − ∂C ∂t + µx ∂C ∂x + 1 2 σ2 x2 ∂2 C ∂x2 dt − σx ∂C ∂x dz + ∂C ∂x (µxdt + σxdz) (17) Simplifying we obtain, dΠ = ∂C ∂t + 1 2 σ2 x2 ∂2 C ∂x2 dt (18) Finally, the rate of return on the riskless portfolio is: dΠ Π = ∂C ∂t + 1 2 σ2 x2 ∂2 C ∂x2 dt −C + ∂C ∂x x = rdt (19) The derivative C(t, x) price must therefore be the solution of the partial differential equation, ∂C ∂t (t, x) + rx ∂C ∂x (t, x) + 1 2 σ2 x2 ∂2 C ∂x2 (t, x) = rC(t, x) (20) 3.2. Difference operators. The principle of the finite difference method is to approximate the derivatives in partial differential equations by a linear combination of the function values. The derivative of a function at the point x can be approximated as: Forward difference divided by h: ∆h[f](x) h = f(x + h) − f(x) h (21) Backward difference divided by h: h[f](x) h = f(x) − f(x − h) h (22) Central difference divided by h: δh[f](x) h = f(x + h/2) − f(x − h/2) h (23) In an analogous way, one can obtain finite difference approximations to higher order derivatives and differential operators. 16
  • 17. Options pricing using Lattice models • October 2019 • with C++ code snippets The second order central difference: f (x) ≈ δ2 h[f](x) h = f (x + h/2) − f (x − h/2) h = f(x+h)−f(x) h − f(x)−f(x−h) h h = f(x + h) − 2f(x) + f(x − h) h2 (24) The second order forward difference: f (x) ≈ ∆2 h[f](x) h = f (x + h) − f (x) h = f(x+2h)−f(x+h) h − f(x+h)−f(x) h h = f(x + 2h) − 2f(x + h) + f(x) h2 (25) The second order backward difference: f (x) ≈ 2 h[f](x) h = f (x) − f (x − h) h = f(x)−f(x−h) h − f(x−h)−f(x−2h) h h = f(x) − 2f(x − h) + f(x − 2h) h2 (26) Mixed partial derivatives can be obtained as follows. Taking the central difference of the x and y variables, we could obtain, for example: ∂2 u ∂x∂y i,j = ∂ ∂x ∂u ∂y ≈ (∂u ∂y )i+1,j − (∂u ∂y )i−1,j 2∆x = ui+1,j+1−ui+1j−1 2∆y − ui−1,j+1−ui−1j−1 2∆y 2∆x = ui+1,j+1 − ui+1,j−1 − ui−1,j+1 + ui−1,j−1 4∆x∆y (27) 3.3. Explicit finite difference scheme. Consider the Black Scholes PDE: ∂C ∂t + rS ∂C ∂S + 1 2 σ2 S2 ∂2 C ∂S2 = rC (28) subject to the payoff condition C(t, ST ) = max(ST − K)+ . We can simply this PDE by substituting it with finite differences. First, let’s substitute x = log S, so that ∂C ∂S = ∂C ∂x · ∂x ∂S = 1 S ∂C ∂x and ∂2 C ∂S2 = − 1 S2 ∂C ∂x + 1 S2 ∂2 C ∂x2 . ∂C ∂t + ν ∂C ∂x + 1 2 σ2 ∂2 C ∂x2 = rC (29) We imagine time and space divided up into discrete intervals (∆t and ∆x), this is the finite difference grid or lattice. To obtain the explicit finite difference method we approximate the equation 29 using a forward difference for ∂C/∂t and central differences for ∂C/∂x and ∂2 C/∂x2 . Denote by Ci,j = C(ti, xj) Therefore, ∂C ∂t t=ti = Ci+1,j − Ci,j ∆t (30) 17
  • 18. Options pricing using Lattice models • October 2019 • with C++ code snippets ∂C ∂x x=xj = Ci+1,j+1 − Ci+1,j−1 2∆x (31) ∂2 C ∂x2 x=xj = Ci+1,j+1 − 2Ci+1,j + Ci+1,j−1 ∆x2 (32) Figure 2: Stencils for grid points for explicit and implicit finite difference schemes in solving a PDE that is first order in t and second order in x Substituting these values in the equation 29 we obtain, Ci+1,j − Ci,j ∆t +r Ci+1,j+1 − Ci+1,j−1 2∆x + 1 2 σ2 Ci+1,j+1 − 2Ci+1,j + Ci+1,j−1 ∆x2 = rCi,j (33) Multiplying throughout by 2∆x2 ∆t, 2r(∆x)2 ∆tCi,j = 2(∆x)2 (Ci+1,j − Ci,j) + r∆x∆t(Ci+1,j+1 − Ci+1,j−1) + σ2 ∆t(Ci+1,j+1 − 2Ci+1,j + Ci+1,j−1) =⇒ Ci,j(2∆x2 )(1 + r∆t) = (r∆x∆t + σ2 ∆t)Ci+1,j+1 + (2∆x2 − 2σ2 ∆t)Ci+1,j + (σ2 ∆t − r∆x∆t)Ci+1,j−1 =⇒ Ci,j = 1 1 + r∆t ∆t r 2∆x + σ2 2∆x2 Ci+1,j+1 + 1 − σ2 ∆x2 ∆t Ci+1,j + 1 2 σ2 ∆x2 − r ∆x ∆t Ci+1,j−1 (34) The coefficients of Ci+1,j+1, Ci+1,j and Ci+1,j−1 can be thought of as the trinomial probabilities. (1 + r∆t) is the discounting factor. Therefore the explicit finite difference method is equivalent of approximating the Black Scholes diffusion process by a discrete trinomial process, where, 18
  • 19. Options pricing using Lattice models • October 2019 • with C++ code snippets Ci,j = 1 1 + r∆t (puCi+1,j+1 + pmCi + 1, j + pdCi+1,j−1) (35) pu = ∆t r 2∆x + σ2 2∆x2 (36) pm = 1 − σ2 ∆x2 ∆t (37) pd = 1 2 σ2 ∆x2 − r ∆x ∆t (38) 3.4. Explicit finite difference implementation. We create a rectangular grid or lattice by adding extra nodes to a trinomial tree, so that we have 2M + 1, M >= N at every time step i instead of just 2i + 1. However, at time step i, given all option values at i + 1, we cannot compute the bottom and top option values (Ci,−M and Ci,M ) using discounted expectations, since this would require knowing option values Ci+1,−M−1 and Ci+1,M+1 which we do not have. With no additional information we can only compute the region indicated by the dashed branches using discounted expectations. In order to be able to compute the remainder of the grid we must add the extra boundary conditions which determine the behavior of the option price as a function asset price for high and low values of the asset price xj. For example, for a European call option we have the following Neumann boundary conditions (the delta for deep ITM calls is 1, whereas for deep OTM calls is 0): ∂C ∂S (t, S) = 1 for large S (39) ∂C ∂S (t, S) = 0 for small S (40) In terms of the grid, the conditions 39 and 40 become: Ci,M − Ci,M−1 Si,M − Si,M−1 = 1 for large S (41) Ci,−M+1 − Ci,−M Si,−M+1 − Si,−M = 0 for small S (42) I price a one-year ATM European call option with S = 100, K = 100, T = 1 year, r = 0.06, δ = 0.03, M = 3, N = 3, ∆x = 0.02. // ExplicitFDMGrid.h #include <iostream> #include <array> class ExplicitFDMGrid { 19
  • 20. Options pricing using Lattice models • October 2019 • with C++ code snippets private: double p_u, p_d, p_m; std::array<std::array<double, 250>, 250> S; std::array<std::array<double, 250>, 250> C; double T; long M; long N; double sigma; double dt; double r; double s_0; double K; char optionType; double q; double drift; double dx; public: ExplicitFDMGrid(double vol, double expiry, long N_, long M_, double spot, double strike, double rate, double div, char optType, double dx); double pv(); double payOff(double s_t); void printTree(); int row(int i, int j); int col(int i, int j); }; // ExplicitFDMGrid.cpp : Computes the value of a European option // the explicit finite difference method #include<iostream> #include "ExplicitFDMGrid.h" #include <cmath> #include <iomanip> ExplicitFDMGrid::ExplicitFDMGrid(double vol, double expiry, long N_, long M_, double spot, double strike, double rate, double div, char optType, double deltax) { N = N_; M = M_; T = expiry; dt = T / N; r = rate; q = div; sigma = vol; dx = deltax; drift = (r - q - pow(sigma, 2.0) / 2.0); p_u = 0.50 * dt * (pow((sigma/dx),2)+(drift/dx)); p_m = 1 - dt * (pow((sigma / dx), 2)); p_d = 0.50 * dt * (pow((sigma / dx), 2) - (drift / dx)); s_0 = spot; K = strike; 20
  • 21. Options pricing using Lattice models • October 2019 • with C++ code snippets optionType = optType; S = { 0.0 }; C = { 0.0 }; std::cout << "np_u = " << p_u; std::cout << "np_m = " << p_m; std::cout << "np_d = " << p_d; //initialize the asset prices at maturity //these apply to every time step for (int j = -M; j <= M; ++j) { for (int i = 0; i <= N; ++i) { S[row(i, j)][col(i, j)] = s_0 * exp(j * dx); } } //initialize the option values at maturity for (int j = -M; j <= M; ++j) { C[row(N, j)][col(N, j)] = payOff(S[row(N, j)][col(N, j)]); } } int ExplicitFDMGrid::row(int i, int j) { return (M+j); } int ExplicitFDMGrid::col(int i, int j) { return i; } void ExplicitFDMGrid::printTree() { std::cout << "nStock price tree"; std::cout << std::setprecision(8); for (int j = 2 * M; j >= 0; --j) { std::cout << "nn"; for (int i = 0; i <= N; ++i) { std::cout << "t" << S[j][i]; } } 21
  • 22. Options pricing using Lattice models • October 2019 • with C++ code snippets std::cout << "nnCall price tree"; for(int j = 2 * M; j >= 0; --j) { std::cout << "nn"; for (int i = 0; i <= N; ++i) { std::cout << "t" << C[j][i]; } } } double ExplicitFDMGrid::payOff(double S_t) { if (optionType == 'C') return std::max(S_t - K, 0.0); if (optionType == 'P') return std::max(K - S_t, 0.0); } double ExplicitFDMGrid::pv() { double df = 0.0; //work backwards for (int i = N - 1; i >= 0; --i) { for (int j = M - 1; j >= -M+1; --j) { df = exp(-r * dt); double v_u = C[row(i + 1, j + 1)][col(i + 1, j + 1)]; double v_m = C[row(i + 1, j)][col(i + 1, j)]; double v_d = C[row(i + 1, j - 1)][col(i + 1, j - 1)]; C[row(i,j)][col(i,j)] = (p_u * v_u + p_m * v_m + p_d * v_d); } //Neumann boundary conditions if (optionType == 'C') { C[row(i, M)][col(i, M)] = C[row(i, M - 1)][col(i, M - 1)] + (S[row(i, M)][col(i, M)] - S[row(i, M - 1)][col(i, M - 1)]); C[row(i, -M)][col(i, -M)] = C[row(i, -M + 1)][col(i, -M + 1)]; } else if (optionType == 'P') { C[row(i, M)][col(i, M)] = C[row(i, M - 1)][col(i, M - 1)]; 22
  • 23. Options pricing using Lattice models • October 2019 • with C++ code snippets C[row(i, -M)][col(i, -M)] = C[row(i, -M + 1)][col(i, -M + 1)] + (S[row(i, -M)][col(i, -M)] - S[row(i, -M + 1)][col(i, -M + 1)]); } } return C[row(0,0)][col(0,0)]; } // test explicit FDM grid #include<iostream> #include "ExplicitFDMGrid.h" int main() { ExplicitFDMGrid* g; g = new ExplicitFDMGrid(0.20, 1, 3, 3, 100, 100, 0.06,0.03,'C',0.2); double V_0 = g->pv(); std::cout << "nOption value = " << V_0; g->printTree(); return 0; } REFERENCES [1] Mark Rubinstein John Cox, Stephen Ross. Option pricing: A simplified approach. Journal of Financial Economics, 1979. 23