pair-trading

Generate mean-reversion long/short signals from Z-scores of two instrument price ratios.

Updated May 5, 2026
One-click install
npx skills add https://github.com/wudye/traderAssistHK --skill pair-trading-wudye
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pair-trading
Source: https://github.com/wudye/traderAssistHK/tree/main/backend/src/skills/pair-trading
Command: npx skills add https://github.com/wudye/traderAssistHK --skill pair-trading-wudye

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, pandas, and includes scripts (resource) components.

What problem does it solve?

Pair trading helps you systematically capture mean reversion between two correlated instruments by issuing opposing long/short signals based on how far their price relationship deviates from its historical average.

Core Features & Use Cases

  • Z-score signal engine for an instrument pair: Computes ratio/spread Z-scores using a rolling lookback window and converts deviations into directional signals.
  • Opposing legs with equal allocation: Produces long/short signals for leg A and leg B with fixed 50/50 capital allocation and opposite directions.
  • Entry/exit thresholds: Opens positions when |Z| exceeds entry_z and closes them when |Z| falls below exit_z.
  • Use case example: For BTC-USDT and ETH-USDT, generate daily long BTC/short ETH when the ratio is unusually low, then close once the ratio reverts toward the mean.

Quick Start

Use the pair-trading skill to generate long/short signals for exactly two instruments by comparing their close-price ratio Z-score over a 60-bar rolling window.

Frequently Asked Questions about pair-trading

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate mean reversion trading signals for a correlated stock or crypto pair?

To generate mean reversion trading signals, compute the Z-score of the price ratio between two correlated instruments over a rolling window, then issue opposing long/short positions when the Z-score exceeds entry thresholds and close them upon reversion.

How does Z-score based pair trading work for market-neutral strategies?

Z-score based pair trading works by measuring the standard deviation of the price ratio between two instruments from its rolling mean, triggering opposite long-short positions when the ratio deviates significantly and unwinding when it reverts.

Can I use this pair trading approach for more than two instruments at once?

No, this approach requires exactly two aligned time series to compute the price ratio spread and generate opposing long-short signals, making it unsuitable for multi-asset portfolios or single-instrument trend following.

How do I set entry and exit thresholds for a long-short pair trading strategy?

Set entry thresholds to open positions when the absolute Z-score of the price ratio exceeds a specified level, and set exit thresholds to close positions when the Z-score falls below a lower mean-reversion boundary.

What data alignment is needed before computing rolling statistics for pair trading signals?

You need to inner-join the date indices of both instruments to ensure exact time alignment before computing rolling mean and standard deviation statistics on the price ratio.

Does pair trading with Z-scores work for crypto instruments like BTC and ETH?

Yes, pair trading with Z-scores works for crypto market-neutral scenarios like BTC and ETH, generating daily long-short signals based on the mean reversion of their close price ratio.