statistical-arbitrage

statistical-arbitrage is a skill for Claude Code, Codex from FeiCoder/Skill-Factory. It costs 58 tokens per session (3,890 once invoked), scanned A, original, MIT.

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

Written for no agent in particular: nothing here depends on one.

Good fit Use it to study or design market-neutral strategies, select related stock pairs, test cointegration, hedge systematic risk, and trade price-spread reversions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/feicoder/skill-factory/statistical-arbitrage
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.

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.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for statistical-arbitrage

README.md
[![agentmods](https://agentmods.dev/badge/skills/feicoder/skill-factory/statistical-arbitrage/github.svg)](https://agentmods.dev/skills/feicoder/skill-factory/statistical-arbitrage)
Your own site
<a href="https://agentmods.dev/skills/feicoder/skill-factory/statistical-arbitrage"><img src="https://agentmods.dev/badge/skills/feicoder/skill-factory/statistical-arbitrage/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for statistical-arbitrage

Your own site · 80×15
<a href="https://agentmods.dev/skills/feicoder/skill-factory/statistical-arbitrage"><img src="https://agentmods.dev/badge/skills/feicoder/skill-factory/statistical-arbitrage.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00058 $0.03890
Opus 5.5 $0.00023 $0.01556
Sonnet 5.5 $0.00012 $0.00778
Haiku 4.5 $0.00006 $0.00389

Measured 1mo ago against content hash ed5bfdfbfb4c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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 × σt 或 spreadt < -δ2 × σt:价差回归,平仓获利

止损条件:

  • 当 spreadt > δ3 × σt 或 spreadt < -δ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. 1mo 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 (11 stars, last pushed 7mo ago), licensed MIT. It adds 58 tokens to every session and 3,890 once invoked, about $0.0002 per session on Opus 5.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

sector-rotation

An analysis framework for comparing industries in the Chinese A-share stock market, using business conditions, price momentum, valuation, and money flows. It produces rankings and higher- or lower-allocation suggestions.

HKUDS/Vibe-Trading · 39 tokens

twitter-reader

Read Twitter/X for financial research through opencli: the user's home timeline, tweet search, trending topics, bookmarks, a user's recent tweets, threads, articles, profiles, followers and following, and notifications. Use this skill whenever the user wants to know what people are saying on Twitter/X or fintwit about…

himself65/finance-skills · 110 tokens

strategy-pivot-designer

Detect backtest iteration stagnation and generate structurally different strategy pivot proposals when parameter tuning reaches a local optimum.

tradermonty/claude-trading-skills · 28 tokens

energy-procurement

Codified expertise for electricity and gas procurement, tariff optimization, demand charge management, renewable PPA evaluation, and multi-facility energy cost management. Informed by energy procurement managers with 15+ years experience at large commercial and industrial consumers. Includes market structure analysis…

hashgraph-online/awesome-codex-plugins · 93 tokens

china-portfolio-monitoring

A monitoring framework for tracking the financial results, operating measures, strategic milestones, and risks of companies held by China-focused private-equity funds. It uses measures such as revenue growth, margins, debt, cash flow, and return on equity.

jwangkun/claude-for-financial-services-cn · 86 tokens

airdrop-hunting-guide

Guide to finding and qualifying for crypto airdrops — eligibility criteria, farming strategies, on-chain activity requirements, Sybil detection avoidance, and tracking tools. Use when helping users understand airdrops, check eligibility, or plan participation strategies.

nirholas/three.ws · 54 tokens