"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
feat(trading): broker capability matrix generated into README
Yufeng Hebdddef01771c
diff --git a/README.md b/README.mdindex 2d7974d23..dd4bfb16e 100644--- a/README.md+++ b/README.md@@ -416,7 +416,38 @@ Every position row must provide a symbol and quantity. Unsupported currencies fa### AI-friendly connector onboarding-Built-in SDK connectors publish one machine-readable onboarding contract: authentication type, required credential fields, optional dependency, install command, and the read-only operation used for verification. `trading_connections` exposes the same contract to MCP clients, while the Portfolio connection center renders it as a generic form. The contract contains field names only — never credential values. What each profile can actually call (read tools, quote paths, order kinds) is generated from the profile registry into [docs/broker-capabilities.md](docs/broker-capabilities.md) and drift-checked in CI.+Built-in SDK connectors publish one machine-readable onboarding contract: authentication type, required credential fields, optional dependency, install command, and the read-only operation used for verification. `trading_connections` exposes the same contract to MCP clients, while the Portfolio connection center renders it as a generic form. The contract contains field names only — never credential values.++<!-- BEGIN GENERATED broker-capability-matrix -->++Which read and write paths each built-in connector actually exposes,+generated from the profile registry (`agent/src/trading/profiles.py`). An+order-capable profile still goes through the mandate gate: placement on live+funds is authorized only with a mandate in place.++| Connector | Environments | Modes | Read paths | Order paths |+| --- | --- | --- | --- | --- |++| alpaca | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place`, `orders.place.requires_mandate`, `orders.read` |+| binance | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place`, `orders.place.requires_mandate`, `orders.read` |+| dhan | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place`, `orders.read` |+| etoro | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `copy.close`, `copy.poll`, `copy.precheck`, `copy.start`, `orders.cancel`, `orders.cancel_close`, `orders.place`, `orders.place.requires_mandate`, `orders.read` |+| futu | live/paper | read + order-capable | `acc_cash_flow.read`, `account.read`, `capital_distribution.read`, `capital_flow.read`, `earnings_calendar.read`, `financials.read`, `history.read`, `history_deals.read`, `orders.read`, `positions.read`, `quotes.read`, `rehab.read` | `orders.place`, `orders.place.requires_mandate`, `orders.read` |+| ibkr | live/paper | read-only | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.read` |+| kis | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place`, `orders.read` |+| longbridge | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place`, `orders.read` |+| mt5 | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place`, `orders.place.requires_mandate`, `orders.read` |+| okx | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place`, `orders.place.requires_mandate`, `orders.read` |+| robinhood | live | read + order-capable | `account.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place.requires_mandate`, `orders.read` |+| scalable | live | read-only | `quotes.read` | none |+| shoonya | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place`, `orders.read` |+| tiger | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place`, `orders.place.requires_mandate`, `orders.read` |+| toss | live | read-only | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.read` |+| trading212 | live/paper | read-only | `account.read`, `instruments.read`, `order_history.read`, `orders.read`, `positions.read` | `orders.read` |+| upbit | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place`, `orders.read` |+| zerodha | live/paper | read + order-capable | `account.read`, `history.read`, `orders.read`, `positions.read`, `quotes.read` | `orders.place`, `orders.read` |++<!-- END GENERATED broker-capability-matrix -->For a terminal-first setup, let the CLI collect secrets locally instead of putting them in a prompt or shell arguments:diff --git a/agent/src/trading/capability_matrix.py b/agent/src/trading/capability_matrix.pyindex 93f801de2..b85b7e532 100644--- a/agent/src/trading/capability_matrix.py+++ b/agent/src/trading/capability_matrix.py@@ -1,11 +1,10 @@"""Generate the broker capability matrix from the profile registry (#1626).-The answer to "what can each connector actually do" lived in per-connector-code and tribal knowledge. The profiles already declare it: environment,-transport, read-only vs order-capable, and the capability tuple. This renders-them into the published table, and the drift test in-``tests/test_capability_matrix.py`` fails CI the moment the table and the-registry disagree, so the doc cannot go stale.+Which read tools, quote paths and order kinds each connector actually has+lived in per-connector code and tribal knowledge. The profiles already+declare it, so render them into the marked block in README.md and let a test+fail CI the moment the block and the registry disagree, so the table cannot+go stale.Regenerate after touching connector profiles:@@ -14,48 +13,60 @@ Regenerate after touching connector profiles:from __future__ import annotations+import refrom pathlib import Pathfrom src.trading.profiles import BUILTIN_PROFILES-DOC_PATH = Path(__file__).resolve().parents[3] / "docs" / "broker-capabilities.md"+README_PATH = Path(__file__).resolve().parents[3] / "README.md"+_BEGIN = "<!-- BEGIN GENERATED broker-capability-matrix -->"+_END = "<!-- END GENERATED broker-capability-matrix -->"-_HEADER = """# Broker capability matrix+_HEADER = """Which read and write paths each built-in connector actually exposes,+generated from the profile registry (`agent/src/trading/profiles.py`). An+order-capable profile still goes through the mandate gate: placement on live+funds is authorized only with a mandate in place.-<!-- GENERATED by `python -m src.trading.capability_matrix`; do not edit by hand. -->--What each built-in connector profile can do, generated from the profile-registry (`agent/src/trading/profiles.py`). An order-capable profile still goes-through the mandate gate: placement on live funds is authorized only with a-mandate in place.--| Connector | Profile | Environment | Transport | Mode | Capabilities |-| --- | --- | --- | --- | --- | --- |+| Connector | Environments | Modes | Read paths | Order paths |+| --- | --- | --- | --- | --- |"""def render() -> str:- rows = []- for profile in sorted(BUILTIN_PROFILES, key=lambda p: (p.connector, p.id)):- caps = ", ".join(f"`{c}`" for c in profile.capabilities)- mode = "read-only" if profile.readonly else "order-capable"- rows.append(- "| {} | {} | {} | {} | {} | {} |".format(- profile.connector,- profile.id,- profile.environment,- profile.transport,- mode,- caps,- )- )- return _HEADER + "\n".join(rows) + "\n"+ """One row per connector: envs, modes, and the union of read/order caps."""+ lines = [_HEADER]+ by_connector: dict[str, list] = {}+ for profile in BUILTIN_PROFILES:+ by_connector.setdefault(profile.connector, []).append(profile)+ for connector in sorted(by_connector):+ profiles = by_connector[connector]+ envs = "/".join(sorted({p.environment for p in profiles}))+ modes = "read-only" if all(p.readonly for p in profiles) else "read + order-capable"+ caps = {c for p in profiles for c in p.capabilities}+ reads = sorted(c for c in caps if c.endswith(".read"))+ orders = sorted(c for c in caps if c.startswith(("orders.", "copy.")))+ read_cell = ", ".join(f"`{c}`" for c in reads) or "none"+ order_cell = ", ".join(f"`{c}`" for c in orders) or "none"+ lines.append(f"| {connector} | {envs} | {modes} | {read_cell} | {order_cell} |")+ return "\n".join(lines) + "\n"+++def render_block() -> str:+ return f"{_BEGIN}\n\n{render()}\n{_END}"+++def sync_readme(readme: str) -> str:+ block = render_block()+ pattern = re.compile(re.escape(_BEGIN) + r".*?" + re.escape(_END), re.DOTALL)+ if not pattern.search(readme):+ raise ValueError(f"README is missing the {_BEGIN} marker block")+ return pattern.sub(lambda _: block, readme)def main() -> None:- DOC_PATH.parent.mkdir(parents=True, exist_ok=True)- DOC_PATH.write_text(render(), encoding="utf-8")- print(f"wrote {DOC_PATH} ({len(BUILTIN_PROFILES)} profiles)")+ text = README_PATH.read_text(encoding="utf-8")+ README_PATH.write_text(sync_readme(text), encoding="utf-8")+ print(f"synced {README_PATH} ({len(BUILTIN_PROFILES)} profiles)")if __name__ == "__main__":diff --git a/agent/tests/test_capability_matrix.py b/agent/tests/test_capability_matrix.pyindex 368f87119..e79c865d3 100644--- a/agent/tests/test_capability_matrix.py+++ b/agent/tests/test_capability_matrix.py@@ -2,31 +2,40 @@from __future__ import annotations-from src.trading.capability_matrix import DOC_PATH, render+from src.trading.capability_matrix import README_PATH, render, render_block, sync_readmefrom src.trading.profiles import BUILTIN_PROFILES-def test_capability_matrix_is_current() -> None:- """CI drift guard: the committed doc equals a fresh render.+def test_capability_matrix_block_in_readme_is_current() -> None:+ """CI drift guard: the README's marked block equals a fresh render.Fails red when a connector profile changed without regenerating:python -m src.trading.capability_matrix"""- assert DOC_PATH.is_file(), f"missing generated doc {DOC_PATH}"- assert DOC_PATH.read_text(encoding="utf-8") == render(), (- "docs/broker-capabilities.md is stale; regenerate with "- "python -m src.trading.capability_matrix"+ text = README_PATH.read_text(encoding="utf-8")+ assert render_block() in text, (+ "README's broker-capability-matrix block is stale; regenerate with python -m src.trading.capability_matrix")-def test_capability_matrix_covers_every_profile() -> None:+def test_capability_matrix_covers_every_connector() -> None:rendered = render()rows = [linefor line in rendered.splitlines()if line.startswith("| ") and "---" not in line and "Connector" not in line]- assert len(rows) == len(BUILTIN_PROFILES)- for profile in BUILTIN_PROFILES:- assert f"| {profile.id} |" in rendered- assert f"| {profile.connector} |" in rendered+ connectors = {p.connector for p in BUILTIN_PROFILES}+ assert len(rows) == len(connectors)+ for connector in connectors:+ assert f"| {connector} |" in rendered+++def test_sync_readme_replaces_only_the_marked_block() -> None:+ text = README_PATH.read_text(encoding="utf-8")+ synced = sync_readme(text)+ assert synced == text # already current+ # drift the block's content while keeping the markers, as a profile edit+ # without regeneration would+ without = text.replace(render(), "stale\n")+ assert sync_readme(without) == text # regenerates back to current