Works with the AI Agents you already use
Stat Arb Pairs Trading
by BanditXBT
Design and audit pairs and stat-arb strategies: cointegration, OU half-life, Kalman hedge ratios, rules, breaks, costs.
$29
About this skill
A pair is tradable only if the spread is mean-reverting out of sample, fast enough relative to costs, and robust to structural breaks. Treat formation-period fit as a hypothesis, not evidence.
-
Start from economic linkage (same industry, ETF vs. constituents, same asset on two venues, spot vs. perp, wrapped vs. underlying). Mining N^2 pairs guarantees false positives; correct for multiple testing (FDR/Bonferroni; see strategy-statistical-validation).
-
Literature: Gatev, Goetzmann, Rouwenhorst (2006), "Pairs Trading: Performance of a Relative-Value Arbitrage Rule", Review of Financial Studies 19(3) (distance method; abstract reports excess returns up to ~11% annualized, 1962-2002). Do and Faff (2010), "Does Simple Pairs Trading Still Work?", Financial Analysts Journal 66(4) (profits kept declining through 2009). Avellaneda and Lee (2010), "Statistical arbitrage in the US equities market", Quantitative Finance 10(7) (PCA/ETF residuals).
-
Prefer residual-vs-factor (sector/PCA) spreads in equities to control factor exposure (see factor-exposure-attribution).
-
Engle-Granger: regress y on x (log prices), test the residual. Use
statsmodels.tsa.stattools.coint(y0, y1, trend='c', maxlag=None, autolag='aic'): null = no cointegration (small p = evidence for it); it uses MacKinnon p-values/critical values for residual-based tests, which plainadfulleron residuals does not. Results can differ by choice of regressand; run both orderings (y0/y1 swapped). -
Johansen: multivariate, gives rank and several vectors:
statsmodels.tsa.vector_ar.vecm.coint_johansen(endog, det_order, k_ar_diff)(det_order -1 none, 0 constant, 1 linear trend; trace and max-eigenvalue stats) andselect_coint_rank. Choose deterministic term and lag order deliberately; sensitive in short samples. -
Power is low on short windows: with a 30-day half-life, one trading year (~252 days) holds only ~8 half-lives. Require stability across rolling subsamples, not one p-value.
dS = θ(μ - S)dt + σ dW. Discretize as AR(1): S_t = a + φ S_{t-1} + ε, θ = -ln(φ)/Δt, half-life = ln2/θ, stationary sd σ_eq = σ_ε/sqrt(1-φ²). Regressing ΔS on S_{t-1} gives b = φ - 1.
Educational analysis, not investment advice. Entry and exit thresholds are starting heuristics to be tuned out of sample.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 13 days ago
- Software
Python 3statsmodelspandas
- Optional
- pykalman
Permissions
No special permissions declared or detected
What's inside
Frequently Asked Questions
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.