Introduction to Stochastic Calculus - Suraj @...

Post on 15-May-2018

217 views 3 download

transcript

Introduction to Stochastic Calculus

Teaching the Teachers

Workshop on Quantitative Finance

December 2016 Adnan Khan

A Quick Look at Stock Prices

Modeling Stock Prices

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

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

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

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

From Random Walks to Brownian Motion

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

Random Walk

Define

The mean of Ri

The Variance of Ri

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

Coin Tossing Game

The variance of the earnings is given by

So we have

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

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

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

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)

The Distribution Histogram

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?

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?

The right scaling

Let the winnings (or alternately the step size) be

i.e.

The quadratic variation then is

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

Brownian Motion

The expectation is given by

The variance is

as

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

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')

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

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)

Markov Property in a Discrete Setting

The index set is discrete (finite or infinite)

Markov Property

Do stock prices follow the Markov property?

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.

Martingales in a Discrete Setting

A sequence is random variables is said to be martingale if

Fair Game

Q: Are stock prices Martingales?

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.

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

Weiner Process

A continuous time continuous space stochastic process

Sample paths are continuous Increments are Normally distributed

i.e. has pdf given by

Weiner Process

Increments are independent

are i.id The covariance is given by

In general

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

Martingales

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

E.g. Weiner process is a martingale

Simulating Brownian Motion

Initialize at 0 as W(0)=0

Simulate Weiner Increments according to

The Weiner Process then follows

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

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

Why worry about Weiner Processes?

A model for stock prices (Bachlier)

Problem with this model is that the price can become negative

Ito Calculus

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

Q: What does this integral mean?

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?

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

Convergence of the Integral

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

This means

Convergence of the Integral

So we have (in the mean square sense)

OR

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

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!!

Taylor Series & Ito’s Lemma

We consider when

So the change involves a deterministic part and a stochastic part

Ito’s Lemma

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

Ito’s Lemma

Ito’s Lemma

Obtain an SDE for the process We observe that

So by Ito’s Lemma

Integration

Using Ito we can derive

E.g. Show that

Example

Evaluate

Evaluate

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 ?

Extension of Ito

So we have the result

Example

If S evolves according to GBM find the SDE for V

Given

Given

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

Arithmetic Brownian Motion

Consider

To ‘solve’ this we consider the process

From extended Ito’s Lemma

Ito Isometry

A shorthand rule when taking averages

Lets find the conditional mean and variance of ABM

Mean and Variance of ABM

We have using Ito Isometry

Geometric Brownian Motion

The process is given by

To solve this SDE we consider

Using extended form of Ito we have