"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(market-data): ask only a US equity for its .US suffix
Haozhe Wu711f26c8a911
diff --git a/agent/src/tools/market_data_tool.py b/agent/src/tools/market_data_tool.pyindex 95702492e..2ed479a94 100644--- a/agent/src/tools/market_data_tool.py+++ b/agent/src/tools/market_data_tool.py@@ -10,6 +10,7 @@ from typing import Anyfrom src.agent.tools import BaseToolfrom src.market_data import DEFAULT_MAX_ROWS, fetch_market_data_json+from backtest.engines._market_hooks import _detect_marketfrom backtest.loaders.registry import VALID_SOURCESfrom backtest.runner import _VALID_INTERVALS@@ -192,11 +193,15 @@ class MarketDataTool(BaseTool):if source not in _SOURCE_ENUM:return _error(f"source must be one of {_SOURCE_ENUM}")if source == "auto":+ # Only what the market detector reads as a US equity: a Chinese+ # futures code (RB0, IF2412) or a joined crypto pair (BTCUSDT) has+ # the same shape and is served without any suffix.bare_us = [code for code in codesif re.fullmatch(r"[A-Za-z][A-Za-z0-9.\-]*", code)and "." not in codeand "-" not in code+ and _detect_market(code) == "us_equity"]if bare_us:return _error(diff --git a/agent/tests/test_market_data_tool.py b/agent/tests/test_market_data_tool.pyindex 3b3de01da..1cd0dccfc 100644--- a/agent/tests/test_market_data_tool.py+++ b/agent/tests/test_market_data_tool.py@@ -497,3 +497,22 @@ def test_canonicalize_interval_keeps_minute_and_month_apart():assert _canonicalize_interval("1h") == "1H"assert _canonicalize_interval("2W") is Noneassert _INTERVAL_CANON["1M"] == "1M"+++def test_market_data_tool_asks_only_a_us_equity_for_its_suffix():+ """Bare ``AAPL`` returns empty frames from the US loaders, so auto asks for+ ``AAPL.US``; a futures code or a joined crypto pair has the same shape and is+ served as written, and must reach the loaders."""+ import src.tools.market_data_tool as mod+ from unittest import mock++ with mock.patch.object(mod, "fetch_market_data_json", side_effect=lambda **kw: "{}"):+ for code in ("RB0", "rb2501", "IF2412", "BTCUSDT"):+ out = json.loads(+ mod.MarketDataTool().execute(codes=[code], start_date="2026-08-20", end_date="2026-08-21")+ )+ assert out == {}, (code, out)+ refused = json.loads(+ mod.MarketDataTool().execute(codes=["AAPL"], start_date="2026-08-20", end_date="2026-08-21")+ )+ assert refused["ok"] is False and "AAPL.US" in refused["error"]