PYTHONadvanced~75 min
Pairs Trading & Cointegration
Estimate a hedge ratio, test the spread for stationarity and half-life, then backtest a z-score strategy honestly with costs and an out-of-sample split.
Task brief
README.md
# Pairs Trading & Cointegration **Role relevance:** Quant research / statistical arbitrage take-home **Estimated time:** 75 minutes **Difficulty:** Advanced **Format:** Jupyter notebook (.ipynb) ## What you are given - pairs_trading_starter.ipynb - a guided notebook that runs end to end even before you fill it in - prices.csv - 750 business days of two price series - Validation targets in the final cell, so you can grade your own work ## What you must deliver 1. The hedge ratio, fitted on the in-sample window only 2. An ADF stationarity test and the spread's half-life 3. A causal z-score signal with the position lagged one day 4. A cost-aware backtest reporting in-sample and out-of-sample separately, plus a written verdict ## Constraints & assumptions The hedge ratio is fitted on the first 500 rows only. The z-score must be rolling, not full-sample. Positions must be lagged before they earn PnL. Costs are 5bp on turnover. ## Submission note Complete the starter file, then compare your work against the mark scheme.
What you'll learn
- Tell cointegration apart from correlation, and test for it
- Use the half-life to set a sensible holding period and thresholds
- Separate a real edge from an overfit with costs and a holdout