{"record":{"id":"cfedd9a94d1e1a09","repo":"microsoft/qlib","slug":"request-error","errorCode":null,"errorMessage":"request error","messagePattern":"request error","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/data_collector/crypto/collector.py","lineNumber":40,"sourceCode":"_CG_CRYPTO_SYMBOLS = None\n\n\ndef get_cg_crypto_symbols(qlib_data_path: [str, Path] = None) -> list:\n    \"\"\"get crypto symbols in coingecko\n\n    Returns\n    -------\n        crypto symbols in given exchanges list of coingecko\n    \"\"\"\n    global _CG_CRYPTO_SYMBOLS  # pylint: disable=W0603\n\n    @deco_retry\n    def _get_coingecko():\n        try:\n            cg = CoinGeckoAPI()\n            resp = pd.DataFrame(cg.get_coins_markets(vs_currency=\"usd\"))\n        except Exception as e:\n            raise ValueError(\"request error\") from e\n        try:\n            _symbols = resp[\"id\"].to_list()\n        except Exception as e:\n            logger.warning(f\"request error: {e}\")\n            raise\n        return _symbols\n\n    if _CG_CRYPTO_SYMBOLS is None:\n        _all_symbols = _get_coingecko()\n\n        _CG_CRYPTO_SYMBOLS = sorted(set(_all_symbols))\n\n    return _CG_CRYPTO_SYMBOLS\n\n\nclass CryptoCollector(BaseCollector):\n    def __init__(\n        self,","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/scripts/data_collector/crypto/collector.py#L22-L58","documentation":"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.","triggerScenarios":"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().","commonSituations":"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.","solutions":["Check network/proxy connectivity to api.coingecko.com (curl https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd).","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.","Pin/upgrade a compatible pycoingecko version matching the current CoinGecko API response.","If the parse branch failed (logged 'request error: {e}'), inspect the logged exception — the response shape changed and the parsing needs updating."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import requests\nr = requests.get(\"https://api.coingecko.com/api/v3/coins/markets\", params={\"vs_currency\": \"usd\"}, timeout=10)\nassert r.status_code == 200, f\"CoinGecko unreachable: {r.status_code}\"","typeGuard":null,"tryCatchPattern":"try:\n    symbols = get_cg_crypto_symbols()\nexcept ValueError as e:\n    if \"request error\" in str(e):\n        # backoff and retry; CoinGecko free tier rate-limits\n        time.sleep(60)\n        symbols = get_cg_crypto_symbols()\n    else:\n        raise","preventionTips":["Cache the symbol list between runs instead of fetching every time.","Respect CoinGecko rate limits; add sleeps when collecting many symbols.","Pin a pycoingecko version tested against the current API."],"tags":["qlib","data-collector","crypto","coingecko","network"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}