ECS550NFB Introduction To Numerical Methods Using Matlab Day 5
ECS550NFB Introduction To Numerical Methods Using Matlab Day 5
ECS550NFB Introduction To Numerical Methods Using Matlab Day 5
Today
Derivatives pricing
I
I
I
Binomial lattices
Monte Carlo simulation
Solving a partial differential equation (e.g. finite differencing)
Notation
I
I
I
I
I
C F P PV
rt -
coupon
face value
price
- present value
interest rate
PV =
T
X
t=0
FT
Ct
+
t
(1 + rt )
(1 + rT )T
cashFlows = [0 3 3 3 3 103];
interestRate = 0.03;
pvvar(cashFlows,interestRate)
Notation
I
- internal
rate of return irr(cashFlows), solution to
PT
FT
Ct
P = t=0 (1+)
t + (1+)T
or P
Ct /m
FT
P = Tt=0 (1+/m)
t + (1+/m)T if coupon is payed m times a year.
V (tn )tn
D - is duration, D = P V (t0 )t0 ++P
, where P V (ti ) is a
PV
present value of cashflow in time ti .
cfdur(cashFlows, interestRate),
DM - is modified duration, DM = D/(1 + /m). Why is it
interesting?
dP
d = DM P , so P DM P
C=
d2 P
d2
1 d2 P
P d2 ,
Why is it interesting?
= P C, so P DM P + P2C ()2
I
I
P3
Pi=1
3
i=1
P
3
D i wi = D
C i wi = C
i=1 wi
=1
minw wT w
s.t.
Pn
Pi=1
n
wi ri = r
i=1 wi
=1
wi 0
Makes sense if returns are normally distributied and the utility
function is quadratic.
[PRisk, PRoR, PWts]= frontcon(returns,covMatrix,100);
Derivatives
I
I
We construct a portofolio: 0 = S0 +
that replicate the option payoff
I
I
I
I
I
u = S0 u + ert = fu
d = S0 d + ert = fd
we get ,
by no-arbitrage principle f0 = 0
it is not the discounted expected value of the
payoff
if we use risk-neutral measure, it can be
interpreted as discounted expected value of
the payoff
I
I
I
Jarrow-Rudd: we set p =
d=e
2
r 2
t t
1
2
and calculate u = e
r 2
t+ t
and
I
I
I
I
I
I
I
I
I
Simple
Fast when problem dimensionality is small
Difficult for more complex path-dependent options
Discretization is important - e.g. poor choice of x may lead to
negative probabilities
Incorporating extensions usually requires careful implementation
I
I
I
simple, flexible
computationally intensive
when facing a complex problem, sometimes the only way to go
sampling error
discretization error
Euler scheme
Brownian motion
dSt = St dt + St dWt
St+t = (1 + t)St + St t
St+t = (1 + t)St + St t
St will be normal, rather than log-normal.
Solution? Using Itos
lemma on dSt = St dt + St dWt we get
d log St = 12 2 dt + dWt
Rt
which is integrated to St = S0 exp 12 2 t + 0 dW ( ) , so we
can generate sample paths using
1 2
St+t = St exp
t + t .
2
To speed things up, should we vectorize? In most cases, yes. The best
advice is to give it a try.
I
I
I
I
= 4.826756
= 4.736975
= 4.860783
= 4.732051
Exchange Option
At time T , we may exchange U for V and receive max{VT UT , 0}.
Suppose Ut and Vt follow bidimensional geometric Brownian motion
with drift r and the two Wiener processes have instantaneous
correlation
dU (t) = rU (t)dt + U U (t)dWU (t)
dV (t) = rV (t)dt + V V (t)dWV (t)
How to generate (correlated) sample paths?
1 p 0
1
T
,
=
, = LL , L =
1
1 2
1 = Z1
2 = Z1 +
p
1 2 Z2
[p,ci] = ExchangeMC(V0,U0,sigmaV,sigmaU,rho,T,r,NRepl)
Payoff is zero whenever the stock price hits the barrier level Sb .
I
I
I
Pdo = P Pdi
Discretization of the time interval of width t, T = M t, price
path is S = {S1 , S2 , . . . , SM }
Pdi = erT E[I(S)(K SM )+ ], where I(S) = 1 iff the price path hit
the barrier (Sj < Sb for some j)
If the barrier is crossed before maturity:
The problem is that we hit the barrier too few times (249 out of
200000), in all other cases, the option price is zero.
[Pdo,CI,NCrossed] =
DOPutMCCond(S0,K,r,T,sigma,Sb,NSteps,NRepl)
Eg
f (z1 ,...,zj )
g(z1 ,...,zj )
f (z1 ,...,zj )
g(z1 ,...,zj ) Ef [I(S)(K
SM )+ |j , Sj ]
is a correction term.
[Pdo,CI,NCrossed] =
DOPutMCCondIS(S0,K,r,T,sigma,Sb,NSteps,NRepl,bp)
N
1 X
S(ti ) K, 0
N
i=1
I
I
Y =
E[Y ]
i=0hS(ti )
i
PN
=E
i=0 S(ti )
r(N +1)t
= S(0) 1e1ert
nQ
o
Payoff is max ( S(ti ))1/N K, 0
[P,CI] = AsianMCGeoCV(S0,K,r,T,sigma,NSamples,NRepl,NPilot)
Option sensitivities.
df (S0 )
dS0
we can use
instead
or improve
and using common numbers
another approach is to calculate option price and in one
simulation - pathwise estimator
I
I
= limS0 0
2
C = erT max{ST K, 0}, where ST = S0 e(r /2)T + T Z
C
dC dST
S0 = dST dS0
I dST
dS0
I dC
dST
I
=
=
ST
S0
erT I{ST
> K}
riskless rate r
stock price follows geometric Brownian motion with constant drift
and volatility
there are no dividends
no borrowing or lending constraints
no transaction costs
The the price of a derivative which payoff depends only on time and
stock price follows the Black-Scholes formula
f
1
2f
f
+ rS
+ 2 S 2 2 rf = 0
t
S 2
S
S = 0, S, 2S, ..., M S
t = 0, t, 2t, ..., N t
fi,j = f (iS, jt)
forward difference
Boundary conditions
fi,N = max{iS K, 0}
f0,j = 0,
fM,j = M S Ker(N j)t
Explicit scheme
fi,j fi,j1
t
fi+1,j fi1,j
2S
fi+1,j 2fi,j + fi1,j
1 22
i (S)2
= rfi,j
2
(S)2
+ riS
+
Implicit scheme
fi,j+1 fi,j
t
fi+1,j fi1,j
2S
fi+1,j 2fi,j + fi1,j
1 22
i (S)2
= rfi,j
2
(S)2
+ riS
+
Crank-Nicolson scheme
We use derivatives in between the grid values
i
h 2
2
2
I f2 (Si , tj+1/2 ) = 1 f2 (Si , tj+1 ) + f2 (Si , tj ) + O(S 2 )
2 S
S
S
I f (Si , tj+1/2 )
t
+ O(t2 )
M1 fj1 = M2 fj
Pricing barrier put option using Crank-Nicholson scheme:
Boundary conditions:
I
I
f (Smax , t) = 0
f (Sb , t) = 0
price = DOPutCK(S0,K,r,T,sigma,Sb,Smax,dS,dt)
American Options
I
I
I
price = AmPutCK(S0,K,r,T,sigma,Smax,dS,dt,omega,tol)
Literature
I
I
I
I
I
I
I
The End