660 likes | 931 Views
Introduction to Algorithmic Trading Strategies Lecture 4. Optimal Pairs Trading by Stochastic Control. Haksun Li haksun.li@numericalmethod.com www.numericalmethod.com. Outline. Problem formulation Ito’s lemma Dynamic programming Hamilton-Jacobi-Bellman equation Riccati equation
E N D
Introduction to Algorithmic Trading StrategiesLecture 4 Optimal Pairs Trading by Stochastic Control Haksun Li haksun.li@numericalmethod.com www.numericalmethod.com
Outline • Problem formulation • Ito’s lemma • Dynamic programming • Hamilton-Jacobi-Bellman equation • Riccatiequation • Integrating factor
Reference • Optimal Pairs Trading: A Stochastic Control Approach. Mudchanatongsuk, S., Primbs, J.A., Wong, W. Dept. of Manage. Sci. & Eng., Stanford Univ., Stanford, CA.
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.
Stochastic Control • We model the difference between the log-returns of two assets as an Ornstein-Uhlenbeckprocess. • 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.
Formulation • Assume a risk free asset, which satisfies • Assume two assets, and . • Assumefollows a geometric Brownian motion. • is the spread between the two assets.
Ornstein-UhlenbeckProcess • 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.
Instantaneous Correlation • Let denote the instantaneous correlation coefficient between and .
Univariate Ito’s Lemma • Assume • is twice differentiable of two real variables • We have
Log example • For G.B.M., ,
Multivariate Ito’s Lemma • Assume • is a vector Ito process • is twice differentiable • We have
Notations • : the value of a self-financing pairs trading portfolio • :the portfolio weight for stock A • :the portfolio weight for stock B
Power Utility • Investor preference:
Problem Formulation • , s.t., • , • Note that we simplify GBM to BM of , and remove some constants.
Dynamic Programming • Consider a stage problem to minimize (or maximize) the accumulated costs over a system path. • Cost = s11 S21 2 5 3 3 s0 s12 s3 S22 4 1 5 5 s23 3 s12 time t = 1 t = 0 t = 2
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, .
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.
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
Value function • Terminal condition: • DP equation: • By Ito’s lemma:
Hamilton-Jacobi-Bellman Equation • Cancel on both LHS and RHS. • Divide by time discretization, . • Take limit as , hence Ito. • The optimal portfolio position is .
Taking Expectation • All disapper because of the expectation operator. • Only the deterministic terms remain. • Divide LHR and RHS by .
Dynamic Programming Solution • Solve for the cost-to-go function, . • Assume that the optimal policy is .
First Order Condition • Differentiate w.r.t. . • In order to determine the optimal position, , we need to solve for to get , , and .
Dis-equilibrium • Let . Rewrite: • Multiply by .
Simplification • Note that • The PDE becomes
Another PDE (1) • Divide by .
Yet Another PDE (1) • Divide by .
Riccati Equation • A Riccati equation is any ordinary differential equation that is quadratic in the unknown function.
Solving a Riccati Equation by Integration • Suppose a particular solution, , can be found. • is the general solution, subject to some boundary condition.
Particular Solution • Either or is a particular solution to the ODE. This can be verified by mere substitution.
Substitution • Suppose . goes to 0 by the definition of
Solving • 1st order linear ODE