HKUDS/Vibe-Trading · warning · EtoroAPIError
instrument_type_id is required for type browse (e.g. 10 for
Error message
instrument_type_id is required for type browse (e.g. 10 for crypto) or use an asset-class query like 'crypto'
What it means
Raised by search_instruments in type-browse mode when instrument_type_id was not supplied and the query token could not be resolved to a known instrument type via the alias catalog.
Source
Thrown at agent/src/trading/connectors/etoro/instruments.py:199
"""
from src.trading.connectors.etoro.client import load_config
cfg = config or load_config()
token = str(query or "").strip()
if not token:
raise EtoroAPIError("search query is required")
clean_limit = max(1, min(int(limit), 50))
clean_mode = str(mode or "auto").strip().lower()
if clean_mode not in ("auto", "symbol", "discover", "type"):
raise EtoroAPIError("mode must be 'auto', 'symbol', 'discover', or 'type'")
if clean_mode == "type" or instrument_type_id is not None:
resolved_type_id = instrument_type_id
if resolved_type_id is None:
resolved_type_id = _instrument_type_id_from_query(token, cfg)
if resolved_type_id is None:
raise EtoroAPIError(
"instrument_type_id is required for type browse "
"(e.g. 10 for crypto) or use an asset-class query like 'crypto'"
)
return list_instruments_by_type(
resolved_type_id,
cfg,
limit=clean_limit,
include_rates=include_rates,
)
rows: list[dict[str, Any]] = []
lookup_mode = clean_mode
if clean_mode == "auto":
lookup_mode = "symbol" if _looks_like_ticker(token) else "discover"
if lookup_mode == "symbol":
rows = _search_by_symbol(cfg, token, limit=clean_limit)
if not rows and clean_mode == "auto":View on GitHub (pinned to 80ffdda44c)
Solutions
- Pass an explicit instrument_type_id (e.g. 10 for crypto)
- Use a recognized asset-class word like 'crypto' or 'stocks'
- Fall back to mode='discover' for fuzzy searching
Example fix
# before
search_instruments('commodities', mode='type')
# after
search_instruments('commodities', mode='type', instrument_type_id=7) Defensive patterns
Strategy: validation
Validate before calling
from src.trading.connectors.etoro.instruments import get_instrument_types
valid_ids = {t['id'] for t in get_instrument_types()}
if desired_type_id not in valid_ids:
# fall back to discover mode instead of type mode
... Try / catch
try:
search_instruments(token, mode='type')
except EtoroAPIError as exc:
if 'instrument_type_id is required' in str(exc):
results = search_instruments(token, mode='discover')
else:
raise Prevention
- Prefer explicit instrument_type_id over natural-language type guesses
- Fall back to discover mode when type resolution fails
When it happens
Trigger: search_instruments('energy futures', mode='type') where 'energy futures' isn't in the alias map; or calling with instrument_type_id=None in type mode with an unrecognized asset-class word.
Common situations: User expects any natural-language phrase to map to a type; alias list doesn't cover the phrase; type ids changed.
Related errors
- instrument type catalog returned no rows
- unsupported instrument_type_id {type_id}
- instrument_id is required and cannot be empty
- invalid JSON response: {exc}
- network error: {last_exc}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/292ec00cd9618164.
Report an issue: GitHub.