introduction to stochastic calculus - suraj @...

60
Introduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative Finance December 2016 Adnan Khan

Upload: phungminh

Post on 15-May-2018

219 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Introduction to Stochastic Calculus

Teaching the Teachers

Workshop on Quantitative Finance

December 2016 Adnan Khan

Page 2: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

A Quick Look at Stock Prices

Modeling Stock Prices

We will look at some stock returns https://www.google.com/finance

Page 3: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Example

GE Stock Returns (2002-2012)

-0.02

0

0.02

0.04

0.06

0.08

0.1

0.12

-0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2

Page 4: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Example

Microsoft Returns 2004-2014

-0.02

0

0.02

0.04

0.06

0.08

0.1

0.12

-0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25

Pro

bab

ilit

y

Returns

DataMSFT

DataMSFT

Page 5: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Are Returns Normally Distributed?

-0.02

0

0.02

0.04

0.06

0.08

0.1

0.12

-0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25

Pro

bab

ilit

y

Returns

DataMSFT

NormalPDF

Page 6: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

From Random Walks to Brownian Motion

Consider a random walk Move right or left based on a coin toss

Page 7: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Random Walk

Define

The mean of Ri

The Variance of Ri

Page 8: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Coin Tossing Game

Heads - wins you a rupee Tails - loses you a rupee After n tosses the earnings are given by the rv

Starting with no money, expected earnings after n tosses

Page 9: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Coin Tossing Game

The variance of the earnings is given by

So we have

Page 10: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative
Page 11: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative
Page 12: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative
Page 13: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

How to Simulate a Random Walk

Need to be able to simulate a coin flip

Uniform Random Number Generator will help

We will describe the Linear Congruential Generator

In reality we can only generate pseudo random numbers but good enough for most purposes

Page 14: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative
Page 15: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative
Page 16: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

MATLAB CODE

clear; clc; p=1000; n(1)=1; a=197; b=2^21; M=1103; for i=1:p n(i+1)=mod(a*n(i)+b,M); hold on plot(n(i),n(i+1),'x') end

Page 17: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

How to Simulate a Coin Toss

Generate a uniformly distributed r.v. on [0,1]

We will use this to generate a Bernoulli r.v. X

If then If then

Page 18: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

MATLAB CODE

clear;clc; n=10000;

for i=1:n u=rand; if u<0.5 ber_(i)=1; else ber_(i)=0; end end hist(ber_,4)

Page 19: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

The Distribution Histogram

Page 20: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Making it more Interesting

Consider the quadratic variation

Let’s start flipping the coin faster say n tosses in time t

Q: What should the winnings be so that the quadratic variation is finite and non zero?

Page 21: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

In terms of the random walk

If we take n steps in time t, how long should each step be so that the variation remains finite and non zero?

Page 22: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

The right scaling

Let the winnings (or alternately the step size) be

i.e.

The quadratic variation then is

Page 23: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Brownian Motion

Consider the random walk, with step size taken every time interval

In the limit as this scaling keeps the random walk finite and non zero

Page 24: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Brownian Motion

The expectation is given by

The variance is

as

The limiting process is called Brownian Motion Bt or Weiner Process Wt

Page 25: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Numerical Experiment

clear;clc; T=10; deltat=.01; n=T/deltat; deltax=(deltat)^(.1); k=100; x=zeros(k,n); time=linspace(0,T,n+1) for j=1:k

for i=1:n r=rand; if r<0.5 x(j,i+1)=x(j,i)-deltax; else if r>0.5 x(j,i+1)=x(j,i)+deltax; end

end end hold on plot(time,x(j,:)) end %mean(x) %var(x) figure plot(time,mean(x)) figure plot(time,var(x),'r')

Page 26: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Stochastic Processes

A stochastic process is a collection of random variables T is the index set, S is the common sample space

• For each fixed denotes a single random variable

•For each fixed is a functions defined on T

Page 27: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Types of Stochastic Processes

Discrete Time Discrete Space (DTMC)

Discrete Time Continuous Space (Time Series)

Continuous Time Discrete Space (CTMC)

Continuous Time Continuous Space (SDE)

Page 28: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Markov Property in a Discrete Setting

The index set is discrete (finite or infinite)

Markov Property

Do stock prices follow the Markov property?

Page 29: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Example

Game A: Consider the following game, you toss a fair coin, if heads appears you win a dollar and for tails you lose a dollar. Let X be your winnings at time n.

Game B: Consider a variant of the above game, if you get heads you win a dollar if you get a head on the next throw but lose a dollar if you get tails on the next throw, if you get tails then you win two dollars if you get a head on the net throw and lose two dollars if you get tails on the next throw.

Page 30: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Martingales in a Discrete Setting

A sequence is random variables is said to be martingale if

Fair Game

Q: Are stock prices Martingales?

Page 31: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Example

(Game A): Consider the following game, you toss a fair coin, if heads appears you win a dollar and for tails you lose a dollar. Let X be your winnings at time n.

(Game C): Consider the following game, you toss a biased coin, if heads appears you win a dollar and for tails you lose a dollar. Let X be your winnings at time n.

Page 32: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Martingale and Markov Properties

Game A is both Markovian and a Martingale

Game B is NOT Markovian but IS a Martingale

Game C IS Markovian but NOT a Martingale

Page 33: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Weiner Process

A continuous time continuous space stochastic process

Sample paths are continuous Increments are Normally distributed

i.e. has pdf given by

Page 34: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Weiner Process

Increments are independent

are i.id The covariance is given by

In general

Page 35: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Martingales in a Continuous Setting

A filtration is a special collection of subsets of the sample space of a stochastic process

It contains all information about the process up to time t (i.e. all possible events that can occur up to time t)

A stochastic process is said to be adapted to the filtration if the value of the process at time t is known when the information represented by is known

Page 36: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Martingales

A stochastic process is a martingale with respect to the filtration and probability P if

E.g. Weiner process is a martingale

Page 37: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Simulating Brownian Motion

Initialize at 0 as W(0)=0

Simulate Weiner Increments according to

The Weiner Process then follows

Page 38: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Simulation

-0.7

-0.6

-0.5

-0.4

-0.3

-0.2

-0.1

0

0.1

00.

15 0.3

0.45 0.

60.

75 0.9

1.05 1.

21.

35 1.5

1.65 1.

81.

95 2.1

2.25 2.

42.

55 2.7

2.85 3

3.15 3.3

3.45 3.

63.

75 3.9

4.05 4.

24.

35 4.5

4.65

Tim

e

Weiner Process

Weiner Process

Page 39: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Simulation

-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

00.

15 0.3

0.45 0.

60.

75 0.9

1.05 1.

21.

35 1.5

1.65 1.

81.

95 2.1

2.25 2.

42.

55 2.7

2.85 3

3.15 3.3

3.45 3.

63.

75 3.9

4.05 4.

24.

35 4.5

4.65

Tim

e

Weiner Process 1

Weiner Process 2

Weiner Process 3

Weiner Process 4

Weiner Process 5

Page 40: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Why worry about Weiner Processes?

A model for stock prices (Bachlier)

Problem with this model is that the price can become negative

Page 41: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Ito Calculus

A better model is that the ‘relative price’ NOT the price itself reacts to market fluctuations

Q: What does this integral mean?

Page 42: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Constructing the Ito Integral

We will try and construct the Ito Stochastic Integral in analogy with the Riemann-Stieltjes integral

Note the function evaluation at the left end point!!! Q: In what sense does it converge?

Page 43: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Stochastic Differential Equations

Consider the following Ito Integral

We use the shorthand notation to write this as

This is a simple example of a stochastic differential equation

Page 44: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Convergence of the Integral

The integral converges in the ‘mean square sense’ To see what this means consider

This means

Page 45: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Convergence of the Integral

So we have (in the mean square sense)

OR

Page 46: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

How to Integrate?

A detour into the world of Ito differential calculus

Q: What is the differential of a function of a stochastic variable?

e.g. If what is Is it true that in the stochastic world as

well? We will see the answer is in the negative We will construct the correct Taylor Rule for functions of

stochastic variables This will help us integrating such functions as well

Page 47: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Taylor Series & Ito’s Lemma

Consider the Taylor expansion

The change in F is given by

We note that behaves like a determinist quantity that is it’s expected value as

i.e. formally!!

Page 48: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Taylor Series & Ito’s Lemma

We consider when

So the change involves a deterministic part and a stochastic part

Page 49: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Ito’s Lemma

We consider a function of a Weiner Process and consider a change in both W and t

Ito’s Lemma

Page 50: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Ito’s Lemma

Obtain an SDE for the process We observe that

So by Ito’s Lemma

Page 51: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Integration

Using Ito we can derive

E.g. Show that

Page 52: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Example

Evaluate

Evaluate

Page 53: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Extension of Ito’s Lemma

Consider a function of a process that itself depends on a Weiner process

What is the jump in V if ?

Page 54: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Extension of Ito

So we have the result

Page 55: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Example

If S evolves according to GBM find the SDE for V

Given

Given

Page 56: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Stochastic Differential Equation

We will now ‘solve’ some SDE

Most SDE do NOT have a closed form solution

We will consider some popular ones that do

Page 57: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Arithmetic Brownian Motion

Consider

To ‘solve’ this we consider the process

From extended Ito’s Lemma

Page 58: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Ito Isometry

A shorthand rule when taking averages

Lets find the conditional mean and variance of ABM

Page 59: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Mean and Variance of ABM

We have using Ito Isometry

Page 60: Introduction to Stochastic Calculus - Suraj @ LUMSsuraj.lums.edu.pk/~adnan.khan/CASMFin2016/Day2-2.pdfIntroduction to Stochastic Calculus Teaching the Teachers Workshop on Quantitative

Geometric Brownian Motion

The process is given by

To solve this SDE we consider

Using extended form of Ito we have