Skip to content

Commit 8fd6d5c

Browse files
authored
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
1 parent 69bb755 commit 8fd6d5c

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

scripts/data_collector/utils.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -282,20 +282,14 @@ def get_us_stock_symbols(qlib_data_path: [str, Path] = None) -> list:
282282
-------
283283
stock symbols
284284
"""
285+
import akshare as ak # pylint: disable=C0415
286+
285287
global _US_SYMBOLS # pylint: disable=W0603
286288

287289
@deco_retry
288290
def _get_eastmoney():
289-
url = "http://4.push2.eastmoney.com/api/qt/clist/get?pn=1&pz=10000&fs=m:105,m:106,m:107&fields=f12"
290-
resp = requests.get(url, timeout=None)
291-
if resp.status_code != 200:
292-
raise ValueError("request error")
293-
294-
try:
295-
_symbols = [_v["f12"].replace("_", "-P") for _v in resp.json()["data"]["diff"].values()]
296-
except Exception as e:
297-
logger.warning(f"request error: {e}")
298-
raise
291+
df = ak.get_us_stock_name()
292+
_symbols = df["symbol"].to_list()
299293

300294
if len(_symbols) < 8000:
301295
raise ValueError("request error")

0 commit comments

Comments
 (0)