Published on

Pair Trading: A Quantitative Approach

Authors
  • avatar
    Name
    Loi Tran
    Twitter

Introduction

Pair trading is a classic market-neutral strategy that involves taking opposing positions in two correlated assets. This post walks through a simple example and connects it to portfolio theory.


Example: Alpha & Omega

Imagine two tech firms, Alpha and Omega. We construct a pair trade:

  • Short Omega
  • Long Alpha

Initial Trade

AlphaOmega
Price$50$40
TradeBuy 20Short 25
Cash Flow-$1000+$1000

After 3 Months

AlphaOmega
Price$45$35
TradeSell 20Buy 25
Cash Flow+$900-$875

Performance

  • Alpha (5050 → 45): 10% drop
  • Omega (4040 → 35): 12.5% drop

Position Types

  • Long Position: Profit when price rises
  • Short Position: Profit when price falls

Scaling Up: Portfolio Construction

Pair trading can be extended to a portfolio of carefully chosen stocks. The goal is to use mathematical models to balance risk and return, factoring in correlations.


Mean-Variance Optimization

The standard way to build a portfolio is through mean-variance optimization:

  • Return Vector: μ=(μ1,μ2,...,μn)\vec{\mu} = (\mu_1, \mu_2, ..., \mu_n)
  • Covariance Matrix:
Σ=[Var(X)Cov(X,Y)Cov(Y,X)Var(Y)]\Sigma = \begin{bmatrix} \mathrm{Var}(X) & \mathrm{Cov}(X,Y) \\ \mathrm{Cov}(Y,X) & \mathrm{Var}(Y) \end{bmatrix}
  • Weight Vector: w=(w1,w2,...,wn)\vec{w} = (w_1, w_2, ..., w_n)

Portfolio Returns

  • Expected Return:

    extExpectedReturn=wμ ext{Expected Return} = \vec{w} \cdot \vec{\mu}
  • Portfolio Variance:

    σ2=wTΣw\sigma^2 = \vec{w}^T \Sigma \vec{w}
  • Objective Function (Loss Function):

    wμλwTΣw\vec{w} \cdot \vec{\mu} - \lambda \vec{w}^T \Sigma \vec{w}

The objective is to find weights w\vec{w} that maximize this function, balancing return and risk according to your preferences.


Portfolio Constraints

Portfolio TypeDescriptionConstraints
Long-Only PortfolioNo shorting, fully investedwi0w_{i} \geq 0, wi=1\sum w_{i} = 1
Long-Short PortfolioAllows shorts, fully investedwiRw_{i} \in \mathbb{R}, wi=1\sum w_{i} = 1
Market NeutralAllows shorts, net exposure is zerowiRw_{i} \in \mathbb{R}, wi=0\sum w_{i} = 0

Alternative Data

Coming soon...


Conclusion

References