mirror of
https://github.com/microsoft/qlib.git
synced 2026-06-20 04:31:42 +08:00
Compare commits
104 Commits
update_rea
...
update_pub
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5dfc661fc3 | ||
|
|
6a123db109 | ||
|
|
c0f608e3f8 | ||
|
|
dd67d235af | ||
|
|
e111fc8172 | ||
|
|
1a0dc06108 | ||
|
|
0f0f49c860 | ||
|
|
f10affe9ca | ||
|
|
b8ff81ecd4 | ||
|
|
d478795b54 | ||
|
|
3bc1ae4aae | ||
|
|
80a81c0bf7 | ||
|
|
8581d30736 | ||
|
|
0486ab1f99 | ||
|
|
7e6bdc9493 | ||
|
|
5222de4934 | ||
|
|
94458af3f7 | ||
|
|
04ffb400b2 | ||
|
|
bfec2aa27a | ||
|
|
fed2691cbe | ||
|
|
abeb5cfbe0 | ||
|
|
59d28b8a11 | ||
|
|
22ca863113 | ||
|
|
01d2011905 | ||
|
|
e4910dd7d1 | ||
|
|
848e1f9b18 | ||
|
|
ece56371d9 | ||
|
|
ef289faf30 | ||
|
|
ed360a58d9 | ||
|
|
043d283d2a | ||
|
|
e28c1e0c38 | ||
|
|
2d595aca08 | ||
|
|
92e1f07a01 | ||
|
|
2a2615a71e | ||
|
|
36e2f66730 | ||
|
|
d31d17e7aa | ||
|
|
e3363208a0 | ||
|
|
fe8a860f5e | ||
|
|
6f39f16695 | ||
|
|
c03017628d | ||
|
|
a9941bd25c | ||
|
|
9d324f6481 | ||
|
|
82e755dc7f | ||
|
|
f45d031727 | ||
|
|
0b938bdddd | ||
|
|
b80abdaf89 | ||
|
|
2e2f9125a7 | ||
|
|
16fc2f54c2 | ||
|
|
b512074567 | ||
|
|
351eea1f78 | ||
|
|
f4bcbe3a0a | ||
|
|
8e1c7d395b | ||
|
|
5281d77fbb | ||
|
|
431b9c1281 | ||
|
|
6a4273c300 | ||
|
|
05a9f8cd30 | ||
|
|
34a53033f1 | ||
|
|
631fa33880 | ||
|
|
276ee144e7 | ||
|
|
b91d0fa076 | ||
|
|
c7d3f1f729 | ||
|
|
deffd9749f | ||
|
|
e82f225dc4 | ||
|
|
10f43b8f01 | ||
|
|
bac5642d69 | ||
|
|
1239a68edc | ||
|
|
07a8d72d50 | ||
|
|
ea9ef1343c | ||
|
|
cc4ac5d4d7 | ||
|
|
1aa61a6735 | ||
|
|
303e62445b | ||
|
|
6a0bc50386 | ||
|
|
86b4d4c707 | ||
|
|
808ef6b95e | ||
|
|
8aaa75daa4 | ||
|
|
34908c8846 | ||
|
|
687a2b209a | ||
|
|
df391f0569 | ||
|
|
44b674ce05 | ||
|
|
d592bfdea1 | ||
|
|
a0236654df | ||
|
|
666c8d541d | ||
|
|
c243557c13 | ||
|
|
624adb40a9 | ||
|
|
bb6acaf932 | ||
|
|
a8f3d382f8 | ||
|
|
625d119f64 | ||
|
|
0cafe3e12e | ||
|
|
a6164092a9 | ||
|
|
a6646dac3e | ||
|
|
5a8ff65a3b | ||
|
|
b43f8eac31 | ||
|
|
a6e9d8b594 | ||
|
|
4330975f4c | ||
|
|
fa1a4ce8f9 | ||
|
|
5b0fb43f31 | ||
|
|
7dec56876f | ||
|
|
9b9accdd68 | ||
|
|
7c9ef8db88 | ||
|
|
b05d442f34 | ||
|
|
0de40d1f8f | ||
|
|
9e4bdc21ac | ||
|
|
dbbcfef723 | ||
|
|
8f16f6b0bd |
30
.github/workflows/python-publish.yml
vendored
30
.github/workflows/python-publish.yml
vendored
@@ -3,16 +3,22 @@
|
||||
|
||||
name: Upload Python Package
|
||||
|
||||
# on:
|
||||
# release:
|
||||
# types: [published]
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
deploy_with_bdist_wheel:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, macos-13, macos-latest]
|
||||
os: [windows-latest, macos-13, macos-latest, macos-15]
|
||||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||
exclude:
|
||||
- os: macos-13
|
||||
@@ -32,13 +38,13 @@ jobs:
|
||||
- name: Build wheel on ${{ matrix.os }}
|
||||
run: |
|
||||
make build
|
||||
- name: Upload to PyPi
|
||||
- name: Build and publish
|
||||
env:
|
||||
TWINE_USERNAME: __token__
|
||||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
||||
TWINE_PASSWORD: ${{ secrets.TESTPYPI_TOKEN }}
|
||||
run: |
|
||||
ls dist
|
||||
twine check dist/*.whl
|
||||
twine upload dist/*.whl --verbose
|
||||
|
||||
deploy_with_manylinux:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -51,15 +57,19 @@ jobs:
|
||||
- name: Build wheel on Linux
|
||||
uses: RalfG/python-wheels-manylinux-build@v0.7.1-manylinux2014_x86_64
|
||||
with:
|
||||
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
|
||||
python-versions: 'cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312'
|
||||
build-requirements: 'numpy cython'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install twine
|
||||
- name: Upload to PyPi
|
||||
python -m pip list
|
||||
- name: Build and publish
|
||||
env:
|
||||
TWINE_USERNAME: __token__
|
||||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
||||
TWINE_PASSWORD: ${{ secrets.TESTPYPI_TOKEN }}
|
||||
run: |
|
||||
twine check dist/pyqlib-*-manylinux*.whl
|
||||
twine upload dist/pyqlib-*-manylinux*.whl --verbose
|
||||
ls dist
|
||||
twine check dist/*.whl
|
||||
|
||||
|
||||
|
||||
11
.github/workflows/test_qlib_from_pip.yml
vendored
11
.github/workflows/test_qlib_from_pip.yml
vendored
@@ -13,10 +13,13 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
# Since macos-latest changed from 12.7.4 to 14.4.1,
|
||||
# the minimum python version that matches a 14.4.1 version of macos is 3.10,
|
||||
# If you want to use python 3.7 in github action, then the latest macos system version is macos-13,
|
||||
# after macos-13 python 3.7 is no longer supported.
|
||||
# so we limit the macos version to macos-13.
|
||||
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-15]
|
||||
# In github action, using python 3.7, pip install will not match the latest version of the package.
|
||||
# Also, python 3.7 is no longer supported from macos-14, and will be phased out from macos-13 in the near future.
|
||||
# All things considered, we have removed python 3.7.
|
||||
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
|
||||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||
|
||||
steps:
|
||||
@@ -34,7 +37,7 @@ jobs:
|
||||
|
||||
- name: Qlib installation test
|
||||
run: |
|
||||
python -m pip install pyqlib
|
||||
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pyqlib==0.9.5.80
|
||||
|
||||
- name: Install Lightgbm for MacOS
|
||||
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-15' }}
|
||||
|
||||
113
.github/workflows/test_qlib_from_source.yml
vendored
113
.github/workflows/test_qlib_from_source.yml
vendored
@@ -1,113 +0,0 @@
|
||||
name: Test qlib from source
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
timeout-minutes: 180
|
||||
# we may retry for 3 times for `Unit tests with Pytest`
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-15]
|
||||
# In github action, using python 3.7, pip install will not match the latest version of the package.
|
||||
# Also, python 3.7 is no longer supported from macos-14, and will be phased out from macos-13 in the near future.
|
||||
# All things considered, we have removed python 3.7.
|
||||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||
|
||||
steps:
|
||||
- name: Test qlib from source
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Update pip to the latest version
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
|
||||
- name: Installing pytorch for macos
|
||||
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-15' }}
|
||||
run: |
|
||||
python -m pip install torch torchvision torchaudio
|
||||
|
||||
- name: Installing pytorch for ubuntu
|
||||
if: ${{ matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' }}
|
||||
run: |
|
||||
python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
|
||||
|
||||
- name: Installing pytorch for windows
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
run: |
|
||||
python -m pip install torch torchvision torchaudio
|
||||
|
||||
- name: Set up Python tools
|
||||
run: |
|
||||
make dev
|
||||
|
||||
- name: Lint with Black
|
||||
run: |
|
||||
make black
|
||||
|
||||
- name: Make html with sphinx
|
||||
# Since read the docs builds on ubuntu 22.04, we only need to test that the build passes on ubuntu 22.04.
|
||||
if: ${{ matrix.os == 'ubuntu-22.04' }}
|
||||
run: |
|
||||
make docs-gen
|
||||
|
||||
- name: Check Qlib with pylint
|
||||
run: |
|
||||
make pylint
|
||||
|
||||
- name: Check Qlib with flake8
|
||||
run: |
|
||||
make flake8
|
||||
|
||||
- name: Check Qlib with mypy
|
||||
run: |
|
||||
make mypy
|
||||
|
||||
- name: Check Qlib ipynb with nbqa
|
||||
run: |
|
||||
make nbqa
|
||||
|
||||
- name: Test data downloads
|
||||
run: |
|
||||
python scripts/get_data.py qlib_data --name qlib_data_simple --target_dir ~/.qlib/qlib_data/cn_data --interval 1d --region cn
|
||||
python scripts/get_data.py download_data --file_name rl_data.zip --target_dir tests/.data/rl
|
||||
|
||||
- name: Install Lightgbm for MacOS
|
||||
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-15' }}
|
||||
run: |
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Microsoft/qlib/main/.github/brew_install.sh)"
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install lightgbm
|
||||
# FIX MacOS error: Segmentation fault
|
||||
# reference: https://github.com/microsoft/LightGBM/issues/4229
|
||||
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb
|
||||
brew unlink libomp
|
||||
brew install libomp.rb
|
||||
|
||||
- name: Check Qlib ipynb with nbconvert
|
||||
run: |
|
||||
make nbconvert
|
||||
|
||||
- name: Test workflow by config (install from source)
|
||||
run: |
|
||||
python -m pip install numba
|
||||
python qlib/workflow/cli.py examples/benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml
|
||||
|
||||
- name: Unit tests with Pytest
|
||||
uses: nick-fields/retry@v2
|
||||
with:
|
||||
timeout_minutes: 60
|
||||
max_attempts: 3
|
||||
command: |
|
||||
cd tests
|
||||
python -m pytest . -m "not slow" --durations=0
|
||||
58
.github/workflows/test_qlib_from_source_slow.yml
vendored
58
.github/workflows/test_qlib_from_source_slow.yml
vendored
@@ -1,58 +0,0 @@
|
||||
name: Test qlib from source slow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
timeout-minutes: 720
|
||||
# we may retry for 3 times for `Unit tests with Pytest`
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-15]
|
||||
# In github action, using python 3.7, pip install will not match the latest version of the package.
|
||||
# Also, python 3.7 is no longer supported from macos-14, and will be phased out from macos-13 in the near future.
|
||||
# All things considered, we have removed python 3.7.
|
||||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||
|
||||
steps:
|
||||
- name: Test qlib from source slow
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Set up Python tools
|
||||
run: |
|
||||
make dev
|
||||
|
||||
- name: Downloads dependencies data
|
||||
run: |
|
||||
python scripts/get_data.py qlib_data --name qlib_data_simple --target_dir ~/.qlib/qlib_data/cn_data --interval 1d --region cn
|
||||
|
||||
- name: Install Lightgbm for MacOS
|
||||
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-15' }}
|
||||
run: |
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Microsoft/qlib/main/.github/brew_install.sh)"
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install lightgbm
|
||||
# FIX MacOS error: Segmentation fault
|
||||
# reference: https://github.com/microsoft/LightGBM/issues/4229
|
||||
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb
|
||||
brew unlink libomp
|
||||
brew install libomp.rb
|
||||
|
||||
- name: Unit tests with Pytest
|
||||
uses: nick-fields/retry@v2
|
||||
with:
|
||||
timeout_minutes: 240
|
||||
max_attempts: 3
|
||||
command: |
|
||||
cd tests
|
||||
python -m pytest . -m "slow" --durations=0
|
||||
14
README.md
14
README.md
@@ -155,16 +155,15 @@ Here is a quick **[demo](https://terminalizer.com/view/3f24561a4470)** shows how
|
||||
This table demonstrates the supported Python version of `Qlib`:
|
||||
| | install with pip | install from source | plot |
|
||||
| ------------- |:---------------------:|:--------------------:|:------------------:|
|
||||
| Python 3.7 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| Python 3.8 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| Python 3.9 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| Python 3.10 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| Python 3.11 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| Python 3.12 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| Python 3.9 | :x: | :heavy_check_mark: | :x: |
|
||||
|
||||
**Note**:
|
||||
1. **Conda** is suggested for managing your Python environment. In some cases, using Python outside of a `conda` environment may result in missing header files, causing the installation failure of certain packages.
|
||||
2. Please pay attention that installing cython in Python 3.6 will raise some error when installing ``Qlib`` from source. If users use Python 3.6 on their machines, it is recommended to *upgrade* Python to version 3.8 or higher, or use `conda`'s Python to install ``Qlib`` from source.
|
||||
3. For Python 3.9, `Qlib` supports running workflows such as training models, doing backtest and plot most of the related figures (those included in [notebook](examples/workflow_by_code.ipynb)). However, plotting for the *model performance* is not supported for now and we will fix this when the dependent packages are upgraded in the future.
|
||||
1. Please pay attention that installing cython in Python 3.6 will raise some error when installing ``Qlib`` from source. If users use Python 3.6 on their machines, it is recommended to *upgrade* Python to version 3.7 or use `conda`'s Python to install ``Qlib`` from source.
|
||||
1. For Python 3.9, `Qlib` supports running workflows such as training models, doing backtest and plot most of the related figures (those included in [notebook](examples/workflow_by_code.ipynb)). However, plotting for the *model performance* is not supported for now and we will fix this when the dependent packages are upgraded in the future.
|
||||
1. `Qlib`Requires `tables` package, `hdf5` in tables does not support python3.9.
|
||||
|
||||
### Install with pip
|
||||
Users can easily install ``Qlib`` by pip according to the following command.
|
||||
@@ -182,7 +181,7 @@ Also, users can install the latest dev version ``Qlib`` by the source code accor
|
||||
|
||||
```bash
|
||||
pip install numpy
|
||||
pip install --upgrade cython
|
||||
pip install --upgrade cython
|
||||
```
|
||||
|
||||
* Clone the repository and install ``Qlib`` as follows.
|
||||
@@ -190,6 +189,7 @@ Also, users can install the latest dev version ``Qlib`` by the source code accor
|
||||
git clone https://github.com/microsoft/qlib.git && cd qlib
|
||||
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**.
|
||||
|
||||
**Tips**: If you fail to install `Qlib` or run the examples in your environment, comparing your steps and the [CI workflow](.github/workflows/test_qlib_from_source.yml) may help you find the problem.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Licensed under the MIT License.
|
||||
from pathlib import Path
|
||||
|
||||
__version__ = "0.9.6.99"
|
||||
__version__ = "0.9.5.80"
|
||||
__version__bak = __version__ # This version is backup for QlibConfig.reset_qlib_version
|
||||
import os
|
||||
from typing import Union
|
||||
|
||||
Reference in New Issue
Block a user