Lecture 5 Pairs T rading by Stochastic Spread Methods Haksun Li haksunlinumericalmethodcom wwwnumericalmethodcom Outline First passage time Kalman filter Maximum likelihood estimate ID: 500698
Download Presentation The PPT/PDF document "Introduction to Algorithmic Trading Stra..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Introduction to Algorithmic Trading StrategiesLecture 5
Pairs Trading by Stochastic Spread Methods
Haksun Li
haksun.li@numericalmethod.com
www.numericalmethod.comSlide2
OutlineFirst passage time
Kalman filterMaximum likelihood estimateEM algorithm
2Slide3
References
As the emphasis of the basic co-integration methods of most papers are on the construction of a synthetic mean-reverting asset, the stochastic spread methods focuses on the dynamic of the price of the synthetic asset.Most referenced academic paper: Elliot, van der Hoek, and Malcolm, 2005, Pairs Trading
Model the spread process as a state-space version of Ornstein-Uhlenbeck processJonathan Chiu, Daniel Wijaya Lukman, Kourosh Modarresi
,
Avinayan
Senthi
Velayutham. High-frequency Trading. Stanford University. 2011The idea has been conceived by a lot of popular pairs trading booksTechnical analysis and charting for the spread, Ehrman, 2005, The Handbook of Pairs TradingARMA model, HMM ARMA model, some non-parametric approach, and a Kalman filter model, Vidyamurthy, 2004, Pairs Trading: Quantitative Methods and Analysis
3Slide4
Spread as a Mean-Reverting Process
The long term mean =
.
The rate of mean reversion =
.
4Slide5
Sum of Power Series
We note that
5Slide6
Unconditional Mean
6Slide7
Long Term Mean
7Slide8
Unconditional Variance
8Slide9
Long Term Variance
9Slide10
Observations and Hidden State Process
The hidden state process is:
The observations:
We want to compute the
expected
state from observations.
10Slide11
First Passage Time
Standardized Ornstein-Uhlenbeck process
First passage time
The
pdf
of
has a maximum value at
11Slide12
A Sample Trading Strategy
,
Buy when
unwind after time
Sell
when
unwind after time
12Slide13
Kalman Filter
The Kalman filter is an efficient recursive filter that estimates the state of a dynamic system from a series of incomplete and noisy
measurements.13Slide14
Conceptual Diagram
prediction at time
t
Update at time
t+1
as new measurements come in
correct for better estimation
14Slide15
A Linear Discrete System
: the state transition model applied to the previous state
: the control-input model applied to control vectors
: the noise process drawn from multivariate Normal distribution
15Slide16
Observations and Noises
: the observation model mapping the true states to observations
: the observation noise
16Slide17
Discrete System Diagram
17Slide18
Prediction
predicted a prior state estimate
predicted a prior
estimate covariance
18Slide19
Update
measurement residual
residual covariance
optimal
Kalman
gain
updated a posteriori state estimate
updated
a posteriori
estimate covariance
19Slide20
Computing the ‘Best’ State Estimate
Given ,
, , , we define the conditional variance
Start with
,
.
20Slide21
Predicted (a Priori) State Estimation
21Slide22
Predicted (a Priori) Variance
22Slide23
Minimize Posteriori Variance
Let the Kalman updating formula be
We want to solve for K such that the conditional variance is minimized.
23Slide24
Solve for K
24Slide25
First Order Condition for k
25Slide26
Optimal Kalman Filter
26Slide27
Updated (a Posteriori) State Estimation
So, we have the “optimal” Kalman
updating rule.
27Slide28
Updated (a Posteriori) Variance
28Slide29
Parameter Estimation
We need to estimate the parameters
from the observable data before we can use the
Kalman
filter model.
We need to write down the likelihood function in terms of
, and then maximize w.r.t.
.
29Slide30
Likelihood Function
A likelihood function (often simply the likelihood) is a function of the parameters of a statistical model, defined as follows: the likelihood of a set of parameter values given some observed outcomes is equal to the probability of those observed outcomes given those parameter values.
30Slide31
Maximum Likelihood Estimate
We find such that
is maximized given the observation.
31Slide32
Example Using the Normal Distribution
We want to estimate the mean of a sample of size
drawn from a Normal distribution.
32Slide33
Log-Likelihood
Maximizing the log-likelihood is equivalent to maximizing the following.
First order condition w.r.t.,
33Slide34
Nelder-Mead
After we write down the likelihood function for the Kalman model in terms of
, we can run any multivariate optimization algorithm, e.g.,
Nelder
-Mead, to search for
.
The disadvantage is that it may not converge well, hence not landing close to the optimal solution.
34Slide35
Marginal Likelihood
For the set of hidden states,
, we write
Assume we know the conditional distribution of
, we could instead maximize the following.
, or
The expectation is a weighted sum of the (log-) likelihoods weighted by the probability of the hidden states.
35Slide36
The Q-Function
Where do we get the conditional distribution of
from?Suppose we somehow have an (initial) estimation of the parameters,
. Then the model has no unknowns. We can compute the distribution of
.
36Slide37
EM Intuition
Suppose we know , we know completely about the mode; we can find
Suppose we know , we can estimate
, by, e.g., maximum likelihood.
What do we do if we don’t know both
and
?
37Slide38
Expectation-Maximization Algorithm
Expectation step (E-step): compute the expected value of the log-likelihood function, w.r.t., the conditional distribution of
under and .
Maximization step (M-step): find the parameters,
, that maximize the Q-value.
38Slide39
EM Algorithms for Kalman Filter
Offline: Shumway and Stoffer smoother approach, 1982Online:
Elliott and Krishnamurthy filter approach, 199939Slide40
A Trading Algorithm
From
, , …,
, we estimate
.
Decide whether to make a trade at
, unwind at
, or some time later, e.g.,
.
As
arrives, estimate
.Repeat. 40Slide41
Results (1)
41Slide42
Results (2)
42Slide43
Results (3)
43