microsoft/qlib · error · ValueError

request error

Error message

request error

What it means

Raised inside get_cg_crypto_symbols in the crypto collector when instantiating CoinGeckoAPI or calling get_coins_markets raises any exception (network failure, pycoingecko error, malformed response). The original exception is chained (`from e`) but the message is the generic 'request error'. A second path logs a warning when parsing resp['id'] fails.

Source

Thrown at scripts/data_collector/crypto/collector.py:40

_CG_CRYPTO_SYMBOLS = None


def get_cg_crypto_symbols(qlib_data_path: [str, Path] = None) -> list:
    """get crypto symbols in coingecko

    Returns
    -------
        crypto symbols in given exchanges list of coingecko
    """
    global _CG_CRYPTO_SYMBOLS  # pylint: disable=W0603

    @deco_retry
    def _get_coingecko():
        try:
            cg = CoinGeckoAPI()
            resp = pd.DataFrame(cg.get_coins_markets(vs_currency="usd"))
        except Exception as e:
            raise ValueError("request error") from e
        try:
            _symbols = resp["id"].to_list()
        except Exception as e:
            logger.warning(f"request error: {e}")
            raise
        return _symbols

    if _CG_CRYPTO_SYMBOLS is None:
        _all_symbols = _get_coingecko()

        _CG_CRYPTO_SYMBOLS = sorted(set(_all_symbols))

    return _CG_CRYPTO_SYMBOLS


class CryptoCollector(BaseCollector):
    def __init__(
        self,

View on GitHub (pinned to 79633dd950)

Solutions

  1. Check network/proxy connectivity to api.coingecko.com (curl https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd).
  2. If rate-limited, wait/backoff and retry; the inner deco_retry retries the whole call, so persistent 429s need spacing between runs or an API key-enabled client.
  3. Pin/upgrade a compatible pycoingecko version matching the current CoinGecko API response.
  4. If the parse branch failed (logged 'request error: {e}'), inspect the logged exception — the response shape changed and the parsing needs updating.
Defensive patterns

Strategy: retry

Validate before calling

import requests
r = requests.get("https://api.coingecko.com/api/v3/coins/markets", params={"vs_currency": "usd"}, timeout=10)
assert r.status_code == 200, f"CoinGecko unreachable: {r.status_code}"

Try / catch

try:
    symbols = get_cg_crypto_symbols()
except ValueError as e:
    if "request error" in str(e):
        # backoff and retry; CoinGecko free tier rate-limits
        time.sleep(60)
        symbols = get_cg_crypto_symbols()
    else:
        raise

Prevention

When it happens

Trigger: Calling get_cg_crypto_symbols() (the crypto collector's get_instrument_list) while CoinGecko's API is unreachable, rate-limited (429), or returns a non-DataFrame-parsable payload; pycoingecko not installed/outdated can also raise at CoinGeckoAPI().

Common situations: Running the crypto data collector without network access or behind a proxy; hitting CoinGecko's free-tier rate limit; pycoingecko version incompatibility with the API response schema.

Related errors


AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15). Data as JSON: /api/errors/cfedd9a94d1e1a09. Report an issue: GitHub.