Upload
komala
View
90
Download
4
Tags:
Embed Size (px)
DESCRIPTION
Introduction to Algorithmic Trading Strategies Lecture 4. Optimal Pairs Trading by Stochastic Control. Haksun Li [email protected] www.numericalmethod.com. Outline. Problem formulation Ito’s lemma Dynamic programming Hamilton-Jacobi-Bellman equation Riccati equation - PowerPoint PPT Presentation
Citation preview
Introduction to Algorithmic Trading StrategiesLecture 4
Optimal Pairs Trading by Stochastic Control
Haksun [email protected]
www.numericalmethod.com
2
Outline Problem formulation Ito’s lemma Dynamic programming Hamilton-Jacobi-Bellman equation Riccati equation Integrating factor
3
Reference Optimal Pairs Trading: A Stochastic Control
Approach. Mudchanatongsuk, S., Primbs, J.A., Wong, W. Dept. of Manage. Sci. & Eng., Stanford Univ., Stanford, CA.
4
Basket Creation vs. Trading In lecture 3, we discussed a few ways to
construct a mean-reverting basket. In this and the next lectures, we discuss how
to trade a mean-reverting asset, if such exists.
5
Stochastic Control We model the difference between the log-
returns of two assets as an Ornstein-Uhlenbeck process.
We compute the optimal position to take as a function of the deviation from the equilibrium.
This is done by solving the corresponding the Hamilton-Jacobi-Bellman equation.
6
Formulation Assume a risk free asset, which satisfies
Assume two assets, and . Assumefollows a geometric Brownian motion.
is the spread between the two assets.
7
Ornstein-Uhlenbeck Process We assume the spread, the basket that we
want to trade, follows a mean-reverting process.
is the long term equilibrium to which the spread reverts.
is the rate of reversion. It must be positive to ensure stability around the equilibrium value.
8
Instantaneous Correlation Let denote the instantaneous correlation
coefficient between and .
9
Univariate Ito’s Lemma
Assume is twice differentiable of two real variables
We have
10
Log example For G.B.M., ,
11
Multivariate Ito’s Lemma
Assume is a vector Ito process is twice differentiable
We have
12
Multivariate Example
13
What is the Dynamic of Asset At?
14
Dynamic of Asset At
15
Notations : the value of a self-financing pairs trading
portfolio :the portfolio weight for stock A :the portfolio weight for stock B
16
Self-Financing Portfolio Dynamic
17
Power Utility Investor preference:
18
Problem Formulation , s.t., ,
Note that we simplify GBM to BM of , and remove some constants.
19
Dynamic Programming
Consider a stage problem to minimize (or maximize) the accumulated costs over a system path.
s0
s11
s12
timet = 0 t = 1
S21
S22
s23
t = 2
3
2
3
5
Cost =
s3
s12
5
4
3
1
5
20
Dynamic Programming Formulation State change:
: time : state : control decision selected at time : a random noise
Cost: Objective: minimize (maximize) the expected
cost. We need to take expectation to account for the
noise, .
21
Principle of Optimality Let be an optimal policy for the basic
problem, and assume that when using , a give state occurs at time with positive probability. Consider the sub-problem whereby we are at at time and wish to minimize the “cost-to-go” from time to time .
Then the truncated policy is optimal for this sub-problem.
22
Dynamic Programming Algorithm For every initial state , the optimal cost of
the basic problem is equal to , given by the last step of the following algorithm, which proceeds backward in time from period to period
23
Value function Terminal condition:
DP equation:
By Ito’s lemma:
24
Hamilton-Jacobi-Bellman Equation Cancel on both LHS and RHS. Divide by time discretization, . Take limit as , hence Ito.
The optimal portfolio position is .
25
HJB for Our Portfolio Value
26
Taking Expectation All disapper because of the expectation
operator. Only the deterministic terms remain. Divide LHR and RHS by .
27
Dynamic Programming Solution Solve for the cost-to-go function, . Assume that the optimal policy is .
28
First Order Condition Differentiate w.r.t. .
In order to determine the optimal position, , we need to solve for to get , , and .
29
The Partial Differential Equation (1)𝐺𝑡−
𝐺𝑉 (𝐺𝑉 (𝑘 (𝜃−𝑥𝑡 ) )+𝐺𝑉𝑥𝜂2
𝐺𝑉𝑉 𝜂2 𝑘 (𝜃− 𝑥𝑡 ))+¿
𝐺𝑥 (𝑘 (𝜃−𝑥𝑡 ))+¿ 12𝐺𝑉𝑉 𝜂
2(𝐺𝑉 (𝑘 (𝜃−𝑥𝑡 ))+𝐺𝑉𝑥𝜂2
𝐺𝑉𝑉 𝜂2 )
2
+¿ 12𝐺𝑥𝑥𝜂
2−
𝐺𝑉𝑥𝜂2𝐺𝑉 (𝑘 (𝜃− 𝑥𝑡 ))+𝐺𝑉𝑥𝜂2
𝐺𝑉𝑉 𝜂2
=0
¿
30
The Partial Differential Equation (2)𝐺𝑡−
𝐺𝑉 𝑘 (𝜃−𝑥𝑡 )𝐺𝑉 (𝑘 (𝜃−𝑥𝑡 ))+𝐺𝑉𝑥𝜂 2
𝐺𝑉𝑉 𝜂2 +¿
𝐺𝑥 (𝑘 (𝜃−𝑥𝑡 ))+¿12
[𝐺𝑉 (𝑘 (𝜃−𝑥𝑡 ))+𝐺𝑉𝑥𝜂2 ]2
𝐺𝑉𝑉 𝜂2+¿12𝐺𝑥𝑥𝜂2−
𝐺𝑉𝑥𝐺𝑉 (𝑘 (𝜃−𝑥𝑡 ) )+𝐺𝑉𝑥𝜂
2
𝐺𝑉𝑉
=0
¿
31
Dis-equilibrium Let . Rewrite:
Multiply by .
32
Simplification Note that The PDE becomes
33
The Partial Differential Equation (3)
𝐺𝑡𝐺𝑉𝑉 𝜂2+𝐺𝑥𝑏𝐺𝑉𝑉 𝜂2+12 𝐺𝑥𝑥𝐺𝑉𝑉 𝜂 4−
12 (𝐺𝑉 𝑏+𝐺𝑉𝑥𝜂2 )
2=0
34
Ansatz for G
35
Another PDE (1)
Divide by .
36
Ansatz for
37
Boundary Conditions
38
Yet Another PDE (1)
Divide by .
39
Yet Another PDE (2)
40
Expansion in
41
Grouping in
(𝑔𝑡+𝑘𝑔 𝛽𝜃+12 𝜂
2𝑔𝛽2+𝜂2𝑔𝛼− 𝜆𝑔𝜂2
𝑘2𝜃2− 𝜆𝑔𝜂2 𝛽2−2 𝜆𝑔𝑘 𝛽𝜃 )+(𝑔𝛽𝑡−𝑘𝑔 𝛽+2𝛼𝑘𝑔 𝜃+2𝜂2𝑔𝛼𝛽+2 𝜆𝑔𝜂2
𝑘2𝜃+2 𝜆𝑔𝑘 𝛽−4𝜆𝑔𝑘 𝜃𝛼−4 𝜆𝑔𝜂2𝛼𝛽)𝑥+(𝑔𝛼 𝑡−2𝛼𝑘𝑔+2𝜂 2𝑔𝛼2− 𝜆𝑔𝜂2
𝑘2−4 𝜆𝑔𝜂2𝛼2+4 𝜆𝑔𝑘𝛼)𝑥2=0
42
The Three PDE’s (1)
43
PDE in
44
PDE in ,
45
PDE in , ,
46
Riccati Equation A Riccati equation is any ordinary differential
equation that is quadratic in the unknown function.
47
Solving a Riccati Equation by Integration Suppose a particular solution, , can be found. is the general solution, subject to some
boundary condition.
48
Particular Solution Either or is a particular solution to the ODE.
This can be verified by mere substitution.
49
Substitution Suppose .
goes to 0 by the definition of
50
Solving
1st order linear ODE
51
Solving for
boundary condition:
52
Solution (1)
53
Solution (2)
54
Solution (3)
55
Solving
Let
56
First Order Non-Constant Coefficients
57
Integrating Factor (1)
We try to find an integrating factor s.t.
Divide LHS and RHS by .
By comparison,
58
Integrating Factor (2)
59
Solution
60
,
61
Solution
𝛽 (𝑡 )=𝑘𝜃𝜂2
(1+√1−𝛾 )exp ( 2𝑘
√1−𝛾(𝑇 −𝑡 ))−1
1+[1− 21−√1−𝛾 ]exp( 2𝑘
√1−𝛾(𝑇 −𝑡 ))
62
Solving
With and solved, we are now ready to solve .
63
Computing the Optimal Position
64
The Optimal Position
65
P&L for Simulated Data
The portfolio increases from $1000 to $4625 in one year.
66
Parameter Estimation Can be done using Maximum Likelihood. Evaluation of parameter sensitivity can be
done by Monte Carlo simulation. In real trading, it is better to be conservative
about the parameters. Better underestimate the mean-reverting speed Better overestimate the noise
To account for parameter regime changes, we can use: a hidden Markov chain model moving calibration window