HKUDS/Vibe-Trading · warning · EtoroAPIError

unsupported period {period!r}

Error message

unsupported period {period!r}

What it means

Raised by _map_interval (used by get_historical_bars) when the period string is not in the supported set (1m,5m,15m,1h,4h,1d,1w after normalization).

Source

Thrown at agent/src/trading/connectors/etoro/sdk.py:315

) -> dict[str, Any]:
    return cancel_open_order(config, order_id, symbol=symbol, request_id=request_id)


def _map_interval(period: str) -> str:
    token = str(period or "1d").strip().lower()
    mapping = {
        "1m": "OneMinute",
        "5m": "FiveMinutes",
        "15m": "FifteenMinutes",
        "30m": "ThirtyMinutes",
        "1h": "OneHour",
        "4h": "FourHours",
        "1d": "OneDay",
        "1w": "OneWeek",
    }
    if token in mapping:
        return mapping[token]
    raise EtoroAPIError(f"unsupported period {period!r}")


def _extract_positions(payload: Any) -> list[dict[str, Any]]:
    if isinstance(payload, dict):
        for key in ("positions", "clientPortfolio", "portfolio", "data"):
            value = payload.get(key)
            if isinstance(value, list):
                return [_position_row(item) for item in value if isinstance(item, dict)]
            if isinstance(value, dict):
                nested = value.get("positions")
                if isinstance(nested, list):
                    return [_position_row(item) for item in nested if isinstance(item, dict)]
    if isinstance(payload, list):
        return [_position_row(item) for item in payload if isinstance(item, dict)]
    return []


def _position_row(item: dict[str, Any]) -> dict[str, Any]:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Use one of the supported keys: 1m, 5m, 15m, 1h, 4h, 1d, 1w
  2. Map your internal interval enum to these keys before calling

Example fix

# before
get_historical_bars('BTC', period='2h')
# after
get_historical_bars('BTC', period='1h')  # or aggregate 1h bars client-side
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED = {'1m','5m','15m','1h','4h','1d','1w'}
if period not in SUPPORTED:
    raise ValueError(f'period must be one of {sorted(SUPPORTED)}')

Type guard

def is_supported_period(p: str) -> bool:
    return p in {'1m','5m','15m','1h','4h','1d','1w'}

Prevention

When it happens

Trigger: get_historical_bars('BTC', period='2h') or period='daily' or '1M' (month) — any unsupported granularity.

Common situations: Passing exchange-specific intervals from another connector (e.g. Futu/Binance granularity), uppercase or verbose period names, requesting intervals the API doesn't offer.

Related errors


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