Skip to content
Finance
Skill

/pair-trade-screener

Statistical arbitrage tool for identifying and analyzing pair trading opportunities. Detects cointegrated stock pairs within sectors, analyzes spread behavior, calculates z-scores, and provides entry/exit recommendations for market-neutral strategies. Use when user requests pair

From plugin
claude-trading-skills
6.9k74 skills2 agents2 commands

Claude Code

$ npx -y skills add tradermonty/claude-trading-skills --skill pair-trade-screener --agent claude-code

SKILL.md

pair-trade-screener.SKILL.md
name: pair-trade-screener
description: Statistical arbitrage tool for identifying and analyzing pair trading opportunities. Detects cointegrated stock pairs within sectors, analyzes spread behavior, calculates z-scores, and provides entry/exit recommendations for market-neutral strategies. Use when user requests pair trading opportunities, statistical arbitrage screening, mean-reversion strategies, or market-neutral portfolio construction. Supports correlation analysis, cointegration testing, and spread backtesting.

Pair Trade Screener

Overview

This skill identifies and analyzes statistical arbitrage opportunities through pair trading. Pair trading is a market-neutral strategy that profits from the relative price movements of two correlated securities, regardless of overall market direction. The skill uses rigorous statistical methods including correlation analysis and cointegration testing to find robust trading pairs.

**Core Methodology:**

  • Identify pairs of stocks with high correlation and similar sector/industry exposure
  • Test for cointegration (long-term statistical relationship)
  • Calculate spread z-scores to identify mean-reversion opportunities
  • Generate entry/exit signals based on statistical thresholds
  • Provide position sizing for market-neutral exposure

**Key Advantages:**

  • Market-neutral: Profits in up, down, or sideways markets
  • Risk management: Limited exposure to broad market movements
  • Statistical foundation: Data-driven, not discretionary
  • Diversification: Uncorrelated to traditional long-only strategies

When to Use This Skill

Use this skill when:

  • User asks for "pair trading opportunities"
  • User wants "market-neutral strategies"
  • User requests "statistical arbitrage screening"
  • User asks "which stocks move together?"
  • User wants to hedge sector exposure
  • User requests mean-reversion trade ideas
  • User asks about relative value trading

Example user requests:

  • "Find pair trading opportunities in the tech sector"
  • "Which stocks are cointegrated?"
  • "Screen for statistical arbitrage opportunities"
  • "Find mean-reversion pairs"
  • "What are good market-neutral trades right now?"

Prerequisites

  • Python 3.9 or newer
  • An FMP API key with access to the company screener and historical-price endpoints
  • `statsmodels>=0.14,<0.15` for ADF and autoregression calculations

Set the API key without placing it on the command line or in a committed file:

export FMP_API_KEY="<fmp-api-key>"

Run the scripts from the repository root with the statistical dependency isolated to the command:

uv run --with 'statsmodels>=0.14,<0.15' python \
  skills/pair-trade-screener/scripts/find_pairs.py \
  --symbols AAPL,MSFT \
  --output /tmp/pair-trade/pairs.json

Analysis Workflow

Step 1: Define Pair Universe

**Objective:** Establish the pool of stocks to analyze for pair relationships.

**Option A: Sector-Based Screening (Recommended)**

Select a specific sector to screen:

  • Technology
  • Financials
  • Healthcare
  • Consumer Discretionary
  • Industrials
  • Energy
  • Materials
  • Consumer Staples
  • Utilities
  • Real Estate
  • Communication Services

**Option B: Custom Stock List**

User provides specific tickers to analyze:

Example: ["AAPL", "MSFT", "GOOGL", "META", "NVDA"]

**Option C: Industry-Specific**

Narrow focus to specific industry within sector:

  • Example: "Software" within Technology sector
  • Example: "Regional Banks" within Financials

**Filtering Criteria:**

  • Minimum market cap: $2B (mid-cap and above)
  • Minimum average volume: 1M shares/day (liquidity requirement)
  • Active trading: No delisted or inactive stocks
  • Same exchange preference: Avoid cross-exchange complications

Step 2: Retrieve Historical Price Data

**Objective:** Fetch price history for correlation and cointegration analysis.

**Data Requirements:**

  • Timeframe: 2 years (minimum 252 trading days)
  • Frequency: Daily closing prices
  • Adjustments: Dividend-adjusted `adjClose` from `/stable/historical-price-eod/dividend-adjusted` when available. The fallback `full` endpoint serves unadjusted `close`; the run then warns per symbol and records `price_basis: close`
  • Clean data: No gaps or missing values

**FMP API Endpoint:**

GET /stable/historical-price-eod/dividend-adjusted?symbol={symbol}   # preferred, adjClose
GET /stable/historical-price-eod/full?symbol={symbol}                  # fallback, unadjusted close
Header: apikey: <FMP_API_KEY>

**Data Validation:**

  • Verify consistent date ranges across all symbols
  • Remove stocks with >10% missing data
  • Fill minor gaps with forward-fill method
  • Log data quality issues

**Script Execution:**

uv run --with 'statsmodels>=0.14,<0.15' python \
  skills/pair-trade-screener/scripts/find_pairs.py \
  --sector Technology \
  --lookback-days 730 \
  --output /tmp/pair-trade/technology.json

Step 3: Calculate Correlation and Beta

**Objective:** Identify candidate pairs with strong linear relationships.

**Correlation Analysis:**

For each pair of stocks (i, j) in the universe: 1. Calculate Pearson correlation coefficient (ρ) 2. Calculate rolling correlation (90-day window) for stability check 3. Filter pairs with ρ >= 0.70 (strong positive correlation)

**Correlation Interpretation:**

  • ρ >= 0.90: Very strong correlation (best candidates)
  • ρ 0.70-0.90: Strong correlation (good candidates)
  • ρ 0.50-0.70: Moderate correlation (marginal)
  • ρ < 0.50: Weak correlation (exclude)

**Beta Calculation:**

For each candidate pair (Stock A, Stock B):

Beta = Covariance(A, B) / Variance(B)

Beta indicates the hedge ratio:

  • Beta = 1.0: Equal dollar amounts
  • Beta = 1.5: $1.50 of B for every $1.00 of A
  • Beta = 0.8: $0.80 of B for every $1.00 of A

**Correlation Stability Check:**

  • Calculate correlation over multiple periods (6mo, 1yr, 2yr)
  • Require correlation to be stable (not deteriorating)
  • Flag pairs where recent correlation < historical correlation by >0.15

Step 4: Cointegr

Read more
@tradermonty
Ships withclaude-trading-skills

Data handling: Privacy policy · Security policy Claude Trading Skills started as a personal project to use AI to improve my own trading process. Claude Trading Skills is a Claude Skills-based trading workflow toolkit for time-constrained individual investors.

6.9k74 skills2 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
6.9k
Star history of tradermonty/claude-trading-skills on GitHub, a chart by star-history.com

Other skills on claude-trading-skills.

More skills from other plugins.

ccxt-cli

ccxt-cli

CCXT command-line interface (ccxt-cli) for interacting with 100+ cryptocurrency exchanges directly from the terminal — no code…

ccxt9d45k
@ccxt@ccxtInstall Skill

Questions about pair-trade-screener.

Which coding agents can use pair-trade-screener?
pair-trade-screener installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.