pair-trading

pair-trading is a skill for Claude Code, Codex from HKUDS/Vibe-Trading. It costs 30 tokens per session (716 once invoked), scanned A, original, MIT.

A trading method that compares two related investments, such as two stocks or cryptocurrencies, and bets that their price relationship will return to its usual level.

In plain words
What is it for?
Use it to calculate the price ratio, measure unusual deviations with a Z-score, and create paired buy-and-sell signals for backtesting.
Why use it?
It gives a rules-based way to trade temporary differences between two related prices instead of relying on the direction of one investment alone.

Skill for Claude CodeCodex

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

Good fit Use it to calculate the price ratio, measure unusual deviations with a Z-score, and create paired buy-and-sell signals for backtesting.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hkuds/vibe-trading/pair-trading
About the project

Vibe-Trading is a personal trading agent that gives an AI system tools for market analysis, algorithmic trading, backtesting, and related workflows. It is for users who want an agent to research and evaluate trading strategies or manage simulated and other trading activities. The catalogue contains skills that expose these trading capabilities to compatible agents.

HKUDS/Vibe-Trading · 39,317 stars · on GitHub · vibetrading.wiki

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 HKUDS/Vibe-Trading --skill pair-trading
Clone the repo
git clone --depth 1 https://github.com/HKUDS/Vibe-Trading

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 pair-trading

README.md
[![agentmods](https://agentmods.dev/badge/skills/hkuds/vibe-trading/pair-trading/github.svg)](https://agentmods.dev/skills/hkuds/vibe-trading/pair-trading)
Your own site
<a href="https://agentmods.dev/skills/hkuds/vibe-trading/pair-trading"><img src="https://agentmods.dev/badge/skills/hkuds/vibe-trading/pair-trading/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 pair-trading

Your own site · 80×15
<a href="https://agentmods.dev/skills/hkuds/vibe-trading/pair-trading"><img src="https://agentmods.dev/badge/skills/hkuds/vibe-trading/pair-trading.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 30 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 716 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. ✓ AI security review Fable 5.1 · 6 Sept 2026 📄 Read the review Third-party audits
  • Snyk pass 7 Sept 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00030 $0.00716
Opus 5.5 $0.00012 $0.00286
Sonnet 5.5 $0.00006 $0.00143
Haiku 4.5 $0.00003 $0.00072

Measured 3mo ago against content hash 6feb52218b18, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pair-trading 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 3mo ago.

The scan reads SKILL.md. This mod also ships 1 executable file (example_signal_engine.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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

agent/src/skills/pair-trading/SKILL.md · 81 lines

How it starts

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

Pair Trading Strategy

Purpose

Select two highly correlated instruments (such as stocks from the same industry or BTC/ETH), monitor how far their price ratio (or spread) deviates from the mean, and trade against extreme deviations while waiting for mean reversion.

Signal Logic

  1. Compute the price ratio: ratio = close_A / close_B
  2. Rolling mean and standard deviation: mean = ratio.rolling(lookback).mean(), std = ratio.rolling(lookback).std()
  3. Z-score: z = (ratio - mean) / std
  4. Signal generation:
    • Z < -entry_z → long A, short B (ratio is too low, expected to revert)
    • Z > +entry_z → short A, long B (ratio is too high, expected to revert)
    • |Z| < exit_z → close the position (reverted back near the mean)

Implementation Notes

  • Pair trading requires exactly two instruments (codes array length = 2)
  • The first instrument is A (leg1), and the second is B (leg2)
  • Signals for A and B are opposite: when A is long, B is short, and vice versa
  • Equal-weight allocation only: A and B each take 50% of capital, with no precise hedge-ratio calculation

Parameters

Parameter Default Description
lookback 60 Lookback window for mean and standard deviation
entry_z 2.0 Entry Z-score threshold
exit_z 0.5 Exit Z-score threshold

Example config.json

{
  "source": "tushare",
  "codes": ["601318.SH", "601628.SH"],
  "start_date": "2023-01-01",
  "end_date": "2024-12-31",
  "initial_cash": 1000000,
  "commission": 0.001,
  "extra_fields": null
}

Cryptocurrency version:

{
  "source": "okx",
  "codes": ["BTC-USDT", "ETH-USDT"],
  "start_date": "2024-01-01",
  "end_date": "2024-12-31",
  "initial_cash": 1000000,
  "commission": 0.001,
  "extra_fields": null
}

Common Pitfalls

  • codes must contain exactly 2 instruments, no more and no less
  • The date indexes of the two instruments must be aligned (use an inner join), otherwise the ratio calculation will be wrong
  • Before the lookback window is filled, Z-scores are NaN, so fill signals with 0
  • Do not generate same-direction signals for both A and B; pair trading is fundamentally a long-short hedge

Read the full file on GitHub · 81 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. 3mo ago First seen · 81 lines · 30 tokens per session scan A 6feb52218b18

Subscribe to this mod's changes

pair-trading is a skill published in the GitHub repository HKUDS/Vibe-Trading (39,317 stars, last pushed yesterday), licensed MIT. It adds 30 tokens to every session and 716 once invoked, about $0.0001 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-30.

Related

pair-trading compared with skills from other repositories

pair-trading next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
pair-tradingHKUDS/Vibe-TradingSkill39kyesterdayMITA30Claude Code, Codex
options-tradingLumiwealth/lumibotSkill2.3kyesterdayGPL-3.0A71Codex
web-documentsLumiwealth/lumibotSkill2.3kyesterdayGPL-3.0A40Codex
research-dataLumiwealth/lumibotSkill2.3kyesterdayGPL-3.0A53Codex
hyperliquidSuperior-Trade/superior-skillsSkill2352mo agoMITA64Claude Code
polymarketSuperior-Trade/superior-skillsSkill2352mo agoMITA68Claude Code
backtestingSuperior-Trade/superior-skillsSkill2352mo agoMITA73Claude Code