You are on page 1of 19




 
   
    20  ! 2555

#$% 
Cointegration and Pair Trading

56# 56
G?D; .D <;  9<;

9 <  21 9>? 2555  15.00 A 16.30 .


B% 206 C 9C
?D;E #F

B < ?D; G9  ;

Cointegration and
Pair Trading:Matlab
Appliacation
Asst. Prof. Dr. Sarayut Nathaphan
0

Discussed Topics
Simple steps in pair trading (Traditional Pair Trading)
Drawbacks of general strategy and suggested
solution.
What is pair trading?
Statistical Arbitrage (cointegration) pair trading
What/Why Stationarity?
Why is stationarity important?
Is correlation the same as cointegration?
What is cointegration?

Simple steps in Pair Trading


(Traditional Approach)
Step1: Pair Formation by finding two assets whose
prices have moved together historically.
Step 2: Creating price ratio
Step 3: Determining +- 2 SD from average of price
ratio to form long-short trading strategy
Step 4: buy underpriced and short overpriced assets
and expecting for profit.
2

Drawback of traditional pair trading


General pair trading strategy bases on historical
price pattern and form boundaries based on past
patterns.
Traditional pair trading bases on correlation
Lacking of future or forecasted price paths, pair
trading strategy may not generated sure profit.
Trading strategy based on non parametric decision
rule.
No guarantee for statistical sure profitable pair
trading namely mean reversion

Statistical Arbitrage
(cointegration
cointegration)) pair trading (1/3)
The presence of a cointegrating relationship
enables us to combine the two assets in a certain
linear combination so that the combined portfolio is
a stationary process.
The portfolio is formed by longing the relative undervalued asset and shorting the relative over-valued
asset.
If two cointegrated assets share a long-run
equilibrium relationship, then deviations from this
equilibrium are only short-term and are expected to
return to zero in future periods.
4

Statistical Arbitrage
(cointegration
cointegration)) pair trading (2/3)
To profit from this relative mis-pricing, a long position
in the portfolio is opened when its value falls
sufficiently below its long-run equilibrium and is
closed out once the value of the portfolio reverts to
its expected value.
Profits may be earned when the portfolio is trading
sufficiently above its equilibrium value by shorting
the portfolio until it reverts to its expected value.

Statistical Arbitrage
(cointegration
cointegration)) pair trading (3/3)
Typical questions which must be answered when
developing a pairs trading strategy include
1. How to identify trading pairs?
2. When is the combined portfolio sufficiently away
from its equilibrium value to open a trading
position?
3. When do we close the position?

What is Pair Trading?


Statistical arbitrage strategy: quantitative trading
strategies that can be implemented using machines
with little human interventions.
Quantitative Speculative strategy by taking a bet
that the price paths of two assets that have
historically moved together will converge again
after any divergence.

What is Pair Trading?


Magnitude of pair trading profit depends on short
term liquidity provision and price discovery or
announcement (news) that temporarily affects
liquidity of one asset in the pair or announcements
that affect both assets but one asset reacts to such
news faster than the other asset.
What is it in layman term (human language)?

What is Pair Trading?


Pairs trading strategy works by taking the arbitrage
opportunity of temporary anomalies between
prices of related assets which have long-run
equilibrium. When such an event occurs, one asset
will be overvalued relative to the other asset. We
can then invest in a two-assets portfolio (a pair)
where the overvalued asset is sold (short position)
and the undervalued asset is bought (long position).
The trade is closed out by taking the opposite
positions of these assets after the asset prices have
settled back into their long-run relationship.
9

What is Pair Trading?


The profit is captured from this short-term
discrepancies in the two asset prices. Since the
profit does not depend on the movement of the
market, pairs trading can be said as a marketneutral investment strategy.
If the value of the portfolio is known to fluctuate
around its equilibrium value then any deviations
from this value can be traded against.

10

What is Pair Trading?


A pairs trading strategy is developed based on the
cointegration coefficients weighted (CCW) rule. The
CCW rule works by trading the number of unit in two
assets based on their cointegration coefficients to
achieve a guaranteed minimum profit per trade.
The minimum profit per trade corresponds to the
pre-set boundaries upper-bound U and lowerbound L chosen to open trades. The optimal pre-set
boundary value is determined by maximizing the
minimum total profit (MTP) over a specified trading
horizon.
11

What is Pair Trading?


The MTP is a function of the minimum profit per
trade and the number of trades during the trading
horizon.
The number of trades is also influenced by the
distance of the pre-set boundaries from the longrun cointegration equilibrium.

12

What is Pair Trading?


Gatev, Goetzmann and Rouwenhorst (2006)
showed that a pairs trading strategy generates
annual returns of 11 percent and a monthly Sharpe
ratio four to six times that of market returns between
1962 and 2002.

13

What/Why Stationarity
Stationarity??
(1/3)
For simple terms, a stochastic process is stationary, if
its statistical properties do not change with time.
(Jan Grandell)
One of the characteristic features that distinguishes
time series data from other types of statistical data
is the fact that, the values of the series at different
time instants will be correlated. Hence a basic
problem in time series analysis is to study the pattern
of the correlation between values at different time
instants and try to construct statistical models which
explain the correlation structure of the series.
14

What/Why Stationarity
Stationarity??
(2/3)
Stationarity is a basic assumption in classical time
series analysis. It means, in effect, that the main
statistical properties of the series remain unchanged
over time.
That is for any set of time points t1, t2, , tn and
any integer c, the joint probability distribution of
[X(t1), X(t2), , X(tn)] is identical with that of [X(t1
+ c), X(t2 + c), , X(tn + c)]

15

What/Why Stationarity
Stationarity??
(3/3
(3/3)
A univariate time series yt is integrated if it can be
brought to stationarity through differencing. The
number of differences required to achieve
stationarity is called the order of integration. Time
series of order d are denoted I(d). Stationary series
are denoted I(0).
An n-dimensional time series yt is cointegrated if
some linear combination 1y1t + + nynt of the
component variables is stationary. The combination
is called a cointegrating relation, and the
coefficients = (1 , , n) form a cointegrating
vector.

16

Example
>> load Data_Canada;
>> Y = Data(:,3:end);
>> figure
>> Plot(dates,Y,LineWidth,2);
>> xlabel(Year);
>> ylabel(Percent);
What can be interpreted?

17

18

>> fprintf('=== Test y1 for a unit root ===\n\n')


>> [h1 PVal1] = adftest(y1,'model','ARD')
>> fprintf('\n === Test y1 for stationarity === \n\n')
>> [h0, PVal0] = kpsstest(y1,'trend',false)
h1 =
0
PVal1 =
0.2867
h0 =
1
PVal0 =
0.0100

19

>>fprintf('\n === Test (1-L)y1 for a unit root === \n\n')


>> [h1D PVal1D] = adftest(diff(y1),'model','ARD')
>> fprintf('\n === Test (1-L)y1 for stationarity === \n\n')
>> [h0D PVal0D] = kpsstest(diff(y1),trend,false)
h1D =
1
PVal1D =
1.0000e-03
h0D =
0
PVal0D =
0.1000
20

21

22

Why is stationarity important?


(1/2
(1/2)
If we say that Yt can change in an arbitrary way
(i.e., one where the probability distribution is not
stable over time), then how can we learn about
patterns?
If each point in time has a different mean, we can
never have multiple data points to average to
estimate that particular mean. We need to assume
a constant mean so that we can take averages
and get meaningful results. (Charlie Gibbon, 2011)

23

Why is stationarity important?


(2/2
(2/2)
When estimation through regression has performed,
nonstationarity always lead to spurious result.
There are two types of stationarity
1. Trend Statoinarity
Yt = 0 + 1t + t,
where t is AR(1) with || < 1.
2. Difference Stationarity
Yt = Yt1 + t.
The AR(1) model with = 1. This is a random
walk model.
24

Is correlation the same as


cointegration?? 1/6
cointegration
If two assets are correlated, it implies that when one
goes up one day, the other would likely go up also
on the same day, and vice versa. Their daily (or
weekly, or monthly) returns would have risen or
fallen in synchrony.
If two assets are cointegrated, meaning that the
two price series cannot wander off in opposite
directions for very long without coming back to a
mean distance eventually.

There is no requirement that two assets must


move synchronously everyday !!!!
25

Is correlation the same as


cointegration?? 2/6
cointegration
Example of correlated assets (Ernest, Chan (2001))

26

Is correlation the same as


cointegration?? 3/6
cointegration
Example of cointegrated assets (Ernest, Chan (2001))

27

Is correlation the same as


cointegration?? 4/6
cointegration
For any two assets who are correlated, spreads
between them may not be diverged and reverted
to make arbitrage profit.
For any two assets who are cointegrated, spreads
between them are temporarily diverged in a short
term manner and will reverted back to the same
spread before diverging.

28

Is correlation the same as


cointegration?? 5/6
cointegration
Cointegration is the foundation upon which pair
trading (statistical arbitrage) is built. If two stocks
simply move in a correlated manner, there may
never be any widening of the spread. Without a
temporary widening of the spread in either
direction, there is no opportunity to short (or buy)
the spread, and no reason to expect the spread to
revert to the mean either.

29

Is correlation the same as


cointegration?? 6/6
cointegration
In this instance, a profitable trade would be to buy
A and short C at around day 10, then exit both
positions at around day 19. Another profitable trade
would be to buy C and short A at around day 31,
then closing out the positions around day 40.

30

What is Cointegration
Cointegration??
Correlation VS Cointegration which one is more
appropriate?
Definition:
Cointegration is an analytic technique for testing for
common trends in multivariate time series and
modeling long-run and short-run dynamics. Two or
more predictive variables in a time-series model are
cointegrated when they share a common stochastic
drift. Variables are considered cointegrated if a linear
combination of them produces a stationary time
series.
31

What is Cointegration
Cointegration??
Cointegration is distinguished from traditional
economic equilibrium, in which a balance of forces
produces stable long-term levels in the variables.
Cointegrated variables are generally unstable in
their levels, but exhibit mean-reverting
"spreads" (generalized by the cointegrating
relation) that force the variables to move around
common stochastic trends.
The tendency of cointegrated variables to revert to
common stochastic trends is expressed in terms of

error-correction.
32

What is Cointegration
Cointegration??
In layman term, cointegration means two or more time
series share long-term behavior
Integrated variables are a specific class of nonstationary variables with important economic and
statistical properties.
Granger (1986) and Engle and Granger (1987) pointed
the differences between I(0) and I(1) as follows:
I(0) has finite variance which does not depend on time,
has limited memory of its past behavior, tend to
fluctuate around the mean (include deterministic trend),
has autocorrelations that decline rapidly as the lag
increases.
33

What is Cointegration
Cointegration??
I(1) series have the main features as
1) Variance depends upon time and goes to
infinity as time goes to infinity
2) The process has an infinitely long memory (an
innovation will permanently affect the process)
3) It wanders widely
4) The autocorrelations tend to one in
magnitude for all time separations

34

You might also like