Skip to content

"Vibe-Trading: Your Personal Trading Agent"

docs+packaging: mt5 extra, source/connector docs, CHANGELOG

staniellb159284af4a2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4fce69445..13535c9f1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,21 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## [Unreleased]
### Added
+- **MetaTrader 5 connector + data source** (Exness-style MT5 brokers,
+ Windows-only `pip install "vibe-trading-ai[mt5]"`). Broker connectors:
+ 11 → **12** — full read surface plus order placement against a locally
+ running terminal, with a bidirectional identity guard (paper profile ⇔
+ demo `trade_mode`, login pinned, contest rejected), connector-level
+ `max_order_volume`/`max_order_notional_usd` guards on demo AND live, and
+ hedging-safe position close by ticket. The live mandate gate gains
+ `forex`/`cfd` instrument vocabulary (schema v1 unchanged) and a lot-aware
+ `quantity_notional_usd` sizing hook so USD caps bind on lot-sized orders
+ (0.1 lot EURUSD ≈ $10,800, never 0.1 × quote). Market-data sources:
+ 20 → **21** — the `mt5` loader heads the forex fallback chain (broker-exact
+ symbols with Exness suffix discovery, 1m–1D bars), `get_market_data` learns
+ forex/metal symbol routing (`EUR/USD`, `XAUUSD.FX` previously fell through
+ to tushare), and akshare's forex path accepts the canonical slash form so
+ degradation off-Windows keeps working.
- **Strategy Development Manager** skill (#457, thanks @shadowinlife, closes
#455) — `sdm_register` / `sdm_status` / `sdm_decay_scan` turn academic
papers and broker research into registered factors/strategies with a
diff --git a/README.md b/README.md
index d4e7200f2..79889459e 100644
--- a/README.md
+++ b/README.md
@@ -297,7 +297,7 @@ Most runs follow the same evidence path: route the request, load the right marke
## 📡 Data Sources & Smart Fallback
-One `get_market_data` call, **19 free market-data sources** (plus the optional **QVeris** premium marketplace). Set `source: "auto"` — the loader picks by symbol, then walks a per-market chain ordered by **IP-ban risk**: never-banned public sources first, throttled / key-gated ones last. Zero config, no single point of failure.
+One `get_market_data` call, **20 free market-data sources** (plus the optional **QVeris** premium marketplace). Set `source: "auto"` — the loader picks by symbol, then walks a per-market chain ordered by **IP-ban risk**: never-banned public sources first, throttled / key-gated ones last. Zero config, no single point of failure.
| Source | Markets | Auth | Role |
|--------|---------|------|------|
@@ -311,6 +311,7 @@ One `get_market_data` call, **19 free market-data sources** (plus the optional *
| `qveris` | global multi-asset | key · credits | **premium marketplace** — 63+ providers via one key (explicit-only, never in auto fallback) |
| `okx` · `ccxt` | crypto | none | OKX + 100+ exchanges |
| `futu` | HK / A | OpenD | optional local FutuOpenD |
+| `mt5` | forex / metals | MT5 terminal | optional local MetaTrader 5 terminal (Windows) — your broker's exact feed, Exness-style symbol suffixes auto-resolved |
| `india_broker` | India (NSE/BSE) | broker login | read-only Shoonya / Dhan bars for `.NS` / `.BO` (fallback-chain tail) |
| `local` | any | none | your own CSV / Parquet / DuckDB via `local:` prefix |
@@ -320,7 +321,8 @@ One `get_market_data` call, **19 free market-data sources** (plus the optional *
- **US** → `yahoo` · `stooq` · `sina` · `eastmoney` · `yfinance` · `tiingo` · `fmp` · `finnhub` · `alphavantage` · `akshare` · `local`
- **HK** → `eastmoney` · `yahoo` · `futu` · `yfinance` · `akshare` · `local`
- **India (NSE/BSE)** → `yahoo` · `yfinance` · `india_broker` · `local`
-- **Crypto** → `okx` · `ccxt` · `yfinance` · `local`  ·  *(futures / fund / macro / forex → `tushare`/`akshare` → `local`)*
+- **Crypto** → `okx` · `ccxt` · `yfinance` · `local`  ·  *(futures / fund / macro → `tushare`/`akshare` → `local`)*
+- **Forex / metals** → `mt5` · `akshare` · `yfinance` · `local`
Beyond OHLCV, **18 read-only data tools** reach into fundamentals & flow — fund flow, dragon-tiger, northbound, margin, block trades, shareholder count, lockup, sector, research reports, news, SEC filings, financial statements, options chains, institutional holdings, market screening, symbol search, and macro — all exposed over MCP. An explicit `local:` symbol never silently falls back to a network source.
@@ -1127,6 +1129,64 @@ The agent exposes connector-scoped tools named `trading_connections`,
Live-broker raw MCP tools are not registered directly as `mcp_<broker>_*`.
No IBKR order-placement tool is registered.
+### MetaTrader 5 (Exness and other MT5 brokers)
+
+Connects to a **locally running MT5 terminal** through the official
+`MetaTrader5` package (**Windows-only**):
+
+```bash
+pip install "vibe-trading-ai[mt5]"
+```
+
+Configure `~/.vibe-trading/mt5.json` (created by hand, chmod 600 where
+supported):
+
+```json
+{
+ "login": 12345678,
+ "password": "...",
+ "server": "Exness-MT5Trial8",
+ "symbol_suffix": "m",
+ "max_order_volume": 1.0,
+ "max_order_notional_usd": 10000
+}
+```
+
+Then:
+
+```bash
+vibe-trading connector use mt5-paper-sdk
+vibe-trading connector check
+vibe-trading connector account
+vibe-trading connector quote EURUSD
+vibe-trading connector history EURUSD
+```
+
+| Profile | Account | Orders |
+|---------|---------|--------|
+| `mt5-paper-sdk` | demo | read-only |
+| `mt5-live-sdk-readonly` | real | read-only |
+| `mt5-paper-trade` | demo | direct (connector size guards apply) |
+| `mt5-live-trade` | real | mandate + kill-switch gated |
+
+Safety boundary: **"paper" is the broker's demo account**, verified on every
+call — the terminal echoes `account_info().trade_mode` and the login, so a
+paper profile attached to a real-money account (or vice versa) is hard-rejected.
+MT5 sizes orders in **lots** (1 lot EURUSD = 100,000 EUR); the live mandate
+gate prices lots through the connector's USD sizing hook, and the connector's
+own `max_order_volume` / `max_order_notional_usd` guards apply on demo AND
+live. Note for hedging accounts (the Exness default): an opposite-side order
+**opens a hedge** — close positions by ticket (`trading_cancel_order` with the
+position ticket, or `close_position`), which pins the deal to the position and
+can only reduce exposure. Rollback/halt path: the kill switch blocks new live
+orders; cancels stay available and are audit-logged. Mandate caps are USD;
+non-USD account currencies are margin-enforced broker-side in the account
+currency.
+
+The `mt5` market-data loader (forex fallback-chain head) shares the same
+`mt5.json` — with no file it attaches read-only to the last-used, logged-in
+terminal.
+
### Config reference
| Field | Type | Default | Description |
diff --git a/agent/SKILL.md b/agent/SKILL.md
index fab66c5f0..97c5d2d1e 100644
--- a/agent/SKILL.md
+++ b/agent/SKILL.md
@@ -1,7 +1,7 @@
---
name: vibe-trading
version: 0.1.11
-description: Professional finance research toolkit — backtesting (8 engines + benchmark comparison panel), factor analysis, Alpha Zoo (460 pre-built alphas across qlib158/alpha101/gtja191/academic/fundamental), options pricing, 87 finance skills, 30 multi-agent swarm teams, Trade Journal analyzer, and Shadow Account (extract → backtest → render) across 20 market-data sources (tushare, yfinance, okx, akshare, baostock, tencent, mootdx, ccxt, futu, local, eastmoney, sina, stooq, yahoo, india_broker, qveris, plus optional-key finnhub/alphavantage/tiingo/fmp).
+description: Professional finance research toolkit — backtesting (8 engines + benchmark comparison panel), factor analysis, Alpha Zoo (460 pre-built alphas across qlib158/alpha101/gtja191/academic/fundamental), options pricing, 87 finance skills, 30 multi-agent swarm teams, Trade Journal analyzer, and Shadow Account (extract → backtest → render) across 21 market-data sources (tushare, yfinance, okx, akshare, baostock, tencent, mootdx, ccxt, futu, mt5, local, eastmoney, sina, stooq, yahoo, india_broker, qveris, plus optional-key finnhub/alphavantage/tiingo/fmp).
dependencies:
python: ">=3.11"
pip:
@@ -74,7 +74,7 @@ Feed a CSV broker export (同花顺 / 东财 / 富途 / generic), and the agent
5. `scan_shadow_signals` — list today's symbols that match your shadow's entry cadence (research only).
### Backtesting
-Create and run quantitative strategies across 8 engines (ChinaA, GlobalEquity, IndiaEquity, Crypto, ChinaFutures, GlobalFutures, Forex + options) with 20 market-data sources (auto-detect + ordered fallback):
+Create and run quantitative strategies across 8 engines (ChinaA, GlobalEquity, IndiaEquity, Crypto, ChinaFutures, GlobalFutures, Forex + options) with 21 market-data sources (auto-detect + ordered fallback):
- **HK/US equities** via yfinance / stooq / yahoo (free, no API key)
- **India equities (NSE/BSE)** via yahoo / yfinance using `<SYMBOL>.NS` (NSE, e.g. `RELIANCE.NS`) or `<SCRIP>.BO` (BSE, e.g. `500325.BO`) — free, no API key. The `IndiaEquityEngine` models T+1 delivery, no overnight shorts (set `allow_short` for intraday), configurable circuit bands, 1-share lots, and the STT/stamp-duty/exchange/GST cost stack. Optionally back-fill from your live broker via the `india_broker` source (Shoonya/Dhan; requires broker login).
- **Cryptocurrency** via OKX or CCXT/100+ exchanges (free, no API key)
@@ -143,7 +143,7 @@ Use `load_skill(name)` to access full methodology docs with code templates.
| `factor_analysis` | IC/IR analysis + layered backtest | None* |
| `analyze_options` | Black-Scholes price + Greeks | None |
| `pattern_recognition` | Detect chart patterns (H&S, double top, etc.) | None |
-| `get_market_data` | Fetch OHLCV data (auto-detect + ordered fallback across 20 sources) | None* |
+| `get_market_data` | Fetch OHLCV data (auto-detect + ordered fallback across 21 sources) | None* |
| `get_fund_flow` | Capital fund-flow (main/retail net inflow) | None* |
| `get_dragon_tiger` | Dragon-tiger list (龙虎榜) top buyer/seller seats | None* |
| `get_northbound_flow` | Northbound (Stock Connect) net flow | None* |
diff --git a/agent/requirements.txt b/agent/requirements.txt
index ba3e6ad74..914d23549 100644
--- a/agent/requirements.txt
+++ b/agent/requirements.txt
@@ -41,6 +41,7 @@ defusedxml>=0.7.1
yfinance>=0.2.30
akshare>=1.12.0
ccxt>=4.0.0
+# optional: pip install "vibe-trading-ai[mt5]" — MetaTrader 5 terminal bridge (Windows only): forex/metals data + broker connector
# REST API & SSE
fastapi>=0.104.0
diff --git a/agent/src/skills/data-routing/SKILL.md b/agent/src/skills/data-routing/SKILL.md
index 6505e257b..17a2d93f8 100644
--- a/agent/src/skills/data-routing/SKILL.md
+++ b/agent/src/skills/data-routing/SKILL.md
@@ -28,6 +28,7 @@ per-source skill.
| tencent | A-shares, HK, US (never-banned) | No | Unrestricted | data-routing |
| mootdx | A-shares (TDX servers, never-banned) | No | China network | data-routing |
| futu | A/HK/US via OpenD gateway | Yes (OpenD running) | Local gateway | data-routing (runner-internal) |
+| mt5 | Forex & metals (your broker's MT5 feed) | Yes (running, logged-in MT5 terminal; optional `~/.vibe-trading/mt5.json`) | Local terminal (Windows) | data-routing (runner-internal) |
| local | User CSV/parquet on disk | No | Offline | data-routing (runner-internal) |
| eastmoney | A-shares, HK, US equities | No (IP-throttled) | Unrestricted | data-routing |
| sina | US equities (daily OHLCV) | No (IP-throttled) | Unrestricted | data-routing |
@@ -97,7 +98,8 @@ same-market sources automatically. Only set a concrete source when the user asks
sina / eastmoney (throttled) > yfinance.
- **HK stocks**: tencent > eastmoney / yahoo > yfinance.
- **Crypto**: okx (single exchange) > ccxt (multi-exchange).
-- **Futures / macro / forex**: tushare > akshare.
+- **Futures / macro**: tushare > akshare.
+- **Forex / metals**: mt5 (local MetaTrader 5 terminal, Windows) > akshare.
## Symbol Format Reference
diff --git a/pyproject.toml b/pyproject.toml
index c07545081..ec8768591 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -97,6 +97,12 @@ include = ["src*", "backtest*", "cli*"]
ibkr = [
"ib_async>=2.0",
]
+mt5 = [
+ # Official Windows-only bridge to a locally running MetaTrader 5 terminal
+ # (broker connector + mt5 data loader). Lazy-imported; on other platforms
+ # the marker makes this a no-op and everything degrades gracefully.
+ "MetaTrader5>=5.0.45; sys_platform == 'win32'",
+]
deepseek = [
"langchain-deepseek>=1.0.0,<2",
]