longbridge-strategy-optimizer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

longbridge-strategy-optimizer

longbridge-strategy-optimizer

Quantitative strategy generation and optimisation framework — grid search, walk-forward validation, and overfitting detection.
Response language: match the user's input language — Simplified Chinese / Traditional Chinese / English.
量化策略生成与优化框架——网格搜索、walk-forward validation和过拟合检测。
响应语言:匹配用户输入语言——简体中文 / 繁体中文 / 英文。

When to use

适用场景

Trigger on prompts asking for:
  • Building or optimising a quant strategy — "帮我优化这个均线策略", "strategy optimization", "参数网格搜索"
  • Walk-forward or overfitting checks — "走前验证", "过拟合检测", "walk-forward validation"
  • Strategy combination — "多策略组合", "strategy combination", "correlation diversification"
  • Sharpe / Calmar ratio targets — "最大化夏普比率", "Calmar ratio optimisation"
Note: computation-intensive calculations should be executed locally. This skill generates the Python code framework; the user runs it on their own machine.
当用户提出以下需求时触发:
  • 构建或优化量化策略——"帮我优化这个均线策略", "strategy optimization", "参数网格搜索"
  • walk-forward验证或过拟合检测——"走前验证", "过拟合检测", "walk-forward validation"
  • 策略组合——"多策略组合", "strategy combination", "correlation diversification"
  • Sharpe比率/Calmar比率目标——"最大化夏普比率", "Calmar ratio optimisation"
注意:计算密集型运算需在本地执行。本技能生成Python代码框架,由用户在自己的机器上运行。

Workflow

工作流程

  1. Clarify the strategy type (momentum / mean-reversion / breakout / factor) and target universe.
  2. Fetch historical daily OHLCV data for the symbol(s).
  3. Define the parameter search space.
  4. Generate a Python framework that:
    • Implements the strategy logic
    • Runs
      GridSearchCV
      -style parameter sweep
    • Splits data into in-sample (IS) and out-of-sample (OOS) windows
    • Applies walk-forward validation (rolling IS/OOS windows)
    • Computes Sharpe, Calmar, max drawdown, and IS/OOS degradation ratio
    • Flags overfitting if OOS Sharpe < 0.5 × IS Sharpe
  5. For multi-strategy combination: compute correlation matrix and suggest weights.
  6. Present results as a parameter heatmap description and key metrics table.
If unsure of exact flag names, run
longbridge <subcommand> --help
before proceeding.
  1. 明确策略类型(动量/均值回归/突破/因子)和目标标的范围。
  2. 获取标的的历史每日OHLCV数据。
  3. 定义参数搜索空间。
  4. 生成Python框架,该框架可:
    • 实现策略逻辑
    • 运行类似
      GridSearchCV
      的参数遍历
    • 将数据划分为样本内(IS)和样本外(OOS)窗口
    • 应用walk-forward validation(滚动IS/OOS窗口)
    • 计算Sharpe比率、Calmar比率、最大回撤以及IS/OOS衰减率
    • 若OOS Sharpe比率 < 0.5 × IS Sharpe比率,则标记为过拟合
  5. 对于多策略组合:计算相关矩阵并建议权重。
  6. 以参数热力图描述和关键指标表格的形式呈现结果。
若不确定具体命令参数,请先运行
longbridge <subcommand> --help
再操作。

CLI

CLI

bash
undefined
bash
undefined

Daily OHLCV — backtest data (up to 500 trading days)

Daily OHLCV — backtest data (up to 500 trading days)

longbridge kline <SYMBOL> --period day --count 500 --format json
undefined
longbridge kline <SYMBOL> --period day --count 500 --format json
undefined

Output structure

输出结构

STRATEGY OPTIMISATION REPORT — <SYMBOL>  <Date>

STRATEGY: <Name / Type>
Universe:  <SYMBOL>
Period:    <start> – <end>  (xxx days)

PARAMETER SEARCH
Parameter       Range         Step    Best Value
fast_ma         5–50          5       xx
slow_ma         20–200        10      xxx
stop_loss       0.5%–5%       0.5%    x.x%

BEST RESULT (IN-SAMPLE)
Sharpe:  x.xx   Calmar:  x.xx   Max DD:  -xx.x%
CAGR:    xx.x%  Win Rate: xx.x%  Trades: xxx

OUT-OF-SAMPLE VALIDATION
Sharpe:  x.xx   Calmar:  x.xx   Max DD:  -xx.x%
IS/OOS Degradation: xx%  → [Acceptable | Possible Overfit | Overfit]

WALK-FORWARD SUMMARY
Window 1: IS Sharpe x.xx → OOS Sharpe x.xx
Window 2: IS Sharpe x.xx → OOS Sharpe x.xx
...

PYTHON CODE FRAMEWORK
<generated Python code>
STRATEGY OPTIMISATION REPORT — <SYMBOL>  <Date>

STRATEGY: <Name / Type>
Universe:  <SYMBOL>
Period:    <start> – <end>  (xxx days)

PARAMETER SEARCH
Parameter       Range         Step    Best Value
fast_ma         5–50          5       xx
slow_ma         20–200        10      xxx
stop_loss       0.5%–5%       0.5%    x.x%

BEST RESULT (IN-SAMPLE)
Sharpe:  x.xx   Calmar:  x.xx   Max DD:  -xx.x%
CAGR:    xx.x%  Win Rate: xx.x%  Trades: xxx

OUT-OF-SAMPLE VALIDATION
Sharpe:  x.xx   Calmar:  x.xx   Max DD:  -xx.x%
IS/OOS Degradation: xx%  → [Acceptable | Possible Overfit | Overfit]

WALK-FORWARD SUMMARY
Window 1: IS Sharpe x.xx → OOS Sharpe x.xx
Window 2: IS Sharpe x.xx → OOS Sharpe x.xx
...

PYTHON CODE FRAMEWORK
<generated Python code>

Error handling

错误处理

Situation简体回复繁體回復English reply
Symbol not found未找到该代码,请确认市场和格式。找不到該代碼,請確認市場和格式。Symbol not found — verify exchange and ticker.
Insufficient history历史数据不足,回测结果可靠性下降。歷史數據不足,回測結果可靠性下降。Insufficient history — backtest reliability is reduced.
command not found: longbridge
请安装 longbridge-terminal 或通过 MCP 连接。請安裝 longbridge-terminal 或透過 MCP 連線。Install longbridge-terminal or connect via MCP.
not logged in
请运行
longbridge auth login
請執行
longbridge auth login
Run
longbridge auth login
.
场景简体回复繁体回复English reply
未找到标的未找到该代码,请确认市场和格式。找不到該代碼,請確認市場和格式。Symbol not found — verify exchange and ticker.
历史数据不足历史数据不足,回测结果可靠性下降。歷史數據不足,回測結果可靠性下降。Insufficient history — backtest reliability is reduced.
command not found: longbridge
请安装 longbridge-terminal 或通过 MCP 连接。請安裝 longbridge-terminal 或透過 MCP 連線。Install longbridge-terminal or connect via MCP.
not logged in
请运行
longbridge auth login
請執行
longbridge auth login
Run
longbridge auth login
.

MCP fallback

MCP fallback

If
longbridge
binary is not found, fall back to
mcp__longbridge__kline
.
若未找到
longbridge
二进制文件, fallback至
mcp__longbridge__kline

Related skills

相关技能

  • longbridge-kline
    — candlestick and OHLCV history
  • longbridge-execution-model
    — realistic execution cost assumptions
  • longbridge-risk-return
    — portfolio efficiency and risk-adjusted return
  • longbridge-capital-flow
    — intraday volume and order flow signals
  • longbridge-kline
    — K线和OHLCV历史数据
  • longbridge-execution-model
    — 真实执行成本假设
  • longbridge-risk-return
    — 投资组合效率与风险调整后收益
  • longbridge-capital-flow
    — 日内成交量与订单流信号

File layout

文件结构

skills/longbridge-strategy-optimizer/
└── SKILL.md
skills/longbridge-strategy-optimizer/
└── SKILL.md