28
Lecture 5 Numerical schemes for SDEs Lecture Notes by Jan Palczewski Computational Finance – p. 1

Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Lecture 5

Numerical schemes for SDEs

Lecture Notesby Jan Palczewski

Computational Finance – p. 1

Page 2: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

A Stochastic Differential Equation (SDE) is an object of thefollowing type

dXt = a(t,Xt)dt + b(t,Xt)dWt, X0 = x.

A solution is a stochastic process X(t), satisfying

Xt = X0 +

∫ t

0a(s,Xs)ds +

∫ t

0b(s,Xs)dWs.

Today we will study algorithms that can be used to solveSDEs.

SDE’s play a prominent role in a range of applications,including biology, chemistry, epidemiology, mechanics,microelectronics and, of course, finance.

Computational Finance – p. 2

Page 3: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

An important SDE is the one for the stock price in theBlack-Scholes model

dSt = Stµdt + StσdWt.

This equation has an analytical solution and we can applyMonte Carlo techniques without further studies.

However, for most SDE’s occurring in practical applications,this is not the case. Take

dXt = a(b − Xt)dt + c√

XtdWt.

This SDE plays an important role in stochastic volatilitymodels and in interest rate theory. It does not, in general,have an explicit solution.

Computational Finance – p. 3

Page 4: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Brownian motion

For computational purposes it is useful to consider discretizedBrownian motion. We thus divide a time interval [0, T ] into Nsubintervals by setting δt = T/N and

tn = n · δt = nT

N, n = 0, . . . , N.

Further, due to properties of Brownian motion we can simulateits values at the selected points by

Wtn+1= Wtn

+ ∆Wn, Wt0 = W0 = 0,

where ∆Wn are independent random variables withdistribution N (0, δt).

Computational Finance – p. 4

Page 5: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

The stochastic integral

∫ T

0σsdWs

is the limit of the approximating sum

N∑

n=0

σtn(Wtn+1

− Wtn),

as the mesh of the partition P = (t0, t1, . . . , tN ) of the interval[0, T ] approaches zero, i.e. when δt goes to zero.

Therefore, if δt is small enough, the above formula is a goodapproximation for the stochastic integral.

Computational Finance – p. 5

Page 6: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

What is the algorithm to simulate the stochastic integral?

How to measure the error of the approximation?

Let us use the definition from the previous slide.

one simulation ———- one omega (ω)

Computational Finance – p. 6

Page 7: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Euler-Maruyama scheme

dXt = a(t,Xt)dt + b(t,Xt)dWt.

The simplest numerical method for solving of SDEs is thestochastic Euler scheme (also called Euler-Maruyamascheme).For the above stochastic differential equation the scheme hasthe form

Xn+1 = Xn + a(tn, Xn)δt + b(tn, Xn)∆Wn,

where∆Wn = Wtn+1

− Wtn.

Computational Finance – p. 7

Page 8: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

In order to obtain this scheme the following approximation isused

∫ tn+1

tn

b(s,Xs)dWs ≈ b(tn, Xn)∆Wn,

∫ tn+1

tn

a(s,Xs)ds ≈ a(tn, Xn)δt.

Computational Finance – p. 8

Page 9: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Testing the Euler scheme

Let us reconsider the following SDE

dSt = Stµdt + StσdWt.

We know that the exact solution is given by

St = S0eσWt+(µ− 1

2σ2)t.

Computational Finance – p. 9

Page 10: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Inputs: T, N, mu, sigma, S0'

&

$

%

delta_t = T/N

Let N[0..N-1] be an array of N independent draws fromN(0,1)

W[0] = 0For n = 0, 1, ..., N-1

W[n+1] = W[n] + sqrt (delta_t) * N[n]

S[0] = S0For n = 0, 1, ..., N-1

S[n+1] = S[n] + S[n] * mu * delta_t+ S[n] * sigma * (W[n+1] - W[n])

Output: S[N]

Computational Finance – p. 10

Page 11: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

We can now vary the step size in order to get some idea aboutthe approximation error.

We will measure the performance in two ways. We make Mindependent runs of the algorithm and compute

1

M

M∑

m=1

∣S0e

σWm[N ]+(µ−σ2

2)T − Sm[N ]

∣≈ E|ST − S[N ]|

∣E

(

S0eσWT +(µ−σ

2

2)T

)

−1

M

M∑

m=1

Sm[N ]∣

∣≈ |EST − ES[N ]|

Computational Finance – p. 11

Page 12: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Convergence of schemes for SDEs

When writing algorithms we use the following notation:

tn = n · δt,

Xn is the computed value at tn.

To study convergence of numerical schemes we have tointroduce a new notation:

Xδtt denotes a process that results from connecting of the

points obtained by a numerical scheme with straight lines,i.e.

Xδtt = Xn +

t − tntn+1 − tn

(Xn+1 − Xn), if t ∈ [tn, tn+1).

δt is the step size used in the algorithm.

Xt is the exact solution.Computational Finance – p. 12

Page 13: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Denote by (Xδtt ) the result of a simulation with the step δt.

The numerical scheme is strongly convergent if

limδt→0

E

(

|XT − XδtT |

)

= 0.

The numerical scheme is weakly convergent if

limδt→0

∣Eg(XT ) − Eg(XδtT )

∣ = 0

for every polynomial g.

Computational Finance – p. 13

Page 14: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

The Euler-Maruyama scheme is strongly and weaklyconvergent. Unfortunately, it is not unconditional. For examplethe following conditions are sufficient:

1) functions a( ) and b( ) are four times continuouslydifferentiable and their first derivatives are bounded, and

2) they do not grow too fast with parameters.

Since the Euler-Maruyama scheme proved to be anapproximation of the solution to the SDE, we may ask howgood this approximation is. This gives rise to the notion ofconvergence order.

Computational Finance – p. 14

Page 15: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Convergence orders

The numerical scheme is strongly convergent with order γ if

E

(

|XT − XδtT |

)

≤ KT (δt)γ.

The constant KT depends on T and the considered SDE.

The numerical scheme is weakly convergent with order γ if∣

∣Eg(XT ) − Eg(XδtT )

∣ ≤ KgT (δt)γ

for every polynomial g. The constant KgT depends on T , g, and

the considered SDE.

Computational Finance – p. 15

Page 16: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Convergence order explained

If a numerical scheme is convergent with order γ, and wemake the step k times smaller then the approximation errorwill decrease by a factor of kγ.

Therefore, the order equal 1 means that if we want to decreaseerror 100 times, we have to make the step 100 times smaller.

The order equal to 1/2 means that if we want to decreaseerror 100 times, we have to make the step 1002 = 10 000 timessmaller. And the computation time grows by the same factor.

Computational Finance – p. 16

Page 17: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Euler-Maruyama scheme is

weakly convergent with order 1,

strongly convergent with order 0.5.

Milstein scheme, which we shall study in a moment, is

weakly convergent with order 1,

strongly convergent with order 1.

Weak convergence:

distribution at moment T only,

useful for pricing of European path-independent options.

Strong convergence:

pathwise property,

should be used if whole paths play a role!

good for path-dependent options.

Computational Finance – p. 17

Page 18: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Consequently, Euler-Maruyama scheme can be successfullyapplied to pricing of path-independent options (options withpayoffs depending only the stock price at the moment ofexercise) i.e. of the form h(ST ).

This is caused by its poor strong convergence order. If youmake the step 100 times smaller, the approximation improvesonly by a factor of 10. Remember that the step cannot be toosmall because of:

1. (computational errors) errors caused by computations ina computer with the use of finite precision numbers (withfinite number of digits),

2. computation time.

Computational Finance – p. 18

Page 19: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Milstein scheme

We will limit ourselves to the following type of SDEs

dXt = a(Xt)dt + b(Xt)dWt, X0 = x.'

&

$

%

X0 = x,

Xn+1 = Xn + a(Xn)δt + b(Xn)∆Wn

+1

2b′(Xn)b(Xn)

(

(∆Wn)2 − δt)

Here b′ is the first derivative of b.

Computational Finance – p. 19

Page 20: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Derivation of Milstein scheme

Milstein scheme is obtained as a result of application ofstochastic Taylor expansion, or more easily, by Ito formula.

Consider the homogeneous scalar stochastic differentialequation

dXt = a(Xt)dt + b(Xt)dWt

and let ti, ti+1 be two consecutive points in our timediscretization.

Computational Finance – p. 20

Page 21: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

The Ito formula says, that for a given function f which is two timescontinuously differentiable, we can write

f(Xs) = f(Xti)+

s

ti

(

f ′(Xu)a(Xu) +1

2f ′′(Xu)b(Xu)2

)

du+

s

ti

f ′(Xu)b(Xu)dWu

We can apply the Ito formula on the expressions a(Xs) and b(Xs), which arethe coefficients in our SDE.

We then obtain

Xti+1= Xti

+

ti+1

ti

(

a(Xti) +

s

ti

(

a′(Xu)a(Xu) +1

2a′′(Xu)b2(Xu)

)

du

+

s

ti

a′(Xu)b(Xu)dWu

)

ds

+

ti+1

ti

(

b(Xti) +

s

ti

(

b′(Xu)a(Xu) +1

2b′′(Xu)b2(Xu)

)

du

+

s

ti

b′(Xu)b(Xu)dWu

)

dWs.

Computational Finance – p. 21

Page 22: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

We want to achieve a method which converges strongly oforder 1.

By using a time discretization, the differentials dW and dt arereplaced by the corresponding discrete versions ∆W and δt.We have

δt · δt = O((δt)2),

∆W · δt = O((δt)3/2),

∆W · ∆W = O(δt).

Therefore: If we are up for a method which converges stronglyof order 1, we can neglect the double integrals from theprevious slide, which are of type dWs · ds and ds · ds.

Computational Finance – p. 22

Page 23: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

We then obtain

Xti+1≈ Xti

+

∫ ti+1

ti

a(Xti)ds

+

∫ ti+1

ti

(

b(Xti) +

∫ s

ti

b′(Xu)b(Xu)dWu

)

dWs

≈ Xti+ a(Xti

)δt + b(Xti)∆Wi +

∫ ti+1

ti

∫ s

ti

b′(Xu)b(Xu)dWudWs

The first two summands in the equation above are well knownfrom the Euler-Maruyama scheme. The third one is new.We approximate the third term above by

∫ ti+1

ti

∫ s

ti

b′(Xu)b(Xu)dWudWs ≈ b′(Xti)b(Xti

)

∫ ti+1

ti

∫ s

ti

dWudWs.

Computational Finance – p. 23

Page 24: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

The integral on the right hand side of the last equality is wellknown from Continuous Time Finance. We obtain

b′(Xti)b(Xti

)

∫ ti+1

ti

∫ s

ti

dWudWs =1

2b′(Xti

)b(Xti)(

(∆Wi)2 − δt

)

Substituting this in our previous approximation we finallyobtain the Milstein scheme

X0 = x,

Xn+1 = Xn + a(Xn)δt + b(Xn)∆Wn

+1

2b′(Xn)b(Xn)

(

(∆Wn)2 − δt)

One can prove that the Milstein scheme converges stronglywith order 1 to the solution of the SDE.

Computational Finance – p. 24

Page 25: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Multidimensional StochasticDifferential Equations

Sometimes an SDE is multidimensional. In this case a(t, x) isa vector valued function, b(t, x) is a matrix valued function andW is a multidimensional Brownian motion. The solution X isthen a vector valued stochastic process.

A multidimensional Brownian motion is a vector process withthe following properties:

a) every coordinate is a Brownian motion

b) coordinates are pairwise independent

Computational Finance – p. 25

Page 26: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

How to simulate multi-dimensional Brownian motion?

Wt = (W 1t ,W 2

t , . . . ,W dt ).

How to solve a multidimensional SDE?

dXt = a(t,Xt)dt + b(t,Xt)dWt,

Xt = (X1t , X2

t , . . . , Xdt ).

Computational Finance – p. 26

Page 27: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

Stochastic Volatility Models

Stochastic volatility models are asset dynamics models inwhich volatility is itself a random object. The following systemof two SDE’s represents a basic version of Heston’s stochasticvolatility model, but there are many other SV models used inpractice.

dSt = Stµdt + St

VtdW 1t ,

dVt = (σ0 − Vt)dt +√

VtdW 2t .

St represents the price of a stock, Vt the volatility is thesolution of an SDE.

Computational Finance – p. 27

Page 28: Numerical schemes for SDEsapalczew/CFP_lecture5.pdfConsequently, Euler-Maruyama scheme can be successfully applied to pricing of path-independent options (options with payoffs depending

To compute the price of a European option with payoff h(ST ) inthe stochastic volatility model we combine the results of lasttwo lectures: numerical solution of SDEs and Monte Carlo.We assume, of course, that the SDE we simulate is given withrespect to a risk neutral measure, so that the price iscomputed as an expectation.'

&

$

%

For m=1, 2, ..., MS[m] = price at T simulated with the Euler-Maruyama

algorithmC[m] = exp(-rT) * h(S[m])

C = C[1] + . . . + C[M]price = C/M

B = ( (C[1] - price)ˆ2 + . . . + (C[M] - price)ˆ2 ) / (M-1)

Result: the price, the confidence interval

Computational Finance – p. 28