"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
feat(trading): generate the broker capability matrix from the profile registry
Yufeng He68f4565109f1
diff --git a/README.md b/README.mdindex 30aafb62a..2d7974d23 100644--- a/README.md+++ b/README.md@@ -416,7 +416,7 @@ 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.+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.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.pynew file mode 100644index 000000000..93f801de2--- /dev/null+++ b/agent/src/trading/capability_matrix.py@@ -0,0 +1,62 @@+"""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.++Regenerate after touching connector profiles:++ python -m src.trading.capability_matrix+"""++from __future__ import annotations++from pathlib import Path++from src.trading.profiles import BUILTIN_PROFILES++DOC_PATH = Path(__file__).resolve().parents[3] / "docs" / "broker-capabilities.md"++_HEADER = """# Broker capability matrix++<!-- 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 |+| --- | --- | --- | --- | --- | --- |+"""+++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"+++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)")+++if __name__ == "__main__":+ main()diff --git a/agent/tests/test_capability_matrix.py b/agent/tests/test_capability_matrix.pynew file mode 100644index 000000000..368f87119--- /dev/null+++ b/agent/tests/test_capability_matrix.py@@ -0,0 +1,32 @@+"""The generated broker capability matrix must match the profile registry (#1626)."""++from __future__ import annotations++from src.trading.capability_matrix import DOC_PATH, render+from src.trading.profiles import BUILTIN_PROFILES+++def test_capability_matrix_is_current() -> None:+ """CI drift guard: the committed doc 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"+ )+++def test_capability_matrix_covers_every_profile() -> None:+ rendered = render()+ rows = [+ line+ for 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