"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(journal): classify .US and .SS suffixed symbols by market (#1916)
Rudy Mizrahi Celekli6ece8115bc1f
diff --git a/agent/src/tools/trade_journal_parsers.py b/agent/src/tools/trade_journal_parsers.pyindex 5106bbd75..cddd3a06d 100644--- a/agent/src/tools/trade_journal_parsers.py+++ b/agent/src/tools/trade_journal_parsers.py@@ -700,8 +700,13 @@ def _infer_market_from_symbol(symbol: str) -> str:# LSE names (#1206); without this they landed in "other"# and shadow analysis silently degraded to NaN.return "uk"- if s.endswith(".SH") or s.endswith(".SZ") or s.endswith(".BJ"):+ if s.endswith((".SH", ".SZ", ".BJ", ".SS")):+ # .SS is Yahoo's alias for Shanghai.return "china_a"+ if s.endswith(".US"):+ # The project's canonical US form (AAPL.US, BF-B.US); checked before+ # the pair split so a share-class hyphen is not read as a pair.+ return "us"if "-" in s or "/" in s:legs = [leg for leg in re.split(r"[-/]", s) if leg]if len(legs) == 2 and all(leg in _FIAT_CODES for leg in legs):diff --git a/agent/tests/test_trade_journal_suffixed_us_market.py b/agent/tests/test_trade_journal_suffixed_us_market.pynew file mode 100644index 000000000..90d80f60c--- /dev/null+++ b/agent/tests/test_trade_journal_suffixed_us_market.py@@ -0,0 +1,39 @@+"""Suffixed US tickers and Yahoo's Shanghai alias get their journal market."""++from __future__ import annotations++import pandas as pd+import pytest++from src.tools.trade_journal_parsers import _infer_market_from_symbol, parse_generic+++ "symbol, market",+ [+ ("AAPL.US", "us"),+ ("aapl.us", "us"),+ ("BF-B.US", "us"),+ ("BRK.B.US", "us"),+ ("600519.SS", "china_a"),+ ("AAPL", "us"),+ ("600519.SH", "china_a"),+ ("BTC-USD", "crypto"),+ ("EUR/USD", "other"),+ ],+)+def test_suffixed_symbols_map_to_their_market(symbol: str, market: str) -> None:+ assert _infer_market_from_symbol(symbol) == market+++def test_generic_journal_rows_with_us_suffix_are_us_market() -> None:+ df = pd.DataFrame(+ {+ "datetime": ["2026-01-02", "2026-01-05"],+ "symbol": ["AAPL.US", "AAPL.US"],+ "side": ["buy", "sell"],+ "quantity": [10, 10],+ "price": [100, 110],+ }+ )+ assert [record.market for record in parse_generic(df)] == ["us", "us"]