
Pair Trade Screener
Screen sector pairs for cointegration and mean-reversion signals with hedge ratios, half-life, and z-score entry/exit ideas using FMP market data.
Overview
Pair Trade Screener is an agent skill for the Idea phase that identifies pair-trading opportunities using cointegration testing, hedge ratios, half-life, and z-score signals with FMP market data.
Install
npx skills add https://github.com/tradermonty/claude-trading-skills --skill pair-trade-screenerWhat is this skill?
- Sector-wide screening and custom pair analysis with cointegration (ADF) and correlation
- Hedge ratio (beta), half-life mean-reversion metrics, and z-score entry/exit signals
- Market-neutral relative-value framing with JSON structured output
- Financial Modeling Prep (FMP) API integration; free tier documented as 250 requests/day
- Python stack: pandas, numpy, scipy, statsmodels, requests
- FMP free tier documented as 250 requests per day
- Python 3.8+ with pandas, numpy, scipy, statsmodels, requests
Adoption & trust: 608 installs on skills.sh; 1.8k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You see correlated tickers but lack a disciplined way to test cointegration, size spreads, and know when z-scores imply entry or exit.
Who is it for?
Solo quant-curious builders or indie fintech hackers prototyping relative-value screeners with a free-tier market data API.
Skip if: Casual investors wanting buy-and-hold advice, or production execution without separate risk, compliance, and brokerage integration.
When should I use this skill?
Identifying pair trading opportunities, cointegration and mean-reversion analysis, sector or custom pair screening with FMP data
What do I get? / Deliverables
You obtain screened pairs with statistical tests, hedge ratios, mean-reversion timing, and structured JSON signals you can feed into your own alerts or execution layer.
- JSON screening results with pair stats and signals
- Cointegration and hedge-ratio summary for chosen pairs
- Documented entry/exit z-score recommendations
Recommended Skills
Journey fit
Pair screening is research before capital commitment—finding statistical relationships and trade candidates fits Idea-phase market research for trading products or personal strategies. research is the canonical shelf because the skill runs cointegration ADF tests, correlation, and signal generation—not shipping a consumer app UI.
How it compares
Research and screening procedural skill—not a broker integration, live execution bot, or generalized backtest platform.
Common Questions / FAQ
Who is pair-trade-screener for?
Developers and solo traders building or validating statistical pair-trade ideas who are comfortable with Python and third-party market data APIs.
When should I use pair-trade-screener?
During Idea research when exploring sector pairs, cointegration, and mean-reversion before you code alerts, paper trade, or expand a trading CLI.
Is pair-trade-screener safe to install?
Review the Security Audits panel on this page; store FMP_API_KEY in secrets, respect API rate limits, and do not treat model output as financial advice.
SKILL.md
READMESKILL.md - Pair Trade Screener
# Pair Trade Screener Statistical arbitrage tool for identifying and analyzing pair trading opportunities using cointegration testing and mean-reversion analysis. ## Overview The Pair Trade Screener finds statistically significant pair trading opportunities by: - Testing for cointegration (long-term equilibrium relationships) - Calculating hedge ratios (beta values) - Measuring mean-reversion speed (half-life) - Generating entry/exit signals based on z-score thresholds **Market Neutral Strategy:** Profit from relative price movements regardless of overall market direction. ## Features ✅ **Sector-wide screening** - Analyze all stocks in a sector ✅ **Custom pair analysis** - Test specific stock combinations ✅ **Statistical rigor** - Cointegration tests (ADF), correlation analysis ✅ **Mean-reversion metrics** - Half-life calculation, z-score tracking ✅ **Trade signals** - Automatic entry/exit recommendations ✅ **FMP API integration** - Free tier sufficient for screening ✅ **JSON output** - Structured results for further analysis ## Installation ### Prerequisites - Python 3.8+ - FMP API key (free tier: 250 requests/day) ### Install Dependencies ```bash pip install pandas numpy scipy statsmodels requests ``` ### Get FMP API Key 1. Visit: https://financialmodelingprep.com/developer/docs 2. Sign up for free account 3. Copy your API key 4. Set environment variable: ```bash export FMP_API_KEY="your_key_here" ``` Or add to `~/.bashrc` / `~/.zshrc` for persistence. ## Usage ### Quick Start ```bash # Screen Technology sector for pairs python scripts/find_pairs.py --sector Technology # Analyze specific pair python scripts/analyze_spread.py --stock-a AAPL --stock-b MSFT ``` ### Screening for Pairs **Sector-Based Screening:** ```bash # Screen entire sector python scripts/find_pairs.py --sector Financials # Adjust correlation threshold python scripts/find_pairs.py --sector Energy --min-correlation 0.75 # Longer lookback period python scripts/find_pairs.py --sector Healthcare --lookback-days 1095 ``` **Custom Stock List:** ```bash # Test specific stocks python scripts/find_pairs.py --symbols AAPL,MSFT,GOOGL,META,NVDA # Tech giants pair screening python scripts/find_pairs.py --symbols JPM,BAC,WFC,C,GS,MS ``` **Full Options:** ```bash python scripts/find_pairs.py \ --sector Technology \ --min-correlation 0.70 \ --min-market-cap 10000000000 \ --lookback-days 730 \ --output tech_pairs.json \ --api-key YOUR_KEY ``` ### Analyzing Individual Pairs **Basic Analysis:** ```bash python scripts/analyze_spread.py --stock-a AAPL --stock-b MSFT ``` **Custom Parameters:** ```bash python scripts/analyze_spread.py \ --stock-a JPM \ --stock-b BAC \ --lookback-days 365 \ --entry-zscore 2.0 \ --exit-zscore 0.5 \ --api-key YOUR_KEY ``` ## Example Output ### Pair Screening Results ``` PAIR TRADING SCREEN SUMMARY ========================================================================== Total pairs analyzed: 45 Cointegrated pairs: 12 Pairs with trade signals: 5 ========================================================================== ACTIVE TRADE SIGNALS ========================================================================== Pair: XOM/CVX Signal: LONG Z-Score: -2.35 Correlation: 0.9421 P-Value: 0.0012 Half-Life: 28.3 days Strength: ★★★ ``` ### Individual Pair Analysis ``` PAIR TRADE ANALYSIS: AAPL / MSFT ========================================================================== [ PAIR STATISTICS ] Correlation: 0.8732 Hedge Ratio (Beta): 1.1523 Data Points: 365 [ COINTEGRATION TEST ] ADF Statistic: -3.8542 P-value: 0.0028 Result: ✅ COINTEGRATED (p < 0.05) Strength: ★★★ Very Strong [ MEAN REVERSION ] Half-Life: 42.1 days Speed: Moderate (suitable for pair trading) [ Z-SCORE ] Current Z-Score: -2.13 Historical Range: [-3.45, 3.12] [ TRADE SIGNAL ] Signal: 🔺 LONG SPREAD Action: Long AAPL, Short MSFT Rationale: Z-score = -2.13 → AAPL cheap relative to MSFT