HKUDS/Vibe-Trading · warning · EtoroAPIError
instrumentIds batch limit is 50
Error message
instrumentIds batch limit is 50
What it means
Raised by get_instrument_metadata when more than 50 valid instrument ids are passed; the eToro instrumentIds endpoint caps batches at 50.
Source
Thrown at agent/src/trading/connectors/etoro/instruments.py:346
raise EtoroAPIError(f"instrument not found for symbol {token!r}")
candidates.sort(key=lambda pair: (-pair[0], pair[1]))
return candidates[0][1]
def get_instrument_metadata(
instrument_ids: list[int] | tuple[int, ...],
config: EtoroConfig | None = None,
) -> dict[str, Any]:
"""Fetch display metadata for one or more instrument ids (batch ≤ 50)."""
from src.trading.connectors.etoro.client import load_config
cfg = config or load_config()
ids = [int(i) for i in instrument_ids if int(i) not in _INVALID_INSTRUMENT_IDS and int(i) > 0]
if not ids:
raise EtoroAPIError("at least one valid instrument_id is required")
if len(ids) > 50:
raise EtoroAPIError("instrumentIds batch limit is 50")
payload = make_client(cfg).request(
"GET",
MARKET_DATA_INSTRUMENTS_PATH,
params={"instrumentIds": ",".join(str(i) for i in ids)},
allow_retry=True,
)
items = _extract_metadata_items(payload)
instruments = [_normalize_metadata_row(item) for item in items if isinstance(item, dict)]
return {"status": "ok", **_base_payload(cfg), "instruments": instruments}
def _canonical_ticker(token: str) -> str:
upper = token.strip().upper()
return _SYMBOL_ALIASES.get(upper, upper)
def _looks_like_ticker(token: str) -> bool:View on GitHub (pinned to 80ffdda44c)
Solutions
- Chunk ids into batches of ≤ 50 and merge results
- Add a helper that splits lists before calling
Example fix
# before
get_instrument_metadata(all_ids)
# after
meta = {}
for i in range(0, len(all_ids), 50):
for row in get_instrument_metadata(all_ids[i:i+50]):
meta[row['instrumentId']] = row Defensive patterns
Strategy: validation
Validate before calling
assert 0 < len(ids) <= 50, 'chunk ids into batches of 50'
Prevention
- Always chunk id lists to the documented batch limit
- Centralize batching in a helper so limits are enforced in one place
When it happens
Trigger: get_instrument_metadata(list_of_75_ids); enriching a portfolio with more than 50 distinct positions in one call.
Common situations: Large portfolios, bulk enrichment jobs, forgetting to chunk batch requests.
Related errors
- evidence limit must be positive
- invalid JSON response: {exc}
- network error: {last_exc}
- request failed without response
- instrument type catalog returned no rows
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/5b0c9b14de48b378.
Report an issue: GitHub.