5+Friday+presentation
-
Upload
pham-hai-yen -
Category
Documents
-
view
217 -
download
0
Transcript of 5+Friday+presentation
-
7/24/2019 5+Friday+presentation
1/45
ECS550NFBIntroduction to Numerical Methods using Matlab
Day 5
Lukas [email protected]
Department of Mathematics, University of Matej Bel
June 12, 2015
http://find/http://goback/ -
7/24/2019 5+Friday+presentation
2/45
Today
Derivatives pricing
Binomial lattices Monte Carlo simulation Solving a partial differential equation (e.g. finite differencing)
This lecture is based on chapters 2, 4, 7, 8 and 9 inBrandimarte, Paolo. Numerical methods in finance and economics: a
MATLAB-based introduction. John Wiley & Sons, 2013.
http://find/ -
7/24/2019 5+Friday+presentation
3/45
Notation
C - coupon F - face value P - price P V - present value
rt - interest rate
P V =Tt=0
Ct(1 + rt)t
+ FT
(1 + rT)T
cashFlows = [0 3 3 3 3 103];interestRate = 0.03;
pvvar(cashFlows,interestRate)
http://find/ -
7/24/2019 5+Friday+presentation
4/45
Notation
- internal rate of return irr(cashFlows), solution toP =
Tt=0
Ct(1+)t +
FT(1+)T
orP =
Tt=0
Ct/m(1+/m)t +
FT(1+/m)T
if coupon is payed m times a year.
D - is duration, D= PV(t0)t0++PV(tn)tnPV , where P V(ti) is a
present value of cashflow in time ti.cfdur(cashFlows, interestRate),
DM- is modified duration, DM=D/(1 + /m). Why is itinteresting?dP
d =
D
MP, so P
D
MP
C= 1Pd2Pd2, Why is it interesting?
d2Pd2
=P C, so P DMP + PC2 ()2bndprice(Yield, CouponRate, Settle, Maturity)
http://find/ -
7/24/2019 5+Friday+presentation
5/45
Example: Portofolio with given duration and convexity
We are asked to create a portofolio with duration D and convexityC from 3 bonds.
How will we set the weights?
3i=1 Diwi=D
3i=1 Ciwi=C
3i=1 wi= 1(Note that this is an approximation)
http://find/ -
7/24/2019 5+Friday+presentation
6/45
Mean-Variance portofolio optimization
We have n stocks with mean returns{r1, r2, rn} and covariance
matrix of their returns How will we set our weights in the portofolio to get on average r
and minimizing risk (measured by the variance)?
minwwTw
s.t.ni=1 wiri= r
ni=1 wi= 1wi0
Makes sense if returns are normally distributied and the utilityfunction is quadratic.
[PRisk, PRoR, PWts]= frontcon(returns,covMatrix,100);
http://find/ -
7/24/2019 5+Friday+presentation
7/45
Derivatives
How do we find a right price? How do we insure against potential losses?
What computational methods can we make use of Solving a partial differential equation (e.g. finite differencing) Monte Carlo simulation Binomial lattices
http://goforward/http://find/http://goback/ -
7/24/2019 5+Friday+presentation
8/45
Derivatives Pricing - simplest case
We construct a portofolio: 0= S0+ that replicate the option payoff
u= S0u + ert =fu
d= S0d + 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 ofthe payoff
Source: Brandimarte, p.105
http://find/ -
7/24/2019 5+Friday+presentation
9/45
Derivatives pricing - continuous time
Price of an Option, whose payoff depends only on the current price ofan underlying asset, or its price at maturity, follows Black-Scholesdifferential equation (deterministic!).
ft
+ rSfS
+12
2S2 2
fS2
rf= 0This PDE captures the dynamic, but we need to supply initial orterminal conditions (f(S, T) = max{S K, 0}).
In most cases, this equation must be solved numerically (but not forvanilla European put/call options blsprice).
http://find/ -
7/24/2019 5+Friday+presentation
10/45
Derivatives pricing - binomial lattices
Source: Brandimarte, p.403
http://goforward/http://find/http://goback/ -
7/24/2019 5+Friday+presentation
11/45
Derivatives pricing - binomial lattices
How do we calibrate the parameters of our binomial lattice? d,u,p We can e.g. match the first two moments ifSt follows
dS=rSdt + SdW
Cox, Ross, Rubinstein (CRR): we have one degree of freedom, sowe can set u= 1/d and reduce the computational burden and get
u= et, d= e
t, p= e
rtdud
Jarrow-Rudd: we set p= 12 and calculate u= e
r2
2
t+
t
and
d= er
2
2tt
http://find/ -
7/24/2019 5+Friday+presentation
12/45
Derivatives pricing - binomial lattices
Left: Stock, Right: European Call option. Source: Brandimarte, p.407
http://find/ -
7/24/2019 5+Friday+presentation
13/45
Binomial lattice - code
function [price, lattice] = LatticeEurCall(S0,K,r,T,sigma,N)
deltaT = T/N;u=exp(sigma * sqrt(deltaT));
d=1/u;
p=(exp(r*deltaT) - d)/(u-d);
lattice = zeros(N+1,N+1);
for i=0:Nlattice(i+1,N+1)=max(0 , S0*(u^i)*(d^(N-i)) - K);
end
for j=N-1:-1:0
for i=0:j
lattice(i+1,j+1) = exp(-r*deltaT) * ...
(p * lattice(i+2,j+2) + (1-p) * lattice(i+1,j+2));
end
end
price = lattice(1,1);
http://find/ -
7/24/2019 5+Friday+presentation
14/45
Binomial lattice - code improvementInefficiencies
we repeat discounted probabilities exp(-r*deltaT)*p and
exp(-r*deltaT)*(1-p) we use a full matrix lattice - half of it is empty
Source: Brandimarte, p.412
http://find/ -
7/24/2019 5+Friday+presentation
15/45
Pricing American Options
We compareimmediate payoffwithcontinuation value fi,j = max{K Si,j, ert(pfi+1,j+1+ (1p)fi,j+1)}
[AssetPrice, OptionValue] = binprice(Price, Strike, Rate,
Time, Increment, Volatility, Flag)
price = AmPutLattice(S0,K,r,T,sigma,N)
http://find/ -
7/24/2019 5+Friday+presentation
16/45
Derivatives Pricing - trinomial lattice
We will set pu, pm, pd to match the momentsofX, where Xt= log St Choice ofx? Rule of thumb x =
t
Source: Brandimarte, p.422
http://goforward/http://find/http://goback/ -
7/24/2019 5+Friday+presentation
17/45
Round-up: Should you use lattices?
Simple Fast when problem dimensionality is small
Difficult for more complex path-dependent options Discretization is important - e.g. poor choice ofx may lead to
negative probabilities Incorporating extensions usually requires careful implementation
http://goforward/http://find/http://goback/ -
7/24/2019 5+Friday+presentation
18/45
Derivatives pricing - Monte Carlo Methods
simple, flexible
computationally intensive when facing a complex problem, sometimes the only way to go
M C l M h d A P h
http://find/http://goback/ -
7/24/2019 5+Friday+presentation
19/45
Monte Carlo Methods - Asset Paths
There are two sources of errors
sampling error discretization error
Euler scheme
Brownian motion
dSt =a(St, t)dt + b(St, t)dWt
St =a(St, t)t + b(St, t))t
Geometric Brownian motion
dSt =Stdt + StdWt
St+t = (1 + t)St+ Stt
Di i i G i B i M i
http://find/ -
7/24/2019 5+Friday+presentation
20/45
Discretizing Geometric Brownian Motion
But if we generate Geometric Brownian motion using
St+t = (1 + t)St+ SttSt will be normal, rather than log-normal.
Solution? Using Itos lemma on dSt=Stdt + StdWt we getd log St=
1
2
2 dt + dWtwhich is integrated to St =S0exp
12 2
t +
t0dW()
, so we
can generate sample paths using
St+t =Stexp 1
22 t + t .
To speed things up, should we vectorize? In most cases, yes. The bestadvice is to give it a try.
E l Si l M t C l f E C ll
http://find/ -
7/24/2019 5+Friday+presentation
21/45
Example: Simple Monte Carlo for European Call
Create many sample paths for Stock price. Discount and take average.
function [Price,CI] = BlsMC2(S0,K,r,T,sigma,NRepl)
nuT = (r - 0.5*sigma^2)*T;siT = sigma * sqrt(T) ;
DiscPayoff = exp(-r*T)*max(0, S0*exp(nuT+siT*randn(NRepl,1))-K) ;
[Price,Var, CI] = normfit(DiscPayoff);
end
M t C l M th d H d i t t i
http://find/ -
7/24/2019 5+Friday+presentation
22/45
Monte Carlo Methods - Hedging strategies
Stop loss strategy - hold an asset ifSt> K, sell it ifSt< K Delta hedging - replicate the option by holding stocks
Comparison of the costs of the strategy
HedgingScript.m
NSteps = 10
true price = 4.732837
cost of stop/loss (S) = 4.826756
cost of delta-hedging = 4.736975
NSteps = 1000
cost of stop/loss (S) = 4.860783
cost of delta-hedging = 4.732051
E h O ti
http://find/ -
7/24/2019 5+Friday+presentation
23/45
Exchange OptionAt time T, we may exchange U for V and receive max{VT UT, 0}.SupposeUt and Vt follow bidimensional geometric Brownian motion
with drift r and the two Wiener processes have instantaneouscorrelation
dU(t) = rU(t)dt + UU(t)dWU(t)
dV(t) = rV(t)dt + VV(t)dWV(t)
How to generate (correlated) sample paths?
=
1 1
, =LLT, L=
1 0
1 2
,
1 = Z1
2 = Z1+
1 2Z2
[p,ci] = ExchangeMC(V0,U0,sigmaV,sigmaU,rho,T,r,NRepl)
Down and out Put option
http://find/ -
7/24/2019 5+Friday+presentation
24/45
Down-and-out Put option
Payoff is zero whenever the stock price hits the barrier level Sb.
Crude Monte Carlo Conditional Monte Carlo Importance sampling
Crude Monte Carlo Down and out Put option
http://find/ -
7/24/2019 5+Friday+presentation
25/45
Crude Monte Carlo - Down-and-out Put option
function [P,CI,NCrossed] = DOPutMC(S0,K,r,T,sigma,Sb,NSteps,NRepl)
Payoff = zeros(NRepl,1);
NCrossed = 0;
for i=1:NRepl
Path=AssetPaths1(S0,r,sigma,T,NSteps,1);
crossed = any(Path
-
7/24/2019 5+Friday+presentation
26/45
Conditional Monte Carlo - Down-and-out Put option
Pdo=P Pdi Discretization of the time interval of width t, T =M t, price
path is S={S1, S2, . . . , S M} Pdi=e
rTE[I(S)(K SM)+], where I(S) = 1 iff the price path hitthe barrier (Sj < Sb for some j)
If the barrier is crossed before maturity:
E[I(S)(K SM)+
|j, Sj] =er(T
t)
Bp(Sj , K , T t), where j,where t=tj denotes the crossing time and Bp is the price of aput option. payoffI(S)ert
Bp(Sj , K , T t), where j, where
t=t j.
The problem is that we hit the barrier too few times (249 out of200000), in all other cases, the option price is zero.
[Pdo,CI,NCrossed] =
DOPutMCCond(S0,K,r,T,sigma,Sb,NSteps,NRepl)
Importance Sampling Down and out Put option
http://find/ -
7/24/2019 5+Friday+presentation
27/45
Importance Sampling - Down-and-out Put option
We can change the sampling design, simulate paths that hit the barriermore often and then correct for this change.
for the path sampling we generate independent normal draws Zj
with expected value =
r 22
t and variance 2t, then set
log Sjlog Sj1=Zj
instead, we will now generate from density with expected value b and thus will cross the barrier more often
Eg
f(Z)I(S)(KSM)+
g(Z) |j, Sj
= f(z1,...,zj)
g(z1,...,zj)Ef[I(S)(K SM)+|j, Sj]
The likelihood ratio f(z1,...,zj)
g(z1,...,zj)is a correction term.
[Pdo,CI,NCrossed] =
DOPutMCCondIS(S0,K,r,T,sigma,Sb,NSteps,NRepl,bp)
Arithmetic Average Asian Option
http://find/ -
7/24/2019 5+Friday+presentation
28/45
Arithmetic Average Asian Option
The call option payoff is
max
1
N
N
i=1
S(ti) K, 0
Crude Monte Carlo Control Covariates
sum of asset prices as control covariate geometric average option as a control covariate
Crude Monte Carlo - Arithmetic Average Asian Option
http://find/ -
7/24/2019 5+Friday+presentation
29/45
Crude Monte Carlo Arithmetic Average Asian Option
function [P,CI] = AsianMC(S0,K,r,T,sigma,NSamples,NRepl)
Payoff = zeros(NRepl,1);
for i=1:NRepl
Path=AssetPaths(S0,r,sigma,T,NSamples,1);Payoff(i) = max(0, mean(Path(2:(NSamples+1))) - K);
end
[P,aux,CI] = normfit( exp(-r*T) * Payoff);
Control Variable - Arithmetic Average Asian Option
http://find/ -
7/24/2019 5+Friday+presentation
30/45
Control Variable Arithmetic Average Asian Option
Sum of asset prices
Y =Ni=0 S(ti) E[Y] =E
Ni=0 S(ti)
=S(0) 1e
r(N+1)t
1ert
[P,CI] = AsianMCCV(S0, K,r,T,sigma,NSamples,NRepl,NPilot)
Control Variable (2) - Arithmetic Average Asian Option
http://find/ -
7/24/2019 5+Friday+presentation
31/45
Control Variable (2) Arithmetic Average Asian Option
Geometric average option
Payoff is max(S(ti))1/N
K, 0
Formula for the price of the geometric average option is available
[P,CI] = AsianMCGeoCV(S0,K,r,T,sigma,NSamples,NRepl,NPilot)
Estimating Greeks by Monte Carlo
http://find/ -
7/24/2019 5+Friday+presentation
32/45
Estimating Greeks by Monte Carlo
Option sensitivities.
= df(S0)dS0 = limS00f(S0+S0)f(S0)
S0
we can use limS0
0E [C(S0+S0,)][C(S0,)]
S0
or improve it using limS00E [C(S0+S0,)]E[C(S0S0,)]
2S0instead
and using common numbers another approach is to calculate option price and in one
simulation - pathwise estimator
Pathwise estimator - Greeks
http://find/ -
7/24/2019 5+Friday+presentation
33/45
at w se est ato G ee s
discounted option payoff is a random variable
C=erT max
{ST
K, 0}
, where ST
=S0
e(r2/2)T+
TZ
CS0
= dCdSTdSTdS0
dSTdS0
= STS0
dCdST
=erTI{ST > K}
so the estimator for is erTST
S0 I{ST > K}
function [Delta, CI] = BlsDeltaMCPath(S0,K,r,T,sigma,NRepl)
nuT = (r - 0.5*sigma^2)*T;
siT = sigma * sqrt(T);VLogn = exp(nuT+siT*randn(NRepl,1));
SampleDelta = exp(-r*T) .* VLogn .* (S0*VLogn > K);
[Delta, dummy, CI] = normfit(SampleDelta);
Finite Difference Methods - Black Scholes formula
http://find/ -
7/24/2019 5+Friday+presentation
34/45
Assumptions
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 andstock price follows the Black-Scholes formula
f
t + rS
f
S+
1
22S2
2f
S2 rf= 0
Finite Difference Methods
http://find/ -
7/24/2019 5+Friday+presentation
35/45
We will work with a discrete grid
S= 0,S, 2S,...,MS t= 0,t, 2t,...,Nt fi,j =f(iS,jt)
There are different ways how to approximate partial derivatives
forward difference fS = fi+1,jfi,j
S
backward difference fS = fi,jfi1,j
S
central difference fS = fi+1,jfi1,j
2S
We also need boundary conditions Call option: f(S, T) = max{S K, 0}, S Put option: f(S, T) = max{K S, 0}, S
Boundary conditions
http://find/ -
7/24/2019 5+Friday+presentation
36/45
y
European vanilla put option fi,N= max{K iS, 0} f0,j =K e
r(Nj)t
fM,j = 0
European vanilla call option
fi,N= max{iS K, 0} f0,j = 0, fM,j =M S Ker(Nj)t
Finite Difference Methods
http://find/ -
7/24/2019 5+Friday+presentation
37/45
Math preliminaries:
Explicit scheme - use forward approximation for the derivativewith respect to the time - may not be stable Implicit scheme - use backward approximation for the derivative
with respect to the time - unconditionally stable Crank-Nicholson method - combination of explicit and implicit
scheme - more precise approximation - unconditionally stable
Source: Brandimarte, chap. 5
Explicit scheme
http://find/ -
7/24/2019 5+Friday+presentation
38/45
fi,j fi,j1t
+ riSfi+1,j fi1,j
2S
+ 1
22i2(S)2
fi+1,j2fi,j+ fi1,j(S)2
=rfi,j
So the explicit scheme takes the following form
fi,j1=afi1,j+ bfi,j+ cfi+1,j
price = EuPutExpl(SO,K,r,T,sigma,Smax.dS,dt)
Stability?
Stability - Explicit scheme
http://find/ -
7/24/2019 5+Friday+presentation
39/45
Explicit scheme is basically a trinomial lattice, hence we must choosethe discretization parameters Sand t, so that the probabilities would
be positive.
Source: Brandimarte, p. 480
Implicit scheme
http://find/ -
7/24/2019 5+Friday+presentation
40/45
fi,j+1 fi,jt
+ riSfi+1,j fi1,j
2S
+ 1
22i2(S)2
fi+1,j2fi,j+ fi1,j(S)2
=rfi,j
So the implicit scheme takes the following form
afi1,j+ bfi,j+ cfi+1,j =fi,j+1
price = EuPutImpl(SO,K,r,T,sigma,Smax.dS,dt)
Stability?
Stability - Implicit scheme
http://find/ -
7/24/2019 5+Friday+presentation
41/45
Stability is not an issue at all. We can see that rewriting the system inmatrix form and inspecting the eigenvalues of the matrix, they are all
smaller than one in absolute value (Brandimarte p. 209).
Source: Brandimarte, p. 480
Crank-Nicolson scheme
http://find/ -
7/24/2019 5+Friday+presentation
42/45
We use derivatives in between the grid values
2
fS2 (Si, tj+1/2) = 12
2
fS2 (Si, tj+1) + 2
fS2 (Si, tj)
+ O(S2)
ft (Si, tj+1/2) =
f(Si,tj+1)f(Si,tj)t + O(t
2)
M1fj1= M2fj
Pricing barrier put option using Crank-Nicholson scheme:Boundary conditions:
f(Smax, t) = 0 f(Sb, t) = 0
price = DOPutCK(S0,K,r,T,sigma,Sb,Smax,dS,dt)
American Options
http://find/ -
7/24/2019 5+Friday+presentation
43/45
to account for free boundary is trivial in the Explicit scheme, thisis however subject to possible instabilities
we can use implicit scheme with iterative Gauss-Seidel method for
solving Ax= b we can also use Crank-Nicholson scheme
price = AmPutCK(S0,K,r,T,sigma,Smax,dS,dt,omega,tol)
Literature
http://goforward/http://find/http://goback/ -
7/24/2019 5+Friday+presentation
44/45
Brandimarte, Paolo. Numerical methods in finance and economics: a MATLAB-based introduction.John Wiley & Sons, 2013.
chapter 2 - Financial Theory chapter 4.5 Variance reduction techniques
chapter 7 - Option pricing by binomial and trinomial lattices chapter 8 - Option pricing by Monte Carlo methods chapter 9 - Option pricing by finite difference methods Hull, John C. Options, futures, and other derivatives. Pearson Education India, 2006.
The End
http://find/ -
7/24/2019 5+Friday+presentation
45/45
Thank you for your attention!
http://find/