pairs-trading

Generate mean-reversion signals from rolling Z-scores of two correlated instruments.

Updated Apr 14, 2026
One-click install
npx skills add https://github.com/loanntc/Paave --skill pairs-trading-loanntc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pairs-trading
Source: https://github.com/loanntc/Paave/tree/main/skills/pair-trading
Command: npx skills add https://github.com/loanntc/Paave --skill pairs-trading-loanntc

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pandas, numpy, requests.

What problem does it solve?

This Skill helps you generate long-short trading signals that exploit temporary divergences in the price relationship of two correlated instruments, aiming for eventual mean reversion.

Core Features & Use Cases

  • Ratio-based Z-score signals: Computes the A/B price ratio, then derives a rolling mean, rolling standard deviation, and Z-score to measure how far the relationship deviates from normal.
  • Hedge-aligned pair positions: Produces opposite-direction signals for the two legs (A long with B short, or A short with B long) using equal 50/50 capital allocation.
  • Entry/exit rule support: Opens positions when Z-score crosses entry thresholds and closes when the absolute Z-score falls below the exit threshold.
  • Use Case: Running a daily BTC/ETH strategy where you enter when the ratio deviates strongly and exit as the ratio returns toward its rolling average.

Quick Start

Generate signals for exactly two instruments by providing a mapping of their OHLCV DataFrames keyed by instrument code to the pair trading signal engine.

Frequently Asked Questions about pairs-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 trading signals are generated by computing the rolling Z-score of the price ratio between two correlated instruments, triggering entry and exit positions when the ratio deviates from its historical mean.

Can I use pair trading signals for daily cryptocurrency strategies?

Yes, pair trading signals support daily cryptocurrency strategies by applying Z-score thresholds to aligned OHLCV data, allowing you to enter and exit long-short positions for assets like BTC and ETH.

How do Z-score entry and exit thresholds work in a long-short pair strategy?

In a long-short pair strategy, entry thresholds open opposite-direction positions when the rolling Z-score crosses configured limits, while exit thresholds close positions as the price ratio reverts toward its rolling average.

Do I need exactly two instruments to calculate rolling Z-score price ratio signals?

Yes, calculating rolling Z-score price ratio signals requires exactly two instruments, performing an inner join on their time indexes to align dates before computing the ratio mean and standard deviation.

What is the best way to align time series data for a pair trading strategy?

The best way to align time series data for pair trading is using an inner join on the date indexes of exactly two instruments, ensuring synchronized price ratios for accurate rolling Z-score calculations.

Does pandas support equal capital allocation for long-short hedge positions?

Yes, using pandas DataFrames, the signal engine outputs hedge-aligned pair positions with equal 50/50 capital allocation, producing opposite-direction signals for the two legs of the pair.