Pairs trading on Indian equities works best when two correlated names diverge from their historical relationship. alphabench's Quant agent can find candidate pairs, estimate dynamic hedge ratios, and backtest a Z-score-based mean-reversion strategy in one conversation.

1. Pick (or discover) a pair

You can either name the pair directly or ask the Researcher agent to find one:

"Find me 5 NSE pairs of large-cap banking stocks with high cointegration over the last 3 years."

For a known pair:

"Backtest a pairs strategy on HDFCBANK HDFCBANK logoNSE:HDFCBANK and ICICIBANK ICICIBANK logoNSE:ICICIBANK."

2. Configure the spread

The Quant agent computes the spread as A - β * B where β is the hedge ratio. By default, β is estimated by rolling OLS regression over a 60-day window, so the hedge is dynamic — it adapts as the relationship between the two stocks evolves.

"Use a 90-day rolling window for the hedge ratio estimate. Enter long when Z-score

< -2, short when Z > 2, exit when |Z| < 0.5."

3. Run the backtest

The agent calls backtest_pairs with:

  • Pair: HDFCBANK HDFCBANK logoNSE:HDFCBANK / ICICIBANK ICICIBANK logoNSE:ICICIBANK
  • Hedge window: 90 days
  • Entry/exit thresholds: ±2 / ±0.5
  • Position sizing: equal notional on each leg

You'll get the standard metrics (Sharpe, CAGR, max DD, win rate) plus pairs-specific diagnostics:

  • Average holding period — pairs trades should mean-revert in days, not months
  • Hedge ratio drift chart — flat is good, drifting is dangerous
  • Z-score distribution — should look approximately normal

4. Sanity-check the cointegration

Before trusting any pairs result, ask:

"Run a Monte Carlo test with 1000 simulations and a walk-forward test on this pair."

The Quant agent calls monte_carlo_test and walk_forward_test. If walk-forward Sharpe collapses below 0.5, the relationship was probably spurious or has decayed.

5. Common pitfalls

  • Single-pair strategies fail: trade a basket of 5–10 pairs to diversify away pair-specific blow-ups.
  • Hedge ratio instability: if β swings wildly across the rolling window, the relationship isn't stable enough for pairs trading.
  • Capital intensity: each pair needs notional on both legs, so capital efficiency is roughly half of a directional strategy. Account for this in position sizing.

6. Next: deploy to paper trading

Once the strategy validates, deploy it to the paper trading engine through the UI for live tick-level testing before risking capital.