mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-22 03:37:34 +08:00
Compare commits
7 Commits
v0.9.5
...
fix_logo_d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c10e185db2 | ||
|
|
41b94059aa | ||
|
|
7db83d84b7 | ||
|
|
35e0fdd1c0 | ||
|
|
598017f634 | ||
|
|
907c888c23 | ||
|
|
02fe6b6974 |
3
.github/workflows/test_qlib_from_pip.yml
vendored
3
.github/workflows/test_qlib_from_pip.yml
vendored
@@ -45,6 +45,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Qlib installation test
|
- name: Qlib installation test
|
||||||
run: |
|
run: |
|
||||||
|
# 2024-05-30 scs has released a new version: 3.2.4.post2,
|
||||||
|
# This will cause the CI to fail, so we have limited the version of scs for now.
|
||||||
|
python -m pip install "scs<=3.2.4"
|
||||||
python -m pip install pyqlib
|
python -m pip install pyqlib
|
||||||
|
|
||||||
- name: Install Lightgbm for MacOS
|
- name: Install Lightgbm for MacOS
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Recent released features
|
|||||||
Features released before 2021 are not listed here.
|
Features released before 2021 are not listed here.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="http://fintech.msra.cn/images_v070/logo/1.png" />
|
<img src="docs/_static/img/logo/1.png" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Qlib is an open-source, AI-oriented quantitative investment platform that aims to realize the potential, empower research, and create value using AI technologies in quantitative investment, from exploring ideas to implementing productions. Qlib supports diverse machine learning modeling paradigms, including supervised learning, market dynamics modeling, and reinforcement learning.
|
Qlib is an open-source, AI-oriented quantitative investment platform that aims to realize the potential, empower research, and create value using AI technologies in quantitative investment, from exploring ideas to implementing productions. Qlib supports diverse machine learning modeling paradigms, including supervised learning, market dynamics modeling, and reinforcement learning.
|
||||||
@@ -166,7 +166,7 @@ Also, users can install the latest dev version ``Qlib`` by the source code accor
|
|||||||
* Clone the repository and install ``Qlib`` as follows.
|
* Clone the repository and install ``Qlib`` as follows.
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/microsoft/qlib.git && cd qlib
|
git clone https://github.com/microsoft/qlib.git && cd qlib
|
||||||
pip install .
|
pip install . # `pip install -e .[dev]` is recommended for development. check details in docs/developer/code_standard_and_dev_guide.rst
|
||||||
```
|
```
|
||||||
**Note**: You can install Qlib with `python setup.py install` as well. But it is not the recommended approach. It will skip `pip` and cause obscure problems. For example, **only** the command ``pip install .`` **can** overwrite the stable version installed by ``pip install pyqlib``, while the command ``python setup.py install`` **can't**.
|
**Note**: You can install Qlib with `python setup.py install` as well. But it is not the recommended approach. It will skip `pip` and cause obscure problems. For example, **only** the command ``pip install .`` **can** overwrite the stable version installed by ``pip install pyqlib``, while the command ``python setup.py install`` **can't**.
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
__version__ = "0.9.5"
|
__version__ = "0.9.5.99"
|
||||||
__version__bak = __version__ # This version is backup for QlibConfig.reset_qlib_version
|
__version__bak = __version__ # This version is backup for QlibConfig.reset_qlib_version
|
||||||
import os
|
import os
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class Client:
|
|||||||
def connect_server(self):
|
def connect_server(self):
|
||||||
"""Connect to server."""
|
"""Connect to server."""
|
||||||
try:
|
try:
|
||||||
self.sio.connect("ws://" + self.server_host + ":" + str(self.server_port))
|
self.sio.connect(f"ws://{self.server_host}:{self.server_port}")
|
||||||
except socketio.exceptions.ConnectionError:
|
except socketio.exceptions.ConnectionError:
|
||||||
self.logger.error("Cannot connect to server - check your network or server status")
|
self.logger.error("Cannot connect to server - check your network or server status")
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ if TYPE_CHECKING:
|
|||||||
from qlib.data.dataset import DataHandler
|
from qlib.data.dataset import DataHandler
|
||||||
|
|
||||||
|
|
||||||
def get_level_index(df: pd.DataFrame, level=Union[str, int]) -> int:
|
def get_level_index(df: pd.DataFrame, level: Union[str, int]) -> int:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
get the level index of `df` given `level`
|
get the level index of `df` given `level`
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ class Normalize:
|
|||||||
na_values={col: symbol_na if col == self._symbol_field_name else default_na for col in columns},
|
na_values={col: symbol_na if col == self._symbol_field_name else default_na for col in columns},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# NOTE: It has been reported that there may be some problems here, and the specific issues will be dealt with when they are identified.
|
||||||
df = self._normalize_obj.normalize(df)
|
df = self._normalize_obj.normalize(df)
|
||||||
if df is not None and not df.empty:
|
if df is not None and not df.empty:
|
||||||
if self._end_date is not None:
|
if self._end_date is not None:
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ from typing import Iterable, Tuple, List
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from lxml import etree
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from yahooquery import Ticker
|
from yahooquery import Ticker
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
@@ -190,17 +189,43 @@ def get_hs_stock_symbols() -> list:
|
|||||||
global _HS_SYMBOLS # pylint: disable=W0603
|
global _HS_SYMBOLS # pylint: disable=W0603
|
||||||
|
|
||||||
def _get_symbol():
|
def _get_symbol():
|
||||||
_res = set()
|
"""
|
||||||
for _k, _v in (("ha", "ss"), ("sa", "sz"), ("gem", "sz")):
|
Get the stock pool from a web page and process it into the format required by yahooquery.
|
||||||
resp = requests.get(HS_SYMBOLS_URL.format(s_type=_k), timeout=None)
|
Format of data retrieved from the web page: 600519, 000001
|
||||||
_res |= set(
|
The data format required by yahooquery: 600519.ss, 000001.sz
|
||||||
map(
|
|
||||||
lambda x: "{}.{}".format(re.findall(r"\d+", x)[0], _v), # pylint: disable=W0640
|
Returns
|
||||||
etree.HTML(resp.text).xpath("//div[@class='result']/ul//li/a/text()"), # pylint: disable=I1101
|
-------
|
||||||
)
|
set: Returns the set of symbol codes.
|
||||||
)
|
|
||||||
time.sleep(3)
|
Examples:
|
||||||
return _res
|
-------
|
||||||
|
{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
|
||||||
|
|
||||||
|
if len(_symbols) < 3900:
|
||||||
|
raise ValueError("The complete list of stocks is not available.")
|
||||||
|
|
||||||
|
# Add suffix after the stock code to conform to yahooquery standard, otherwise the data will not be fetched.
|
||||||
|
_symbols = [
|
||||||
|
_symbol + ".ss" if _symbol.startswith("6") else _symbol + ".sz" if _symbol.startswith(("0", "3")) else None
|
||||||
|
for _symbol in _symbols
|
||||||
|
]
|
||||||
|
_symbols = [_symbol for _symbol in _symbols if _symbol is not None]
|
||||||
|
|
||||||
|
return set(_symbols)
|
||||||
|
|
||||||
if _HS_SYMBOLS is None:
|
if _HS_SYMBOLS is None:
|
||||||
symbols = set()
|
symbols = set()
|
||||||
|
|||||||
3
setup.py
3
setup.py
@@ -166,6 +166,9 @@ setup(
|
|||||||
"lxml",
|
"lxml",
|
||||||
"baostock",
|
"baostock",
|
||||||
"yahooquery",
|
"yahooquery",
|
||||||
|
# 2024-05-30 scs has released a new version: 3.2.4.post2,
|
||||||
|
# this version, causes qlib installation to fail, so we've limited the scs version a bit for now.
|
||||||
|
"scs<=3.2.4",
|
||||||
"beautifulsoup4",
|
"beautifulsoup4",
|
||||||
# In version 0.4.11 of tianshou, the code:
|
# In version 0.4.11 of tianshou, the code:
|
||||||
# logits, hidden = self.actor(batch.obs, state=state, info=batch.info)
|
# logits, hidden = self.actor(batch.obs, state=state, info=batch.info)
|
||||||
|
|||||||
Reference in New Issue
Block a user