liangwei-zhang/six-stock/pair-trading
Claude Code and agent skill by liangwei-zhang/six-stock
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Pair trading strategy. Trades mean reversion using the spread/ratio Z-score of two correlated instruments. Requires at least two instruments.
Install
npx vskill@latest install liangwei-zhang/six-stock/pair-tradingSKILL.md
The same SKILL.md was published earlier as hkuds/vibe-trading/pair-trading.
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
- Compute the price ratio:
ratio = close_A / close_B - Rolling mean and standard deviation:
mean = ratio.rolling(lookback).mean(),std = ratio.rolling(lookback).std() - Z-score:
z = (ratio - mean) / std - 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 (
codesarray 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
Cryptocurrency version:
Common Pitfalls
codesmust 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
Dependencies
Signal Convention
- Instrument A:
0.5= long,-0.5= short,0= flat - Instrument B: direction is opposite to A
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingVibe-Trading/agent/src/skills/pair-trading/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/liangwei-zhang/six-stock/pair-trading)