You are on page 1of 10

Pairs Trading1

University of Oxford
Oxford-Man Institute

Álvaro Cartea
alvaro.cartea@maths.ox.ac.uk

December 15, 2021

1 Notes based on textbook “Algorithmic and High-Frequency Trading” with

Sebastian Jaimungal and Jose Penalva.


1 / 10
Mean reversion
Let Xt denote a stochastic process that follows

Xt+1 = α + β Xt + σ ϵt , (1)

where α and β are constants, σ is a non-negative constant, and ϵ are


i.i.d. with distribution N(0, 1). If in (1) one sets α = 0 and β = 1 we
obtain a driftless random walk.

1815
Amazon

1810
Midprice

1805

1800

0 0.2 0.4 0.6 0.8 1


Time

Figure: Midprices AMZN July 13, 2018.

2 / 10
Comovements

1425
1.004 Amazon
Google
1420
1.002
Midprice/mean

1 1415

0.998
1410
0.996
1405
0.994

1400
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Time

Figure: GOOG and AMZN on July 13, 2018 for the whole day of trading: (left
panel) midprices; (right panel) the value a portfolio which is long 1.04 shares of
GOOG and short 0.7687 shares of AMZN (i.e., the co-integration factor). The
dashed line indicates the mean-reverting level, the dash-dotted lines indicate
the 2-standard deviation bands.

3 / 10
Simple strategy

If a trader believes that the mean-reverting pattern persists, then the


strategy is
▶ buy (sell) portfolio when its value is below (above) its
mean-reverting level
▶ For example, to sell the portfolio it requires the trader to sell 1.04
shares in GOOG and buy 0.76 shares in AMZN.

4 / 10
Portfolio with two assets

▶ Let q a denote units of security A and q b denote units of security B.


▶ We denote by
εt = q a StA + q b StB (2)
the value of the portfolio
▶ In the example depicted in Figure 2 security A is GOOG and security
B is AMZN, thus q a = 1.04 and q b = −0.76.

5 / 10
Co-integration of prices

Assume that the prices (or midprices) of the securities are given by a
vector autoregression of order one, i.e., VAR(1), thus

StA = ca + b11 St−1


A B
+ b12 St−1 + ϵAt , (3a)

StB = cb + b21 St−1


A B
+ b22 St−1 + ϵBt , (3b)
where ca , cb , b˙˙ are constants, and ϵAt and ϵBt are error terms.

6 / 10
Back to one asset

If we only focus on security A, which is given by (3a), it would be


difficult to observe a pattern that could lead to a trading strategy.
However, note that if the cross term b12 is zero, then the price dynamics
of security A would exhibit mean reversion. If S a is given by

StA = ca + b11 St−1


A
+ ϵAt , (4)

then S A follows an AR(1) process.


A
Rewrite (4), by subtracting St−1 on both sides of equation (4) and
re-arrange, as
StA − St−1
A A
+ ϵAt ,

= κ1 θ1 − St−1 (5)
where κ1 = 1 − b11 is the speed of mean-reversion and θ1 = ca /(1 − b11 )
is the mean-reversion level of the prices.

7 / 10
Pairs trading

First, we write the VAR model (3) in matrix form:

S t = A + B S t−1 + ϵt , (6)

where S is the vector of prices and A a vector of constants, both with


dimension 2 × 1. The matrix B of constants is of dimension 2 × 2 and ϵ
is a 2 × 1 vector of errors.
Second, we subtract the vector of prices S t−1 on both sides of (6) and
after re-arranging we obtain

∆S t = κ (θ − S t−1 ) + ϵt , (7)

where ∆ represents the difference operator, i.e., ∆S t = S t − S t−1 , κ is a


2 × 2 matrix and θ is a 2 × 1 vector. Here κ = I − B, where I is the
−1
identity matrix, and θ = (I − B) A.
The intuition of the model that expresses changes in prices, as in (7), is
similar to that discussed in the univariate case (5).

8 / 10
Pairs trading
Third, to devise a strategy that benefits from prices that revert to a
mean level we diagonalise the matrix κ. Thus, we write

κ = U Λ U −1 , (8)

where  
κ 0
Λ= 1 (9)
0 κ2
contains the eigenvalues of κ, and U contains the eigenvectors of κ.
The next step is to premultiply (7) by U −1 and write
 
∆S̃ t = κ̃ θ̃ − S̃ t−1 + ϵ̃t , (10)

where S̃ = U −1 S, θ̃ = U −1 θ h, and κ̃
i = Λ.
1 2 ⊺
The new vector of prices S̃ = S̃ S̃ are prices of two portfolios. Each
¯
portfolio contains a linear combination of shares in asset S A and in asset
SB.

9 / 10
100 100

80 80

60 60

40 40

20 20

0 0
-20 0 20 40 60 80 0 10 20 30 40 50 60

(a) band = 0.25 × std.dev . (b) band = 0.5 × std.dev .

100 100

80 80

60 60

40 40

20 20

0 0
0 10 20 30 40 50 -10 0 10 20 30 40 50

10 / 10
(c) band = 1.0 × std.dev . (d) band = 2.0 × std.dev .

You might also like