1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-28 06:22:45 +08:00

Compare commits

..

6 Commits

Author SHA1 Message Date
Linlang
b85a5c224e fixed pytest error in CI 2025-03-12 14:11:42 +08:00
Linlang
880a5d27b1 fix issue 1887 2025-03-11 20:19:13 +08:00
Linlang
922494bdbb format with black 2025-03-10 17:15:37 +08:00
Linlang
3277c2a512 fix pytest error 2025-03-10 17:06:36 +08:00
Linlang
06c8c4e37f format with black 2025-03-10 17:04:51 +08:00
Linlang
84373de6e5 fix the bug that the HS STMBOLS URL is faild 2025-03-10 16:57:53 +08:00
4 changed files with 7 additions and 25 deletions

View File

@@ -44,8 +44,6 @@ dependencies = [
"matplotlib",
"jupyter",
"nbconvert",
"pyarrow",
"tables",
]
[project.optional-dependencies]
@@ -81,6 +79,7 @@ package = [
test = [
"yahooquery",
"baostock",
"akshare",
]
analysis = [
"plotly",

View File

@@ -279,11 +279,8 @@ class StaticDataLoader(DataLoader, Serializable):
)
self._data.sort_index(inplace=True)
elif isinstance(self._config, (str, Path)):
if str(self._config).strip().endswith(".parquet"):
self._data = pd.read_parquet(self._config, engine="pyarrow")
else:
with Path(self._config).open("rb") as f:
self._data = pickle.load(f)
with Path(self._config).open("rb") as f:
self._data = pickle.load(f)
elif isinstance(self._config, pd.DataFrame):
self._data = self._config

View File

@@ -13,6 +13,7 @@ import functools
from pathlib import Path
from typing import Iterable, Tuple, List
import akshare as ak
import numpy as np
import pandas as pd
from loguru import logger
@@ -202,18 +203,9 @@ def get_hs_stock_symbols() -> list:
-------
{600000.ss, 600001.ss, 600002.ss, 600003.ss, ...}
"""
url = "http://99.push2.eastmoney.com/api/qt/clist/get?pn=1&pz=10000&po=1&np=1&fs=m:0+t:6,m:0+t:80,m:1+t:2,m:1+t:23,m:0+t:81+s:2048&fields=f12"
try:
resp = requests.get(url, timeout=None)
resp.raise_for_status()
except requests.exceptions.HTTPError as e:
raise requests.exceptions.HTTPError(f"Request to {url} failed with status code {resp.status_code}") from e
try:
_symbols = [_v["f12"] for _v in resp.json()["data"]["diff"]]
except Exception as e:
logger.warning("An error occurred while extracting data from the response.")
raise
stock_info_a_code_name_df = ak.stock_info_a_code_name()
stock_codes = stock_info_a_code_name_df["code"].tolist()
_symbols = [code for code in stock_codes if code and code.strip()]
if len(_symbols) < 3900:
raise ValueError("The complete list of stocks is not available.")

View File

@@ -50,12 +50,6 @@ pip install -r requirements.txt
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data_1min --region cn --interval 1min
# us 1d
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/us_data --region us --interval 1d
# us 1min
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/us_data_1min --region us --interval 1min
# in 1d
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/in_data --region in --interval 1d
# in 1min
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/in_data_1min --region in --interval 1min
```
### Collector *YahooFinance* data to qlib