pair-trading

Generate mean-reversion trading signals from price ratios and Z-scores for two instruments.

30.4k|4.9k|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/HKUDS/Vibe-Trading --skill pair-trading
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pair-trading
Source: https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/pair-trading
Command: npx skills add https://github.com/HKUDS/Vibe-Trading --skill pair-trading

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill removes the manual effort of watching two correlated instruments by translating their ratio and Z-score into actionable pair trading signals that seize mean-reversion moves.

Core Features & Use Cases

  • Signal generation: Computes the spread ratio, rolling mean, standard deviation, and Z-score to signal long A/short B or the opposite when deviations exceed entry thresholds and quiet the position near the exit band.
  • Risk-aligned parameters: Users can tune lookback, entry_z, and exit_z to balance responsiveness and noise filtration for both equities and crypto pairs.
  • Use case: Deploy it on a pair like BTC-USDT and ETH-USDT to hedge volatility by always taking opposing directional exposure and closing when the ratio normalizes.

Quick Start

Ask the pair trading skill to monitor BTC-USDT and ETH-USDT with a 60-bar lookback and signal opposing long-short positions when the spread Z-score crosses ±2 or reverts within 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?

Mean reversion trading signals are generated by computing the price ratio and Z-score of two correlated instruments. When the spread Z-score crosses configurable entry thresholds, it triggers opposing long-short positions that close as the ratio normalizes.

Can I use pandas to calculate Z-score spread for crypto pairs like BTC and ETH?

Yes, you can calculate the Z-score spread for crypto pairs using pandas. The workflow computes the rolling mean and standard deviation of the price ratio for aligned OHLCV data to signal divergence and convergence events for assets like BTC-USDT and ETH-USDT.

What is the best way to set entry and exit thresholds for a pair trading strategy?

The best way to set entry and exit thresholds is to tune the entry_z and exit_z parameters. This balances responsiveness and noise filtration, triggering opposite positions when the Z-score crosses bands like ±2 and closing them when it reverts within 0.5.

Does this pair trading approach require aligned OHLCV data for both symbols?

Yes, this pair trading approach requires aligned OHLCV data for exactly two symbols. Ensuring timestamp alignment is a necessary prerequisite to accurately calculate the spread ratio, rolling statistics, and Z-score for mean-reversion signals.

How do I hedge risk with long-short positions using a price ratio?

You hedge risk by taking opposing directional exposure on two correlated instruments based on their price ratio. When the Z-score deviates from the mean, you open opposite long-short positions to capture the convergence when the spread normalizes.

Why does my pair trading Z-score strategy generate noisy signals?

A pair trading Z-score strategy generates noisy signals when the lookback window is too short or entry thresholds are too narrow. Adjusting the rolling lookback parameters and widening the entry_z band filters market noise and improves signal reliability.