Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(grounding): lock HK-prefixed symbols (HK.06693 -> 06693.HK) so identity gate stops depending on search_symbol

laiyierjiangsu7ce70d7ef539
diff --git a/agent/src/agent/grounding.py b/agent/src/agent/grounding.py
index b408e9254..7d74142ac 100644
--- a/agent/src/agent/grounding.py
+++ b/agent/src/agent/grounding.py
@@ -198,6 +198,7 @@ _JOINED_CRYPTO_RE = re.compile(
_CANONICAL_SYMBOL_RE = re.compile(
r"(?<![A-Za-z0-9_])(?:"
r"\d{3,6}\.(?:SH|SZ|BJ|SS|HK|KS|KQ)|"
+ r"HK\.\d{3,6}|" # <-- added: HK-prefixed code (Futu connector format, e.g. HK.06693)
r"[A-Z][A-Z0-9&.-]{0,19}\.(?:US|NS|BO|FX|TO|V)|"
r"[A-Z0-9]{2,15}(?:-|/)(?:USDT|USDC|USD|BTC|ETH)|"
r"[A-Z]{2,15}(?:" + "|".join(_JOINED_CRYPTO_QUOTE_SUFFIXES) + r")|"
@@ -800,6 +801,12 @@ def _normalize_symbol(value: Any) -> str:
if base_part.isalpha():
return f"{base_part}-{quote}"
return symbol
+ # HK-prefixed listing (Futu connector format, e.g. HK.06693 / HK.01288):
+ # rewrite to the canonical .HK suffix so identity matching agrees with the
+ # market-data chain (06693.HK) used by get_market_data.
+ if base == "HK" and suffix.replace(".", "", 1).isdigit():
+ digits = suffix.split(".")[0]
+ return f"{digits.zfill(5)}.HK"
if suffix == "SS":
suffix = "SH"
if suffix == "HK" and base.isdigit():