Pair trading strategy. Trades mean reversion using the spread/ratio Z-score of two correlated instruments. Requires at least two instruments.
58
67%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./agent/src/skills/pair-trading/SKILL.mdSelect 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.
ratio = close_A / close_Bmean = ratio.rolling(lookback).mean(), std = ratio.rolling(lookback).std()z = (ratio - mean) / stdcodes array length = 2)leg1), and the second is B (leg2)| 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 |
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
}codes must contain exactly 2 instruments, no more and no lessNaN, so fill signals with 0pip install pandas numpy0.5 = long, -0.5 = short, 0 = flat8643fcd
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.