pair-trading

Generate mean-reversion trade signals from two correlated instruments using price ratio and Z-score.

Updated May 15, 2026
One-click install
npx skills add https://github.com/philipcoller-777/Vibe-Trading-TV2 --skill pair-trading-philipcoller-777
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pair-trading
Source: https://github.com/philipcoller-777/Vibe-Trading-TV2/tree/main/agent/src/skills/pair-trading
Command: npx skills add https://github.com/philipcoller-777/Vibe-Trading-TV2 --skill pair-trading-philipcoller-777

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, pandas, requests.

What problem does it solve?

Pair trading enables traders to exploit mean reversion between two highly correlated instruments by trading the price ratio (or spread) around its mean using a Z-score.

Core Features & Use Cases

  • Two-instrument requirement: exactly two codes must be provided; signals are calculated from their price ratio.
  • Mean-reversion signals: thresholds trigger long/short pairs to capture reversion.
  • Deterministic, backtestable workflow: outputs per-instrument signals that can be fed into a execution engine.

Quick Start

Provide two correlated instruments to the engine and run it to generate mean-reversion pair-trading 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 trading signals for two correlated instruments?

Mean-reversion trading signals are generated by computing the price ratio between two correlated instruments and applying a Z-score to the spread. Configurable lookback, entry, and exit thresholds trigger long or short signals to capture reversion back to the mean.

What is pair trading and how does a Z-score identify entry and exit points?

Pair trading exploits mean reversion between two highly correlated instruments by trading the price ratio around its mean. The Z-score measures the spread's deviation, triggering long or short pairs when the entry threshold is crossed and exiting upon reversion to the exit threshold.

Can I use this mean-reversion workflow for both equities and crypto backtesting?

Yes, this mean-reversion workflow applies to both equities and crypto trading. It requires exactly two instruments with aligned OHLCV data to compute the price ratio and generate deterministic, backtestable trade signals for your execution engine.

How do I handle NaN values during the initial lookback window when calculating the price ratio?

NaN values during the initial lookback window are handled automatically by the deterministic workflow. The engine computes the price ratio and Z-score while managing the incomplete data period, ensuring per-instrument signals are only generated once the lookback window is fully populated.

What are the limitations of using a price ratio and Z-score for mean-reversion backtesting?

The approach is limited to exactly two correlated instruments with aligned OHLCV data. It assumes the price ratio mean-reverts, so it may not work for instruments whose correlation breaks down, and it requires configuring appropriate lookback and threshold parameters to avoid false signals.

Do I need aligned OHLCV data to calculate the price ratio for pair trading?

Yes, aligned OHLCV data for exactly two instruments is required to calculate the price ratio and Z-score. The deterministic workflow depends on this aligned historical data to output accurate per-instrument mean-reversion trade signals for backtesting.