"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(etoro): use instrumentTypeIds for asset-class browse
Ofek Shaked2002070f7f02
diff --git a/agent/src/tools/trading_connector_tool.py b/agent/src/tools/trading_connector_tool.pyindex 3f53923e3..d72d8f16a 100644--- a/agent/src/tools/trading_connector_tool.py+++ b/agent/src/tools/trading_connector_tool.py@@ -552,7 +552,7 @@ class EtoroSearchInstrumentsTool(BaseTool):description = ("Search eToro instruments by ticker (BTC, AAPL), free text, or asset class ""(crypto, stocks, forex). Tickers use exact internalSymbolFull lookup; "- "asset-class labels browse via instrumentTypeId on /market-data/instruments."+ "asset-class labels browse via instrumentTypeIds on /market-data/instruments.")parameters = {"type": "object",diff --git a/agent/src/trading/connectors/etoro/instruments.py b/agent/src/trading/connectors/etoro/instruments.pyindex 86d214545..fa08e482e 100644--- a/agent/src/trading/connectors/etoro/instruments.py+++ b/agent/src/trading/connectors/etoro/instruments.py@@ -3,7 +3,7 @@eToro Public API conventions (see eToro builders docs):- Exact ticker lookup: ``GET /market-data/search?internalSymbolFull=BTC``- Fuzzy discovery: ``GET /market-data/search?search=<query>&limit=<n>``-- Asset-class browse: ``GET /market-data/instruments?instrumentTypeId=<n>``+- Asset-class browse: ``GET /market-data/instruments?instrumentTypeIds=<n>``- Search responses use ``items[]`` with ``instrumentId`` (lowercase ``d``).- Metadata enrichment: ``GET /market-data/instruments?instrumentIds=...``- Quotes (all profiles): ``GET /market-data/instruments/rates?instrumentIds=...``@@ -108,7 +108,8 @@ def search_instruments(``discover`` (fuzzy ``search`` param only), or ``type`` (browse by``instrument_type_id`` / asset-class alias).instrument_type_id: Optional eToro ``instrumentTypeID`` filter (e.g. ``10``- for crypto). When set, uses ``GET /market-data/instruments``.+ for crypto). When set, uses ``GET /market-data/instruments`` with+ ``instrumentTypeIds``.include_rates: When browsing by type, attach bid/ask/last from the flat``/market-data/instruments/rates`` endpoint (works on all profiles)."""@@ -192,7 +193,7 @@ def list_instruments_by_type(payload = make_client(cfg).request("GET",MARKET_DATA_INSTRUMENTS_PATH,- params={"instrumentTypeId": type_id},+ params={"instrumentTypeIds": type_id},allow_retry=True,)items = _extract_metadata_items(payload)@@ -203,7 +204,6 @@ def list_instruments_by_type(]normalized = [_normalize_metadata_row(item) for item in filtered]normalized = [row for row in normalized if row.get("instrument_id") is not None]- normalized.sort(key=lambda row: str(row.get("symbol") or row.get("display_name") or ""))instruments = normalized[:clean_limit]if include_rates:_attach_rates(cfg, instruments)diff --git a/agent/tests/test_etoro_connector.py b/agent/tests/test_etoro_connector.pyindex 2bb1d5193..1d52a0d29 100644--- a/agent/tests/test_etoro_connector.py+++ b/agent/tests/test_etoro_connector.py@@ -304,7 +304,7 @@ def test_crypto_query_browses_instrument_type_catalog(monkeypatch) -> None:def _transport(method: str, url: str, **kwargs: Any) -> _FakeResponse:captured.append((url, dict(kwargs.get("params") or {})))- if "/market-data/instruments" in url and kwargs.get("params", {}).get("instrumentTypeId") == 10:+ if "/market-data/instruments" in url and kwargs.get("params", {}).get("instrumentTypeIds") == 10:return _FakeResponse(200,{@@ -336,7 +336,7 @@ def test_crypto_query_browses_instrument_type_catalog(monkeypatch) -> None:assert result["instruments"][0]["symbol"] == "BTC"assert all(row.get("instrument_type_id") == 10 for row in result["instruments"])assert not any("/market-data/search" in url for url, _ in captured)- assert any(params.get("instrumentTypeId") == 10 for _, params in captured)+ assert any(params.get("instrumentTypeIds") == 10 for _, params in captured)def test_crypto_browse_can_attach_flat_market_data_rates(monkeypatch) -> None: