I'm trying to backtest Pairs Trading but have become a bit confused on the different methods of selecting pairs, how to look for trading signals and what size of the positions to take in the assets.

What I'm doing right now is that I'm testing for cointegration amongst pairs, which I'm doing with Engle-Granger to get the coefficients in the stationary linear combination of the assets.

$X_t = bY_t+a + \epsilon_t$

After that I check the residual $\epsilon_t = X_t-bY_t-a$ for trading signals. If the absolute value of the residual is larger than some predetermined amount I would open the trade. The trade is closed when the residual is reversed back to 0.

When receiving a signal, I want to trade long/short with equal amounts (1 dollar long/short), as in Gatev et al. and many others. But what I realized is that using these signals and this residual you could actually make a loss from a long/short position with equal amounts.

So I tried to figure out how they (Gatev and others) looked for trading signals, but everywhere I look it's very poorly explained (especially in their original article). It just says that they use cointegration or OLS or something equivalent and then trade 1 dollar long, 1 dollar short etc.

So what is it that they do? Do they test for stationary in the linear combination without the constant a? $X_t = bY_t + \epsilon_t$

Or is there perhaps any additional condition (in the trading signals) I could add to avoid this potential loss of incurring? Since it depends on the value of the assets at the time of closing I would guess not. Would you recommend looking at some other residual for trading signals?

I know you could take positions 1 and b in the different assets to ensure no trade makes any loss, but this severely complicates the computations of the returns w.r.t. the committed capital. Because of that, I'd rather not use this method.


Since I've been misunderstood, I will try to clearify what I'm asking.

The profit from each trade:$P = N_x X_c - N_x X_o + N_y Y_o - N_yY_c$ if you're long in X and short in Y.

Assuming our relationship from the cointegration we have the closing resp. opening we have:

$X_o = bY_o + a + \epsilon_o$ where $\epsilon_o$ is larger than some value U or less than -U. If we're long in X and short in Y this would mean that its less than -U.

$X_c = bY_c + a + \epsilon_c$ where $\epsilon_c$ is larger than 0.

This gives us the profit: $$P = N_x (bY_c + a + \epsilon_c) - N_x (bY_o + a + \epsilon_o) + N_y Y_o - N_yY_c = $$

Let's now say we take positions 1 and b in X resp. Y. This gives us: $$P=\epsilon_c - \epsilon_o > U$$

However, if I would invest equal amounts in each asset the profit would be:

$$P = Y_c/Y_o - X_c/X_o$$

which is not strictly positive. So that's why I asked what Gatev et al. (and others) used to look for trading signals. Do they model the stationary time series as $X_t = bY_t + \epsilon_t$? They mension normalised price series also, but they don't explain in detail what it is that they do. This confuses me and I can't figure it out.

  • $\begingroup$ Are you seriously asking for trading ideas? $\endgroup$ Commented Mar 7, 2013 at 23:58
  • $\begingroup$ @chrisaycock, is there a way to delineate what constitutes value-added in terms of strategy related questions and what is merely asking others to do the grunt work in terms of strategy profiling and idea generation? I think most recently more and more of the same type of questions are popping up and to be honest I find most a mismatch with the intentions of this site. This particular one looks like a borderline case to me. Any views? $\endgroup$
    – Matt Wolf
    Commented Mar 8, 2013 at 3:48
  • $\begingroup$ @Freddy That's the kind of thing you should ask on Meta. $\endgroup$ Commented Mar 8, 2013 at 3:51
  • 3
    $\begingroup$ I'm just amidst my education and recently started my studies in math. finance. I was merely trying to understand what's been done in the research of pairs trading, not having someone come up with trading ideas for me (I'm sorry it was interpreted in that way). I don't see why you have to be so condescending, this site isn't exclusively for professionals, is it? $\endgroup$ Commented Mar 8, 2013 at 9:10
  • $\begingroup$ What values do you substitute for X & Y? Prices or log prices? $\endgroup$
    – dkhokhlov
    Commented Mar 9, 2013 at 20:27

3 Answers 3


I'll try to solve your query by way of an example.

$X= 2*Y + a + e$, here you go Short on $X$ and Long on $Y$, and the coefficient of $Y$ is $2$. Let's say $X=100$ and $Y=49$ (i.e. $X$'s and $Y$'s current price) and $a=1$ and also $e=1$.

Now you need to execute a trade to make money when $e$ becomes $0$. So in order to make money from the trade, you will sell 1 share of $X$ and buy 2 shares of $Y$. Now where ever the price will move if your coefficients are same i.e 2 and $a=1$, the moment $e$ becomes 0 you'll make money.

In this pair trade you don't need to put equal money in both $X$ and $Y$, but whatever quantity of $X$ you sell you have to buy twice quantity of $Y$.


I do understand your confusion, for someone who has already started research in these topics there might be many questions. regarding size of position: it definitely doesn't have to be 1, or generally the same in both assets. After receiving a signal you have to get into trade with sizes that are appropriate to your ideas, e.g if you want to be say 'delta hedged' or 'market nerutral' you have to choose the values that gives you... cointegration vector.

  • $\begingroup$ What do you mean by that last part? ("you have to choose the values that gives you... cointegration vector"). I know the sizes is different in different models and have different properties. However I wanted to test the 'market neutral' portfolio with equal amounts in each asset, however as I've implemented it now I could still get losses, that's why I asked what residual you could check to avoid this. $\endgroup$ Commented Mar 8, 2013 at 16:11
  • $\begingroup$ yo should take a trade with sizes introduced by this vector $\endgroup$
    – 4pie0
    Commented Mar 10, 2013 at 15:23
  • $\begingroup$ I'm not completely sure if I follow you, do you mean as Benjamin explained in his comment? But how could I use this to go 1 dollar long/1 dollar short? $\endgroup$ Commented Mar 10, 2013 at 17:29
  • $\begingroup$ please give a concrete example of assets and cointegrating relationship (not true coefficients but potential example to know that we are talking about the same) $\endgroup$
    – 4pie0
    Commented Mar 10, 2013 at 18:35
  • $\begingroup$ Well, using the cointegration relationship as defined in my question, $X_t$ and $Y_t$ would be the price series of Stock X and Stock Y, and the coefficients could vary.. but lets say b=2, a=10? $\endgroup$ Commented Mar 10, 2013 at 18:49

I cannot get your point o even if it was a question, but there are another techniques to co integrate pairs. eg Johansen tests ?

You just described how to implement a simple execution strategy.

  • $\begingroup$ I know there are different methods of testing for cointegration, but that was not my question. I briefly explained the strategy to emphasize what confounded me. I've edited my question, hopefully it more clear to what I'm asking for. $\endgroup$ Commented Mar 8, 2013 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.