"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
Fixed grounding
William Liaof3fe61921816
diff --git a/agent/src/agent/grounding.py b/agent/src/agent/grounding.pyindex c2f27e033..5c1877aa2 100644--- a/agent/src/agent/grounding.py+++ b/agent/src/agent/grounding.py@@ -206,13 +206,18 @@ _AGGREGATE_AMOUNT_RE = re.compile(# two window lengths survive. ASCII units carry a trailing word boundary so# "120 more" is not read as a quantity; the CJK branch cannot, because 周 and# 内 are both word characters and "1–4 周内" must still mask.+#+# Bare 万/萬 is a ten-thousand multiplier and, in the trading-plan domain, is a+# quantity (volume/market-cap/money), never a per-share price: "量 5–10 万" and+# "119 万" must not be read as OHLC claims. Span-local: the unit must follow+# the number, so "收盘 0.49,量 119 万" still masks only the volume._QUANTITY_WITH_UNIT_RE = re.compile(r"\d[\d,]*(?:\.\d+)?"r"(?:\s*/\s*\d[\d,]*(?:\.\d+)?)*"r"(?:\s*[-–—~至]\s*\d[\d,]*(?:\.\d+)?)?"r"\s*[-–—]?\s*"r"(?:"- r"(?:股|手|张|份|口|笔|倍|个月|周|天|日|年|次)"+ r"(?:股|手|张|份|口|笔|倍|个月|周|天|日|年|次|万|萬)"r"|(?:shares?|contracts?|lots?|units?|sessions?|bars?|periods?|"r"wks?|weeks?|months?|days?|years?|yrs?)\b"r")",diff --git a/agent/tests/test_agent_grounding.py b/agent/tests/test_agent_grounding.pyindex 1eba0c753..415db9fe6 100644--- a/agent/tests/test_agent_grounding.py+++ b/agent/tests/test_agent_grounding.py@@ -1313,6 +1313,25 @@ def test_plan_levels_are_not_read_as_observed_price_claims(segment: str) -> Noneassert GroundingLedger._numbers_without_dates_or_percent(segment) == []+# Bare 万/萬 (ten-thousands) is a quantity, never a per-share price: volume+# figures written without the 股 unit ("量 5–10 万", "119 万") were parsed as+# OHLC claims and rejected the FLT.TO draft on the first attempt (Aug 2026).+_VOLUME_QUANTITIES_IN_WAN = [+ "量 5–10 万",+ "量 5-10 万",+ "119 万",+ "量 119 萬",+ "量 150 万股",+ "量 5–10 万股",+]++[email protected]("segment", _VOLUME_QUANTITIES_IN_WAN, ids=range(len(_VOLUME_QUANTITIES_IN_WAN)))+def test_wan_quantities_are_not_read_as_price_claims(segment: str) -> None:+ """A volume in ten-thousands is not an observed price claim."""+ assert GroundingLedger._numbers_without_dates_or_percent(segment) == []++# The other side of the same guard. Every entry here is an assertion about what# the instrument did, and each must survive the mask above — otherwise the# relaxation is a way to state a price without being checked.@@ -1330,6 +1349,9 @@ _ASSERTIONS_THAT_MUST_STAY_CHECKED = [# currency prefix and no marker/operator must stay checked.("现价 $5.97", [5.97]),("开盘 $6.80 最高 $7.18 最低 $6.68", [6.80, 7.18, 6.68]),+ # A 万 quantity must not hide a nearby observed quote (span-local):+ # the volume is masked, the close beside it stays checked.+ ("收盘 0.49,量 119 万", [0.49]),]