HKUDS/Vibe-Trading · warning · EtoroAPIError

unsupported instrument_type_id {type_id}

Error message

unsupported instrument_type_id {type_id}

What it means

Raised by list_instruments_by_type when the provided integer instrument_type_id is not present in the catalog loaded from the eToro API.

Source

Thrown at agent/src/trading/connectors/etoro/instruments.py:264

        "instruments": normalized[:clean_limit],
    }


def list_instruments_by_type(
    instrument_type_id: int,
    config: EtoroConfig | None = None,
    *,
    limit: int = 10,
    include_rates: bool = False,
) -> dict[str, Any]:
    """List tradable instruments for an eToro ``instrumentTypeID`` (e.g. ``10`` = crypto)."""
    from src.trading.connectors.etoro.client import load_config

    cfg = config or load_config()
    type_id = int(instrument_type_id)
    id_to_label, _ = _load_instrument_type_catalog(cfg)
    if type_id not in id_to_label:
        raise EtoroAPIError(f"unsupported instrument_type_id {type_id}")

    clean_limit = max(1, min(int(limit), 50))
    payload = make_client(cfg).request(
        "GET",
        MARKET_DATA_INSTRUMENTS_PATH,
        params={"instrumentTypeIds": type_id},
        allow_retry=True,
    )
    items = _extract_metadata_items(payload)
    filtered = [
        item
        for item in items
        if isinstance(item, dict) and _instrument_type_id(item) == type_id
    ]
    normalized = [_normalize_metadata_row(item) for item in filtered]
    normalized = [row for row in normalized if row.get("instrument_id") is not None]
    instruments = normalized[:clean_limit]
    if include_rates:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Call get_instrument_types() to list valid ids and pick from there
  2. Update hardcoded ids to current catalog values

Example fix

# before
list_instruments_by_type(10)  # 10 no longer valid
# after
valid = {t['id'] for t in get_instrument_types()}
assert 10 in valid
list_instruments_by_type(10)
Defensive patterns

Strategy: validation

Validate before calling

valid = {t['id'] for t in get_instrument_types()}
if type_id not in valid:
    raise ValueError(f'{type_id} not in catalog; valid: {sorted(valid)}')

Prevention

When it happens

Trigger: list_instruments_by_type(999) with an id that eToro's catalog doesn't contain; stale hardcoded id after eToro changes their taxonomy.

Common situations: Hardcoded type ids from older API versions; guessed ids; copy-paste from outdated docs.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/2cee4bc02d9b19f8. Report an issue: GitHub.