I am new to pairs trading and am in the process of constructing the code for backtesting a basic pair trading strategy. While I understand the basic idea behind the pair trading strategy, I am having trouble understanding which stock to short or long should future price dynamics change between the pair.

My question: Let say stock A currently trades at a price that is more expensive than Stock B. If this relationship continues to persist, whenever there is a divergence in price, I will short A and long B. But if price dynamics change such that price of B > price of A, I would need to switch between the entry such that when there is a divergence, I will need to now short B and long A.

Is this correct?


Yes you are correct.

If price of A > B, then short A and long B. When prices of A and B diverge:

  • (a) because of A: Make money since A is (by pairs trading assumption) over priced and we shorted.
  • (b) because of B: Make money since B is (again, by pairs trading assumption) under priced and we were long.
  • (c) Because of both A and B: Both A was overpriced and B was under priced is a combination of the above two cases and we make money.

These three cases exhaust the scenario that the prices diverged. We do not need to know which of the cases happened to make money.

For more information, see http://en.wikipedia.org/wiki/Pairs_trade

  • $\begingroup$ @user1234440, please let us know if we answered your question. $\endgroup$ – Theja Sep 28 '13 at 2:55

Please see e.g. wikipedia entry for cointegration. You should also probably read the original paper here and/or the book by Vidyamurtha.

Vidyamurtha's book is a bit messy, but IMO quite OK.

Also, I think it's going to be pretty hard to make pairs trading work in practice. It's just a too old idea and it's being done too much and you're going to have a tough time finding suitable pairs.

You should improve your math a lot and think of a better algorithm ;)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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