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.