"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(loaders): ask Stooq for class shares by their hyphenated ticker
Rudy Mizrahi Celekli739faa82a3c8
diff --git a/agent/backtest/loaders/stooq_loader.py b/agent/backtest/loaders/stooq_loader.pyindex 00ddfc25c..bf211c1b3 100644--- a/agent/backtest/loaders/stooq_loader.py+++ b/agent/backtest/loaders/stooq_loader.py@@ -134,12 +134,21 @@ def map_symbol(symbol: str) -> str:"""Translate a Vibe-Trading symbol into Stooq's ticker convention.Args:- symbol: Project-side symbol, e.g. ``AAPL.US``.+ symbol: Project-side symbol, e.g. ``AAPL.US`` or ``BRK.B.US``.Returns:- The lower-cased Stooq ticker, e.g. ``aapl.us``.+ The lower-cased Stooq ticker, e.g. ``aapl.us`` or ``brk-b.us``.+ Stooq hyphenates a US class share; ``brk.b.us`` is a different symbol+ from Berkshire class B."""- return symbol.strip().lower()+ cleaned = symbol.strip().lower()+ if cleaned.endswith(".us"):+ base = cleaned[:-3]+ if "." in base and "-" not in base:+ left, right = base.split(".", 1)+ if left.isalpha() and right.isalpha() and len(right) == 1:+ return f"{left}-{right}.us"+ return cleaneddef _compact_date(value: str) -> str:diff --git a/agent/tests/test_stooq_loader.py b/agent/tests/test_stooq_loader.pyindex 63bc430b2..80aad8be9 100644--- a/agent/tests/test_stooq_loader.py+++ b/agent/tests/test_stooq_loader.py@@ -76,6 +76,12 @@ class TestMapSymbol:def test_strips_and_lowercases(self):assert stooq_loader.map_symbol(" MSFT.US ") == "msft.us"+ def test_class_share_is_hyphenated(self):+ # Stooq lists Berkshire class B as brk-b.us; brk.b.us is not that symbol.+ assert stooq_loader.map_symbol("BRK.B.US") == "brk-b.us"+ assert stooq_loader.map_symbol("BF.A.US") == "bf-a.us"+ assert stooq_loader.map_symbol("BRK-B.US") == "brk-b.us"+# ---------------------------------------------------------------------------# CSV parsing via fetch