"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(loaders): strip the project .US suffix before calling alpha vantage
Rudy Celeklibc92de09fa5b
diff --git a/agent/backtest/loaders/alphavantage_loader.py b/agent/backtest/loaders/alphavantage_loader.pyindex e9cc6344a..869c3a41f 100644--- a/agent/backtest/loaders/alphavantage_loader.py+++ b/agent/backtest/loaders/alphavantage_loader.py@@ -189,6 +189,10 @@ class DataLoader:requests.RequestException: Network failure, propagated unchanged."""symbol = code.strip().upper()+ # Alpha Vantage carries US tickers bare; ``.US`` is not one of its+ # exchange suffixes, so the project's US marker must be dropped.+ if symbol.endswith(".US"):+ symbol = symbol[: -len(".US")]if not symbol:return Nonediff --git a/agent/tests/test_alphavantage_loader.py b/agent/tests/test_alphavantage_loader.pyindex cfc0f35eb..cac6f492b 100644--- a/agent/tests/test_alphavantage_loader.py+++ b/agent/tests/test_alphavantage_loader.py@@ -108,6 +108,15 @@ class TestFetch:_, kwargs = mock_get.call_argsassert kwargs["params"]["symbol"] == "AAPL"+ def test_project_us_suffix_is_stripped_for_the_request(self, monkeypatch):+ monkeypatch.setenv("ALPHAVANTAGE_API_KEY", "ABC123")+ payload = _payload(("2024-01-02", 1, 1, 1, 1, 1))+ with patch.object(av, "throttled_get_json", return_value=payload) as mock_get:+ out = av.DataLoader().fetch(["AAPL.US"], "2024-01-01", "2024-01-31")+ _, kwargs = mock_get.call_args+ assert kwargs["params"]["symbol"] == "AAPL"+ assert set(out) == {"AAPL.US"}+def test_no_key_returns_empty_without_http(self):with patch.object(av, "throttled_get_json") as mock_get:out = av.DataLoader().fetch(["AAPL"], "2024-01-01", "2024-01-31")