HKUDS/Vibe-Trading · error · ValueError

universe {universe!r} not recognized; expected one of {sorte

Error message

universe {universe!r} not recognized; expected one of {sorted(_UNIVERSE_TAG)}

What it means

_load_universe_panel looks the universe string up in the _UNIVERSE_TAG registry; unknown keys are rejected with the sorted list of valid ones (e.g. csi300, btc-usdt and friends).

Source

Thrown at agent/src/tools/alpha_bench_tool.py:122

    """Load OHLCV(+amount, +vwap) wide panel for the requested universe.

    Returns a dict keyed by panel column (open/high/low/close/volume/amount/vwap)
    where each value is a wide ``pd.DataFrame`` indexed by date (DatetimeIndex)
    with one column per instrument.

    Args:
        universe: ``csi300`` | ``sp500`` | ``btc-usdt``.
        period: ``YYYY-YYYY`` or ``YYYY-MM-DD/YYYY-MM-DD``.
        use_cache: When True (default) reuse a pickle in
            ``~/.vibe-trading/cache/`` if the same universe+period was fetched
            before. Set to False to force a re-fetch.

    Raises:
        ValueError: unknown universe or bad period.
        RuntimeError: ``TUSHARE_TOKEN`` unset when csi300 is requested.
    """
    if universe not in _UNIVERSE_TAG:
        raise ValueError(
            f"universe {universe!r} not recognized; expected one of {sorted(_UNIVERSE_TAG)}"
        )
    start, end = _parse_period(period)

    cache_dir = Path.home() / ".vibe-trading" / "cache"
    cache_path = cache_dir / f"{universe}_{start}_{end}.pkl"
    if use_cache and cache_path.is_file():
        cached = _read_pickle_cache(cache_path)
        if cached is not None:
            logger.info("universe %s: loaded from cache %s", universe, cache_path)
            return cached

    if universe == "csi300":
        panel = _load_csi300_panel(start, end)
    elif universe == "sp500":
        panel = _load_sp500_panel(start, end)
    elif universe == "btc-usdt":
        panel = _load_btc_panel(start, end)

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Use one of the names listed in the error message exactly (case-sensitive)
  2. Check _UNIVERSE_TAG keys (sorted in the message) for the supported set
  3. If a new universe is needed, register its loader and tag in the module first

Example fix

// before
run_alpha_bench(universe='CSI-300', period='2023')
// after
run_alpha_bench(universe='csi300', period='2023')
Defensive patterns

Strategy: validation

Validate before calling

from src.tools.alpha_bench_tool import _UNIVERSE_TAG
universe = universe.strip().lower()
assert universe in _UNIVERSE_TAG, f'use one of {sorted(_UNIVERSE_TAG)}'

Type guard

def is_known_universe(u: str) -> bool:
    from src.tools.alpha_bench_tool import _UNIVERSE_TAG
    return u in _UNIVERSE_TAG

Try / catch

try:
    _load_universe_panel(universe, period)
except ValueError as e:
    if 'not recognized' in str(e):
        show_supported_universities()

Prevention

When it happens

Trigger: Calling run_bench/run_bench_strict/run_alpha_bench with universe='CSI300' (case mismatch), 'sp500', or a typo like 'csi-300'.

Common situations: LLM tool calls guessing universe names; case-sensitive mismatches; new universes not yet registered in _UNIVERSE_TAG.

Related errors


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