pair-trading

Generate mean-reversion trading signals from a two-instrument price ratio using Z-scores.

Updated Apr 14, 2026
One-click install
npx skills add https://github.com/Liangwei-zhang/six-stock --skill pair-trading-liangwei-zhang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pair-trading
Source: https://github.com/Liangwei-zhang/six-stock/tree/main/Vibe-Trading/agent/src/skills/pair-trading
Command: npx skills add https://github.com/Liangwei-zhang/six-stock --skill pair-trading-liangwei-zhang

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pair trading automates the process of generating hedged, mean-reverting trading signals from two correlated assets by analyzing the price ratio, its rolling mean and standard deviation, and the Z-score to trigger entries and exits.

Core Features & Use Cases

  • Automated signal generation for two-instrument mean-reversion trading using the price ratio (A/B).
  • Risk management through strict pair-ownership: long one leg and short the other with equal allocation and explicit exit rules.
  • Use Case: A quant trader can generate daily signals for BTC-ETH or two correlated equities with aligned histories and deterministic entry/exit logic.

Quick Start

Run the pair-trading engine on two aligned instruments to generate long/short signals based on the Z-score of their price ratio.

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 two correlated assets?

Mean-reversion signals are generated by computing the Z-score of two aligned instruments' price ratio to trigger entries and exits. The engine requires exactly two correlated assets and outputs per-instrument long and short signals based on rolling mean deviations.

What is pair trading and how does Z-score determine entry and exit logic?

Pair trading uses a two-instrument price ratio to compute Z-scores and trigger mean-reversion entries and exits. Long and short positions are opened when the Z-score deviates from its rolling mean and closed when the ratio reverts to historical norms.

How do I calculate rolling mean and standard deviation for a two-instrument price ratio?

Calculate rolling mean and standard deviation for a two-instrument price ratio by aligning the historical data of both assets. The engine computes these rolling statistics to standardize the ratio into a Z-score for deterministic signal generation.

Does pair trading signal generation work with unaligned historical price data?

Pair trading signal generation requires exactly two instruments with aligned historical price data. The engine handles index alignment and NaN values internally to compute accurate rolling statistics and Z-scores for deterministic entry and exit signals.

Can I use quantitative pair trading for risk management with equal allocation?

Quantitative pair trading manages risk by enforcing strict pair-ownership with equal allocation across both legs. You long one instrument and short the other, relying on explicit Z-score exit rules to close the hedged position when the ratio reverts.

Why does my pair trading Z-score return NaN for missing index dates?

Pair trading Z-scores return NaN when index alignment fails or missing data prevents rolling calculations. The engine requires exactly two instruments with aligned histories and handles NaN values to ensure deterministic entry and exit signal generation.