From 9a037fbb1288c7f9579668b4a2d5e6b44429f67b Mon Sep 17 00:00:00 2001 From: Jactus Date: Sun, 27 Sep 2020 15:45:29 +0800 Subject: [PATCH 01/31] Add CI --- .github/workflows/test.yml | 65 ++++++++++++++++++++++++++++++++++++++ requirements.txt | 24 ++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 requirements.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..0814607e2f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,65 @@ +name: Test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-16.04, ubuntu-18.04, windows-latest, macos-latest] + python-version: [3.5, 3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade cython + pip install numpy jupyter jupyter_contrib_nbextensions + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python setup.py install + + - name: Install test dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Test with pytest + run: | + pytest ../qlib + + - name: Test documents + run: | + pip install sphinx sphinx_rtd_theme + make html + + - name: Test data downloads and examples + run: | + python scripts/get_data.py qlib_data_cn --target_dir ~/.qlib/qlib_data/cn_data + cd examples + estimator -c estimator/estimator_config.yaml + jupyter nbconvert --execute estimator/analyze_from_estimator.ipynb + + + + + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..165619920f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,24 @@ +requests==2.22.0 +six==1.14.0 +lxml==4.5.0 +statsmodels==0.12.0 +pandas==1.1.2 +matplotlib==3.3.2 +scipy==1.3.3 +numpy==1.17.4 +Cython==0.29.21 +fire==0.3.1 +gevent_socketio==0.3.6 +hyperopt==0.2.4 +lightgbm==3.0.0 +loguru==0.5.3 +plotly==4.10.0 +pymongo==3.11.0 +PyYAML==5.3.1 +redis==3.5.3 +redis_lock==0.2.0 +sacred==0.8.1 +scikit_learn==0.23.2 +torch==1.6.0 +tqdm==4.49.0 +yahooquery==2.2.7 From cd5120fb30c08455fcbd183ba62f92d265e10ec6 Mon Sep 17 00:00:00 2001 From: Jactus Date: Sun, 27 Sep 2020 18:48:50 +0800 Subject: [PATCH 02/31] Add PEP8 style check and add bug report issue template --- .github/ISSUE_TEMPLATE/bug-report.md | 38 ++++++++++++++++++++++++++++ .github/workflows/test.yml | 14 +++++----- .gitignore | 2 ++ 3 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug-report.md diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000000..7cf52786c3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,38 @@ +--- +name: "\U0001F41B Bug Report" +about: Submit a bug report to help us improve Qlib +labels: bug + +--- + +## πŸ› Bug Description + + + +## To Reproduce + +Steps to reproduce the behavior: + +1. +1. +1. + + +## Expected Behavior + + + +## Screenshot + + + +## Environment + + - Qlib version: + - Python version: + - OS (`Windows`, `Linux`, `MacOS`): + - Commit number: + +## Additional Notes + + \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0814607e2f..ebd7085135 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: - name: Install test dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest + pip install flake8 pytest pep8 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 @@ -43,6 +43,11 @@ jobs: # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Check PEP8 python code style + run: | + find . -name \*.py -exec pep8 {} + + + - name: Test with pytest run: | pytest ../qlib @@ -57,9 +62,4 @@ jobs: python scripts/get_data.py qlib_data_cn --target_dir ~/.qlib/qlib_data/cn_data cd examples estimator -c estimator/estimator_config.yaml - jupyter nbconvert --execute estimator/analyze_from_estimator.ipynb - - - - - \ No newline at end of file + jupyter nbconvert --execute estimator/analyze_from_estimator.ipynb \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5c8ce5e3a9..0af365d7b0 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ mlruns/ tags +.pytest_cache/ +.vscode/ From fffcf9cc9898334240b46e9479024f3f71d78be2 Mon Sep 17 00:00:00 2001 From: Jactus Date: Sun, 27 Sep 2020 19:01:41 +0800 Subject: [PATCH 03/31] Add feature request issue template --- .github/ISSUE_TEMPLATE/feature-request.md | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/feature-request.md diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 0000000000..1cfc8f4d10 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,24 @@ +--- +name: "\U0001F31FFeature Request" +about: Request for a new Qlib feature + +--- + +## 🌟 Feature Description + + +## Motivation + +1. Application scenario +2. Related works (Papers, Github repos etc.): +3. Any other relevant and important information: + + + +## Alternatives + + + +## Additional Notes + + \ No newline at end of file From 32db5d5422b630cb2131b566ee85bb3f9320451e Mon Sep 17 00:00:00 2001 From: Jactus Date: Mon, 28 Sep 2020 09:42:42 +0800 Subject: [PATCH 04/31] Update CI and add doc & question issue template --- .github/ISSUE_TEMPLATE/documentation.md | 9 +++++++++ .github/ISSUE_TEMPLATE/feature-request.md | 1 + .github/ISSUE_TEMPLATE/question.md | 10 ++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 21 +++++++++++++++++++++ .github/workflows/test.yml | 12 +----------- 5 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/documentation.md create mode 100644 .github/ISSUE_TEMPLATE/question.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE/documentation.md b/.github/ISSUE_TEMPLATE/documentation.md new file mode 100644 index 0000000000..96c70e5afa --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.md @@ -0,0 +1,9 @@ +--- +name: "\U0001F4D6 Documentation" +about: Report an issue related to documentation + +--- + +## πŸ“– Documentation + + diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md index 1cfc8f4d10..b5f90203d5 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.md +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -1,6 +1,7 @@ --- name: "\U0001F31FFeature Request" about: Request for a new Qlib feature +labels: enhancement --- diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000000..2d35dc9517 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,10 @@ +--- +name: "❓Questions & Help" +about: Have some questions? We can offer help. +labels: question + +--- + +## ❓ Questions and Help + +We sincerely suggest you to carefully read the [documentation](http://qlib.readthedocs.io/) of our library as well as the official [paper](https://arxiv.org/abs/2009.11189). After that, if you still feel puzzled, please describe the question clearly under this issue. \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..2add176d34 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,21 @@ + + +## Description + + +## Motivation and Context + + + +## How Has This Been Tested? + + + + +## Screenshots (if appropriate): + +## Types of changes + +- [ ] Fix bugs +- [ ] Add new feature +- [ ] Update documentation diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebd7085135..f11ccf44a7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: - name: Install test dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest pep8 + pip install flake8 pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 @@ -43,19 +43,9 @@ jobs: # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Check PEP8 python code style - run: | - find . -name \*.py -exec pep8 {} + - - - name: Test with pytest run: | pytest ../qlib - - - name: Test documents - run: | - pip install sphinx sphinx_rtd_theme - make html - name: Test data downloads and examples run: | From c803b1aca742d277447b2f461c7003e684c6f1a4 Mon Sep 17 00:00:00 2001 From: Jactus Date: Mon, 28 Sep 2020 11:25:54 +0800 Subject: [PATCH 05/31] Add release drafter --- .github/release-drafter.yml | 33 +++++++++++++++++++++++++++ .github/workflows/release-drafter.yml | 19 +++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000000..ec8ea5d69a --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,33 @@ +name-template: 'v$RESOLVED_VERSION 🌈' +tag-template: 'v$RESOLVED_VERSION' +categories: + - title: '🌟 Features' + labels: + - 'feature' + - 'enhancement' + - title: 'πŸ› Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: 'πŸ“š Documentation' + label: + - 'doc' + - 'documentation' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch +template: | + ## Changes + + $CHANGES \ No newline at end of file diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000000..90dbf7b797 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,19 @@ +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5.11.0 + with: + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml + # config-name: my-config.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 600a516bccc16845d48bd07379bfba7d3e464c46 Mon Sep 17 00:00:00 2001 From: Jactus Date: Mon, 28 Sep 2020 14:10:34 +0800 Subject: [PATCH 06/31] Update issue template --- .github/ISSUE_TEMPLATE/bug-report.md | 4 ++-- .github/PULL_REQUEST_TEMPLATE.md | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 7cf52786c3..721f7113c3 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -28,10 +28,10 @@ Steps to reproduce the behavior: ## Environment - - Qlib version: + - Qlib version (use the command: `print(qlib.__version__)`): - Python version: - OS (`Windows`, `Linux`, `MacOS`): - - Commit number: + - Commit number (optional, please provide it if you are using the dev version): ## Additional Notes diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 2add176d34..26701a9e24 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,11 +8,14 @@ ## How Has This Been Tested? - - - +- [ ] Pass the test by running: `pytest qlib/tests/test_all_pipeline.py` under upper directory of `qlib`. +- [ ] If you are adding a new feature, test on your own test scripts. -## Screenshots (if appropriate): + + +## Screenshots of Test Results (if appropriate): +1. Pipeline test: +2. Your own tests: ## Types of changes From c34ef89e935d82d2596ff88b3bd0f6ffda2925a3 Mon Sep 17 00:00:00 2001 From: Jactus Date: Mon, 28 Sep 2020 14:40:12 +0800 Subject: [PATCH 07/31] Add collect_info script --- .github/ISSUE_TEMPLATE/bug-report.md | 4 +++- scripts/collect_info.py | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 scripts/collect_info.py diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 721f7113c3..0ba45684ee 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -28,7 +28,9 @@ Steps to reproduce the behavior: ## Environment - - Qlib version (use the command: `print(qlib.__version__)`): +**Note**: One could run `python scripts/collect_info.py` under the `qlib` directory to get the following information. + + - Qlib version: - Python version: - OS (`Windows`, `Linux`, `MacOS`): - Commit number (optional, please provide it if you are using the dev version): diff --git a/scripts/collect_info.py b/scripts/collect_info.py new file mode 100644 index 0000000000..da4c406ae2 --- /dev/null +++ b/scripts/collect_info.py @@ -0,0 +1,24 @@ +import sys, platform +import qlib + +def linux_distribution(): + try: + return platform.linux_distribution() + except: + return "N/A" + +print('Qlib version: {} \n'.format(qlib.__version__)) +print("""Python version: {} \n +linux_distribution: {} +system: {} +machine: {} +platform: {} +version: {} +""".format( +sys.version.split('\n'), +linux_distribution(), +platform.system(), +platform.machine(), +platform.platform(), +platform.version(), +)) \ No newline at end of file From eb044d9fdc097d0ed4b63537f0cb753f909d1ccd Mon Sep 17 00:00:00 2001 From: zhupr Date: Mon, 28 Sep 2020 14:43:09 +0800 Subject: [PATCH 08/31] Add FAQ --- README.md | 3 +- docs/FAQ/FAQ.rst | 66 ++++++++++++++++ docs/index.rst | 5 ++ qlib/data/cache.py | 187 +++++++++++---------------------------------- qlib/data/data.py | 12 +-- 5 files changed, 123 insertions(+), 150 deletions(-) create mode 100644 docs/FAQ/FAQ.rst diff --git a/README.md b/README.md index 7aca385d57..42038e4d0b 100644 --- a/README.md +++ b/README.md @@ -154,10 +154,9 @@ Qlib provides a tool named `Estimator` to run the whole workflow automatically ( - Auto Correlation of forecasting signal (model prediction) ![Auto Correlation](http://fintech.msra.cn/images/analysis/analysis_model_auto_correlation.png?v=0.1) - - Portfolio analysis - Backtest return - ![Report](http://fintech.msra.cn/images/analysis/report.png) + ![Report](http://fintech.msra.cn/images/analysis/report.png?v=0.1)