Skip to content

Blog / Financial Models & Research

Pairs Trading: When Two Stocks Move Together but Don’t Stay Together

Two stocks can have similar price movements because they belong to the same sector, operate under similar business conditions or respond to the same market factors. However, a high correlation between two stocks does not necessarily mean their prices will maintain a stable relationship over time.

Pairs Trading: When Two Stocks Move Together but Don't Stay Together

This distinction becomes important in pairs trading, where the idea is to take opposing positions in two stocks when their relative prices move apart, expecting the difference to narrow again.

I explored this using Python and two types of synthetic stock pairs. The first group had a mean-reverting relationship built into the price generation process. The second group shared a common market trend but had no such stable relationship.

Each pair had 1,250 daily price observations. I used linear regression on the first 500 observations to estimate the hedge ratio and calculate the spread between the two log-price series. The remaining 750 observations were used for testing.

The trading rule was based on the z-score of the spread. A position was opened when the z-score moved beyond positive or negative two and closed when it returned within 0.5 of zero. I also included a simplified transaction cost of 0.1% for each entry or exit.

Looking at the example pair in the dashboard, the model opened nine trades and held positions during approximately 18% of the test period.

Rather than drawing a conclusion from one pair, I ran the same calculation on 200 mean-reverting pairs and 200 pairs that only appeared to move together.

Around 98% of the mean-reverting pairs generated positive simulated results, with an average cumulative return of 24.8%. For the second group, only 48% generated positive results, with an average return of negative 0.6%. The worst result in this group was approximately negative 26%.

The difference between these two groups is more interesting to me than the returns themselves. The trading rules were identical. What changed was the underlying relationship between the two price series.

With actual market data, identifying a stable relationship would be a separate challenge. I would want to check cointegration, spread stationarity and whether the estimated hedge ratio remains stable over different periods.

The synthetic data in this experiment was deliberately constructed to demonstrate mean reversion. The return calculation also uses simplified spread-based profit and loss rather than a complete long-short portfolio model.

This is part of my own learning around statistical modelling and financial markets, not an investment recommendation.