From 8fd6d5ca7eab59a69bf5c62f84e8b4e2a4e8910b Mon Sep 17 00:00:00 2001 From: Linlang <30293408+SunsetWolf@users.noreply.github.com> Date: Wed, 4 Feb 2026 17:37:47 +0800 Subject: [PATCH] fix: the bug that the US STMBOLS URL is faild (#1975) * fix the bug that the US STMBOLS URL is faild * recover code * fix package dependence error * fix package dependence error * fix package dependence error * fix package dependence error * fix package dependence error * format with black * disable pylint error --- scripts/data_collector/utils.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/scripts/data_collector/utils.py b/scripts/data_collector/utils.py index 7b0c05768..bf87d0de5 100644 --- a/scripts/data_collector/utils.py +++ b/scripts/data_collector/utils.py @@ -282,20 +282,14 @@ def get_us_stock_symbols(qlib_data_path: [str, Path] = None) -> list: ------- stock symbols """ + import akshare as ak # pylint: disable=C0415 + global _US_SYMBOLS # pylint: disable=W0603 @deco_retry def _get_eastmoney(): - url = "http://4.push2.eastmoney.com/api/qt/clist/get?pn=1&pz=10000&fs=m:105,m:106,m:107&fields=f12" - resp = requests.get(url, timeout=None) - if resp.status_code != 200: - raise ValueError("request error") - - try: - _symbols = [_v["f12"].replace("_", "-P") for _v in resp.json()["data"]["diff"].values()] - except Exception as e: - logger.warning(f"request error: {e}") - raise + df = ak.get_us_stock_name() + _symbols = df["symbol"].to_list() if len(_symbols) < 8000: raise ValueError("request error")