HKUDS/Vibe-Trading · warning · EtoroAPIError
at least one valid instrument_id is required
Error message
at least one valid instrument_id is required
What it means
Raised by get_instrument_metadata when, after filtering out invalid/non-positive ids, no ids remain to request.
Source
Thrown at agent/src/trading/connectors/etoro/instruments.py:344
if not candidates:
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)
View on GitHub (pinned to 80ffdda44c)
Solutions
- Check the id list is non-empty and contains positive ints before calling
- Fix upstream data producing 0/None instrument ids
Example fix
# before
get_instrument_metadata([0, -1])
# after
ids = [i for i in raw_ids if isinstance(i, int) and i > 0]
if ids:
get_instrument_metadata(ids) Defensive patterns
Strategy: validation
Validate before calling
ids = [i for i in raw_ids if int(i) > 0 and int(i) not in _INVALID_INSTRUMENT_IDS]
if not ids:
return {} # nothing to enrich Type guard
def valid_metadata_ids(ids: list[int]) -> list[int]:
return [i for i in ids if i > 0][:50] Prevention
- Filter and dedupe id lists before batch metadata calls
- Skip enrichment when positions carry no valid instrument id
When it happens
Trigger: get_instrument_metadata([]), or passing only ids like 0 or negatives; downstream _enrich_positions_with_metadata with positions whose ids all filter out.
Common situations: Empty positions list passed for enrichment; data quality issue where all instrument ids are 0/missing.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- search query is required
- mode must be 'auto', 'symbol', 'discover', or 'type'
- unsupported instrument_type_id {type_id}
- symbol is required
- invalid instrument id {instrument_id}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/e53d81894293ad4f.
Report an issue: GitHub.