pair-trading

Compute Z-score signals for mean-reversion pair trading on two correlated instruments.

Updated Jun 12, 2026
One-click install
npx skills add https://github.com/GGwujun/SigmX --skill pair-trading-ggwujun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pair-trading
Source: https://github.com/GGwujun/SigmX/tree/main/agent/src/skills/pair-trading
Command: npx skills add https://github.com/GGwujun/SigmX --skill pair-trading-ggwujun

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pair trading reduces the manual effort to identify and trade mean-reverting spreads between two correlated instruments by automatically computing ratio-based signals and execution-ready signals.

Core Features & Use Cases

  • Two-instrument setup: works with exactly two instruments to generate paired signals.
  • Ratio-based mean reversion: computes price ratio, rolling mean and std, and derives Z-score to trigger entries and exits.
  • Execution-ready signals: outputs per-instrument positions (long/short/flat) aligned for hedged trading and backtesting.
  • Use Case: pair two stocks in the same sector or BTC/ETH, take long on the cheaper relative instrument and short the expensive one when Z-score crosses thresholds.

Quick Start

Provide two correlated instruments and run the engine to generate and backtest pair-trade signals.

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 signals for a pair of correlated stocks?

To generate mean-reversion signals for a pair of correlated stocks, you compute the price ratio, rolling mean, and standard deviation to derive a Z-score, which then triggers long, short, or flat positions for each leg based on threshold crossings.

What is pair trading and how does a Z-score spread work?

Pair trading is a strategy that takes a long position in a cheaper relative instrument and a short position in an expensive one. A Z-score spread works by measuring the distance of the price ratio from its rolling mean to signal entries and exits.

Can I use this pair-trading technique with crypto assets like BTC and ETH?

Yes, you can use this pair-trading technique with crypto assets like BTC and ETH. The engine requires exactly two correlated instruments, applying the ratio-based Z-score logic across inner-joined historical dates to output execution-ready signals.

How do I backtest a pair-trading strategy using historical price data?

You backtest a pair-trading strategy by providing two correlated instruments to the engine, which aligns their historical data using inner-joined dates, computes the ratio Z-score, and outputs per-asset long, short, or flat signals suitable for execution.

What are the limitations of using a two-instrument setup for ratio-based mean reversion?

The main limitation of this ratio-based mean reversion setup is that it requires exactly two instruments and demands precise handling of NaN values during the lookback period to accurately compute rolling statistics and generate valid execution signals.

Does pair trading require exactly two assets to calculate the rolling mean and standard deviation?

Yes, pair trading requires exactly two assets to calculate the rolling mean and standard deviation. The strategy constructs its mean-reversion signals by computing the price ratio Z-score between the two specific correlated instruments provided.