statistical-arbitrage

A guide to statistical arbitrage, a trading approach that uses historical relationships between securities to seek gains when prices move away from their usual relationship. It covers pair trading, cointegration, principal-component strategies, and industry rotation.

In plain words
What is it for?
Use it to study or design market-neutral strategies, select related stock pairs, test cointegration, hedge systematic risk, and trade price-spread reversions.
Why use it?
It explains ways to reduce broad market exposure with long and short positions, while noting that historical relationships can stop working.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/feicoder/skill-factory/statistical-arbitrage
Any agent
npx skills add FeiCoder/Skill-Factory --skill statistical-arbitrage
Clone the repo
git clone --depth 1 https://github.com/FeiCoder/Skill-Factory

Made for: Claude Code, Codex.

Per session 58 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,890 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00058 $0.03890
Opus 5 $0.00029 $0.01945
Sonnet 5 $0.00012 $0.00778
Haiku 4.5 $0.00006 $0.00389

Measured 2d ago against content hash ed5bfdfbfb4c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

statistical-arbitrage scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/pairs_trading.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

produced_skill/arbitrage/statistical-arbitrage/SKILL.md · 429 lines

How it starts

The opening of the file, as written. The whole thing — 429 lines — stays where its author put it; the contents beside it link to each section on GitHub.

统计套利

概述

统计套利是一种基于数学模型和历史统计规律的风险套利策略。它利用证券价格的历史统计规律进行套利,与无风险套利不同,统计套利存在历史规律失效的风险。其核心思想是通过构建多头和空头组合来对冲市场风险,获取与市场无关的稳定Alpha收益。

何时使用此技能:

  • 当需要构建市场中性策略时
  • 当需要寻找相关性强的资产对进行配对交易时
  • 当需要在熊市或震荡市中获取稳定收益时
  • 当需要利用行业或区域间的相关性进行套利时

核心概念

1. 统计套利定义

Morgan Stanley将统计套利定义为:一种基于模型的投资过程,在不依赖于经济含义的情况下,运用数量手段构建资产组合,根据证券价格与数量模型所预测的理论价值进行对比,构建证券投资组合的多头和空头,从而对市场风险进行规避,获取一个稳定的Alpha。

2. 统计套利 vs 无风险套利

特征 统计套利 无风险套利
理论基础 历史统计规律 价格必然收敛
风险 历史规律可能失效 理论无风险
收益 概率性Alpha 确定性收益
适用范围 相关性资产对 期货到期收敛

3. 主要方法分类

统计套利主要有两大方法:

  1. β中性策略:基于日收益率建模,目标是在组合β值为零的前提下获取Alpha收益
  2. 协整策略:基于股价序列的协整关系建模,利用累计收益率的偏离进行套利

推荐策略:协整策略更优,因为:

  • 直接利用原始变量(股价)建模
  • 更容易把握累计收益率的偏离
  • 错误信号较少

配对交易策略

配对交易原理

配对交易(Pairs Trading)是最经典的统计套利方法:

  1. 选取业务相似、股价具备均衡关系的上市公司股票
  2. 做空近期相对强势股,做多相对弱势股
  3. 等两者价差恢复均衡时平仓了结

关键特点:

  • 投资标的是两只股票的价差(相对价值而非绝对价值)
  • 多空同时建仓,对冲掉绝大部分市场风险
  • 属于市场中性策略,与大盘走势相关性低

配对筛选流程

Step 1: 行业划分
   └─ 在同一行业内筛选股票对,保证主营业务相似

Step 2: 收益率相关性检验
   └─ 要求配对股票历史收益率相关系数 > 阈值(建议 > 0.85)

Step 3: 协整关系检验
   └─ 检验两只股票价格序列是否存在长期均衡关系

Step 4: 价差形态过滤
   └─ 筛选价差回归速度快的股票对,获得更多交易机会

协整检验方法

两只股票存在协整关系的条件:

  1. 两者的历史股价序列都是一阶单整(非平稳,但一阶差分后平稳)
  2. 这两个序列的某种线性组合是平稳的

协整方程:

Pa,t = α + β × Pb,t + εt

其中 εt(残差)必须是平稳序列。

检验步骤:

  1. 计算任意两只股票的相关系数
  2. 筛选相关系数较高的股票对(> 0.85)
  3. 对筛选后的股票对进行协整检验(EG两步法或Johansen检验)
  4. 选择残差平稳的股票对作为候选配对

交易策略设计

核心参数设置

参数 含义 推荐范围
δ1 建仓阈值 1.0 ~ 1.3(σ倍数)
δ2 平仓阈值 -1.0 ~ -0.7(σ倍数)
δ3 止损阈值 2.0 ~ 3.0(σ倍数)

交易信号

入场条件:

  • spreadt > δ1 × σt:股票A相对高估,股票B相对低估
    • 卖空股票A,买入β倍股票B
  • spreadt < -δ1 × σt:股票A相对低估,股票B相对高估
    • 买入股票A,卖空β倍股票B

平仓条件:

  • spreadt > δ2 × σtspreadt < -δ2 × σt:价差回归,平仓获利

止损条件:

  • spreadt > δ3 × σtspreadt < -δ3 × σt:协整关系破坏,立即止损

阈值优化原则

  • δ1 越大:潜在套利空间越大,但交易次数减少
  • δ1 越小:潜在套利空间越小,但交易次数增加
  • δ2 越接近0:平仓收益越高,但可能错失交易机会

最优阈值确定方法: 回测优化,在样本内寻找收益最大化的参数组合

Read the full file on GitHub · 429 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 429 lines · 58 tokens per session scan A ed5bfdfbfb4c

Subscribe to this mod's changes

statistical-arbitrage is a skill published in the GitHub repository FeiCoder/Skill-Factory (10 stars, last pushed 6mo ago), licensed MIT. It adds 58 tokens to every session and 3,890 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

twitter-reader

Read Twitter/X for financial research using opencli (read-only). Use this skill whenever the user wants to read their Twitter feed, search for financial tweets, view bookmarks, look up user profiles, or gather market sentiment from Twitter/X. Triggers include: "check my feed", "search Twitter for", "show my…

himself65/finance-skills · 161 tokens

chenhao-limit-up

Use when evaluating A-share limit-up (涨停板) setups through Chen Hao's sentiment and momentum lens: market emotion cycles, board strength, follow-through, and short-term aggressive momentum trading.

questflowai/investorskills · 44 tokens

copy-trading-solana

Copy trade Solana wallets - mirror trades automatically.

alsk1992/CloddsBot · 15 tokens

southwest

Search Southwest Airlines fares and points pricing via Patchright browser automation. SW is not in any GDS or API. Covers all fare classes, Companion Pass value, and fare drop monitoring.

borski/travel-hacking-toolkit · 40 tokens

alpaca-trade-api-sdk

Integrate and build on the @alpacahq/alpaca-trade-api TypeScript SDK for the Alpaca Trading and Market Data APIs (the unified Alpaca client, ergonomic order builders, normalized market-data shapes, pagination, typed errors, resilience, and real-time streaming). Use when writing or reviewing code that imports…

alpacahq/alpaca-trade-api-js · 123 tokens

alphagbm-greeks

Greeks dashboard for any option contract or multi-leg position. Covers first-order Greeks (Delta, Gamma, Theta, Vega, Rho) and second-order Greeks (Charm, Vanna, Volga). Returns individual and position-level Greeks with scenario heatmaps. Use when: checking option sensitivities, managing position risk, understanding…

AlphaGBM/skills · 128 tokens