Receber por email
← Voltar para o catálogo

longbridge-pairs-trading

Pairs trading / statistical-arbitrage strategy via Longbridge Securities — tests cointegration between two correlated assets using the Engle-Granger (ADF) method, computes the optimal hedge ratio via OLS, calculates spread Z-score, half-life of mean reversion, and generates entry/exit signals (long spread when Z > 2, short spread when Z < -2, exit when |Z| < 0.5). Triggers: "配对交易", "统计套利", "协整", "

27estrelas
Atualizado há 4 meses

Ver no GitHub ↗ Licença: MIT

Como adicionar

/plugin marketplace add longbridge/skills

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Para o autor da skill

Cole no README do seu repo

Mostra que sua skill está catalogada na Skillteca, gera backlink e tráfego rastreável.

[![Skillteca](https://www.skillteca.com.br/api/badge/longbridge-pairs-trading/svg)](https://www.skillteca.com.br/skills/longbridge-pairs-trading)

Skills relacionadas

Ver todas de Marketing →

Alerta por categoria

Receba novas skills de Marketing toda segunda

1 email curto, só com as skills novas de Marketing. 4 minutos de leitura, sem spam, cancela com 1 clique.

Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.

Ler descrição completa

longbridge-pairs-trading

Statistical-arbitrage strategy for a pair of correlated securities. Tests for cointegration, estimates hedge ratio, computes spread Z-score, and outputs actionable long/short signals with half-life and position sizing guidance.

Response language: match the user's input language — Simplified Chinese / Traditional Chinese / English.

When to use

  • User provides two ticker symbols and asks for pairs trading analysis, spread mean-reversion, cointegration test, or statistical arbitrage.
  • Triggers: "MSFT 和 GOOGL 配对交易", "HSBC vs StanChart 协整", "pairs trade AAPL MSFT", "价差均值回归".

Workflow

  1. Fetch 252 daily candles for each symbol:

`` longbridge kline <SYMBOL_A> --period day --count 252 --format json longbridge kline <SYMBOL_B> --period day --count 252 --format json ``

  1. Align on time, drop unmatched rows (different trading calendars).
  2. Cointegration test (Engle-Granger):
  3. OLS regress ln(close_A) on ln(close_B) → hedge ratio β
  4. Compute residuals (spread) = ln(close_A) − β × ln(close_B)
  5. Run ADF test on residuals; if p-value < 0.05, declare cointegrated
  6. Spread statistics:
  7. Spread mean μ, std σ
  8. Z-score = (spread_current − μ) / σ
  9. Half-life λ = −ln(2) / OLS_slope of Δspread ~ spread_{t-1} (AR(1))
  10. Signal:
  11. Z > 2.0: 价差处于历史高位区间(统计上偏离均值偏大)/ Spread at historical high (statistically elevated)
  12. Z < −2.0: 价差处于历史低位区间(统计上偏离均值偏小)/ Spread at historical low (statistically depressed)
  13. |Z| < 0.5: 价差回归均值区间 / Spread near historical mean
  14. Position sizing: suggest equal-dollar or volatility-scaled sizing; note that execution must be simultaneous.

Run longbridge kline --help to confirm current flag names before calling.

CLI

longbridge kline --help

longbridge kline <SYMBOL_A> --period day --count 252 --format json
longbridge kline <SYMBOL_B> --period day --count 252 --format json

Output

| Metric | 简体 | 繁體 | English | |---|---|---|---| | Hedge ratio β | 对冲比率 | 對沖比率 | Hedge ratio | | Cointegration p-value | 协整 p 值 | 協整 p 值 | Cointegration p-value | | Spread Z-score | 价差 Z 分 | 價差 Z 分 | Spread Z-score | | Half-life | 半衰期(天) | 半衰期(天) | Half-life (days) | | Signal | 交易信号 | 交易訊號 | Trade signal |

Output: cointegration verdict → spread statistics table → current signal → position guidance. Add a risk note if p-value > 0.05 (not cointegrated). Cite Longbridge Securities / 数据来源:长桥证券 / 數據來源:長橋證券.

以上内容仅供参考,不构成投资建议。投资决策请结合自身风险承受能力独立判断。
The above is for reference only and does not constitute investment advice. Investment decisions should be made based on your own risk tolerance.

Error handling

| Situation | 简体回复 | 繁體回復 | English reply | |---|---|---|---| | command not found: longbridge | 回退到 MCP 或提示安装 longbridge-terminal | 回退到 MCP 或提示安裝 longbridge-terminal | Fall back to MCP or install longbridge-terminal | | not logged in / unauthorized | 请运行 longbridge auth login | 請執行 longbridge auth login | Run longbridge auth login | | ADF p-value > 0.05 | 两标的未通过协整检验,配对交易风险较高 | 兩標的未通過協整檢驗,配對交易風險較高 | Not cointegrated; pairs trade is high-risk | | Insufficient overlapping dates | 两标的历史数据重叠不足,无法建立配对 | 兩標的歷史數據重疊不足 | Insufficient overlapping history | | Other stderr | 直接显示原始错误 | 直接顯示原始錯誤 | Surface verbatim |

MCP fallback

When the CLI is unavailable, fall back to the MCP server. Discover available tools from the MCP server's tool list at runtime.

Related skills

  • longbridge-kline — raw OHLCV data
  • longbridge-correlation — correlation matrix and rolling correlation as a pre-screen
  • longbridge-volatility-strategy — vol context for spread width

File layout

longbridge-pairs-trading/
└── SKILL.md
Compartilhar X LinkedIn