pair-trading

pair-trading is a skill for Claude Code, Codex from skloxo/TideTrading. It costs 30 tokens per session (716 once invoked), scanned A, a copy of pair-trading, MIT.

A trading method that compares two related assets, such as two industry stocks or BTC and ETH. It trades when their price relationship moves unusually far from its usual average, expecting it to move back.

In plain words
What is it for?
Use it to backtest trades involving exactly two instruments: buy one and sell the other when their price ratio is unusually low or high, then close the positions when it returns near normal.
Why use it?
Trading one asset alone can expose you to the direction of the whole market. Comparing two assets can focus the trade on a temporary difference between them, although the relationship may not return as expected.

Skill for Claude CodeCodex

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

Good fit Use it to backtest trades involving exactly two instruments: buy one and sell the other when their price ratio is unusually low or high, then close the positions when it returns near normal.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/skloxo/tidetrading/pair-trading
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 skloxo/TideTrading --skill pair-trading
Clone the repo
git clone --depth 1 https://github.com/skloxo/TideTrading

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/skloxo/tidetrading/pair-trading/github.svg)](https://agentmods.dev/skills/skloxo/tidetrading/pair-trading)
Your own site
<a href="https://agentmods.dev/skills/skloxo/tidetrading/pair-trading"><img src="https://agentmods.dev/badge/skills/skloxo/tidetrading/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/skloxo/tidetrading/pair-trading"><img src="https://agentmods.dev/badge/skills/skloxo/tidetrading/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.
Origin 100% copy Near-identical to another mod 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 $0.00015 $0.00358
Sonnet 5 $0.00006 $0.00143
Haiku 4.5 $0.00003 $0.00072

Measured 9d ago against content hash 6feb52218b18, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, 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 9d 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

This is a copy

100% identical to pair-trading — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

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. 9d 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 skloxo/TideTrading (10 stars, last pushed 2d ago), licensed MIT. It adds 30 tokens to every session and 716 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to pair-trading, differing in 0 lines, and is treated as a copy.

Related

Other skills, from other repositories

daily-deep-brief

A scheduled, pre-market investment briefing for Hong Kong and United States stocks. A deterministic preparation step gathers data and an agent adds judgment, while a later step validates and publishes the result.

KCNyu/clawock · 163 tokens

hk-stock-analysis

A workspace-aware analysis workflow for Hong Kong-listed stocks. It retrieves prices, technical indicators, market comparisons, and news through a local data pipeline, then adds Hong Kong-specific investment context.

KCNyu/clawock · 126 tokens

us-stock-analysis

Workspace-aware US stock analysis for kcn. Routes through clawock analyze-us / clawock us-quotes instead of generic web search, then layers fundamental/technical/news analysis on top. Use when user asks to analyze a US ticker (e.g. "analyze AAPL", "look at RKLB", "compare TSLA vs NVDA"), check earnings, run…

KCNyu/clawock · 97 tokens

invest-analyst

A framework for producing professional investment research, including company reports, industry studies, event analysis, analyst-expectation reviews, comparisons, and market summaries. It connects several investment research workflows into one process.

taxueseek/fund-investment-guide · 193 tokens

invest-fund

A Chinese-language guide for analysing investment funds, with different workflows for comparing funds, reviewing ETFs, examining new funds, and studying industry funds.

taxueseek/fund-investment-guide · 142 tokens

invest-cli

An investment-analysis command-line tool that fetches data for Chinese stocks and funds, US stocks, and stock screening, then applies matching analysis frameworks. A command-line tool is a program operated from a terminal.

taxueseek/fund-investment-guide · 107 tokens