A market-neutral statistical-arbitrage strategy that pairs stocks by minimum normalized-price distance.

Published: 2026-05-03

URL: https://pyquantnews.substack.com/p/your-monthly-alpha-lab-deep-dive-4a8


Welcome to your monthly Alpha Lab deep dive. At the end of each month, you’ll get a deep dive featuring Python code to backtest and analyze a live trading strategy. Remember, you can also drive the conversation and support topics your way. Create new threads to start conversations about the code, strategies, and topics you care about.

In this month’s deep dive inside PyQuant News Alpha Lab, you’ll build a market-neutral pairs trading strategy designed to profit when two historically co-moving stocks temporarily diverge, then mean revert. We’ll implement the full workflow in Python (Zipline) using liquid U.S. equities: each day you screen to the top 500 by 21-day average dollar volume (price >$5), then form pairs over a 12-month (252-day) formation window by minimizing normalized price distance (sum of squared deviations). You track the 20 closest pairs each cycle.

The strategy is straightforward: refresh pairs every 6 months, then enter a trade when a pair’s normalized spread moves more than 2 standard deviations from its rolling mean—short the relative winner and buy the relative loser—and exit when the spread reverts. You cap exposure at 5 open pairs with equal-weight sizing per leg.

By the end, you’ll have a complete backtest—from pair selection through execution—plus performance evaluation using CAGR, Sharpe ratio, annualized volatility, and max drawdown.