mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-09 22:10:56 +08:00
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
This commit is contained in:
@@ -282,20 +282,14 @@ def get_us_stock_symbols(qlib_data_path: [str, Path] = None) -> list:
|
|||||||
-------
|
-------
|
||||||
stock symbols
|
stock symbols
|
||||||
"""
|
"""
|
||||||
|
import akshare as ak # pylint: disable=C0415
|
||||||
|
|
||||||
global _US_SYMBOLS # pylint: disable=W0603
|
global _US_SYMBOLS # pylint: disable=W0603
|
||||||
|
|
||||||
@deco_retry
|
@deco_retry
|
||||||
def _get_eastmoney():
|
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"
|
df = ak.get_us_stock_name()
|
||||||
resp = requests.get(url, timeout=None)
|
_symbols = df["symbol"].to_list()
|
||||||
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
|
|
||||||
|
|
||||||
if len(_symbols) < 8000:
|
if len(_symbols) < 8000:
|
||||||
raise ValueError("request error")
|
raise ValueError("request error")
|
||||||
|
|||||||
Reference in New Issue
Block a user