pair-trading

Generate hedged long/short signals from Z-score deviations in two correlated instruments.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/ebrahim-sani/trading-automation --skill pair-trading-ebrahim-sani
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pair-trading
Source: https://github.com/ebrahim-sani/trading-automation/tree/main/vibe-trading/agent/src/skills/pair-trading
Command: npx skills add https://github.com/ebrahim-sani/trading-automation --skill pair-trading-ebrahim-sani

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill detects temporary deviations in the price ratio or spread between two correlated instruments and generates hedged long/short signals to capture mean reversion while minimizing market directional exposure.

Core Features & Use Cases

  • Z-score based signals: Computes the rolling mean and standard deviation of the price ratio to produce entry and exit signals based on configurable Z-score thresholds.
  • Two-leg, equal-weight hedging: Enforces exactly two instruments with opposite directions and equal capital allocation for a simple paired hedge.
  • Use Case: Backtest or generate live signals for a stock pair or crypto pair (for example, BTC-USDT and ETH-USDT) where you want to trade statistical arbitrage opportunities.

Quick Start

Use the pair-trading skill to produce long-short signals for two aligned time series (for example BTC-USDT and ETH-USDT) using a 60-bar lookback, entry Z=2.0 and exit Z=0.5.

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 stocks?

To generate mean reversion signals, compute the rolling Z-score of the price ratio between two correlated instruments. The skill uses a configurable lookback window and Z-score thresholds to trigger entry and exit signals for hedged long and short positions.

What is statistical arbitrage and how does Z-score pair trading work?

Statistical arbitrage using Z-score pair trading detects temporary deviations in the spread or price ratio between two correlated instruments. It computes rolling statistics to produce entry and exit signals, capturing mean reversion while minimizing directional market exposure through equal-weight hedging.

Can I use pandas for backtesting pair trading strategies on crypto pairs?

Yes, pair trading strategies can be backtested on crypto pairs like BTC-USDT and ETH-USDT. The skill processes aligned OHLCV time series using pandas to compute rolling price ratio statistics and generate backtested long-short statistical arbitrage signals.

How do I configure entry and exit Z-score thresholds for a pair trading strategy?

Entry and exit Z-score thresholds are configured as numeric values, such as an entry Z-score of 2.0 and an exit Z-score of 0.5. These thresholds define when the spread deviation is large enough to enter a hedged position and when it reverts enough to exit.

Does this pair trading approach support more than two instruments for hedging?

No, this approach enforces exactly two instruments with opposite directions and equal capital allocation. It is specifically designed for simple two-leg paired hedges in equity or crypto markets where two-instrument statistical arbitrage is desirable.