Skip to main content
Glama
CaioAllgayer

TradeLab-MCP

by CaioAllgayer

TradeLab-MCP

量化研究 MCP 服务器。AI 定义策略。MetaTrader 5 的 Strategy Tester 执行回测。

IA (Codex / GPT / Grok / Gemini / Claude)
        │ MCP
        ▼
Trading Research MCP
        │
        ▼
terminal64.exe  →  Strategy Tester oficial  →  runs/<run_id>/

Fork 自 PHUICMT/mcp-mt5(MIT)。不在 Python 中重新实现 tester。

原理

MT5 是订单、成交、tick、点差、SL/TP、保证金、佣金和 P&L 的权威。

Python 只负责组织实验(run_id、manifest、hashes、parser、派生统计信息)。

每次回测都会生成一个唯一标识符。不会通过“最新文件”来检索任何内容。

runs/20260817_073412_a8f231/
  tester.ini
  strategy.mq5
  strategy.ex5
  report.htm
  tester.log
  trades.csv
  metrics.json
  manifest.json

Related MCP server: OpenFinClaw CLI

MCP 工具(V1)

工具

功能

health

MT5、MetaEditor、终端、数据目录、Experts、Tester、build

compile

编译 .mq5 并返回 hashes

run_backtest

官方 Tester → run_id + 指标 + 产物

run_batch

同一策略、多个资产,顺序执行

get_run

通过 run_id 检索实验

get_trades

run_id 的标准化交易

compare_runs

比较不同 run 之间的指标 diff

walk_forward

IS/OOS 窗口,每个窗口都是一次官方回测

smoke_test

编译 + 简短 tester(可配置符号/周期/模型/数据)

安装

Windows + MetaTrader 5 + Python 3.10+。

cd C:\Users\caioa\TradeLab-MCP
python -m pip install -e ".[dev]"

MCP 客户端:

{
  "mcpServers": {
    "tradelab": {
      "command": "tradelab-mcp",
      "env": {
        "MT5_INSTALL": "C:\\Program Files\\MetaTrader 5",
        "TRADE_LAB_ROOT": "C:\\Users\\caioa\\TradeLab-MCP\\research"
      }
    }
  }
}

变量:MT5_INSTALLMT5_DATAMT5_TERMINAL_HASHTRADE_LAB_ROOT

示例

Compile este EA e faça um backtest de PETR4 D1,
entre 2015 e 2025, usando real ticks.

智能体调用 run_backtest(strategy="experts/RSI2.mq5", symbol="PETR4", timeframe="D1", from_date="2015.01.01", to_date="2025.08.01", model=4) 并收到:

{
  "run_id": "20260817_073412_a8f231",
  "status": "completed",
  "symbol": "PETR4",
  "period": "D1",
  "model": "real_ticks",
  "metrics": {
    "total_trades": 134,
    "net_profit": 18342.21,
    "profit_factor": 1.48
  }
}

get_run("20260817_073412_a8f231") 返回的正是该实验。

EA 在 MT5 中的存放位置

所有自动测试 EA 都发布在:

<MQL5>\Experts\TradeLab MCP\

在这台 PC 上解析为:

C:\Users\caioa\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\TradeLab MCP

在 Strategy Tester 中,该 expert 显示为 TradeLab MCP\RSI2。该文件夹始终相对于活动终端(layout.experts_dir),而不是固定的 hash。

git 中的源代码仍在 experts/。MCP 会将源代码 + .ex5 + 本地 includes 复制到终端文件夹。

实验室的 EA 基类(CTrade、ArraySetAsSeries、一个仓位)尚未标准化——稍后再慢慢加入。

验收 EA

experts/RSI2.mq5

  • RSI(2)

  • 如果 RSI < 10 则买入

  • 如果 RSI > 70 则退出

  • 一个仓位

  • 无优化

第 1 号验收测试是:在手动 Strategy Tester 和通过 MCP 使用相同的 EA / 资产 / 日期 / 输入 / 资金 / model 时,必须产生相同的指标和相同的交易。

测试

pytest

集成测试(Windows + 真实 MT5):

$env:TRADE_LAB_INTEGRATION = "1"
$env:TRADE_LAB_SYMBOL = "EURUSD"
pytest tests/test_integration_mt5.py -v

优先级

可复现性 > 可靠性 > 简单性 > 速度 > 功能

V1 是顺序执行的(数据目录中的锁 mt5.lock)。没有并行 Python 回测器。没有将 .opt 解析器作为官方来源。

A
license - permissive license
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    D
    maintenance
    MCP server that provides AI agents with financial tools including real-time quotes, backtesting, technical analysis, and multi-exchange data via a simple CLI interface.
    1
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    An MCP server exposing a registry of paper-backed quantitative trading methods plus a deterministic, no-LLM decision helper for reproducible trading research.
    13
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    MCP server that exposes the Backtest360 backtesting engine API as tools, enabling AI agents to conversationally discover indicators, build and validate strategies, run backtests, and read results.
    14
    MIT

View all related MCP servers

Related MCP Connectors

  • MCP server exposing the Backtest360 engine API as tools for AI agents.

  • MCP server for Gainium — manage trading bots, deals, and balances via AI assistants

  • Build, backtest, and deploy quantitative trading strategies from your AI agent.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/CaioAllgayer/TradeLab-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server