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

Compare commits

...

1895 Commits

Author SHA1 Message Date
Linlang Lv (iSoftStone Information)
091f542b42 Merge branch 'main' of github.com:microsoft/qlib into fix_docs 2024-05-17 17:42:15 +08:00
Ikko Eltociear Ashimine
917e3a725e Update dump_pit.py (#1759)
seperated -> separated

Co-authored-by: Linlang Lv (iSoftStone Information) <v-lvlinlang@microsoft.com>
2024-05-10 14:42:41 +08:00
Chuan Xu
b1e0e77c97 Fix the bug of reading string NA as NaN in the function exists_qlib_data. (#1736)
* Fix the bug of reading NA string as NaN in exists_qlib_data.

* Fix the .gitignore file.

* Update the fix and add some comments.

* format with black

---------

Co-authored-by: Chuan Xu <chuan.xu@sas.com>
Co-authored-by: Linlang Lv (iSoftStone Information) <v-lvlinlang@microsoft.com>
2024-05-10 13:09:39 +08:00
Linlang
ea245f5435 Fix issue 1729 (#1776)
* fix issue 1729

* fix issue 1729

* fix issue 1729

---------

Co-authored-by: Linlang Lv (iSoftStone Information) <v-lvlinlang@microsoft.com>
2024-05-10 11:04:59 +08:00
Linlang
3779b5186a bump version (#1784)
Co-authored-by: Linlang Lv (iSoftStone Information) <v-lvlinlang@microsoft.com>
2024-05-08 13:50:55 +08:00
Young
194284b1ac Update version 2024-05-07 14:15:35 +08:00
Linlang Lv (iSoftStone Information)
77d34e080b modify file extension 2024-04-10 14:29:34 +08:00
Linlang Lv (iSoftStone Information)
69daea0adc modify file extension 2024-04-10 14:24:05 +08:00
Xisen Wang
1bb8f2fa23 Enhance README with LightGBM Installation Guidance for Mac M1 Users (#1766)
* Update README.md

* Update README.md

* Update README.md
2024-03-20 20:48:52 +08:00
Linlang
39f88daaa7 download orderbook data (#1754)
* download orderbook data

* fix CI error

* fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* test fix CI error

* optimize get_data code

* optimize get_data code

* optimize get_data code

* optimize README

---------

Co-authored-by: Linlang <v-linlanglv@microsoft.com>
2024-03-07 14:41:21 +08:00
Linlang
975aeb7a99 fix docs 2024-01-05 11:43:54 +08:00
Linlang
98f569eed2 add_baostock_collector (#1641)
* add_baostock_collector

* modify_comments

* fix_pylint_error

* solve_duplication_methods

* modified the logic of update_data_to_bin

* modified the logic of update_data_to_bin

* optimize code

* optimize pylint issue

* fix pylint error

* changes suggested by the review

* fix CI faild

* fix CI faild

* fix issue 1121

* format with black

* optimize code logic

* optimize code logic

* fix error code

* drop warning during code runs

* optimize code

* format with black

* fix bug

* format with black

* optimize code

* optimize code

* add comments
2023-11-21 20:31:47 +08:00
JJ
ceff886f49 Update data.rst (#1679)
Fixed a couple of small spelling errors.
2023-11-16 18:11:29 +08:00
Ikko Eltociear Ashimine
15b64768e2 Update README.md (#1637)
an -> a
2023-11-15 17:03:26 +08:00
Andy li
8bf2678676 fix the warning (#1656) 2023-11-03 17:03:11 +08:00
JJ
fb80e318e2 Update quick.rst (#1667)
Fixed small spelling error.
2023-10-20 17:23:34 +08:00
zhuan
ecbeeafdc1 Update requirements.txt (#1521) 2023-09-15 17:18:04 +08:00
Fivele-Li
69e28ceab8 suppress the SettingWithCopyWarning of pandas (#1513)
* df value is set as expected, suppress the warning;

* depress warning with pandas option_context

---------

Co-authored-by: Cadenza-Li <362237642@qq.com>
2023-09-01 18:12:49 +08:00
Fivele-Li
4c30e5827b Troubleshooting pip version issues in CI (#1504)
* CI failed to run on 23.1 and 23.1.1

* add pyproject.toml

* upgrade pip in slow.yml

* upgrade build-system requires

* troubleshooting pytest problem

* troubleshooting pytest problem

* troubleshooting pytest problem

* troubleshooting pytest problem

* add qlib root path to python sys.path

* add qlib root path to $PYTHONPATH

* add qlib root path to $PYTHONPATH

* add qlib root path to $PYTHONPATH

* modify pytest root;

* remove set env

* change_pytest_command_CI

* change_pytest_command_CI

* fix_ci

* fix_ci

* fix_ci

* fix_ci

* fix_ci

* fix_ci

* fix_ci

* remove_toml

* recover_toml

---------

Co-authored-by: lijinhui <362237642@qq.com>
Co-authored-by: linlang <Lv.Linlang@hotmail.com>
2023-08-24 21:24:50 +08:00
Di
5387ea5c1f Add exploration noise to rl training collector (#1481)
* Update vessel.py

Add exploration_noise=True  to training collector

* Update vessel.py

Reformat
2023-08-18 17:41:02 +08:00
Di
05d67b3828 Add multi pass portfolio analysis record (#1546)
* Add multi pass port ana record

* Add list function

* Add documentation and support <MODEL> tag

* Add drop in replacement example

* reformat

* Change according to comments

* update format

* Update record_temp.py

Fix type hint

* Update record_temp.py
2023-08-04 17:41:12 +08:00
Linlang
38edac5069 fix docs (#1618)
Co-authored-by: Linlang <v-linlanglv@microsoft.com>
2023-08-02 20:14:54 +08:00
Fivele-Li
b4b7a2fdd4 depress warning with pandas option_context (#1524)
Co-authored-by: Cadenza-Li <362237642@qq.com>
2023-08-01 19:02:04 +08:00
JJ
480f233e3f Update introduction.rst (#1578) 2023-07-26 16:42:53 +08:00
Gene
953621ac7e Update README.md (#1553) 2023-07-26 16:38:22 +08:00
JJ
87a026fef3 Update introduction.rst (#1579)
Fixed a spelling mistake. I changed deicsions to decisions.
2023-07-26 16:37:59 +08:00
Linlang
8676303077 fix_ci (#1608)
Co-authored-by: Linlang <v-linlanglv@microsoft.com>
2023-07-19 17:33:47 +08:00
you-n-g
1a32ba1806 Bump Version & Fix CI (#1606)
* Bump Version & Fix CI

* Update test_qlib_from_pip.yml
2023-07-18 20:54:15 +08:00
you-n-g
842b8e8563 Update __init__.py 2023-07-18 19:28:17 +08:00
Linlang
7d7e96a655 Fixed pyqlib version issue on macos (#1605)
* change_publish

* Update .github/workflows/python-publish.yml

---------

Co-authored-by: Linlang <v-linlanglv@microsoft.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2023-07-18 19:25:08 +08:00
you-n-g
be4646b4b7 Adjust rolling api (#1594)
* Intermediate version

* Fix yaml template & Successfully run rolling

* Be compatible with benchmark

* Get same results with previous linear model

* Black formatting

* Update black

* Update the placeholder mechanism

* Update CI

* Update CI

* Upgrade Black

* Fix CI and simplify code

* Fix CI

* Move the data processing caching mechanism into utils.

* Adjusting DDG-DA

* Organize import
2023-07-14 12:16:12 +08:00
you-n-g
8d3adf34ac Postpone PR stale. (#1591) 2023-07-12 09:59:09 +08:00
Lewen Wang
b1dfc77ad7 Update qlibrl docs. (#1588)
* Update qlibrl docs.

* Update docs/component/rl/guidance.rst

* Update docs/component/rl/guidance.rst

* Update docs/component/rl/guidance.rst

---------

Co-authored-by: Litzy <litzy0619owned@gmail.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2023-07-07 15:40:03 +08:00
Yang
3e074c8435 fix download token (#1577) 2023-07-06 12:38:52 +08:00
Linlang
b7e5f63a07 fix_pip_ci (#1584)
* fix_pip_ci

* fix_ci_get_data_error

---------

Co-authored-by: Linlang <v-linlanglv@microsoft.com>
2023-07-05 21:23:15 +08:00
you-n-g
4db30b1225 Update README.md for RL (#1573)
* Update README.md

* Update README.md
2023-06-28 10:53:58 +08:00
you-n-g
b1e7b19a3d Update __init__.py 2023-06-27 11:55:40 +08:00
you-n-g
27f476b311 Update __init__.py 2023-06-26 00:00:46 +08:00
you-n-g
0e61cac6a8 Update release-drafter.yml (#1569)
* Update release-drafter.yml

* Update release-drafter.yml
2023-06-25 23:48:37 +08:00
Linlang
21f0b394e7 change get_data url (#1558)
* change_url

* fix_CI

* fix_CI_2

* fix_CI_3

* fix_CI_4

* fix_CI_5

* fix_CI_6

* fix_CI_7

* fix_CI_8

* fix_CI_9

* fix_CI_10

* fix_CI_11

* fix_CI_12

* fix_CI_13

* fix_CI_13

* fix_CI_14

* fix_CI_15

* fix_CI_16

* fix_CI_17

* fix_CI_18

* fix_CI_19

* fix_CI_20

* fix_CI_21

* fix_CI_22

* fix_CI_23

* fix_CI_24

* fix_CI_25

* fix_CI_26

* fix_CI_27

* fix_get_data_error

* fix_get_data_error2

* modify_get_data

* modify_get_data2

* modify_get_data3

* modify_get_data4

* fix_CI_28

* fix_CI_29

* fix_CI_30

---------

Co-authored-by: Linlang <v-linlanglv@microsoft.com>
2023-06-25 23:39:11 +08:00
Wendi Li
cd4ab998fb Update on Dynamic Benchmark (#1539)
* move config file to benchmark_dynamic & switch default sim task model to GBDT

* Update benchmark_dynamic results

* Change the default value of alpha of DDG-DA
2023-06-03 08:42:24 +08:00
you-n-g
0e9ac9dce7 Fix CI (#1529) 2023-05-31 08:39:52 +08:00
yaxuan999
efffb2819a added KRNN and Sandwich models and their example results based on Alpha360 (#1414)
* Update README.md

updated the result of KRNN and Sandwich models based on Alpha360

* Update README.md

* Update README.md

* Add files via upload

* Update README.md

* Update README.md

* Update README.md

* Add files via upload

* Delete pytorch_krnn.py

* Delete pytorch_sandwich.py

* Add files via upload

* Update pytorch_sandwich.py

* Update pytorch_krnn.py

* Update pytorch_sandwich.py

* Update pytorch_krnn.py

* Update README.md

* Update README.md

* Update requirements.txt

* Update requirements.txt

* Update README.md

* Update README.md

* Update pytorch_sandwich.py

* Update link on index

---------

Co-authored-by: Young <afe.young@gmail.com>
2023-05-26 18:42:58 +08:00
Fivele-Li
19a0eb78bc Fix TCN model input dimension mismatch (#1520)
* transpose dimension 1 and 2 to match nn.Conv1d input

* 1.update TCN benchmarks;
2.Emphasize updating the benchmark table;

* replace specific version with main

---------

Co-authored-by: lijinhui <362237642@qq.com>
2023-05-26 14:44:34 +08:00
Fivele-Li
370477288d fix_DDG-DA_workflow_bug (#1516)
* 1.specify group_keys=False to avoid FutureWarning;
2.fix get train_start from dict unexpected problem;

* fix black

* Add comments

* Add make file

---------

Co-authored-by: Young <afe.young@gmail.com>
2023-05-24 15:49:58 +08:00
you-n-g
94268619c4 Update README.md 2023-05-23 09:50:00 +08:00
Huoran Li
8d60a6a02b Resolve RL FIXMES (#1503)
* Solve several small FIXMEs left in RL

* Add TODO in example

* Minor bugfix

* black
2023-05-17 16:57:08 +08:00
Fivele-Li
7234308651 Add base config in yml (#1500)
* path on Windows contains double '/' which may cause open file failed.

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* add baseConfig in yml,user can add new keys or update/drop keys in baseConfig;

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* pip release version 23.1 on Apr.15 2023, CI failed to run, Please refer to #1495 ofr detailed logs. The pip version has been temporarily fixed to 23.0.1.

* 1.Search for baseConfig in multiple directories;
2.Add user instructions in qrun;

* fix format with black

* 1.modify baseConfig key to BASE_CONFIG_PATH;
2.only find config file in absolute path and relative path;

* load BASE_CONFIG_PATH on absolute path & relative path;

* fix Lint with black

---------

Co-authored-by: lijinhui <362237642@qq.com>
2023-05-12 17:35:37 +08:00
Chaoying
acf5df27ce Add support for redis password (#1508) 2023-05-08 16:17:15 +08:00
Chaoying
37a59f28d3 Fix deprecated syntax in numpy (#1507)
* Fix deprecated syntax in numpy

* Replace np.bool with bool
2023-05-08 16:17:02 +08:00
YQ Tsui
b084c352f5 provide dtype to empty series to surpress warning; fix type (#1449) 2023-05-05 17:47:44 +08:00
Maksim Zayakin
9e22e5168b Remove unused DNNModelPytorch params (#1470)
* Remove lr_decay and lr_decay_steps params

More flexible way to pass a scheduler (via callable function) is already
supported

* remove lr_decay and lr_decay_steps from mlp workflow configs
2023-04-28 17:48:40 +08:00
Fivele-Li
dceff7b471 Specify the tianshou version to match the dev environment to avoid the error in issue #1477. (#1502) 2023-04-28 13:50:25 +08:00
Huoran Li
7f1e8c5206 Refine Qlib RL data format (#1480)
* wip

* wip

* wip

* Fix naming errors

* Backtest test passed

* Why training stuck?

* Minor

* Refine train configs

* Use dummy in training

* Remove pickle_dataframe

* CI

* CI

* Add more strict condition to filter orders

* Pass test

* Add TODO in example

---------

Co-authored-by: Young <afe.young@gmail.com>
2023-04-26 21:14:30 +08:00
Fivele-Li
46264dfec9 normpath for Windows (#1495)
* path on Windows contains double '/' which may cause open file failed.

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* locate import numpy error

* pip release version 23.1 on Apr.15 2023, CI failed to run, Please refer to #1495 ofr detailed logs. The pip version has been temporarily fixed to 23.0.1.

---------

Co-authored-by: lijinhui <362237642@qq.com>
2023-04-26 16:26:12 +08:00
Fivele-Li
754799ab05 update ubuntu CI version; (#1488)
* update ubuntu CI version;
(End of standard support for 18.04 LTS - 31 May 2023)

* update ubuntu CI version;

---------

Co-authored-by: lijinhui <362237642@qq.com>
2023-04-10 17:06:48 +08:00
you-n-g
32c3070b73 Refine DDG-DA (#1472)
* Run ddg-da successfully

* Support include valid; More parameters

* Support L2 reg & visualization

* Blackformat

* Enable fill_method

* Support specify handler & optim dataset

* Fix Pylint
2023-04-07 15:00:21 +08:00
you-n-g
40de67265a Update Docs about some concepts in DataHandler (#1485) 2023-04-07 10:02:16 +08:00
saurabh dave
e6f9a94fc5 fix: removed extra blank link between sections (#1451) 2023-04-03 17:32:01 +08:00
Fivele-Li
73937863f1 Merge pull request #1475 from qianyun210603/bugfix
[BUGFIX] potential file// url parsing error
2023-03-24 11:22:57 +08:00
BookSword
d010219ba6 Merge branch 'main' into bugfix 2023-03-23 16:11:19 +08:00
BookSword
4fc8a5f25f merge 2023-03-23 16:05:09 +08:00
Linlang
0e8bfcb5d3 fix_pylint_w0719 (#1463)
* fix_pylint_w0719

* remove_fixme
2023-03-17 19:25:49 +08:00
you-n-g
e457ca8511 Improve annotation & documentation for handler (#1312)
* Improve annotation & documentation for handler

* Add type
2023-03-15 21:15:40 +08:00
Huoran Li
4dbb8ecb86 Remove (#1464) 2023-03-15 15:26:44 +08:00
Huoran Li
653c082e7a Order execution open source (#1447)
* Waiting for bin data

* Complete readme

* CI

* Add inst filter by time

* Update qlib/data/dataset/processor.py

* typo

* Fix time filter bug

* Add Filter and set Universe

* Complete data pipeline

* Fix Provider Logger Info Args

* Add DQN; a minor bugfix in ppo reward.

* update readme. modify assertion logic in strategy check.

* Fix Doc issues and fix black

* Fix pylint Error

---------

Co-authored-by: Young <afe.young@gmail.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2023-03-13 12:06:28 +08:00
you-n-g
f98e04ca9d Fix Field Name Error 2023-03-03 16:28:47 +08:00
Cadenza-Li
76f2fb1a1a Add ipynb format check (#1439)
* Update test_qlib_from_source.yml

* add ipynb format check to workflow

* test ipynb CI

* modify nbqa check path

* add pylint flake8 mypy check to ipynb

* check ipynb with black and pylint

* reformat .ipynb files

* format line length

nbqa black . -l 120

* update nbqa .ipynb format CI

* format old ipynb files

* add nbconvert check to CI

* adjust CI order to avoid repeating download data
2023-02-21 09:23:22 +08:00
Huoran Li
5eb5ac1f1f RL backtest pipeline on 5-min data (#1417)
* Workflow runnable

* CI

* Slight changes to make the workflow runnable. The changes of handler/provider should be reverted before merging.

* Train experiment successful

* Refine handler & provider

* test passed

* Ready to test on server

* Minor

* Test passed

* TWAP training

* Add PPOReward

* Add a FIXME

* Refine PPO reward according to PR comments

* Minor

* Resolve PR comments

* CI issues

* CI issues

* CI issues
2023-02-13 12:43:22 +08:00
Young
6295939346 Update to Dev Version 2023-01-29 18:55:23 +08:00
Young
5f3e322784 Update Version 2023-01-29 18:53:25 +08:00
you-n-g
691b7f1f60 Remove Json
Because it is a standard library of Python.
2023-01-20 09:03:08 +08:00
Huoran Li
d8fc9aea6b RL Training pipeline on 5-min data (#1415)
* Workflow runnable

* CI

* Slight changes to make the workflow runnable. The changes of handler/provider should be reverted before merging.

* Train experiment successful

* Refine handler & provider

* CI issues

* Resolve PR comments

* Resolve PR comments

* CI issues

* Fix test issue

* Black
2023-01-18 16:17:06 +08:00
YQ Tsui
d8764660dc [BUGFIX] allow sell in limit-up case and allow buy in limit-down case in topk strategy (#1407)
* 1) check limit_up/down should consider direction; 2) fix some typo, typehint etc

* fix error

* Update test_all_pipeline.py

Believe it's just some arbitrary number.
The excess return is expected to change when trading logic changes.

* add flag forbid_all_trade_at_limit to keep previous behivour for backward compatibility
2023-01-10 09:46:18 +08:00
Linlang
7f08e6c7b3 fix subprocess.check_output bug (#1409)
* fix_check_output_bug

* change_log_info

* recover_feature
2023-01-06 21:44:23 +08:00
Linlang
0f3abfed74 fix_labeler_bug (#1406) 2023-01-03 14:10:56 +08:00
Huoran Li
44ce91ee9d Simple RL notebook (#1395)
* Simple RL notebook

* Add link to the notebook

Co-authored-by: Young <afe.young@gmail.com>
2023-01-03 00:17:18 +08:00
Wendi Li
ebb8ec34f3 [DDG-DA] Update crowd-sourced data results (#1405)
* [DDG-DA] Update crowd-sourced data experiments

* Remove internal data version

* Modify README
2023-01-03 00:15:50 +08:00
YQ Tsui
4fe3ffccfd fix typo, staticmethod etc. (#1402)
* config.py: fix typo; static method

* fix typo in qlib/utils/paral

* 1) limit numpy version as numba support for 1.24+ has not been released; 2) no need to use custom numba version for pytest.

* remove useless argument

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-12-31 08:02:05 +08:00
YQ Tsui
2f5ce3dc01 Plot enhancement (#1390)
* horizontally put the bar figures

* 1) use rangebreaks to handle gaps in datetime axis instead of make them string; 2) allow simultaneously plot rankic in ic_figure

* pylint improvement

* fix black lint

* better axis formatting

* default not show gaps

* resolve doc built error

* fix pylint

* Update qlib/contrib/report/analysis_model/analysis_model_performance.py

More detailed description

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* Update qlib/contrib/report/analysis_model/analysis_model_performance.py

for Python backward compatibility

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* add doc string

* fix black

* 1) limit numpy version as numba support for 1.24+ has not been released; 2) no need to use custom numba version for pytest.

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-12-31 07:58:41 +08:00
Linlang
756bd0f65b Fix ZScoreNorm processor bug (#1398)
* fix_ZScoreNorm_bug

* fix_CI_error

* fix_CI_error

* add_test_processor

* fix_pylint_error

* fix_some_error_and_optimize_code

* modify_terrible_code

* optimize_code

* optimize_code
2022-12-30 20:42:37 +08:00
Linlang
667fb0e4d9 add label to PR Automatically (#1393)
* auto_add_label

* add md file to rule

* change name and rules

* change_label_name

* change_rule_syntax

* change match rule

* change label name
2022-12-17 00:12:33 +08:00
you-n-g
f326f83fae Remove Wrong Package Name (#1394)
* Remove Wrong Package Name

* Update requirements.txt
2022-12-16 08:10:36 +08:00
Chia-hung Tai
cbd69fb0ed The limit threshold in Taiwan stock market is also 10%. (#1391)
* The limit threshold in Taiwan stock market is also 10%.

* Warning limit_threshold when it is None.
2022-12-12 21:37:01 +08:00
YQ Tsui
5e3924d7a6 fix some typo in doc/comments (#1389)
* fix typo in docstrings

* fix typo

* fix typo

* fix black lint

* fix black lint
2022-12-11 14:29:16 +08:00
Linlang
57f9813f85 optimize_yahoo_collector (#1388) 2022-12-11 12:05:54 +08:00
Young
26d24b5b23 Bump to Dev Version 2022-12-09 18:21:39 +08:00
Young
b8bb3adbc8 Bump Qlib Version 2022-12-09 18:06:11 +08:00
Chia-hung Tai
ea10da32ba Fix warning in processor.py. (#1386)
* Fix warning in processor.py.

* Remove comment.
2022-12-08 23:47:05 +08:00
Huoran Li
577923a9f0 Fix RL example bug (#1384)
* Fix data pipeline

* Add TODO
2022-12-06 20:49:56 +08:00
Hyeongmin Moon
9d8a8c6f13 Resolve issues while running Automatic update of daily frequency data (from yahoo finance) for US region (#1358)
* Update YahooNormalizeUS1dExtend(#1196)

* Prevent pandas read_csv errors while running update_data_to_bin for US region

* Fix parse_index error while running update_data_to_bin for US region

* prevent pandas.read_csv error on specific symbol names

* Reordering parameters for better rendering

* removes prefix during feature_dir existence checking

* add explanation comments
2022-12-05 14:50:28 +08:00
you-n-g
d44175e425 Fix RL command Error (#1382) 2022-12-05 09:39:26 +08:00
Maxim Smolskiy
5b73b80293 Fix the Errors/Warnings when building Qlib's documentation (#1381)
* Fix the Errors/Warnings when building Qlib's documentation

* Fix

* Fix

* Empty

* Test CI

* Add doc compiling checking to CI

* Fix

* Tries to be consistent with Makefile

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-12-05 09:29:03 +08:00
YQ Tsui
6a47416a2d Fix logging_level: make logging level specified in qlib.init applies to all loggers (#1368)
* fix logging_level: make logging level specified in qlib.init apply to all loggers

* downgrade loglevel in expmanager __init__ to debug (it will be called in each process in multiprocessing operations such as read data)

* correct gramma error

* fix black lint

* use functor to cache loggers and set level

* correct black lint

* correct pylint

* correct pylint
2022-11-29 08:09:22 +08:00
YQ Tsui
4f5ae4d224 fix csi500 end date issue (#1373) 2022-11-28 18:06:29 +08:00
Di
7e5bab599a Add early stopping to double ensemble model, add example (#1375)
* Add early stopping to double ensemble model, add example

* Fix lint error
2022-11-28 14:02:44 +08:00
Linlang
c4ee9ff882 Fixed log_param error (#1362)
* fix_qrun_error

* add_description
2022-11-20 14:18:35 +08:00
YQ Tsui
cc01812c62 Fix typos and grammar errors in docstrings and comments (#1366)
* fix gramma error in doc strings

* fix typos in exchange.py

* fix typos and gramma errors

* fix typo and rename function param to avoid shading python keyword

* remove redundant parathesis; pass kwargs to parent class

* fix pyblack

* further correction

* assign -> be assigned to
2022-11-20 14:15:59 +08:00
Chia-hung Tai
0c4db8b0f8 Set _artifact_uri when mlflow_run is not None. (#1367)
* Set _artifact_uri when mlflow_run is not None.

* Fix black.
2022-11-19 11:56:30 +08:00
Chia-hung Tai
e47b0f1c50 Fix typo. (#1365) 2022-11-19 11:52:34 +08:00
you-n-g
994f89319d Optimize the implementation of uri & Fix async log bug (#1364)
* Optimize the implementation of uri

* remove redundant func

* Set the right order of _set_client_uri

* Update qlib/workflow/expm.py

* Simplify client & add test.Add docs; Fix async bug

* Fix comments & pylint

* Improve README
2022-11-18 13:11:31 +08:00
Maxim Smolskiy
b51e881be3 Fix the Errors with unexpected indentation when building Qlib's documentation (#1352)
* Fix ERROR: Unexpected indentation in qlib/data/dataset/handler.py

* Fix ERROR: Unexpected indentation in qlib/data/dataset/__init__.py

* Fix ERROR: Unexpected indentation in ../qlib/data/cache.py

* Fix ERROR: Unexpected indentation in qlib/model/meta/task.py

* Fix ERROR: Unexpected indentation in qlib/model/meta/dataset.py

* Fix ERROR: Unexpected indentation in qlib/workflow/online/manager.py

* Fix ERROR: Unexpected indentation in qlib/workflow/online/update.py

* Fix ERROR: Unexpected indentation in /qlib/workflow/__init__.py

* Fix ERROR: Unexpected indentation in qlib/data/base.py

* Fix ERROR: Unexpected indentation in qlib/data/dataset/loader.py

* Fix ERROR: Unexpected indentation in qlib/contrib/evaluate.py

* Fix ERROR: Unexpected indentation in qlib/workflow/record_temp.py

* Fix ERROR: Unexpected indentation in qlib/workflow/task/gen.py

* Fix ERROR: Unexpected indentation in qlib/strategy/base.py

* Fix qlib/data/dataset/handler.py

* Retest
2022-11-15 08:49:36 +08:00
Maxim Smolskiy
8802653bb9 Fix the Warnings with duplicate object description when building Qlib's documentation (#1353)
* Add :noindex: to docs/advanced/task_management.rst

* Add :noindex: to docs/component/data.rst

* Add :noindex: to docs/component/model.rst

* Add :noindex: to docs/component/online.rst

* Add :noindex: to docs/component/recorder.rst

* Add :noindex: to docs/component/report.rst

* Retest
2022-11-14 18:53:25 +08:00
Maxim Smolskiy
82afd6a67a Fix the Warnings in rst files when building Qlib's documentation (#1349)
* Fix docs/advanced/alpha.rst

* Fix docs/reference/api.rst

* Fix docs/component/strategy.rst

* Fix docs/start/integration.rst

* Fix docs/component/report.rst

* Fix docs/component/data.rst

* Fix docs/component/rl/framework.rst

* Fix docs/introduction/quick.rst

* Fix docs/advanced/task_management.rst

* Fix CHANGES.rst

* Fix docs/developer/code_standard_and_dev_guide.rst

* Fix docs/hidden/client.rst

* Fix docs/component/online.rst

* Fix docs/start/getdata.rst

* Add docs/hidden to exclude patterns

* Add docs/developer/code_standard_and_dev_guide.rst to index.rst

* Change docs/developer/code_standard_and_dev_guide.rst place in index.rst
2022-11-13 22:07:08 +08:00
qianyun210603
4001a5d157 Bug fix for Rank and WMA operators (#1228)
* bug fix: 1) 100 should be used to scale down percentileofscore return to 0-1, not length of array; 2) for (linear) weighted MA(n), weight should be n, n-1, ..., 1 instead of n-1, ..., 0

* use native pandas fucntion for rank

* remove useless import

* require pandas 1.4+

* rank for py37+pandas 1.3.5 compatibility

* lint improvement

* lint black fix

* use hasattr instead of version to check whether rolling.rank is implemented
2022-11-13 19:03:23 +08:00
He Yi
ff2154c618 fix bug in fix clip_outlier in class RobustZScoreNorm(Processor) (#1294) 2022-11-11 19:53:33 +08:00
Xu Yang
a82cc0b129 update TSDataSampler refineing the memory layout of data array to speed up NN training (#1342)
* update TSDataSampler

* reformat code with black

* use pre-commit to reformat the code

* Add documents

* More docstring

* More Safety

Co-authored-by: Young <afe.young@gmail.com>
2022-11-11 19:35:10 +08:00
you-n-g
3b471a0fe3 Fix CI (#1347) 2022-11-11 10:25:04 +08:00
you-n-g
b46bf8283d Update README.md 2022-11-10 21:15:33 +08:00
Lewen Wang
e182124e75 Add docs for qlib.rl (#1322)
* Add docs for qlib.rl

* Update docs for qlib.rl

* Add homepage introduct to RL framework

* Update index Link

* Fix Icon

* typo

* Update catelog

* Update docs for qlib.rl

* Update docs for qlib.rl

* Update figure

* Update docs for qlib.rl

* Update setup.py

* FIx setup.py

* Update docs and fix some typos

* Fix the reference to RL docs

* Update framework.svg

* Update framework.svg

* Update framework.svg

* Update docs for qlibrl.

* Update docs for qlibrl.

* Update docs for Qlibrl.

* Update docs for qlibrl.

* Update docs for qlibrl.

* Update docs for qlibrl.

* Add new framework

* Update jpg

* Update framework.svg

* Update framework.svg

* Update Qlib framework and description

* Update grammar

* Update README.md

* Update README.md

* Update docs/component/rl.rst

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* Update docs/component/rl.rst

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* Update docs for qlib.rl

* Change theme for docs.

* Update docs for qlib.rl

* Update docs for qlib.rl

* Update docs for qlib.rl

* Update docs for qlib.rl.

* Update docs for qlib.rl

* Update docs for qlib.rl

* Update docs for qlib.rl

Co-authored-by: Young <afe.young@gmail.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-11-10 21:10:44 +08:00
Huoran Li
35794846ff Refine RL todos (#1332)
* Refine several todos

* CI issues

* Remove Dropna limitation of `quote_df` in Exchange  (#1334)

* Remove Dropna limitation of `quote_df` of Exchange

* Impreove docstring

* Fix type error when expression is specified (#1335)

* Refine fill_missing_data()

* Remove several TODO comments

* Add back env for interpreters

* Change Literal import

* Resolve PR comments

* Move  to SAOEState

* Add Trainer.get_policy_state_dict()

* Mypy issue

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-11-10 21:10:11 +08:00
Jinge Wang
49a5bccfec Don't disable existing logger when initializing qlib. (#1339)
* Don't disable existing logger when initializing qlib.

* Add comma in the end of the config line.

* Add comment to the added config.

Co-authored-by: Jinge Wang <jingewang@microsoft.com>
2022-11-10 09:20:33 +08:00
lerit
59fbf23a71 fix position access error (#1267)
* fix position access error

position is s sub attribute of _value
error since commit(id:89972f6c6f9fa629b4f74093d4ba1e93c9f7a5e5)

* lint with blank
2022-11-08 10:51:43 +08:00
qianyun210603
94e420f755 Correct errors and typos in doc strings (#1338)
* add missing parameters to doc string in order_generate

* fix some typos in doc strings

* reformat base on code style standard

* Update qlib/backtest/__init__.py

* Update examples/run_all_model.py

* Update examples/run_all_model.py

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-11-07 23:37:18 +08:00
lerit
2fae407b19 Update dump_bin.py (#1273)
dump_fix data that not in calendar_list, throw error:
```
NaT is not in list
```
2022-11-04 21:15:23 +08:00
wony
67d618d4b2 Update cache.py (#1329)
make D.feature([symbol], [Feature('close')], disk_cache=1) work correctly
2022-11-03 17:08:22 +08:00
Chia-hung Tai
fb5888be9e Use mock data for element operator tests. (#1330) 2022-10-30 16:27:59 +08:00
Linlang
08de1a1874 fix_CI_error (#1325) 2022-10-22 17:32:56 +08:00
Linlang
1861c8edaf optimize_CI (#1314) 2022-10-20 08:38:05 +08:00
Huoran Li
3c62d131a5 Migrate amc4th training (#1316)
* Migrate amc4th training

* Refine RL example scripts

* Resolve PR comments

Co-authored-by: luocy16 <luocy16@mails.tsinghua.edu.cn>
2022-10-19 10:17:43 +08:00
Chao Wang
bc06f0301e Update README.md (#1279)
typo fix.
2022-10-14 11:50:19 +08:00
Chia-hung Tai
84e9df2603 Add REG_US and REG_TW into test case: test_utils.py. (#1310)
* Add REG_US and REG_TW into test case: test_utils.py.

* Fix black.

* Trigger checks.

* Add REG_US and REG_TW into test case: test_utils.py.

* Fix black.

* Trigger checks.
2022-10-14 11:49:30 +08:00
Huoran Li
216a8ec2de RL backtest with simulator (#1299)
* RL backtest with simulator

* Minor modification in init_qlib

* Cherry pick PR 1302

* Resolve PR comments

* Fix missing data processing

* Minor bugfix

* Add TODOs and docs

* Add a comment
2022-10-12 16:44:28 +08:00
Yuchen Fang
54928e956d General handler for open source data preprocessing (#1302)
* feat(data):  add a general highfreq data handler for open source

Add HighFreqOpenHandler and HighFreqOpenBacktestHandler for data pipeline without paused_num
information.

* fix: position of parameter init

* style(data): 💄 rename open to general

* style(data): 💄 lint

* style: 💄 delete useless comment & fix inheritance relation

* style: 💄 lint

* style: 💄 remove duplicated function

Co-authored-by: mingzhehan <v-zhaoxing@Microsoft.com>
2022-10-12 15:18:30 +08:00
lerit
4fa37a96bf Update __init__.py (#1287)
doc for search_records
2022-10-12 08:29:54 +08:00
Chia-hung Tai
b22ecd145b Fix typo (#1308) 2022-10-07 22:32:07 +08:00
Huoran Li
bee05f56ef Migrate backtest logic from NT (#1263)
* Backtest migration

* Minor bug fix in test

* Reorganize file to avoid loop import

* Fix test SAOE bug

* Remove unnecessary names

* Resolve PR comments; remove private classes;

* Fix CI error

* Resolve PR comments

* Refactor data interfaces

* Remove convert_instance_config and change config

* Pylint issue

* Pylint issue

* Fix tempfile warning

* Resolve PR comments

* Add more comments
2022-09-19 14:54:26 +08:00
you-n-g
e762548295 Add docs for the reampling example. (#1285)
* Update features_sample.py

* Update features_sample.py
2022-09-14 18:02:19 +08:00
Huoran Li
7c64ea5c08 Fix _update_dealt_order_amount bug. (#1291)
* Fix bug

* A weird Mypy issue
2022-09-14 14:14:20 +08:00
Chao Wang
80bf16f9a8 Expm typo fix add log (#1271)
* My own implementation of ChangeInstrument Op. There is a newer, simpler
implemenation from remote.
On branch main
Your branch is behind 'origin/main' by 127 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Changes to be committed:
       modified:   qlib/data/ops.py

Changes not staged for commit:
       modified:   qlib/contrib/evaluate.py
       modified:   qlib/contrib/strategy/signal_strategy.py
       modified:   qlib/utils/__init__.py
       modified:   qlib/workflow/cli.py
       modified:   qlib/workflow/expm.py

Untracked files:
       .idea/

------------------------ >8 ------------------------
Do not modify or remove the line above.
Everything below it will be ignored.
diff --git a/qlib/data/ops.py b/qlib/data/ops.py
index bdc032c0..23db25cc 100644
--- a/qlib/data/ops.py
+++ b/qlib/data/ops.py
@@ -32,6 +32,90 @@ except ValueError as e:

 np.seterr(invalid="ignore")

+#################### Change instrument ########################
+# In some case, one may want to change to another instrument when calculating, for example
+# calculate beta of a stock with respect to a market index
+# this would require change the calculation of features from the stock (original instrument) to
+# the index (reference instrument)
+# #############################
+
+
+class ChangeInstrument(ExpressionOps):
+    """Change Instrument Operator
+    In some case, one may want to change to another instrument when calculating, for example, to
+    calculate beta of a stock with respect to a market index.
+    This would require changing the calculation of features from the stock (original instrument) to
+    the index (reference instrument)
+    Parameters
+    ----------
+    instrument: new instrument for which the downstream operations should be performed upon.
+                i.e., SH000300 (CSI300 index), or ^GPSC (SP500 index).
+
+    feature: the feature to be calculated for the new instrument.
+    Returns
+    ----------
+    Expression
+        feature operation output
+    """
+
+    def __init__(self, instrument, feature):
+        self.instrument = instrument
+        self.feature = feature
+
+    def __str__(self):
+        return "{}({},{})".format(type(self).__name__, self.instrument, self.feature)
+
+    def load(self, instrument, start_index, end_index, freq):
+        """load  feature
+
+        Parameters
+        ----------
+        instrument : str
+            instrument code, however, the actual instrument loaded is self.instrument through initialization
+        start_index : str
+            feature start index [in calendar].
+        end_index : str
+            feature end  index  [in calendar].
+        freq : str
+            feature frequency.
+
+        Returns
+        ----------
+        pd.Series
+            feature series: The index of the series is the calendar index
+        """
+        from .cache import H  # pylint: disable=C0415
+
+        # cache
+        args = str(self), self.instrument, start_index, end_index, freq
+        if args in H["f"]:
+            return H["f"][args]
+        if start_index is not None and end_index is not None and start_index > end_index:
+            raise ValueError("Invalid index range: {} {}".format(start_index, end_index))
+        try:
+            series = self._load_internal(self.instrument, start_index, end_index, freq)
+        except Exception as e:
+            get_module_logger("data").debug(
+                f"Loading data error: instrument={instrument}, expression={str(self)}, "
+                f"start_index={start_index}, end_index={end_index}, freq={freq}. "
+                f"error info: {str(e)}"
+            )
+            raise
+        series.name = str(self)
+        H["f"][args] = series
+        return series
+
+    def _load_internal(self, instrument, start_index, end_index, freq):
+        series = self.feature.load(self.instrument, start_index, end_index, freq)
+        return series
+
+    def get_longest_back_rolling(self):
+        return self.feature.get_longest_back_rolling()
+
+    def get_extended_window_size(self):
+        return self.feature.get_extended_window_size()
+
+
 #################### Element-Wise Operator ####################

@@ -1541,6 +1625,7 @@ class TResample(ElemOperator):

 TOpsList = [TResample]
 OpsList = [
+    ChangeInstrument,
     Rolling,
     Ref,
     Max,

* update expm.py

* removed duplicate implementation for ChangeInstrument
2022-09-02 17:32:31 +08:00
you-n-g
dffaeaf07b Fix CI pylint bug (#1270)
* Fix CI pylint bug

* Update log.py
2022-08-30 08:53:57 +08:00
animic
157ef529bb update recorder.rst (#1264) 2022-08-29 17:50:51 +08:00
Linlang
ae85562a03 fix_yahoo_collector_bug (#1257) 2022-08-29 17:49:14 +08:00
Huoran Li
1d65d28b28 Qlib simulator refinement (redo of PR 1244) (#1262)
* Use dict-like configuration

* Rename from_neutrader to integration

* SAOE strategy

* Optimize file structure

* Optimize code

* Format code

* create_state_maintainer_recursive

* Remove explicit time_per_step

* CI test passed

* Resolve PR comments

* Pass all CI

* Minor test issue

* Refine SAOE adapter logic

* Minor bugfix

* Cherry pick updates

* Resolve PR comments

* CI issues

* Refine adapter & saoe_data logic

* Resolve PR comments

* Resolve PR comments

* Rename ONE_SEC to EPS_T; complete backtest loop

* CI issue

* Resolve Yuge's PR comments
2022-08-24 14:09:45 +08:00
路旁的叶修
e78fe48a26 Update signal_strategy.py (#1251) 2022-08-22 17:45:54 +08:00
OussCHE
8480407150 fixes #1187 error "Please install necessary libs for CatBoostModel." (#1246)
* Update __init__.py

* Update __init__.py
2022-08-22 17:17:07 +08:00
you-n-g
a25b736c64 Refine type hint and recorder (#1248)
* Refine type hint and recorder

* log environment automatically

* Add literal annotation

* fix type hint bug 3.7
2022-08-12 22:48:13 +08:00
Hyeongmin Moon
75aae820e8 Add simplified download command (#1234)
* Simplify the download command(microsoft#1232)

* Update simplified download instruction
2022-08-05 17:41:16 +08:00
Jinge Wang
558603beca Add csi500 benchmark for MLP model. (#1215)
* Add csi500 benchmark for MLP model.

* Update MLP metric for Alpha158 dataset.

Co-authored-by: vincilee <vincilee1994@outlook.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-08-05 16:57:40 +08:00
aprilpear
157481abd1 Add Linear model results on dataset=csi500 (#1210)
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-08-05 16:53:49 +08:00
huajunzh-msft
9d7a0f032a Add result of doubleensemble model on CSI500 (#1201)
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-08-05 16:50:26 +08:00
Ning Tang
58f9eed3c9 Update LightGBM alpha158 csi500 result (#1199)
* Update the arguments of LightGBModel

* update README table

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-08-05 16:45:54 +08:00
lcrun
8f1e28c43f Add csi500 experiment result to CatBoost (#1197)
Co-authored-by: canl@microsoft.com <canl@microsoft.com>
2022-08-05 16:43:05 +08:00
you-n-g
e7c660f0d4 More time for slow test (#1247) 2022-08-05 16:34:21 +08:00
Huoran Li
2752bdc92c Migrate NeuTrader to Qlib RL (#1169)
* Refine previous version RL codes

* Polish utils/__init__.py

* Draft

* Use | instead of Union

* Simulator & action interpreter

* Test passed

* Migrate to SAOEState & new qlib interpreter

* Black format

* . Revert file_storage change

* Refactor file structure & renaming functions

* Enrich test cases

* Add QlibIntradayBacktestData

* Test interpreter

* Black format

* .

.

.

* Rename receive_execute_result()

* Use indicator to simplify state update

* Format code

* Modify data path

* Adjust file structure

* Minor change

* Add copyright message

* Format code

* Rename util functions

* Add CI

* Pylint issue

* Remove useless code to pass pylint

* Pass mypy

* Mypy issue

* mypy issue

* mypy issue

* Revert "mypy issue"

This reverts commit 8eb1b0174e.

* mypy issue

* mypy issue

* Fix the numpy version incompatible bug

* Fix a minor typing issue

* Try to skip python 3.7 test for qlib simulator

* Resolve PR comments by Yuge; solve several CI issues.

* Black issue

* Fix a low-level type error

* Change data name

* Resolve PR comments. Leave TODOs in the code base.

Co-authored-by: Young <afe.young@gmail.com>
2022-08-01 09:56:07 +08:00
wony
687edd79d0 Update __init__.py (#1213)
# BUGFIX: remove_fields_space() function will drop Feature object field
2022-07-26 12:20:35 +08:00
Dao Zhang
ba705d39e0 add liability (#1230)
* add liability

* Update scripts/data_collector/fund/README.md

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

Co-authored-by: Dao Zhang <daoz@microsoft.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-07-26 10:41:06 +08:00
you-n-g
a53f59cdf7 Update handler.py to fix CI (#1227)
* Update handler.py

* Update handler.py
2022-07-25 10:19:09 +08:00
you-n-g
8e063828f9 Update test_qlib_from_source_slow.yml (#1222) 2022-07-22 11:15:52 +08:00
Di
86f08e47e8 Qlib data doc (#1207)
* Explain data crawler structure

* Add documentation for data and feature

* Update scripts/data_collector/yahoo/README.md

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* Remove some confusing wording

* Add third party data source

* Fix command typo

* Update commands

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-07-22 09:24:58 +08:00
EricChangMSR
8199822ca0 Update README.md fixed typo (#1221)
Changed a typo from "carefully desgined by" to "carefully designed by"
2022-07-22 09:20:55 +08:00
Yuchen Fang
1b9915501c Add data handler for order book data (#1212)
* order book

* clean hx
2022-07-20 23:33:51 +08:00
you-n-g
c65c598bde Update the math of Metrics (#1211)
* Update the math of Metrics

* Update README.md

* Update README.md
2022-07-18 21:24:56 +08:00
you-n-g
fb5779a64c Update docs of strategy (#1209) 2022-07-18 08:53:46 +08:00
Lewen Wang
d149c2b177 Use average weights in DoubleEnsemble. (#1205)
* Use average weights in DoubleEnsemble.

* Use average weights in DoubleEnsemble.

Co-authored-by: lwwang1995 <lewenwang@msrawsa02.corp.microsoft.com>
2022-07-17 23:02:46 +08:00
you-n-g
6fddae9965 Update getdata.rst 2022-07-15 17:58:23 +08:00
you-n-g
107d716cf8 Update Data Updating Docs (#1203)
* Update README.md

* Update README.md

* Update README.md
2022-07-15 14:19:02 +08:00
you-n-g
792285b64f Update data.rst 2022-07-14 18:25:23 +08:00
you-n-g
78b6b16640 Update README.md 2022-07-08 17:56:59 +08:00
you-n-g
b9bba4940f Update README.md 2022-07-08 17:56:25 +08:00
you-n-g
c34051c1ce Be compatible with Google Colab (#1188)
* Update workflow_by_code.ipynb

* Update workflow_by_code.ipynb

* Update workflow_by_code.ipynb

* Update workflow_by_code.ipynb

* Update workflow_by_code.ipynb
2022-07-08 14:23:25 +08:00
you-n-g
a0c83d7997 Add introduction for workflow_by_code.py (#1186)
* Update workflow_by_code.py

* Update workflow_by_code.py
2022-07-08 10:16:08 +08:00
you-n-g
82b10ee37a Update README.md (#1185) 2022-07-08 10:15:48 +08:00
plpycoin
9b446f9a92 Update __init__.py (#1177)
chore: bugfix, darwin also contains a "win" :), so ...
2022-07-07 20:04:24 +08:00
YaOzI
59b1820447 Add a make.bat file in docs folder for Windows (#1131)
Co-authored-by: Bingyao Liu <Bingyao.Liu@sofund.com>
2022-07-07 19:44:16 +08:00
YaOzI
1dededa33f Improve the style of documentation (#1132)
This commit improves the documentation (rst files) only in the
following three ways:

* Aligned section headers with their underline/overline punctuation characters

* Deleted all trailling whitespaces in rst files

* Deleted a few trailling newlines at the end of the rst files

Co-authored-by: Bingyao Liu <Bingyao.Liu@sofund.com>
2022-07-07 19:42:27 +08:00
Hyeongmin Moon
e62684eddf fix bug on TRA dataset (#1135)
* fix bug on TRA dataset

solve issue "qrun TRA model error (#1062)"

* apply black pylint
2022-07-07 19:33:50 +08:00
Lewen Wang
8a5efda0f6 Update README.md (#1179) 2022-07-07 00:06:47 +08:00
you-n-g
a6700d81ff Update test_qlib_from_source_slow.yml's timeout setting. (#1178)
* Update test_qlib_from_source_slow.yml

* Update test_qlib_from_source.yml

* Update test_pit.py

* Update test_pit.py

* Update test_pit.py

* Update test_pit.py
2022-07-06 20:44:10 +08:00
you-n-g
623774d8fb Update README.md 2022-07-06 17:44:16 +08:00
Chao Wang
3db22452fb Adding ChangeInstrument op (#1005)
* add ChangeInstrument to ops

Adding Change instrument OP. This op allows one to use  features of a different instrument.

* Update __init__.py

update parse_field to accommodate ChangeInstrument

* Propose test

* Add test case and fix bug

* Update ops.py

* Update ops.py

* simplify the operator further

* implement abstract method

* fix arg bug

* clean test

Co-authored-by: Young <afe.young@gmail.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-07-04 08:45:26 +08:00
you-n-g
b655f90511 Fix mount path bug (#1129)
* Fix mount path bug

* Update __init__.py
2022-07-03 21:30:08 +08:00
you-n-g
5e404909cf Add retry for git actions & Fix MacOS Segment Error (#1173)
* Update test_qlib_from_source_slow.yml

* Update test_qlib_from_source.yml

* Update test_qlib_from_source.yml

* Update test_qlib_from_pip.yml

* Update test_qlib_from_source.yml
2022-07-01 09:52:42 +08:00
Huoran Li
23c657a7a2 Backtest Mypy (#1130)
* Done

* Fix test errors

* Revert profit_attribution.py

* Minor

* A minor update on collect_data type hint

* Resolve PR comments

* Use black to format code

* Fix CI errors
2022-06-28 22:16:46 +08:00
you-n-g
9bf3423a64 Auto log uncommmitted code (#1167)
* Auto log uncommmitted code

* Support set record name & trainer;

* Update recorder.py
2022-06-28 19:53:21 +08:00
Yuge Zhang
25ecb1135f Qlib RL framework (stage 2) - trainer (#1125)
* checkpoint

(cherry picked from commit 1a8e0bd4671ee6d624a7d09bb198a273282cd050)

* Not a workable version

(cherry picked from commit 3498e185684cd5590d3ab97e0ab69eab8c1e0e3a)

* vessel

* ckpt

* .

* vessel

* .

* .

* checkpoint callback

* .

* cleanup

* logger

* .

* test

* .

* add test

* .

* .

* .

* .

* New reward

* Add train API

* fix mypy

* fix lint

* More comment

* 3.7 compat

* fix test

* fix test

* .

* Resolve comments

* fix typehint
2022-06-28 19:53:05 +08:00
Linlang
2ca0d88d2d change_pitdata_source (#1171)
* change_pitdata_source

* retain_normalize

* add_comment
2022-06-28 16:29:59 +08:00
Linlang
50d74b5560 split_CI (#1141) 2022-06-28 10:17:29 +08:00
you-n-g
a87b02619a Qlib dev doc (#1142) 2022-06-21 09:46:30 +08:00
you-n-g
da676a20a2 Add time limit for CI (#1127)
* Add time limit for CI

* Update test_macos.yml
2022-06-16 16:35:20 +08:00
you-n-g
13d904d9a9 Update Version To Dev 2022-06-15 14:53:54 +08:00
Young
36950b905d Update Qlib Version 2022-06-15 14:48:54 +08:00
you-n-g
58540f76ee Csi500 example (#1126)
* Stage code

* Update results and scripts
2022-06-15 10:18:13 +08:00
YaOzI
3e6e2865ce Fixed a few mixed Chinese punctuation typos (#1123) 2022-06-14 20:12:14 +08:00
you-n-g
3fcbaa33fa Fix hist_ref in update.py (#1096)
* Fix hist_ref in update.py

* Update setup.py
2022-06-14 11:59:43 +08:00
you-n-g
50409ff17b Add log info for ensemble (#1113)
* Add log info for ensemble

* Update ensemble.py

* Update setup.py
2022-06-14 11:58:57 +08:00
you-n-g
afcea404a5 opt local trainer (better mem releasing) (#1116)
* opt local trainer (better mem releasing)

* Update setup.py

* Update data.py

* fix CI
2022-06-14 11:58:39 +08:00
you-n-g
e24ef67663 Update README.md 2022-06-14 10:53:09 +08:00
you-n-g
2d5eecb9a2 Update README.md 2022-06-14 10:52:50 +08:00
Huoran Li
89972f6c6f Refine backtest codes (#1120)
* Refine backtest code

* Keep working

* Minor

* Resolve PR comments

* Fix import error

* Fix import error
2022-06-10 12:14:48 +08:00
Linlang
1ef8e61abd fix_pylint_for_CI (#1119)
* fix_pylint_for_CI

* reformat_with_black

* fix_pylint_C3001

* fix_flake8_error
2022-06-09 16:12:33 +08:00
you-n-g
1a4114b683 Add explanation for the evalution metrics of Qlib (#1090)
* Add explanation for the evalution metrics of Qlib

* Update evaluate.py
2022-05-31 19:37:55 +08:00
Linlang
e874ef2bc1 change_datasource (#1109)
* change_datasource

* split_test_data_and_complete_data

* fix_CI
2022-05-31 19:35:49 +08:00
Huoran Li
14b2b355a7 Update .gitignore (#1110) 2022-05-30 21:27:49 +08:00
Huoran Li
64fadff218 Add .idea/ into gitignore (#1108) 2022-05-25 13:59:35 +08:00
you-n-g
a02ac95538 add gym (#1104) 2022-05-21 23:50:18 +08:00
you-n-g
cc94c32db6 init_instance_by_config enhancement (#1103)
* fix SepDataFrame when we del it to empty

* init_instance_by_config enhancement

* Update test_sepdf.py
2022-05-21 20:16:22 +08:00
Yuge Zhang
9a40fd3cdc Qlib RL framework (stage 1) - single-asset order execution (#1076)
* rl init

* aux info

* Reward config

* update

* simple

* update saoe init

* update simulator and seed

* minor

* minor

* update sim

* checkpoint

* obs

* Update interpreter

* init qlib simulator

* checkpoint

* Refine codebase

* checkpoint

* checkpoint

* Add one test

* More tests

* Simulator checkpoint

* checkpoint

* First-step tested

* Checkpoint

* Update data_queue API

* Checkpoint

* Update test

* Move files

* Checkpoint

* Single-quote -> double-quote

* Fix finite env tests

* Tested with mypy

* pep-574

* No call for env done

* Update finite env docs

* Fix csv writer

* Refine tester

* Update logger

* Add another logger test

* Checkpoint

* Add network sanity test

* steps per episode is not correct

* Cleanup code, ready for PR

* Reformat with black

* Fix pylint for py37

* Fix lint

* Fix lint

* Fix flake

* update mypy command

* mypy

* Update exclude pattern

* Use pyproject.toml

* test

* .

* .

* Refactor pipeline

* .

* defaults run bash

* .

* Revert and skip follow_imports

* Fix toml issue

* fix mypy

* .

* .

* .

* Fix install

* Minor fix

* Fix test

* Fix test

* Remove requirements

* Revert

* fix tests

* Fix lint

* .

* .

* .

* .

* .

* update install from source command

* .

* Fix data download

* .

* .

* .

* .

* .

* .

* Fix py37

* Ignore tests on non-linux

* resolve comments

* fix tests

* resolve comments

* some typo

* style updates

* More comments

* fix dummy

* add warning

* Align precision in some system

* Added some impl notes

Co-authored-by: Young <afe.young@gmail.com>
2022-05-21 18:19:24 +08:00
you-n-g
c4281121e3 Update README.md (#1091)
* Update README.md

* Fix typo
2022-05-08 20:19:19 +08:00
Linlang
2de9903200 fix_issue_1060 (#1092)
* fix_issue_1060

* fix_import_error
2022-05-07 20:59:06 +08:00
Linlang
2cf842bcfe add_test_pit (#1089)
* add_test_pit

* add_test_pit_to_tests

* add_baostock_to_setup

* add_pip_to_CI

Co-authored-by: Linlang Lv (iSoftStone) <v-linlanglv@microsoft.com>
2022-05-06 16:47:20 +08:00
you-n-g
9e381493c2 Add instructions to add models (#1088) 2022-05-05 21:27:24 +08:00
Chia-hung Tai
a73b60d05a Update detailed_workflow.ipynb (#1084)
time_per_step bug.
2022-05-03 15:11:27 +08:00
you-n-g
64979ad769 Yahoo data Docs (#1077) 2022-04-29 17:24:53 +08:00
you-n-g
c5cf8fb9cc fix est_sepdf.py with black 2022-04-29 17:21:20 +08:00
Linlang
5d579d1a20 fix_macos_CI (#1081)
Co-authored-by: Linlang Lv (iSoftStone) <v-linlanglv@microsoft.com>
2022-04-29 17:04:28 +08:00
you-n-g
3c9c76b384 fix SepDataFrame when we del it to empty (#1082) 2022-04-29 14:29:17 +08:00
you-n-g
9d0a8f61d1 Make sepdf more like DataFrame (#1080) 2022-04-28 19:13:45 +08:00
Linlang
701b18af1b fix_issue_715 (#1070)
* fix_issue_715

* fix_issue_1065

Co-authored-by: Linlang Lv (iSoftStone) <v-linlanglv@microsoft.com>
2022-04-28 16:09:31 +08:00
Hubedge
84ff662a26 Fixed pandas FutureWarning (#1073)
* Fixed pandas FutureWarning

`FutureWarning: Passing a set as an indexer is deprecated and will raise in a future version. Use a list instead.`

* fixed another pandas FutureWarning

```
scripts/data_collector/index.py:228: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  new_df = new_df.append(_tmp_df, sort=False)
```

* fixed more pandas futurewarnings
2022-04-27 18:43:26 +08:00
金戈
00e40e775b Fixed typos in workflow.rst (#1068)
* Update workflow.rst

Fixed a typo. `please refer to Qlib Model` should be `please refer to Qlib Data` in Dataset section.

* Fix typo. `preprossing` should be `preprocessing`

* Update data.rst

Remove extra `of`.
2022-04-27 18:36:47 +08:00
code-review-doctor
45fe5e6974 Fix issue probably-meant-fstring found at https://codereview.doctor (#1072) 2022-04-25 16:12:40 +08:00
you-n-g
366a9c33f3 Bump to Dev Version 2022-04-25 16:11:47 +08:00
Young
982e0da715 Update Version 2022-04-25 00:08:08 +08:00
you-n-g
cd5e5d5235 fast fillna (#1074)
* fast fillna

* fix TSDataSampler bug
2022-04-24 23:24:32 +08:00
you-n-g
caea495f40 Update handler.py (#1044) 2022-04-22 09:16:06 +08:00
Linlang
d934c8caba fix_issue_1019_1026 (#1046)
Co-authored-by: Linlang Lv (iSoftStone) <v-linlanglv@microsoft.com>
2022-04-22 09:15:53 +08:00
wuzhe1234
a139986f4e Change Power to a NpPairOperator (#1052)
* Change Power to a NpPairOperator

* Change Power to pair operator and use black to format
2022-04-21 20:50:16 +08:00
you-n-g
12c3de42d0 Update Tutorial Notebook 2022-04-21 10:08:47 +08:00
Chia-hung Tai
fe0f9427f2 Use the region in qlib.config for FileCalendarStorage. (#1049)
* Use the region in qlib.config for FileCalendarStorage.

* Fix black.

* Make region as an optional parameter.
2022-04-20 19:20:43 +08:00
Wangwuyi123
a973e4fb66 Update test_macos.yml (#1055) 2022-04-15 18:17:16 +08:00
Wangwuyi123
c60366addd update ci with test doc (#1054) 2022-04-15 18:16:45 +08:00
you-n-g
41447f320b fix tra dataset bug (#1050) 2022-04-15 17:15:44 +08:00
you-n-g
e1271a83f7 Update setup.py (#1048) 2022-04-14 20:41:06 +08:00
Tuozhen Liu
30b531086c Fixed issue #943 about TCTS init_fore_model (#1047)
p.init_fore_model = False -> p.requires_grad = False
2022-04-14 11:23:08 +08:00
Wentao Xu
87926513cb Add the HIST and IGMTF model on Alpha360 (#1040)
* Commit the code of HIST and IGMTF on Alpha360

* add stock index

* Update README.md

* delete useless code

* fix the bug of code format with black

* fix pylint bugs

* fix the bugs of pylint

* fix pylint bugs

* fix flake8
2022-04-14 01:45:49 +08:00
plpycoin
7bfc7e1797 chore: bug-fix for crypto data collector (#1038) 2022-04-13 22:22:31 +08:00
Wangwuyi123
85e7cdcac3 Update setup.py (#1043) 2022-04-12 16:26:55 +08:00
Chao Wang
08fd1d3f42 update cli.py (#1008)
* update cli.py

update cli.py so that one can specify exp_manager uri in "qlib_init" and "experiment_name" in *.yaml file.

* black cli.py

* Resolving pre-commit-hook changes
2022-04-12 08:58:28 +08:00
you-n-g
defd6758f6 Update README.md 2022-04-11 16:06:35 +08:00
Qin Molei
61cc1a3867 Update README.md (#1039) 2022-04-10 20:57:12 +08:00
Yuchen Fang
655ed982cf Add high-frequency feature engineering code (#1022)
* highfreq data processing

* lint

* lint

* lint
2022-04-10 10:41:22 +08:00
you-n-g
2952c443ca Add Qlib notebook tutorial (#1037)
* Add Qlib notebook tutorial

* Update tutorial
2022-04-08 21:29:41 +08:00
you-n-g
7f1293ec34 Update PIT.rst 2022-04-06 22:17:27 +08:00
you-n-g
73438807f9 Add docs for CSRankNorm (#1032) 2022-04-06 19:57:27 +08:00
you-n-g
962751c72d Update README.md 2022-04-06 10:19:41 +08:00
igor17400
56cfa480dc Ibovespa index support (#990)
* feat: download ibovespa index historic composition

ibovespa(ibov) is the largest index in Brazil's stocks exchange.
The br_index folder has support for downloading new companies for the current index composition.
And has support, as well, for downloading companies from historic composition of ibov index.

Partially resolves issue #956

* fix: typo error instead of end_date, it was written end_ate

* feat: adds support for downloading stocks historic prices from Brazil's stocks exchange (B3)

Together with commit c2f933 it resolves issue #956

* fix: code formatted with black.

* wip: Creating code logic for brazils stock market data normalization

* docs: brazils stock market data normalization code documentation

* fix: code formatted the with black

* docs: fixed typo

* docs: more info about python version used to generate requirements.txt file

* docs: added BeautifulSoup requirements

* feat: removed debug prints

* feat: added ibov_index_composition variable as a class attribute of IBOVIndex

* feat: added increment to generate the four month period used by the ibov index

* refactor: Added get_instruments() method inside utils.py for better code usability.

Message in the PR request to understand the context of the change

In the course of reviewing this PR we found two issues.

    1. there are multiple places where the get_instruments() method is used,
	and we feel that scripts.index.py is the best place for the
	get_instruments() method to go.
    2. data_collector.utils has some very generic stuff put inside it.

* refactor: improve brazils stocks download speed

The reason to use retry=2 is due to the fact that
Yahoo Finance unfortunately does not keep track of the majority
of Brazilian stocks.

Therefore, the decorator deco_retry with retry argument
set to 5 will keep trying to get the stock data 5 times,
which makes the code to download Brazilians stocks very slow.

In future, this may change, but for now
I suggest to leave retry argument to 1 or 2 in
order to improve download speed.

In order to achieve this code logic an argument called retry_config
was added into YahooCollectorBR1d and YahooCollectorBR1min

* fix: added __main__ at the bottom of the script

* refactor: changed interface inside each index

Using partial as `fire.Fire(partial(get_instruments, market_index="br_index" ))`
will make the interface easier for the user to execute the script.
Then all the collector.py CLI in each folder can remove a redundant arguments.

* refactor: implemented  class interface retry into YahooCollectorBR

* docs: added BR as a possible region into the documentation

* refactor: make retry attribute part of the interface

This way we don't have to use hasattr to access the retry attribute as previously done
2022-04-06 09:01:29 +08:00
you-n-g
6edd0bf298 fix ddgda run all bug & pylint (#1031) 2022-04-03 20:43:02 +08:00
Chao Wang
fe155703b0 update doc for TopK-Drop (#1015)
updated doc for TopK-Drop.
2022-03-29 09:18:37 +08:00
Chaoying
3c4f4bfd44 Fix Chinese punctuation regex comment (#1012) 2022-03-29 09:16:21 +08:00
Linlang Lv (iSoftStone)
5200ff520a fix_download_data_for_CI 2022-03-25 16:56:02 +08:00
Linlang Lv (iSoftStone)
30e457119c add_pre-commit_and_flake8_to_CI 2022-03-25 16:56:02 +08:00
Young
243e516cf1 Add pre-commit 2022-03-25 16:56:02 +08:00
Chaoying
e229b567ad Support feature names contain Chinese punctuation (#1003) 2022-03-24 19:49:25 +08:00
you-n-g
f129bfef5d Update README.md 2022-03-24 16:21:52 +08:00
Chaoying
9dd5e07819 Add PRef operator (#988) (#1000)
* Add PRef operator (#988)

* Fix type annotations

* Add test_pref_operator test case field

* Add note to PITProvider

* Add period parameter comment
2022-03-24 15:29:08 +08:00
you-n-g
00ed35fc1b Update README.md 2022-03-23 10:47:53 +08:00
Chaoying
3f53a097b0 Fix format for PULL_REQUEST_TEMPLATE.md (#1001) 2022-03-22 18:40:30 +08:00
you-n-g
fb230a8097 Update README.md 2022-03-22 09:22:30 +08:00
you-n-g
ff4724e248 Known Limitations In Recroder (#999) 2022-03-22 09:21:48 +08:00
Chia-hung Tai
73d90f7f44 Add lightgbm min version. (#995)
See https://github.com/microsoft/LightGBM/pull/4604
2022-03-21 08:00:28 +08:00
you-n-g
b7988e6428 Add backtest example to online simulation (#984) 2022-03-19 01:53:14 +08:00
Chauncey
8efc8b92ef Optimize the pit collector script (#982)
* Optimize the pit collector script

* Add copyright notice to collector.py

* Remove unnecessary parameters for test_pit.py

* Update test_pit.py

* Update test_pit.py
2022-03-18 21:51:36 +08:00
Chauncey
f2a5ecd98a Fix comment typo (#987) 2022-03-17 19:25:15 +08:00
Linlang
705354cc28 fix-issue948 (#986)
Co-authored-by: Linlang Lv (iSoftStone) <v-linlanglv@microsoft.com>
2022-03-17 19:24:17 +08:00
you-n-g
1b5d0d4d6d Update report.rst (#980) 2022-03-15 21:30:50 +08:00
you-n-g
f4a481945b Update README.md (#981) 2022-03-15 20:40:52 +08:00
Chauncey
5f18ba7970 Fix pit download_data script TypeError (#978) (#979)
* Fix pit download_data script TypeError (#978)

* Format pit collector with black

* Format pit collector with black
2022-03-15 14:02:14 +08:00
you-n-g
2681c61c60 Fix log object bug (#977) 2022-03-14 17:33:13 +08:00
Chia-hung Tai
776b0c5bb4 Skip idx.is_lexsorted() when pandas version is larger than 1.3.0. (#973)
* Skip idx.is_lexsorted() when pandas version is larger than 1.3.0. The future warning is annoying.

* Skip idx.is_lexsorted() when pandas version is larger than 1.3.0. The future warning is annoying.

* Rewrite code.
2022-03-13 23:24:54 +08:00
Chia-hung Tai
829ad9f5e9 Use callback in LGBM.train. (#974) 2022-03-13 11:20:18 +08:00
you-n-g
921c13cc90 safe remove file and more friendly log (#967)
* save remove file and more friendly log

* fix pylint
2022-03-13 11:11:41 +08:00
Wangwuyi123
0f519f6053 Update yahooquery marked words (#966)
* Update collector.py

* Update collector.py

* Update collector.py

* Update collector.py

* Update collector.py

* Update collector.py

* Update collector.py

* Update collector.py

* Update collector.py

* Update scripts/data_collector/yahoo/collector.py

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* Update collector.py

* Update collector.py

* Update collector.py

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-03-12 20:49:38 +08:00
you-n-g
2ed806c846 Remove redundant import [fix pylint] (#962) 2022-03-11 12:15:37 +08:00
Jiabao Qu
d2f0bebf60 feat: add instrument context to inst_processor (#959)
* feat: add context to data loader

* refactor: add instrument to interface of InstProcessor

Co-authored-by: Jiabao Qu <qujiabao@logiocean.com>
2022-03-11 12:15:13 +08:00
you-n-g
615a381038 Merge pull request #938 from SunsetWolf/fix-csi500
Fix csi500
2022-03-11 12:09:22 +08:00
bxdd
568a88fddb fix cn annotation in PIT script (#958) 2022-03-11 10:15:20 +08:00
Chauncey
058f976727 Fix pit docs format (#957)
* Fix pit docs list format

* Fix pit docs format
2022-03-11 10:13:31 +08:00
bxdd
faa99f30fa Support Point-in-time Data Operation (#343)
* add period ops class

* black format

* add pit data read

* fix bug in period ops

* update ops runnable

* update PIT test example

* black format

* update PIT test

* update tets_PIT

* update code format

* add check_feature_exist

* black format

* optimize the PIT Algorithm

* fix bug

* update example

* update test_PIT name

* add pit collector

* black format

* fix bugs

* fix try

* fix bug & add dump_pit.py

* Successfully run and understand PIT

* Add some docs and remove a bug

* mv crypto collector

* black format

* Run succesfully after merging master

* Pass test and fix code

* remove useless PIT code

* fix PYlint

* Rename

Co-authored-by: Young <afe.young@gmail.com>
2022-03-10 14:27:52 +08:00
Linlang Lv (iSoftStone)
837067b9e1 fix-csi500 2022-03-09 23:03:28 +08:00
Chia-hung Tai
3a911bc09b Add REG_TW. (#955) 2022-03-08 23:48:27 +08:00
you-n-g
90be21bb40 Change to Dev Version 2022-03-08 22:32:28 +08:00
Young
7540b1257b update version 2022-03-08 22:21:24 +08:00
Chia-hung Tai
57f7ed9914 [949] - Remove argument internal in BaseRun::download_data. (#953)
* [949] - Remove argument internal in BaseRun::download_data.

* Fix black.

* Fix bug.
2022-03-08 10:26:35 +08:00
Chao Wang
9e3d0249f7 fix bug (#950)
fix bug in  elif isinstance(self.N, float) and 0 < self.N < 1:
2022-03-06 23:42:31 +08:00
cuicorey
2ac964c470 Fix error message in position.py (#922)
* Update position.py

* Update position.py

fix CI error
2022-03-06 23:42:02 +08:00
Chia-hung Tai
07f0d4f599 [930] Fix typo HasingStockStorage to HashingStockStorage. (#947) 2022-03-04 12:40:04 +08:00
Chia-hung Tai
ea4fb33ff2 Fix wrong error messages. (#946) 2022-03-03 14:33:24 +08:00
you-n-g
ed0c238787 Update initialization.rst 2022-03-02 21:39:44 +08:00
Linlang
80af395b3c Update initialization.rst (#941) 2022-03-02 20:51:37 +08:00
Chia-hung Tai
4dc66932d5 [931] Remove mutable default argument. (#932) 2022-02-28 18:37:46 +08:00
Linlang Lv (iSoftStone)
40dd84857c update-csi500 2022-02-28 03:48:07 +08:00
BigTreei
74cc21fc2c add CSI500 data collector 2022-02-28 03:33:36 +08:00
you-n-g
ec8969a3ae Update initialization.rst 2022-02-23 12:10:17 +08:00
you-n-g
528f74af09 performance mprovement (#921)
* performance mprovement

* memory refine
2022-02-19 18:36:23 +08:00
you-n-g
d482726f28 Update README.md (#920) 2022-02-19 00:46:32 +08:00
you-n-g
cfc3e886ed Add data analysis feature for report (#918)
* Add data analysis feature for report

* better display
2022-02-17 08:24:42 +08:00
you-n-g
60d45ad770 Enhance pytorch nn (#917)
* enhance pytorch_nn

* fix dim bug

* Black format

* Fix pylint error
2022-02-15 19:22:48 +08:00
Wendi Li
0e8b94a552 Update README.md (#915)
Add the memory and disk requirement of DDG-DA.
2022-02-15 09:27:51 +08:00
you-n-g
4bf127eba5 Some links about high-frequency trading (#884)
* Some links about high-frequency trading

* Update highfreq.rst

* Update highfreq.rst

* Update highfreq.rst
2022-02-13 20:22:05 +08:00
you-n-g
c149c8616c Update strategy.rst 2022-02-12 23:10:46 +08:00
you-n-g
3274e16c95 Support Reweighter for HighFreq Model (#908) 2022-02-07 21:45:53 +08:00
you-n-g
d496cf7476 Update Portfolio README.md (#900)
* Update README.md

* Update README.md
2022-02-07 16:04:11 +08:00
you-n-g
357ee74b6f Update pytorch_lstm_ts.py 2022-02-07 00:05:49 +08:00
aurora5161
5da5cf5175 add weight param (#907) 2022-02-06 22:34:00 +08:00
Young
6a946761cf Black(new version) Format 2022-02-06 22:33:16 +08:00
you-n-g
76b7b5f24b Update README.md 2022-02-01 12:32:28 +08:00
dependabot[bot]
d7d19feb4e Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/TabNet (#898)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-27 11:17:01 +08:00
dependabot[bot]
bba6972a55 Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/Transformer (#897)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-27 11:16:54 +08:00
dependabot[bot]
18af288692 Bump numpy from 1.17.4 to 1.21.0 in /examples/hyperparameter/LightGBM (#896)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-27 11:16:48 +08:00
dependabot[bot]
ba056850cb Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/XGBoost (#895)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-27 11:16:41 +08:00
you-n-g
aed5b8ebc0 Update Benchmark Docs (#899)
* Update README.md

* Update README.md

* Update README.md
2022-01-27 11:16:24 +08:00
you-n-g
79355666a9 Docs improvement of backtest (#885)
* Docs improvement of backtest

* Update strategy.rst
2022-01-26 19:59:59 +08:00
SunsetWolf
144e1e2459 Fix pylint (#888)
* add_pylint_to_workflow

* fix-pylint

* fix_pylinterror

* fix-issue
2022-01-26 19:27:24 +08:00
you-n-g
635632e4ed Update handler processors docs (#879)
* Update handler.py

* Update handler.py

* Update handler.py
2022-01-25 11:28:23 +08:00
you-n-g
c5834476e2 expression example (#887) 2022-01-25 10:49:00 +08:00
you-n-g
01afd06e18 fix workflow bug (#882)
* fix workflow bug

* Fix output of pytorch NN

* Fix parameter bug
2022-01-22 10:18:37 +08:00
you-n-g
d533219738 Update data.rst (#878) 2022-01-21 14:08:59 +08:00
you-n-g
5b5c99fe75 Add more docs about initialization (#880)
* Add more docs about initialization

* Update initialization.rst
2022-01-21 14:08:04 +08:00
you-n-g
da48f42f3f Make the logic of handler Clear (#877) 2022-01-20 22:36:28 +08:00
you-n-g
f979dcf5e8 Update __init__.py 2022-01-20 22:35:57 +08:00
you-n-g
97aa16a078 Update __init__.py 2022-01-20 02:02:56 +08:00
you-n-g
094be9be86 Update python-publish.yml 2022-01-20 01:56:35 +08:00
you-n-g
d9b9386032 Update __init__.py 2022-01-20 01:49:53 +08:00
Young
b86a30aae7 Bump to 0.8.2 2022-01-20 01:43:26 +08:00
you-n-g
2c5a4691f3 fall back error (#875) 2022-01-20 01:39:24 +08:00
you-n-g
54344c4426 Update config.py (#871) 2022-01-19 19:51:36 +08:00
you-n-g
303cdb8ce3 update required package for test 2022-01-19 13:10:46 +08:00
you-n-g
1a0ac1ab6d Remove arctic from Qlib core to Contrib (#865)
* Remove arctic from Qlib core to Contrib

* fix empty df bug
2022-01-19 10:39:37 +08:00
Wangwuyi123
a79e446724 Update README.md (#863) 2022-01-19 09:57:11 +08:00
you-n-g
bdf1fb29a6 Fix pytorch_nn.py step bug (#864)
* Update pytorch_nn.py

* Update pytorch_nn.py
2022-01-18 22:39:19 +08:00
dependabot[bot]
86e1265f69 Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/ADARNN (#870)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:17:25 +08:00
dependabot[bot]
628eb7fa73 Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/ADD (#869)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:17:15 +08:00
dependabot[bot]
2a1b512cd2 Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/ALSTM (#868)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:17:04 +08:00
dependabot[bot]
50e7901e87 Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/CatBoost (#867)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:16:47 +08:00
dependabot[bot]
3ba54cd1ab Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/DoubleEnsemble (#866)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:16:23 +08:00
dependabot[bot]
483d01f0c1 Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/GRU (#833)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:16:13 +08:00
dependabot[bot]
61836cba3d Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/LightGBM (#830)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:16:03 +08:00
dependabot[bot]
aeb5e40c77 Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/SFM (#829)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:14:50 +08:00
dependabot[bot]
116f0fa7a7 Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/TCTS (#834)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:13:57 +08:00
dependabot[bot]
5296cce725 Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/GATs (#831)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:13:29 +08:00
dependabot[bot]
292fcc9e98 Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/TRA (#832)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:13:23 +08:00
dependabot[bot]
d3fbf066cf Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/Localformer (#835)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:13:06 +08:00
dependabot[bot]
52ecb79e0b Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/MLP (#836)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:12:57 +08:00
dependabot[bot]
59c52eac0a Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/TCN (#837)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:12:42 +08:00
dependabot[bot]
f455305a2a Bump numpy from 1.17.4 to 1.21.0 in /examples/benchmarks/LSTM (#838)
Bumps [numpy](https://github.com/numpy/numpy) from 1.17.4 to 1.21.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt)
- [Commits](https://github.com/numpy/numpy/compare/v1.17.4...v1.21.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 22:12:34 +08:00
you-n-g
a67f67db6e Update README.md 2022-01-18 10:20:07 +08:00
you-n-g
5c2e99aee3 Update .readthedocs.yml 2022-01-18 09:25:30 +08:00
luocy16
2bb8a4ce0e Supporting Arctic Backend Provider & Orderbook, Tick Data Example (#744)
* change weight_decay & batchsize

* del weight_decay

* big weight_decay

* mid weight_decay

* small layer

* 2 layer

* full layer

* no weight decay

* divide into two data source

* change parse field

* delete some debug

* add Toperator

* new format of arctic

* fix cache bug to arctic read

* fix connection problem

* add some operator

* final version for arcitc

* clear HZ cache

* remove not used function

* add topswrappers

* successfully import data and run first test

* A simpler version to support arctic

* Successfully run all high-freq expressions

* Black format and fix add docs

* Add docs for download and test data

* update scripts and docs

* Add docs

* fix bug

* Refine docs

* fix test bug

* fix CI error

* clean code

Co-authored-by: bxdd <bxddream@gmail.com>
Co-authored-by: wangwenxi.handsome <wangwenxi.handsome@gmail.com>
Co-authored-by: Young <afe.young@gmail.com>
2022-01-18 09:13:11 +08:00
you-n-g
7f274b1e4e Fix code and docs for issues (#853)
* Docs for model and strategy

* add some docs about workflow and online

* safe_load yaml

* DDG-DA paper link and comments for code
2022-01-17 13:57:44 +08:00
Pengrong Zhu
2aee9e0145 Add future calendar collector (#795)
* fix Windows mount

* add future_calendar_collector

* update docs

Co-authored-by: Young <afe.young@gmail.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2022-01-16 10:14:27 +08:00
you-n-g
a62e2ec4de Update __init__.py 2022-01-15 23:07:31 +08:00
Young
e7954bdb32 update version 2022-01-15 22:49:14 +08:00
you-n-g
d6f69aefea Update data.rst 2022-01-15 19:22:31 +08:00
you-n-g
1bebe9780e Fix the read the docs error (#852) 2022-01-15 19:15:06 +08:00
you-n-g
7a4a92bc69 Update data.rst 2022-01-14 13:17:52 +08:00
you-n-g
271782c9dd Update data.rst 2022-01-14 09:19:12 +08:00
you-n-g
d0113ea7df pylint code refine & Fix nested example (#848)
* refine code by CI

* fix argument error

* fix nested eample
2022-01-14 09:09:21 +08:00
you-n-g
c3996955ef Update README.md 2022-01-13 15:29:43 +08:00
Jiabao Qu
8261965015 fix: highfreq_gdbt_model of prepare data (#846)
Co-authored-by: Jiabao Qu <qujiabao@logiocean.com>
2022-01-12 21:36:23 +08:00
Jiabao Qu
6f71f8a46b chore: remove hard code input dimension of model pytorch_tcts (#843)
Co-authored-by: Jiabao Qu <qujiabao@logiocean.com>
2022-01-12 19:12:20 +08:00
Chia-hung Tai
edd8badeaf [840] - Test case for operators. (#841)
* [840] - Test case for operators.

* Move import to the head of file and add test_setting.
2022-01-11 18:44:15 +08:00
Young
19689024d4 Fix exp uri CI bug 2022-01-10 17:29:27 +08:00
you-n-g
0304df0d5b Update README.md 2022-01-10 16:56:18 +08:00
Young
181ee3c070 FIX File Name 2022-01-10 16:55:20 +08:00
you-n-g
cf35562e84 DDG-DA paper code (#743)
* Merge data selection to main

* Update trainer for reweighter

* Typos fixed.

* update data selection interface

* successfully run exp after refactor some interface

* data selection share handler &  trainer

* fix meta model time series bug

* fix online workflow set_uri bug

* fix set_uri bug

* updawte ds docs and delay trainer bug

* docs

* resume reweighter

* add reweighting result

* fix qlib model import

* make recorder more friendly

* fix experiment workflow bug

* commit for merging master incase of conflictions

* Successful run DDG-DA with a single command

* remove unused code

* asdd more docs

* Update README.md

* Update & fix some bugs.

* Update configuration & remove debug functions

* Update README.md

* Modfify horizon from code rather than yaml

* Update performance in README.md

* fix part comments

* Remove unfinished TCTS.

* Fix some details.

* Update meta docs

* Update README.md of the benchmarks_dynamic

* Update README.md files

* Add README.md to the rolling_benchmark baseline.

* Refine the docs and link

* Rename README.md in benchmarks_dynamic.

* Remove comments.

* auto download data

Co-authored-by: wendili-cs <wendili.academic@qq.com>
Co-authored-by: demon143 <785696300@qq.com>
2022-01-10 16:52:37 +08:00
Chia-hung Tai
184ce34a34 [807] Move the REG_CONSTANT/EPS to constant.py. (#811)
* [807] Move the REG_CONSTANT to constant.py.

* import REG_US.

* Move EPS to constant.py.
2022-01-09 21:39:46 +08:00
Chia-hung Tai
382ababc01 Add description of the pu template. (#812) 2022-01-09 21:14:11 +08:00
Chia-hung Tai
bcf18c14de Fix typos and comments. (#815)
* Fix typos and comments.

* Add comma before and.
2022-01-09 21:13:25 +08:00
Chia-hung Tai
6c1332f604 Fix some warnings in log.py. (#805)
* Fix some warnings in log.py.

* Fix typo and using black format.

* Fix black.

* Rename dict_ to attrs
2022-01-06 15:36:00 +08:00
you-n-g
93088485c3 Update README.md (#802)
* Update README.md

* Update README.md

* Update README.md

* Update README.md
2022-01-04 19:16:04 +08:00
Chia-hung Tai
c633d3fec0 Fix BaseStrategy path. (#801)
qlib.strategy.base.BaseStrategy is the current path.
2022-01-04 18:55:40 +08:00
you-n-g
0b6d99bd38 Add a more understandable example of data workflow (#797)
* Update data.rst

* Update data.rst
2022-01-04 09:07:44 +08:00
you-n-g
03cce8c908 Some Optimization of online code (#784)
* Some Optimization of online code

* more flexible updater and load_object & fix p*_uri

* make recorder more friendly

* remove unused import
2022-01-03 15:52:03 +08:00
安阁锐
e76b409d9a Fix $volume normalization issue (#792)
* Fix $volume normalization issue

Fix: https://github.com/microsoft/qlib/issues/765

* black formatting

black formatting

* black formatting

black formatting

* black formatting

black formatting
2022-01-01 23:44:17 +08:00
Arthur Cui
3e79a088ef Add Crypto dataset from coingecko (#733)
* add crypto symbols collectors

* add crypto data collector

* add crypto symbols collectors

* add crypto data collector

* solver region and source problem

* fix merge

* fix merge

* clean all cn information

Co-authored-by: DefangCui <170007807@pku.edu.cn>
2021-12-31 22:24:26 +08:00
SunsetWolf
dfc0ed3c01 fix_typo (#790)
Signed-off-by: unknown <lv.linlang@qq.com>
2021-12-31 22:14:47 +08:00
you-n-g
f59cfe51e0 Fix account shared bug (#791)
* Fix account shared bug

* fix bug in nested executor
2021-12-31 15:56:21 +08:00
Pengrong Zhu
1ecdfd45fe fix dump_bin:DumpDataUpdate (#783) 2021-12-29 09:29:08 +08:00
Chao Ning
622303b83a add map_location to torch.load to make it work when cuda is unavailable (#782) 2021-12-29 00:02:04 +08:00
Chao Ning
6bafd0a09b Reformat example data names: use {region}_data for 1-day data, and {region}_data_1min for 1-min data (#781)
* Fix high-freq data name from `yahoo_cn_1min` to `cn_data_1min`

* re-format example data names using `qlib_{region}_{feq}`, e.g. qlib_cn_1d

* re-format example data names using `{region}_{feq}`, e.g. us_1d and cn_1min

* keep using  for 1day data, and change 1min data to
2021-12-28 23:58:49 +08:00
you-n-g
aed9c09091 Update news 2021-12-28 19:54:30 +08:00
Dong Zhou
1b8f0b4575 support optimization based strategy (#754)
* support optimization based strategy

* fix riskdata not found & update doc

* refactor signal_strategy

* add portfolio example

* Update examples/portfolio/prepare_riskdata.py

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* fix typo

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* fix typo

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* update doc

* fix riskmodel doc

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2021-12-28 18:44:20 +08:00
you-n-g
4709909782 Add hook for supporting RL strategy (#768) 2021-12-27 12:16:36 +08:00
Pengrong Zhu
a0f49fe2e7 fix cn_index collector (#780) 2021-12-26 14:12:48 +08:00
you-n-g
2840570dd3 Fix Typo in README.md 2021-12-26 00:42:16 +08:00
you-n-g
00ad122175 Update Contributor list (#779) 2021-12-26 00:25:03 +08:00
you-n-g
3493f29e16 Enhance Task Dict Var (#778) 2021-12-26 00:18:44 +08:00
you-n-g
e33de44cb9 Update Docs of Alpha360 (#777) 2021-12-25 18:07:44 +08:00
Chia-hung Tai
e843e021a2 Use encoding="utf-8" in open. (#773) 2021-12-25 18:00:56 +08:00
Chia-hung Tai
5aa5a6f356 Replace scripts/get_data.py to get_data.py. (#775)
For the consitency in this page, replace scripts/get_data.py to get_data.py.
2021-12-25 16:12:04 +08:00
Chia-hung Tai
f490708025 Fix typo leanable to learnable. (#774) 2021-12-25 16:07:40 +08:00
you-n-g
41a5778684 Update strategy.rst
Add docs for the prediction score
2021-12-25 15:24:58 +08:00
you-n-g
ef161715f7 Add docs about the patameters (#771) 2021-12-24 15:26:27 +08:00
you-n-g
d087054a59 Add Cache to avoid frequently loading calendar (#766) 2021-12-23 09:08:52 +08:00
cuicorey
350fbe91c9 Change BCELoss in MLP model (#756) 2021-12-20 19:03:33 +08:00
you-n-g
2aca74cd21 Black Format 2021-12-20 18:21:31 +08:00
you-n-g
92ff3d20b9 Update processor.py 2021-12-20 18:18:59 +08:00
you-n-g
0552120a2e Update documents for qlib_uri 2021-12-20 14:18:53 +08:00
you-n-g
3480fd932f Update README.md 2021-12-18 12:29:36 +08:00
Pengrong Zhu
957f9a18e9 fix IndexError of the last trading day in backtest calendar (#751) 2021-12-17 11:11:56 +08:00
you-n-g
6c83632fc4 Update README.md 2021-12-14 18:13:04 +08:00
Arthur Cui
125922b77a solve VERSION.txt bug (#732)
* solve VERSION.txt bug

* back to main version

* change setup and init to follow pypi type

* add read function

* solve black format

Co-authored-by: DefangCui <170007807@pku.edu.cn>
2021-12-12 12:02:20 +08:00
Pengrong Zhu
5e69d089c0 add description of dataset document (#742) 2021-12-12 09:49:10 +08:00
Pengrong Zhu
c10c349b20 remove unneeded code from workflow_by_code.ipynb && fix analysis_model_performance (#740) 2021-12-11 13:23:00 +08:00
upgradvisor-bot
7cb1f7cee0 Hyperopt upgrade (#741)
* Upgrade hyperopt

* Do not use newly added progress bar

Co-authored-by: Raphael Sofaer <rsofaer@gmail.com>
2021-12-11 12:37:08 +08:00
you-n-g
d0ff5eea9d Update README.md 2021-12-10 17:39:15 +08:00
you-n-g
e99f00b445 Add method parameter for volume (#734) 2021-12-09 10:45:25 +08:00
you-n-g
e50ad4309e Update news 2021-12-08 10:24:58 +08:00
Young
d89ae2370f update version to dev 2021-12-08 08:25:28 +08:00
Young
ee3d4092ae release 0.8.0 2021-12-08 07:32:03 +08:00
you-n-g
ae83f9056f docs improvement (#730) 2021-12-07 21:45:29 +08:00
Pengrong Zhu
c276de4040 Fix backtest (#719)
* modify FileStorage to support multiple freqs

* modify backtest's sample documentation

* change the logging level of read data exception from error to debug

* fix the backtest exception when volume is 0 or np.nan

* fix test_storage.py

* add backtest_daily

* modify backtest_daily's docstring

* add __repr__/__str__ to Position

* fix the bug of nested_decision_execution example

Co-authored-by: Young <afe.young@gmail.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2021-12-07 19:04:23 +08:00
you-n-g
84103c7d43 Fix update record bug(#723) 2021-12-03 10:03:30 +08:00
you-n-g
6d6c586dc2 Update data crawler 2021-11-28 13:44:49 +08:00
you-n-g
54ef18ec4e Update the docs ops.py (#718)
* Update ops.py

* Update ops.py
2021-11-26 18:15:44 +08:00
demon143
0dfbf8c413 add logger (#709)
* Add files via upload

* Update README.md

* Update README.md

* Update README.md

* Delete change doc.gif

* Add files via upload

* Update README.md

* Delete change doc.gif

* Add files via upload

* Delete change doc.gif

* Add files via upload

* Update README.md

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* Add files via upload

* Delete Task-Gen-Recorder-CollectorV3.drawio (2).drawio.svg

* Add files via upload

* Delete Task-Gen-Recorder-CollectorV3.drawio.drawio.svg

* Add files via upload

* Delete Task-Gen-Recorder-CollectorV3.drawio.drawio (1).svg

* Add files via upload

* Delete Task-Gen-Recorder-CollectorV3.drawio (2).drawio (1).svg

* Add files via upload

* Delete Task-Gen-Recorder-CollectorV3.drawio (1).drawio (1).svg

* Add files via upload

* Add files via upload

* Delete Task-Gen-Recorder-CollectorV3.drawio (1).svg

* Delete Task-Gen-Recorder-Collector.svg

* Update manage.py

* Update utils.py

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2021-11-23 17:29:02 +08:00
cslwqxx
f9c35284e1 Update README.md 2021-11-23 15:58:32 +08:00
you-n-g
3974bfe746 Add SigAnaRecord in to workflow_by_code.py (#707)
* Update workflow_by_code.py

* Update workflow_by_code.py
2021-11-23 12:37:50 +08:00
you-n-g
45ebb1d0e0 support adding from date when updating pred (#703)
* support adding from date when updating pred

* fix updating data error
2021-11-22 19:52:52 +08:00
you-n-g
103f8579c1 Update README.md 2021-11-22 18:19:16 +08:00
fengcunguang
654033733d Add A New Baseline: ADD (#704) 2021-11-22 18:16:50 +08:00
Pengrong Zhu
d224ea447e Fix high-freq data (#702)
* fix the collector.py yahoo 1min factor calculation

* fix HFSignalRecord
2021-11-20 15:03:53 +08:00
demon143
9265b66e09 Update task_management.rst (#700) 2021-11-18 18:23:43 +08:00
you-n-g
d4b56d97b5 Update __init__.py 2021-11-18 18:22:09 +08:00
Chao Wang
0b3b95f22f Update workflow_by_code.ipynb (#697)
changed model_strategy to signal_stragey. there is no model_strategy under qlib.contrib.strategy.
2021-11-18 09:21:45 +08:00
demon143
0596174b94 Update task_management.rst (#654)
* Update task_management.rst

* Update task_management.rst

* Update task_management.rst

* Update task_management.rst

* Update task_management.rst

* Update task_management.rst

* Update task_management.rst

* Update task_management.rst

* Update task_management.rst

* Update task_management.rst

* Update task_management.rst

* Add files via upload
2021-11-18 09:20:54 +08:00
you-n-g
779b1786bd Merging Backtest improve (#694)
* Fix private import

* temporarily fix create exp conflicts for remote mlflow

Co-authored-by: Dong Zhou <Zhou.Dong@microsoft.com>
2021-11-16 11:43:35 +08:00
Lewen Wang
007082a112 Add AdaRNN baseline. (#689)
* Update TCTS.

* Update TCTS README.

* Update TCTS README.

* Update TCTS.

* Add ADARNN.

* Update README.

* Reformat ADARNN.

* Add README for adarnn.

Co-authored-by: lewwang <lwwang@microsoft.com>
2021-11-16 11:24:43 +08:00
you-n-g
4e380b611e Delete .DS_Store 2021-11-14 23:54:20 +08:00
Young
1e410c99be Support auto skip flawed data 2021-11-13 07:44:26 +00:00
Pengrong Zhu
b223c4304d add ops_warning_log to config (#685) 2021-11-12 22:23:29 +08:00
you-n-g
f2771f1beb Callable Exp (#683) 2021-11-12 14:56:22 +08:00
Ckend
01bdf6c1b1 bugfix: Fix the problem that caused highfreq's yaml to be unusable (#678) 2021-11-10 22:32:58 +08:00
Pengrong Zhu
9639a8cac9 add default protocol_version (#677)
* add default protocol_version

* add comment to serial.Serializable.get_backend
2021-11-10 14:37:18 +08:00
you-n-g
cae4c9c924 An example to get index from TSDataSampler (#679) 2021-11-10 14:35:27 +08:00
you-n-g
a2be6e28e9 handler demo cache (#606)
* handler demo  cache

* Update data_cache_demo.py

* example to reusing processed data in memory

* Skip dumping task of task_train

* FIX Black

Co-authored-by: Wangwuyi123 <51237097+Wangwuyi123@users.noreply.github.com>
2021-11-08 17:33:10 +08:00
you-n-g
fdbc666678 Fix private import 2021-11-08 09:53:58 +08:00
you-n-g
7800dd4ec9 Merge pull request #650 from microsoft/backtest_improve
Improve the backtest design and APIs
2021-11-08 09:10:33 +08:00
Young
3fa48d7017 simplify record tmp 2021-11-05 12:57:14 +00:00
Mark Zhao
b18132dce1 More citations (#673)
* check lexsort

* check lexsort

* lexsort comment

* lexsort comment

* fix GPU identification bug

* Create README.md

* Update README.md

* Create README.md

* Create README.md

* Update README.md

* Create README.md

* Update README.md

* Update README.md

* Create README.md

* Create README.md

* Create README.md
2021-11-05 19:43:50 +08:00
you-n-g
16957176a9 Update README.md
Update  benchmark link
2021-11-05 13:00:32 +08:00
fengcunguang
f0b9a807ea Add A New Baseline: TCN (#668) 2021-11-04 20:30:52 +08:00
Mark Zhao
5ee2d9496b GPU identification bug fix for GATs (#669)
* check lexsort

* check lexsort

* lexsort comment

* lexsort comment

* fix GPU identification bug
2021-11-03 14:41:46 +08:00
Young
4f2d6b0d84 fix pytorch memory amount error 2021-11-02 20:41:39 +08:00
Young
3943b7001f fix CI bug for AyncCaller 2021-11-02 14:32:09 +08:00
Young
2593185721 Simplify TSDataset and async recorder 2021-11-02 11:07:40 +08:00
Young
7a884fa9f2 remove redundant file only when remote artifact 2021-11-01 18:55:44 +08:00
Dong Zhou
d929d4bb21 rm recorder temp file 2021-11-01 09:29:44 +00:00
Young
e54b019ee2 solve init kwargs conflictions 2021-11-01 06:22:25 +00:00
Young
426b98a3bc make the logic of online manager cleaner 2021-11-01 02:40:54 +00:00
Young
82f8ff9066 Update seperate dataframe 2021-11-01 00:51:21 +08:00
you-n-g
7b15682c63 Update initialization.rst 2021-10-30 21:42:22 +08:00
you-n-g
df36839a7f Update README.md 2021-10-30 21:36:15 +08:00
Pengrong Zhu
4cecaba618 fix 'duplicate axis' error when updating cache (#661) 2021-10-29 22:52:42 +08:00
Pengrong Zhu
63b823f343 add logs in case of ops.py errors (#659)
* add logs in case of ops.py errors

* Update qlib/data/ops.py

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2021-10-29 08:52:43 +08:00
you-n-g
e41c0ac90a Adjusting gbdt.py's parameter (#660)
* Update gbdt.py

* Update gbdt.py

* Update gbdt.py
2021-10-28 19:43:05 +08:00
Young
31e9d529de Add multi horizon task generator 2021-10-28 00:01:19 +08:00
Young
5fa56703ae add handler pickle attr, enhance init_instance_by_config 2021-10-26 23:32:33 +08:00
Dong Zhou
c6bb11fe56 avoid trade without enough cash 2021-10-25 05:46:19 +00:00
Dong Zhou
3d7ebd1fe0 add back trade_val 2021-10-22 10:13:15 +00:00
Dong Zhou
7313b4dad0 fix impact cost 2021-10-22 08:58:37 +00:00
Dong Zhou
b70caff522 add doc 2021-10-22 08:49:20 +00:00
Dong Zhou
96b422a906 support market impact cost 2021-10-22 08:44:47 +00:00
Young
64130d9407 Fix the aggregation function of IndexData 2021-10-22 15:20:45 +08:00
Young
a58bc03a8e add sepdf(make mini project only rely on qlib) 2021-10-21 13:15:02 +00:00
Young
f537222ce3 make handler seperable 2021-10-21 12:38:24 +00:00
Dong Zhou
c427c64845 fix calendar 2021-10-19 06:17:53 +00:00
Young
22ff8fdc44 simple change log 2021-10-16 17:14:37 +00:00
Young
4efb0a75c1 Being compatible with previous Qlib version 2021-10-16 16:43:38 +00:00
Young
052aad7982 simplify signal parameter 2021-10-15 14:48:31 +00:00
Young
12f05c7182 Merge branch 'backtest_improve' of github.com:microsoft/qlib into backtest_improve 2021-10-15 11:27:33 +00:00
Young
ac08468330 Make static prediction easier 2021-10-15 11:21:03 +00:00
Dong Zhou
df9745f134 support empty order 2021-10-15 09:07:03 +00:00
Dong Zhou
2e49a5f7c0 fix order generator 2021-10-15 07:04:47 +00:00
you-n-g
3ab5721448 Fix OrderGenerator's return value 2021-10-15 14:28:08 +08:00
you-n-g
6a94b45503 Update order_generator.py 2021-10-15 13:52:55 +08:00
you-n-g
7c31012b50 Auto injecting model and dataset for Recorder (#645)
* Auto injecting model and dataset for Recorder

* Support using Feature in expression
2021-10-15 13:50:24 +08:00
you-n-g
334b92ace7 Checking dataset empty (#647)
* Checking dataset empty

* add dataset checker
2021-10-14 23:35:12 +08:00
you-n-g
9a175d7507 improve the doc of auto init (#541)
* improve the doc of auto init

* Update setup.py

* Update setup.py

* change cvxpy version

Co-authored-by: Wangwuyi123 <51237097+Wangwuyi123@users.noreply.github.com>
2021-10-12 11:58:27 +08:00
Lewen Wang
17ea44e0cf Update TCTS. (#643)
* Update TCTS.

* Update TCTS README.

* Update TCTS README.

* Update TCTS.

Co-authored-by: lewwang <lwwang@microsoft.com>
2021-10-12 10:08:48 +08:00
you-n-g
c0ce712be9 more detailed docs for workflow (#639)
* more detailed docs for workflow

* add more detailed docs for workflow
2021-10-11 15:38:18 +08:00
demon143
8e81a017c1 Update manage.py (#628)
* Update manage.py

* Update manage.py

* Update manage.py

* Create manage.py

* Update manage.py

* Update qlib/workflow/task/manage.py

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2021-10-11 15:37:50 +08:00
you-n-g
706727988c Update README.md 2021-10-09 23:37:07 +08:00
you-n-g
e99224e5c2 Update benchmark based on new backtest (#634)
* free random seed

* update model baselines

* more robust for parameters
2021-10-07 22:57:19 +08:00
Pengrong Zhu
8c8d1336de fix workflow_config_lightgbm_multi_freq.yaml (#635) 2021-10-06 17:18:27 +08:00
Pengrong Zhu
d01de411a8 add support for macos-11 (#630)
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2021-10-03 16:49:17 +08:00
Young
28fe4d4bb4 update file strategy test 2021-10-03 14:58:37 +08:00
Young
873129aa9b update fix CI tests bugs 2021-10-03 14:58:37 +08:00
Young
3a152f9b8b fix CI 2021-10-03 14:58:37 +08:00
Young
2b75b41a08 remove 3.6 2021-10-03 14:58:37 +08:00
you-n-g
00d17f0a52 Update python-publish.yml 2021-10-01 03:03:26 +08:00
you-n-g
6bec33e854 Merge pull request #438 from microsoft/nested_decision_exe
Support Highfreq Backtest with the Model/Rule/RL Strategy
2021-10-01 02:47:53 +08:00
Young
48a860c8b7 fix backtest yaml 2021-09-30 18:43:36 +00:00
Young
4099050935 Merge remote-tracking branch 'origin/main' into nested_decision_exe 2021-09-30 18:41:15 +00:00
wangwenxi-handsome
3760a18a8d Merge nested main (#597)
* MVP for Indian Stocks in qlib using yahooquery

* cleaned with black

* cleaned with black

* add YahooNormalizeIN and YahooNormalizeIN1d

* cleaned the code

* added 1min for IN and also updated readme

* update comments

* fix comments

* recorder support upload both raw file and directory

* fix comments

* Update README.md

* Fix docs of QlibRecorder

* sort index after loader (#538)

make sure the fetch method is based on a index-sorted pd.DataFrame

* refactor online serving rolling api

* refactor TRA

* format by black

* fix horizon

* fix TRA when use single head

* clean up

* improve pretrain

* update README

* fix tra when logdir is None

* fix tra when logdir is None

* Update strategy.py

* Update README.md

* Update README.md

* Conda Suggestion

* code standard docs

* Update ensemble.py (#560)

* Fix CI  Bug (#575)


Co-authored-by: yuxwang <anduinnn@foxmail.com>

* Update gen.py (#576)

* Fix multi-process loop calls (#574)

* check lexsort in the 'lazy_sort_index' function (#566)

* check lexsort

* check lexsort

* lexsort comment

* lexsort comment

* Delete .DS_Store

* Update README.md

* bug fix & use oracle transport pretrain

* mend

* Add `backend_freq_config` parameter, support multi-freq uri

* Add sample_config to QlibDataLoader, support multi-freq

* add multi-freq example

* get_cls_kwargs renamed get_callable_kwargs

* support multi-freq uri

* Add inst_processors to D.features

* Fix typo

* Fix the index type of the multi-freq example

* Fix duplicate mlflow directories in tests

* Add DataPathManager to QlibConfig && modify inst_processors to supports list only

* Modify the default value in the multi_freq example

* Modify client-server mode and dataset-cache to disable inst_processor

* Add wheel package to github CI

* fix comment

* Update FAQ.rst

* Update README.md

Fix wrong link

* Update the docs of TaskManager (#586)

* Update manage.py

* update yaml

* update run_all_model

* Modify the Feature to be case sensitive (#589)

* update README

* remove verbose

* fix spell bug

* fix typos (#592)

* Update Release Note

* fix portfolio bug

* Add calendar support for resample

* add freq kwargs

* test.yml: Remove redundant code (#595)

* Supporting shared processor (#596)

* Supporting shared processor

* fix readonly reverse bug

* remove pytests dependency

* with fit bug

* fix parameter error

* fix comments

* Fix undefined names in Python code (#599)

* Update pytorch_tabnet.py

$ `flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics`
```
./qlib/qlib/contrib/model/pytorch_tabnet.py:567:38: F821 undefined name 'inp'
            self.independ.append(GLU(inp, out_dim, vbs=vbs))
                                     ^
./qlib/examples/model_rolling/task_manager_rolling.py:75:18: F821 undefined name 'task_train'
        run_task(task_train, self.task_pool, experiment_name=self.experiment_name)
                 ^
2     F821 undefined name 'task_train'
2
```

* Fix undefined names in Python code

* from qlib.model.trainer import task_train

* update seed

* fix some docstring

* add comments

* Fix SimpleDatasetCache

* Update setup.py

updated classifiers

* Update setup.py

change to matplotlib==3.3

* Update python-publish.yml

added python 3.9

* updategrade version number

* Update model list

* fix the type of filter_pipe

* fix comment

* fix record_temp

* update cvxpy version

* Update code_standard.rst (#587)

* Update code_standard.rst

* Update docs/developer/code_standard.rst

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* Add file lock for MLflowExpManager (#619)

* fix torch version

* Share version number (#620)

* Update initialization.rst (#622)

* Update initialization.rst

* Update docs/start/initialization.rst

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* Update docs/start/initialization.rst

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* fix bugs for running previous exmaple

* fix deal amount bug

* update change doc (#623)

* Add files via upload

* Update README.md

* Update README.md

* Update README.md

* Delete change doc.gif

* Add files via upload

* Update README.md

* Delete change doc.gif

* Add files via upload

* Delete change doc.gif

* Add files via upload

* Update README.md

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* update doc

* simplify run all model

* fix run all model bug

* Fix Models (#483)

* fix gat dataset

* fix tft model

* Update tft.py

* Fix tft.py

Co-authored-by: Pengrong Zhu <zhu.pengrong@foxmail.com>

* type and skip empty exp

* fix model yaml config

* fix tft import bug

* skip empty result

* fix model and yaml bug

* fix wrong generate parameter

* Modify multi-freq example (#626)

* modify the example of multi-freq

* add Copyright

* add a comment to average_ops.py

* modify the example of multi-freq

* add comment to multi_freq_handler.py

* add the Ref expression description to multi_freq_handler.py

* add expression description to multi_freq_handler.py

* update images

* fix workflow and update framework

Co-authored-by: Gaurav <2796gaurav@gmail.com>
Co-authored-by: 2796gaurav <17353992+2796gaurav@users.noreply.github.com>
Co-authored-by: bxdd <bxd98@126.com>
Co-authored-by: Young <afe.young@gmail.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
Co-authored-by: Dong Zhou <Zhou.Dong@microsoft.com>
Co-authored-by: ZhangTP1996 <ztp18@mails.tsinghua.edu.cn>
Co-authored-by: demon143 <59681577+demon143@users.noreply.github.com>
Co-authored-by: Wangwuyi123 <51237097+Wangwuyi123@users.noreply.github.com>
Co-authored-by: yuxwang <anduinnn@foxmail.com>
Co-authored-by: Pengrong Zhu <zhu.pengrong@foxmail.com>
Co-authored-by: Mark Zhao <50850474+markzhao98@users.noreply.github.com>
Co-authored-by: cslwqxx <cslwqxx@users.noreply.github.com>
Co-authored-by: Dong Zhou <evanzd@users.noreply.github.com>
Co-authored-by: SaintMalik <37118134+saintmalik@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Anurag Kumar <mailanu98@gmail.com>
Co-authored-by: demon143 <785696300@qq.com>
2021-10-01 02:15:30 +08:00
you-n-g
8cf6ed3564 Update VERSION.txt 2021-09-30 22:59:05 +08:00
you-n-g
92055d64ec Update VERSION.txt 2021-09-30 22:53:57 +08:00
you-n-g
b9809a4c33 make the prediction update more friendly (#609)
* make the prediction update more friendly

* Update test_storage.py

* LabelUpdater

* Update test_storage.py

* Update test_storage.py

* Update test_storage.py

* Update test_storage.py

* Update setup.py

* Update workflow_config_lightgbm_Alpha158.yaml

* Update workflow_config_lightgbm_Alpha158.yaml

* Update workflow_config_lightgbm_Alpha158.yaml

* Update workflow_config_lightgbm_Alpha158.yaml

* Update workflow_config_lightgbm_Alpha158.yaml

* Update setup.py

* Update setup.py

* test CI only

* test CI only

* Update workflow_config_lightgbm_Alpha158.yaml

* Update setup.py

* fix "Segmentation fault" in macos

* Update test.yml

github action no longer supported ubuntu-16.04

* Update api.rst

update doc with new_lable

* Update api.rst

Co-authored-by: Wangwuyi123 <51237097+Wangwuyi123@users.noreply.github.com>
Co-authored-by: Pengrong Zhu <zhu.pengrong@foxmail.com>
2021-09-30 20:54:44 +08:00
you-n-g
fc243fd29b Fix Models (#483)
* fix gat dataset

* fix tft model

* Update tft.py

* Fix tft.py

Co-authored-by: Pengrong Zhu <zhu.pengrong@foxmail.com>
2021-09-30 13:11:06 +08:00
demon143
b6a8bd5b80 update change doc (#623)
* Add files via upload

* Update README.md

* Update README.md

* Update README.md

* Delete change doc.gif

* Add files via upload

* Update README.md

* Delete change doc.gif

* Add files via upload

* Delete change doc.gif

* Add files via upload

* Update README.md

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2021-09-29 19:42:38 +08:00
demon143
6ee0fe366c Update initialization.rst (#622)
* Update initialization.rst

* Update docs/start/initialization.rst

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

* Update docs/start/initialization.rst

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2021-09-27 21:44:06 +08:00
you-n-g
55b6ff123e Share version number (#620) 2021-09-27 16:12:12 +08:00
you-n-g
45ea4bae4e Add file lock for MLflowExpManager (#619) 2021-09-26 16:21:15 +08:00
demon143
17d472cf01 Update code_standard.rst (#587)
* Update code_standard.rst

* Update docs/developer/code_standard.rst

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2021-09-26 15:35:14 +08:00
you-n-g
c500a01226 update cvxpy version 2021-09-25 17:12:02 +08:00
zhupr
114c38b4c3 fix the type of filter_pipe 2021-09-20 19:04:59 +08:00
you-n-g
414c3082c0 Update model list 2021-09-18 12:57:58 +08:00
Young
3fc2f8c93c updategrade version number 2021-09-16 02:15:16 +00:00
Anurag Kumar
66ff3e5bf6 Update python-publish.yml
added python 3.9
2021-09-16 10:09:39 +08:00
Anurag Kumar
8ff68a182e Update setup.py
change to matplotlib==3.3
2021-09-16 10:09:39 +08:00
Anurag Kumar
a105ef1d76 Update setup.py
updated classifiers
2021-09-16 10:09:39 +08:00
zhupr
d02965ea70 Fix SimpleDatasetCache 2021-09-16 10:08:56 +08:00
Christian Clauss
b8d1e08010 Fix undefined names in Python code (#599)
* Update pytorch_tabnet.py

$ `flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics`
```
./qlib/qlib/contrib/model/pytorch_tabnet.py:567:38: F821 undefined name 'inp'
            self.independ.append(GLU(inp, out_dim, vbs=vbs))
                                     ^
./qlib/examples/model_rolling/task_manager_rolling.py:75:18: F821 undefined name 'task_train'
        run_task(task_train, self.task_pool, experiment_name=self.experiment_name)
                 ^
2     F821 undefined name 'task_train'
2
```

* Fix undefined names in Python code

* from qlib.model.trainer import task_train
2021-09-14 12:13:27 +08:00
you-n-g
163e3c6266 replace multi processing with joblib (#477)
* replace multi processing with joblib

* update class Parallel and data.py

* update class Parallel and data.py

* update class Parallel and data.py

* update class Parallel and data.py

* update class Parallel and data.py

* update class Parallel and data.py

* update class Parallel and data.py

* update class Parallel and data.py

* Fix Parallel support for maxtasksperchild

Co-authored-by: wangw <1666490690@qq.com>
Co-authored-by: zhupr <zhu.pengrong@foxmail.com>
2021-09-14 01:16:03 +08:00
you-n-g
6203e4c09e Update the docs of Report 2021-09-13 17:53:34 +08:00
you-n-g
51709c20d8 Supporting shared processor (#596)
* Supporting shared processor

* fix readonly reverse bug

* remove pytests dependency

* with fit bug

* fix parameter error
2021-09-13 17:11:08 +08:00
Christian Clauss
28c99c77be test.yml: Remove redundant code (#595) 2021-09-13 14:31:32 +08:00
you-n-g
bb5cdfe050 Update Release Note 2021-09-12 17:06:00 +08:00
SaintMalik
fb21c591bb fix typos (#592) 2021-09-12 16:39:22 +08:00
Dong Zhou
5279e71423 Merge pull request #591 from evanzd/fix_tra
Fix TRA
2021-09-11 18:48:13 +08:00
Dong Zhou
f35254c288 update README 2021-09-10 07:38:22 +00:00
Pengrong Zhu
5e82c18cb2 Modify the Feature to be case sensitive (#589) 2021-09-10 11:47:23 +08:00
demon143
2759e8c28d Update the docs of TaskManager (#586)
* Update manage.py
2021-09-09 20:13:45 +08:00
you-n-g
2461575d30 Update README.md
Fix wrong link
2021-09-09 08:28:48 +08:00
Pengrong Zhu
867667531d Update FAQ.rst 2021-09-08 18:06:51 +08:00
zhupr
0fc52333b7 Add wheel package to github CI 2021-09-07 20:41:10 +08:00
zhupr
ab9b6dc47a Modify client-server mode and dataset-cache to disable inst_processor 2021-09-07 20:41:10 +08:00
zhupr
4c5a4d5cd7 Modify the default value in the multi_freq example 2021-09-07 20:41:10 +08:00
zhupr
e84cc23589 Add DataPathManager to QlibConfig && modify inst_processors to supports list only 2021-09-07 20:41:10 +08:00
zhupr
707399a245 Fix duplicate mlflow directories in tests 2021-09-07 20:41:10 +08:00
zhupr
6e88ccca88 Fix the index type of the multi-freq example 2021-09-07 20:41:10 +08:00
zhupr
ee5f3de800 Fix typo 2021-09-07 20:41:10 +08:00
zhupr
3605cd7b96 Add inst_processors to D.features 2021-09-07 20:41:10 +08:00
zhupr
d1cbf4c3d9 support multi-freq uri 2021-09-07 20:41:10 +08:00
zhupr
6011a21308 get_cls_kwargs renamed get_callable_kwargs 2021-09-07 20:41:10 +08:00
zhupr
76a05f37a9 add multi-freq example 2021-09-07 20:41:10 +08:00
zhupr
c99494eb76 Add sample_config to QlibDataLoader, support multi-freq 2021-09-07 20:41:10 +08:00
zhupr
e8126b0c39 Add backend_freq_config parameter, support multi-freq uri 2021-09-07 20:41:10 +08:00
Young
88d2f9263e fix sum index data bug 2021-09-02 01:57:44 +00:00
wangwenxi.handsome
f71b0c1189 250s 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
919380597b close and reindex 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
4da3f3b104 broadcast_to and get single data 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
9446116642 redundant references 2021-09-02 09:56:38 +08:00
Young
5003e49197 fix metric calculation error 2021-09-02 09:56:38 +08:00
Young
5f0ee6ce68 fix bugs 2021-09-02 09:56:38 +08:00
Young
9a74471ab6 Pass basic tests 2021-09-02 09:56:38 +08:00
Young
d39c8de800 draft design 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
43a8f502ed fix bug 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
7ee4a207bc add lru 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
25f54ddaeb new high freq struc 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
d9ad8ff791 index_data 2021-09-02 09:56:38 +08:00
Young
13a9b7cea0 type error bug 2021-09-02 09:56:38 +08:00
Young
9c326fd398 add import order 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
f111e34bd2 align interface 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
be0d9e6a22 update freq 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
e134c358fd fix index data bug 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
16b954866f get_base_info 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
f7d7f1a223 fix nanmean 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
8eb7a1fddc numpy_order_indicator 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
222c2fd21a fix exchange bug 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
f67b99a30e update exchange 2021-09-02 09:56:38 +08:00
wangwenxi.handsome
2da6a8c770 fix Path re 2021-08-31 11:57:14 +00:00
Dong Zhou
8f4d320832 bug fix & use oracle transport pretrain 2021-08-30 07:32:04 +00:00
cslwqxx
e2739ac72c Update README.md 2021-08-29 12:29:11 +08:00
you-n-g
19d15ddc38 Merge pull request #513 from 2796gaurav/main
MVP for Indian Stocks in qlib using yahooquery
2021-08-26 20:59:26 +08:00
you-n-g
12af8f304b Delete .DS_Store 2021-08-26 15:36:35 +08:00
Mark Zhao
25b771ddf1 check lexsort in the 'lazy_sort_index' function (#566)
* check lexsort

* check lexsort

* lexsort comment

* lexsort comment
2021-08-25 18:07:30 +08:00
Pengrong Zhu
1158472489 Fix multi-process loop calls (#574) 2021-08-25 18:05:35 +08:00
you-n-g
84d2cb3226 Update gen.py (#576) 2021-08-25 18:05:10 +08:00
Wangwuyi123
509bfcb02e Fix CI Bug (#575)
Co-authored-by: yuxwang <anduinnn@foxmail.com>
2021-08-25 08:51:39 +08:00
Young
309dfa36cc Add a example to collecting all the decisions 2021-08-15 15:22:48 +00:00
demon143
6608a40965 Update ensemble.py (#560) 2021-08-14 18:07:49 +08:00
wangwenxi-handsome
735153a50d Cash Update (#559)
* fix negative cash

* update order test

* fix bug

* update file_order_test
2021-08-12 23:44:22 +08:00
you-n-g
3e75cead93 code standard docs 2021-08-12 09:19:57 +00:00
you-n-g
6697f209d4 Conda Suggestion 2021-08-12 16:30:46 +08:00
you-n-g
05b9fb5a47 Fix bug when Account.benchmark_config is None 2021-08-09 19:23:17 +08:00
wangwenxi.handsome
7c858803f0 add position test 2021-08-08 14:32:33 +00:00
wangwenxi.handsome
74e1ee6921 update position and negative cash 2021-08-06 04:34:30 +00:00
you-n-g
e3b57b1901 Update README.md 2021-08-06 09:59:30 +08:00
you-n-g
82a5223166 Update README.md 2021-08-06 09:59:30 +08:00
ZhangTP1996
398131cff7 Update strategy.py 2021-08-05 17:21:10 +08:00
Young
8e87950292 Print volume limitation log 2021-08-04 11:04:28 +00:00
Dong Zhou
e71e2f941c fix tra when logdir is None 2021-08-02 19:02:37 +08:00
Dong Zhou
0483406c12 fix tra when logdir is None 2021-08-02 03:57:14 -07:00
wangwenxi.handsome
3ff1d91d61 add __init__ 2021-08-02 07:45:03 +00:00
wangwenxi.handsome
f5db0e1b05 fix vol limit bug 2021-08-02 03:49:03 +00:00
wangwenxi.handsome
0f2d85d098 volume limit update 2021-08-01 16:03:08 +00:00
wangwenxi.handsome
5c2ddac7f0 volume limit 2021-07-31 09:31:01 +00:00
Dong Zhou
da1f4db968 update README 2021-07-30 16:05:07 +08:00
Dong Zhou
a7c41b6969 improve pretrain 2021-07-30 16:05:07 +08:00
Dong Zhou
5b7b48e376 clean up 2021-07-30 16:05:07 +08:00
Dong Zhou
4f9f978909 fix TRA when use single head 2021-07-30 16:05:07 +08:00
Dong Zhou
319a2f38cc fix horizon 2021-07-30 16:05:07 +08:00
Dong Zhou
a2c38c979e format by black 2021-07-30 16:05:07 +08:00
Dong Zhou
07655f2d5b refactor TRA 2021-07-30 16:05:07 +08:00
Young
9303415666 refactor online serving rolling api 2021-07-29 18:13:12 +08:00
Young
73f5cc0a2b add suspend check in twap 2021-07-29 04:11:18 +00:00
you-n-g
05d28469ad sort index after loader (#538)
make sure the fetch method is based on a index-sorted pd.DataFrame
2021-07-29 12:06:59 +08:00
Young
ab3c4a2c05 new twap (more even) 2021-07-28 03:11:56 +00:00
you-n-g
c1992b1bb1 Merge pull request #456 from ultmaster/rl-dummy
Dummy RL example on nested decision framework
2021-07-27 22:58:15 +08:00
v-mingzhehan
e817413769 Restore examples 2021-07-27 14:52:29 +00:00
v-mingzhehan
0b607da690 Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-07-27 14:32:36 +00:00
Young
0d41ca26ab fix data format bug & twap peeking strategy 2021-07-27 14:17:59 +00:00
wangwenxi.handsome
ba1c575aa9 doc and black for indicator 2021-07-27 12:14:43 +00:00
wangwenxi.handsome
66971d5f0d fix indicator 2021-07-27 09:06:13 +00:00
Young
fcca242807 add cash settlement mechanism 2021-07-26 17:14:41 +00:00
wangwenxi.handsome
4924717276 fix black 2021-07-26 11:25:14 +00:00
wangwenxi.handsome
c202a4b1e6 fix _get_base_vol_pri clip_time_range 2021-07-26 11:21:05 +00:00
you-n-g
dc6859bdd9 Fix docs of QlibRecorder 2021-07-26 19:00:47 +08:00
you-n-g
a6f9dde006 Update README.md 2021-07-26 18:36:09 +08:00
Young
bdebe12cf2 support empty benchmark
Empty benchmark could accelerate the learning process
2021-07-26 06:14:57 +00:00
Young
1d22ee56d3 recorder support upload both raw file and directory 2021-07-25 16:35:16 +00:00
wangwenxi.handsome
e88c45e13c update position 2021-07-25 12:38:54 +00:00
wangwenxi.handsome
103d3034bf Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into nested_decision_exe 2021-07-25 12:37:04 +00:00
wangwenxi-handsome
4ffb05ae59 Update Action 2021-07-24 22:08:15 +08:00
wangwenxi.handsome
6dcbf51298 update action 2021-07-24 11:36:28 +00:00
wangwenxi-handsome
9d732e9646 Update Action 2021-07-24 10:12:59 +00:00
wangwenxi.handsome
a8ea66b83e black 2021-07-23 09:33:04 +00:00
you-n-g
9e6f4ec578 Merge pull request #520 from wangwenxi-handsome/nested_decision_exe
abstract Quote class from Exchange
2021-07-23 14:36:36 +08:00
wangwenxi.handsome
301e0477ec Merge branch 'nested_decision_exe' of https://github.com/wangwenxi-handsome/qlib into nested_decision_exe 2021-07-23 05:52:09 +00:00
wangwenxi.handsome
0ec6b87d39 fix little bug 2021-07-23 05:50:41 +00:00
you-n-g
d445f28e5f Merge branch 'main' into nested_decision_exe 2021-07-23 12:38:20 +08:00
you-n-g
bbba9600a1 Merge branch 'nested_decision_exe' into nested_decision_exe 2021-07-23 12:15:45 +08:00
wangwenxi.handsome
2c8a3ded08 high_performance_data_structure 2021-07-22 15:20:03 +00:00
panshuaiyin
3810a4cd33 Update data.rst
use own alpha-factor
2021-07-22 20:07:04 +08:00
you-n-g
48af7126b6 Update news about models 2021-07-22 11:07:09 +08:00
Ying-Tao Luo
025b1dcff9 Add two new models in model zoo 2021-07-22 11:05:39 +08:00
Ying-Tao Luo
29e66b2dea Add two new model in zoo
Add transformer and localformer (SLGT) models for time series prediction in finance in the Quant Model Zoo.
2021-07-22 11:05:39 +08:00
Ying-Tao Luo
698e59ac72 Add performance of two new models
Add the performance of transformer and localformer.
2021-07-22 11:05:39 +08:00
Ying-Tao Luo
e006ef40ad Update pytorch_localformer_ts.py 2021-07-22 11:05:39 +08:00
Young
59d4bc9394 update run_all_model and black format 2021-07-22 11:05:39 +08:00
Ying-Tao Luo
b07e0bffb1 Add files via upload 2021-07-22 11:05:39 +08:00
Ying-Tao Luo
161343018f Add files via upload 2021-07-22 11:05:39 +08:00
Ying-Tao Luo
bee031af68 Add files via upload 2021-07-22 11:05:39 +08:00
Ying-Tao Luo
35840606a8 Update pytorch_localformer.py 2021-07-22 11:05:39 +08:00
Ying-Tao Luo
2df9b6e076 Add files via upload 2021-07-22 11:05:39 +08:00
Ying-Tao Luo
0c3eaf3f16 Add files via upload 2021-07-22 11:05:39 +08:00
Ying-Tao Luo
2eee064eb8 Add files via upload 2021-07-22 11:05:39 +08:00
Ying-Tao Luo
096ef5a62b Update pytorch_transformer.py
Have passed black
2021-07-22 11:05:39 +08:00
Ying-Tao Luo
dd0eebed53 Update pytorch_localformer.py
Have passed black.
2021-07-22 11:05:39 +08:00
Ying-Tao Luo
7b20abeda1 Add files via upload
Add naive transformer model and a improved transformer model.
2021-07-22 11:05:39 +08:00
wangwenxi.handsome
10c182e2b0 add order_indicator doc 2021-07-21 14:09:12 +00:00
wangwenxi.handsome
83d4387e9f pandas_order_indicator 2021-07-21 12:47:31 +00:00
you-n-g
5519420efd Update test_macos.yml
Give more comments about the MacOS test yaml
2021-07-21 18:30:25 +08:00
zhupr
eb3c5b3088 macos-test-ci split out separately 2021-07-21 18:25:31 +08:00
zhupr
f03df874bf fix macos-test-ci 2021-07-21 18:25:31 +08:00
2796gaurav
8fa22bd2e1 added 1min for IN and also updated readme 2021-07-21 14:16:22 +05:30
Gaurav
d1c8d885aa cleaned the code 2021-07-21 17:59:50 +05:30
zhupr
bf7732e284 fix df_features.index conține np.nan 2021-07-21 14:28:20 +08:00
v-mingzhehan
9bf8c999e6 type checking update 2021-07-20 06:14:40 +00:00
Young
4e862f7d1f add print cash in verbose mode and code format 2021-07-20 05:13:05 +00:00
wuzhe1234
3f5334ab39 Update qrun to automaticly save the config to the artifacts uri 2021-07-19 13:32:14 +08:00
v-mingzhehan
62583ea6ec Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-07-19 04:18:17 +00:00
Young
92f2891664 fix order factor setting issue
Move the factor setting from init phase to dealing phase.
2021-07-19 02:37:44 +00:00
zhupr
c97a96363d Add a check if change is mutated to YahooNormalize1d 2021-07-18 20:28:46 +08:00
v-mingzhehan
25ff62f542 Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-07-18 09:00:47 +00:00
slowy07
2023f714c9 [fixed] lgtm issue : unused imported module of 'signal' and change to PEP8 style code imported module 2021-07-18 15:25:18 +08:00
slowy07
f8a2b0533b lgtm issue: fixing unused import of 'time' 2021-07-18 15:25:18 +08:00
chaosyu
3183a232df update doc str 2021-07-18 15:24:23 +08:00
chaosyu
8b715268bd use list_kwargs instead filter_string 2021-07-18 15:24:23 +08:00
chaosyu
28cb827a23 fix lint issue 2021-07-18 15:24:23 +08:00
chaosyu
b723f14619 apply filter string to recorder collector 2021-07-18 15:24:23 +08:00
chaosyu
47535ba530 add mlflow filter string support to limit too much run number 2021-07-18 15:24:23 +08:00
Young
4a62e02fca add get_data_cal_avail_range method 2021-07-18 07:12:14 +00:00
v-mingzhehan
572181ef5d Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-07-18 03:55:39 +00:00
Young
ed12c7fca3 add common_infra warning and fix time bug 2021-07-18 03:13:15 +00:00
v-mingzhehan
5f50614dbc Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-07-17 16:31:31 +00:00
Young
7738f39546 filter zero base price 2021-07-17 06:54:44 +00:00
Gaurav
d70e5a4f88 add YahooNormalizeIN and YahooNormalizeIN1d 2021-07-17 10:40:16 +05:30
wangwenxi.handsome
2b8d4dc3c2 callable 2021-07-16 14:09:36 +00:00
wangwenxi.handsome
6ad52e8cf5 black and doc 2021-07-16 13:55:49 +00:00
wangwenxi.handsome
567841e1c6 get qlib data in exchange 2021-07-16 12:56:49 +00:00
wangwenxi.handsome
110141ddac add doc 2021-07-16 09:17:29 +00:00
wangwenxi.handsome
65b44349cd add PandasQuote 2021-07-16 08:29:32 +00:00
you-n-g
3b8087677c Update online.rst 2021-07-16 12:24:33 +08:00
Young
5241b2f918 Merge branch 'nested_decision_exe' of github.com:microsoft/qlib into nested_decision_exe 2021-07-16 03:17:54 +00:00
Young
344f4f69d2 add data calendar API and refine order cal api 2021-07-16 03:11:07 +00:00
wangwenxi.handsome
f295497e2c Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into nested_decision_exe 2021-07-15 13:38:38 +00:00
wangwenxi.handsome
aae4b02ab8 *tuple 2021-07-15 13:34:39 +00:00
Young
d907817ce9 unify variable names 2021-07-15 13:17:26 +00:00
zhupr
4ec41ea0e7 Add a check if change is mutated to YahooNormalize1d 2021-07-15 19:13:25 +08:00
v-mingzhehan
870f834577 Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-07-15 08:31:39 +00:00
Young
94b456714d refactor index_range to trade_range 2021-07-15 08:02:09 +00:00
Gaurav
cfcd9fb1f8 cleaned with black 2021-07-15 11:24:41 +05:30
Gaurav
457dcaa466 cleaned with black 2021-07-14 20:12:00 +05:30
Gaurav
3c740fc2de MVP for Indian Stocks in qlib using yahooquery 2021-07-14 19:54:55 +05:30
Young
571d27cba7 exchange support expression buy sell limit 2021-07-14 13:07:14 +00:00
v-mingzhehan
831773a0d6 Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-07-14 09:12:54 +00:00
you-n-g
6d91f28474 Update README.md 2021-07-14 10:07:02 +08:00
you-n-g
be8653c505 Update contributing section 2021-07-14 09:56:12 +08:00
wangwenxi.handsome
7b9e338a0d add docs 2021-07-14 09:45:09 +08:00
wangwenxi.handsome
0646e53d24 fix spell error 2021-07-14 09:45:09 +08:00
wangwenxi.handsome
ca14e36f7a initial account by position 2021-07-14 09:45:09 +08:00
Young
9b38e62f21 Add more friendly index range by timing 2021-07-13 14:46:53 +00:00
wangwenxi.handsome
4c4b30ebec fix base price and volumn 2021-07-13 16:15:52 +08:00
chaosyu
a8974ce535 bug fix: ClientProvider cannot set connection to calendar and instrument providers 2021-07-13 10:49:21 +08:00
chaosyu
79026e5390 fix bug that duplicate rows will cause reindex failed when dumping with csv files 2021-07-13 10:49:21 +08:00
Gaurav Chauhan
4610e16ac2 updated readme of yahoo collector where region parameter was incorrect (#504)
* updated readme of yahoo collector where region parameter was incorrect

* changes

update readme of yahoo collector where region parameter was incorrect

* update readme of yahoo collector

update readme of yahoo collector where region parameter was incorrect

* updated changes

* updated readme of cn1d data

Co-authored-by: Gaurav Chauhan01/HO/Analytics/General <Gaurav.Chauhan01@bajajallianz.in>
2021-07-13 09:46:13 +08:00
wangwenxi.handsome
b504cc6ac8 update readme and rst 2021-07-12 21:51:08 +08:00
v-mingzhehan
c29e5b2621 Fix circular import 2021-07-12 13:50:13 +00:00
Young
d5059e609f change to dev version 2021-07-12 02:49:25 +00:00
Young
215f7e0d22 update version for release 0.7.0 2021-07-11 14:34:44 +00:00
Young
45bde7527e move the pa sign from last step to first 2021-07-11 01:53:21 +00:00
Young
155019ba35 move the pa sign from last step to first 2021-07-09 10:34:18 +00:00
v-mingzhehan
ece7b662e2 Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-07-09 09:32:15 +00:00
Young
80f5426693 update docsting 2021-07-09 08:29:19 +00:00
Young
cbd52b7905 align range limit 2021-07-09 08:17:10 +00:00
Young
17d8b8a7cc fix calculating base_price 2021-07-09 08:16:01 +00:00
Young
eada8640b9 align range limit 2021-07-09 08:12:13 +00:00
Young
32ae6e4259 fix calculating base_price 2021-07-08 05:54:36 +00:00
v-mingzhehan
5c5379e09d Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-07-07 12:26:43 +00:00
Young
e8f5a1e491 black format 2021-07-07 10:52:52 +00:00
Young
0c946cffd6 add supporting setting trade unit in exchange 2021-07-07 10:47:54 +00:00
you-n-g
1fb50d521b Merge branch 'main' into nested_decision_exe 2021-07-07 17:30:31 +08:00
wangwenxi.handsome
8c743a46c7 use init_instance_by_config 2021-07-07 17:27:29 +08:00
wangwenxi.handsome
93796bdcef add exchange kwargs 2021-07-07 17:27:29 +08:00
wangwenxi.handsome
267ee3555d fix all example 2021-07-07 17:27:29 +08:00
wangwenxi.handsome
8b28575dad fill placehorder dict and list 2021-07-07 17:27:29 +08:00
wangwenxi.handsome
4488c3b625 code optimization 2021-07-07 17:27:29 +08:00
wangwenxi.handsome
bd6080b8f5 yaml update 2021-07-07 17:27:29 +08:00
wangwenxi.handsome
cbe7c5285a high_fre_yaml 2021-07-07 17:27:29 +08:00
Wenxi Wang (FA Talent)
85c75a6639 config_extend 2021-07-07 17:27:29 +08:00
xixi
d1b8ed9613 fix qrun 2021-07-07 17:27:29 +08:00
xixi
d6984a3f2d fill_placehorder 2021-07-07 17:27:29 +08:00
Young
e42aa67f52 Supporting skip empty decisions 2021-07-06 12:27:07 +00:00
Young
4e41e9c8f2 simplify the portfolio-based report 2021-07-06 12:27:01 +00:00
Young
6fd50a5bfa Supporting skip empty decisions 2021-07-06 12:08:53 +00:00
Young
dd8231edeb simplify the portfolio-based report 2021-07-06 11:10:13 +00:00
Young
03d6facbd2 fix TWAP strategy 2021-07-06 10:02:20 +00:00
v-mingzhehan
354f7e68c2 Constrain TWAP trade step 2021-07-06 08:47:55 +00:00
v-mingzhehan
e214557e3a Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-07-06 06:43:34 +00:00
Young
bdac9f4dda supporting seperated buy and sell price 2021-07-06 06:35:10 +00:00
Young
cb72857710 fix annotation recursive error 2021-07-06 05:23:13 +00:00
v-mingzhehan
82645233e7 Support order dataframe 2021-07-06 03:50:34 +00:00
xiaowuhu
dafef0ac08 Update workflow.rst
should be China instead of china
2021-07-06 09:22:11 +08:00
xiaowuhu
1cb43ea69b Update workflow.rst
remove 空格 before module_path, kwargs, etc, otherwise, yaml parser will report error: ruamel.yaml.scanner.ScannerError: mapping values are not allowed here
2021-07-06 09:21:14 +08:00
you-n-g
7ca9cf79f7 Update README.md 2021-07-05 19:47:49 +08:00
v-mingzhehan
e063d3536c Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-07-05 09:37:22 +00:00
you-n-g
35f090a6e4 Update what's new 2021-07-04 16:47:33 +08:00
Lewen Wang
ace7484304 Update TCTS. (#495)
* Update TCTS Model.

Co-authored-by: lewwang <lwwang@microsoft.com>
2021-07-04 16:45:05 +08:00
Young
7048bef7c6 fix ffr and order amount 2021-07-04 08:11:17 +00:00
Young
50c0e99f98 fix ffr and order amount 2021-07-04 08:08:03 +00:00
bxdd
9b74a19b14 Merge pull request #493 from bxdd/optimize_resam_data
optimize performance of resam data in rule_strategy & exchange
2021-07-04 02:44:53 +08:00
bxdd
ecf2f24d59 fix comments 2021-07-03 18:42:40 +00:00
Young
ef7fe8aa75 support parallel HF trading 2021-07-03 09:22:23 +00:00
bxdd
2d4f0e80f9 black format 2021-07-02 08:47:52 +08:00
bxdd
946c9392a1 support check_transform_proc module_path 2021-07-02 08:47:52 +08:00
bxdd
8dd5788bac fix comments & update resam ts_last method 2021-07-01 16:31:58 +00:00
bxdd
8b85b9eee7 optimize performance of resam data in rule_strategy & exchange 2021-07-01 14:35:49 +00:00
v-mingzhehan
2b4a493617 Order patch 2021-07-01 09:41:08 +00:00
Young
a401f1eafe improve the docstring 2021-06-30 08:50:03 +00:00
v-mingzhehan
24d5a3127b Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-06-30 08:30:33 +00:00
Young
bbf5d1bbbb add file order strategy 2021-06-30 07:34:23 +00:00
bxdd
b242d6e1e1 delMiniTimer in haandler storage test 2021-06-30 11:34:08 +08:00
bxdd
8d1b1979d9 update handler_storage test 2021-06-30 11:34:08 +08:00
bxdd
9985befe69 update HashingStockStorage 2021-06-30 11:34:08 +08:00
lzh222333
b523b27d5a add docstring 2021-06-30 10:59:34 +08:00
lzh222333
0b83fb3564 more general exception 2021-06-30 10:59:34 +08:00
lzh222333
d96f7a67c6 bug & docs fixed 2021-06-30 10:59:34 +08:00
lzh222333
a7862387a2 fixed update bugs 2021-06-30 10:59:34 +08:00
lzh222333
c4c438249c modify OnlineToolR 2021-06-30 10:59:34 +08:00
you-n-g
90bbf2b7c6 Fix account update bar_count bug 2021-06-30 08:29:47 +08:00
bxdd
e1b6f310c9 add Handler Storage 2021-06-28 20:06:15 +00:00
Yuge Zhang
20d566ceee Merge branch 'rl-dummy' of github.com:ultmaster/qlib into rl-dummy 2021-06-28 18:01:41 +08:00
Yuge Zhang
8e8bba1a96 Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-06-28 18:01:02 +08:00
Young
27f0db669f black format & add comments & add randStrategy direction 2021-06-28 17:47:30 +08:00
Young
72c9593aa7 adapting strategies to latest interfaces. 2021-06-28 17:47:30 +08:00
Young
c907d8deb4 fix bugs of random strategy 2021-06-28 17:47:30 +08:00
Young
e78cdd4a08 return the detailed order indicator 2021-06-28 17:47:30 +08:00
Young
9b91758aed performance optimization for cal_sam_minute 2021-06-28 17:47:30 +08:00
Young
b41267fa59 successful run random order gen in day script 2021-06-28 17:47:30 +08:00
Young
b68294da93 add InfPosition 2021-06-28 17:47:30 +08:00
Young
4f384d37ce API enhancement 2021-06-28 17:47:30 +08:00
bxdd
284d96761b fix bug in resam feature 2021-06-27 17:49:49 +00:00
you-n-g
8709dde65b Merge pull request #481 from ai4stocks/working_workflow_fix_ipynb
examples/workflow_by_code.ipynd: fix an error in R.get_recorder() par…
2021-06-26 19:57:24 +08:00
Guodong Xu
d66733c358 examples/workflow_by_code.ipynd: fix an error in R.get_recorder() parameters
get_recorder() needs specify 'recorder_id='. However workflow_by_code.ipynd
didn't. This patch fixes it.

Without this fix, here is the error message jupyter-notebook reports:

"---------------------------------------------------------------------------
TypeError Traceback (most recent call last)

<ipython-input-7-e6a7b5f4da00> in <module>
26 # backtest and analysis
27 with R.start(experiment_name="backtest_analysis"):
---> 28 recorder = R.get_recorder(rid, experiment_name="train_model")
29 model = recorder.load_object("trained_model")
30

TypeError: get_recorder() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given"

Signed-off-by: Guodong Xu <guodong.xu@linaro.org>
2021-06-26 18:25:47 +08:00
Dong Zhou
9cf574b697 Merge pull request #479 from linhx25/main
Add TRA Model
2021-06-25 18:08:23 +08:00
linhx25
107e40f3ee Add TRA Model 2021-06-25 16:12:50 +08:00
bxdd
b6564cd760 support trade decision update 2021-06-24 19:09:36 +00:00
bxdd
1517a9eb91 add default executor config & update bug in indicator 2021-06-24 13:59:10 +00:00
you-n-g
4837ba8db3 Merge pull request #476 from bxdd/qlib_ops_config
Support using config to register custom operators
2021-06-24 20:41:48 +08:00
Qian Chen
2ab4a9adb3 Set self.fitted = True instead of self._fitted. 2021-06-24 20:40:59 +08:00
bxdd
8d0b673341 add custom_ops docstring 2021-06-24 15:00:45 +08:00
you-n-g
8ebdb1e873 Merge pull request #463 from zhupr/support_extend_data
Support extend data
2021-06-24 13:53:30 +08:00
zhupr
39340fbf06 fix: typo 2021-06-24 11:07:40 +08:00
zhupr
0e277723a3 Merge remote-tracking branch 'qlib/main' into qlib_main
# Conflicts:
#	scripts/data_collector/yahoo/README.md
2021-06-24 00:09:54 +08:00
zhupr
1418417034 fix automatic update of daily frequency data 2021-06-23 23:59:59 +08:00
you-n-g
b261f7b501 Update README.md 2021-06-23 20:51:21 +08:00
zhupr
bab50e8837 fix YahooNormalize1min && update docs 2021-06-23 16:13:26 +08:00
bxdd
0eee4a0f2e support config custom_ops 2021-06-23 15:56:36 +08:00
Young
21eb71d4a9 update framework for online serving 2021-06-23 02:05:38 +00:00
v-mingzhehan
583fbbef3c Resolve init conflict 2021-06-22 07:07:19 +00:00
v-mingzhehan
d226ac8c32 Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-06-22 07:07:07 +00:00
bxdd
ab97e82484 fix bug in Exchange 2021-06-22 15:03:05 +08:00
v-mingzhehan
7525854bed Add shortcut in init 2021-06-22 03:47:39 +00:00
v-mingzhehan
56cf43da44 Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-06-22 03:27:34 +00:00
zhupr
46714adf4c modify the YahooNormalize1min factor calculation 2021-06-22 11:15:09 +08:00
bxdd
4ac6e6e246 fix account bug & update indicator_analysis & fix some comments 2021-06-22 02:42:09 +08:00
zhupr
99fb49650a add end_date parameter to collector.normalize_data 2021-06-21 17:20:37 +08:00
zhupr
985fd0816c Fix cn_index.collector network error 2021-06-21 17:18:04 +08:00
Young
d0f54343c7 support subclass of TSDatasetH 2021-06-21 00:24:31 +08:00
Young
a3679e6758 simplify the code and prevent float when shifting 2021-06-21 00:24:31 +08:00
zhupr
b6c31540e8 add function to automatically update daily frequency data 2021-06-17 23:07:56 +08:00
zhupr
a4f6e04199 modify dump_update starts with the last end date of each symbol 2021-06-17 22:33:31 +08:00
you-n-g
0aee46ee79 Merge pull request #466 from you-n-g/online_hotfix
Online bug fix, enhancement &  docs for dataset, workflow, trainer ...
2021-06-17 11:38:44 +08:00
Young
9c8d423a86 fix ModelUpdater 2021-06-16 14:10:51 +00:00
zhupr
b4efbd53b2 Fix 'report' compatibility with matplotlib versions 2021-06-16 22:00:43 +08:00
you-n-g
5a50d7c952 Merge pull request #471 from Derek-Wds/main
Update Recorder Wrapper to prevent reinitialization
2021-06-16 17:46:31 +08:00
Jactus
0fe8b281ba Update R wrapper logic 2021-06-16 12:28:20 +08:00
lewwang
5331ab93f8 Update TCTS README. 2021-06-16 12:23:22 +08:00
Jactus
64582e9d46 Add QlibException 2021-06-15 15:02:11 +08:00
Jactus
9e0e2ff736 Update QlibRecorder wrapper 2021-06-15 14:46:31 +08:00
bxdd
9e45528165 update backtest time range 2021-06-14 22:31:31 +08:00
bxdd
f78e90171b fix comments & add VAStrategy & add trade indicator 2021-06-14 21:32:18 +08:00
Young
973c4137e4 fix mlflow & task bug 2021-06-12 13:54:26 +00:00
Young
730f6258d6 add warning and * 2021-06-11 10:40:56 +00:00
Young
5850490b24 simplify the code and add docs 2021-06-11 08:29:10 +00:00
Young
d4b36bdab4 Online fix
- Skip duplicated qlib.auto_init()
- Fix TSDatasetH flt_col bug!
- Resolve qlib log attribute confliction
- Trainer API enhancement
- More docs and user-friendly warning
2021-06-11 02:06:07 +00:00
you-n-g
40416d8c30 Merge pull request #464 from lwwang1995/main
Add TCTS baseline.
2021-06-10 10:18:20 +08:00
lewwang
567e42840c asdf 2021-06-09 18:37:25 +08:00
lewwang
65ddca133f asdf 2021-06-09 18:36:12 +08:00
lewwang
d199256d34 asdf 2021-06-09 18:35:14 +08:00
lewwang
073fe4668e asdf 2021-06-09 18:34:31 +08:00
lewwang
89d53853e5 asdf 2021-06-09 18:30:42 +08:00
lewwang
bb6c1572ca asdf 2021-06-09 18:29:55 +08:00
lewwang
4c4e77b11f asdf 2021-06-09 18:28:31 +08:00
lewwang
38c7b7303a dsaf 2021-06-09 18:26:50 +08:00
lewwang
02d0eedd68 update 2021-06-09 18:21:16 +08:00
lewwang
5a3dde93a8 update 2021-06-09 18:15:06 +08:00
lewwang
177f6a59d2 asdf 2021-06-09 17:47:24 +08:00
lewwang
492a62a569 tcts demo page 2021-06-09 17:32:24 +08:00
zhupr
9a44fbf9c1 fix PEP8: qlib/scripts/data_collector/fund/collector.py 2021-06-08 22:52:31 +08:00
zhupr
03eb0882de fix YahooNormalizeCN1minOffline bugs 2021-06-08 22:23:05 +08:00
zhupr
a845a2271b add normalize 1min to use local data && change the default parameters for collecting 1min 2021-06-08 14:45:20 +08:00
you-n-g
ba021f6007 Merge pull request #462 from arisliang/patch-1
Remove non-existing parameter description
2021-06-08 13:03:43 +08:00
al
7d9544fb91 Remove non-existing parameter from doc
Remove non-existing TradeExchange parameter from generate_target_weight_position doc
2021-06-08 09:35:36 +08:00
you-n-g
12b7be333d Merge pull request #461 from Derek-Wds/main
Fix exception hook bug
2021-06-07 21:07:33 +08:00
Jactus
ed54f1213c Fix exception hook bug 2021-06-07 17:13:36 +08:00
Yuge Zhang
76be5d50e5 Refine example 2021-06-07 10:56:12 +08:00
zhupr
554b9c7826 fix YahooCollector getting 1min data occasionally missing 2021-06-05 23:43:48 +08:00
zhupr
6f150f3fd6 Add YahooCollector support for extend data 2021-06-04 22:28:42 +08:00
Yuge Zhang
a06fa2bc44 Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-06-04 15:06:00 +08:00
bxdd
46d253b457 update Exchange.deal_order 2021-06-04 14:41:38 +08:00
Yuge Zhang
1581ef12ac Update impl for robustness 2021-06-04 13:01:49 +08:00
Yuge Zhang
c43805eff6 Update end-to-end example and requirements 2021-06-04 12:20:27 +08:00
bxdd
8aee853a11 update Exchange 2021-06-04 00:55:10 +08:00
you-n-g
2a0d991d9b Merge pull request #459 from you-n-g/online_srv
fix DelayTrainerRM
2021-06-03 15:55:11 +08:00
lzh222333
1320e53f81 fix DelayTrainerRM 2021-06-03 03:23:48 +00:00
Yuge Zhang
bf02fc23f8 Add RL strategy demo 2021-06-02 23:20:27 +08:00
Yuge Zhang
f5ac6230e1 Refactor for strategy 2021-06-02 22:04:54 +08:00
Young
8222795ac4 fix format with black 2021-06-02 09:16:46 +00:00
you-n-g
616a742db7 Merge pull request #435 from you-n-g/online_srv
Multiprocessing support for Online Serving
2021-06-02 17:12:19 +08:00
lzh222333
811d2c975e update & fix 2021-06-02 08:56:15 +00:00
Yuge Zhang
2314405613 Rename files 2021-06-02 16:53:39 +08:00
Yuge Zhang
cc8339acd9 Add a few comments 2021-06-02 16:49:52 +08:00
Yuge Zhang
d515efb46e Finish RL dummy example 2021-06-02 16:41:18 +08:00
lzh222333
6272ce108f Merge remote-tracking branch 'microsoft/main' into online_srv 2021-06-02 08:32:12 +00:00
you-n-g
64896745d0 Merge pull request #457 from zhupr/fix_XGBoost_predict_error
fix XGBoost predict error
2021-06-02 16:14:18 +08:00
Yuge Zhang
3200bb88c8 Update an initial version of RL 2021-06-02 15:11:38 +08:00
zhupr
b2fe2385d5 fix XGBoost predict error 2021-06-01 21:02:32 +08:00
bxdd
4d48c96d30 fix CI 2021-06-01 18:50:50 +08:00
Yuge Zhang
83535bff6a Playground checkpoint 2021-06-01 18:08:11 +08:00
Yuge Zhang
a8e96e59f8 Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy 2021-06-01 17:51:39 +08:00
Yuge Zhang
449e3f40c8 Update init in backtest 2021-06-01 17:51:29 +08:00
bxdd
04fff8ca36 solve conflict 2021-06-01 17:46:47 +08:00
bxdd
a183d8a631 update workflow_by_code & update executor 2021-06-01 17:44:22 +08:00
lzh222333
8d05cd2daf modify tests.config.py 2021-06-01 09:40:53 +00:00
lzh222333
231bdf8608 Merge remote-tracking branch 'microsoft/main' into online_srv 2021-06-01 08:29:02 +00:00
bxdd
a46d99a2be black format 2021-06-01 16:20:21 +08:00
bxdd
bf16e1ab47 update Order with dataclass 2021-06-01 16:19:01 +08:00
lzh222333
ab6b88ce14 delete useless import 2021-06-01 07:48:14 +00:00
lzh222333
94ab4bbf3f add docs 2021-06-01 07:45:39 +00:00
Yuge Zhang
cdc59a78f0 Merge branch 'nested_decision_exe' into rl-dummy 2021-06-01 11:34:45 +08:00
Yuge Zhang
d3dac068df Update simple playground 2021-06-01 11:33:44 +08:00
bxdd
60e082e446 add infra interface & fix no KeyboardInterpret bug 2021-05-31 20:40:11 +08:00
you-n-g
4ff0c4fb0f Update strategy.rst 2021-05-31 08:52:41 +08:00
you-n-g
b3eece155f Merge pull request #452 from arisliang/patch-1
Add import stock pool in doc
2021-05-30 09:44:47 +08:00
al
02e34eb9e9 Add import stock pool (csi300) in documentation 2021-05-30 08:27:21 +08:00
bxdd
bf3b757294 fix bugs 2021-05-29 00:31:40 +08:00
bxdd
96e393b599 del DEBUG log 2021-05-28 22:32:33 +08:00
bxdd
029b63c9dd fix bugs & add highfreq backtest example 2021-05-28 22:29:21 +08:00
Yuge Zhang
c26bee126b Support loading for backtest 2021-05-28 17:31:08 +08:00
you-n-g
3033fdf4b7 Merge pull request #444 from zhupr/feature_importance
add get_feature_importance to model interpret
2021-05-28 16:23:53 +08:00
zhupr
ef11a9d95c modify the default value of exists_skip in the GetData.qlib_data parameter to False 2021-05-28 14:57:06 +08:00
zhupr
98eacf8f88 add test/config.py 2021-05-28 13:24:47 +08:00
you-n-g
43cad1ec27 Merge pull request #442 from arisliang/patch-3
Update 1min demo data in CSV format
2021-05-28 11:22:10 +08:00
you-n-g
e7aa7ffcdd Merge pull request #447 from arisliang/patch-2
Remove repeated package from requirements
2021-05-28 10:46:58 +08:00
you-n-g
ed3c9d9212 Merge pull request #448 from arisliang/patch-4
Update integration.rst
2021-05-28 10:46:25 +08:00
you-n-g
2f3fbae73b Merge pull request #450 from arisliang/patch-5
Update report.rst
2021-05-28 10:45:52 +08:00
al
e409bee9b9 Update report.rst
typo
2021-05-28 07:54:45 +08:00
al
7ceec37848 Update integration.rst
Fix typo
2021-05-27 22:35:43 +08:00
bxdd
6a636546c4 Merge github.com:microsoft/qlib into bxdd-qlib_highfreq_backtest 2021-05-27 21:16:35 +08:00
bxdd
4085b447aa move backtest to core, fix calendar bugs, add some docstring 2021-05-27 21:14:39 +08:00
al
c12c861b7a Remove repeated package from requirements 2021-05-27 19:37:57 +08:00
bxdd
2ad61f12b3 rename var in backtest 2021-05-27 17:03:53 +08:00
zhupr
0a4e241608 add get_feature_importance to model interpret 2021-05-27 14:19:10 +08:00
lzh222333
ca0363ded8 update trainer and manage 2021-05-27 06:04:46 +00:00
al
5a382d7e99 Update data.rst
Update csv format according to feedback
2021-05-27 12:40:55 +08:00
al
9b431bc503 Update 1min demo data in CSV format 2021-05-26 22:01:15 +08:00
you-n-g
cbbf6cd822 Merge pull request #441 from zhupr/fix_yahoo_collector
Fix YahooCollector can't download 1min data
2021-05-26 21:41:14 +08:00
you-n-g
928bae08f4 Merge pull request #440 from arisliang/patch-2
Update collector.py
2021-05-26 21:40:23 +08:00
you-n-g
c65fc226bd Merge pull request #439 from arisliang/patch-1
Update README.md
2021-05-26 21:39:53 +08:00
zhupr
114162693f Fix YahooCollector can't download 1min data 2021-05-26 18:29:41 +08:00
al
b884c8c571 Update collector.py
fix typo
2021-05-26 18:00:23 +08:00
al
6222940b9c Update README.md
fix typo
2021-05-26 17:50:49 +08:00
you-n-g
bb0c555803 Merge pull request #372 from zhupr/data_storage
add data storage
2021-05-26 14:30:46 +08:00
zhupr
5da33562dd remove uri parameter from storage && modify file_storage 2021-05-26 12:33:57 +08:00
bxdd
ee74489c37 solve the conflict 2021-05-25 02:53:44 +08:00
bxdd
75fcb3800d Merge branch 'qlib_highfreq_backtest' of github.com:bxdd/qlib into bxdd-qlib_highfreq_backtest 2021-05-25 02:40:34 +08:00
bxdd
0c6e505455 fix comments 2021-05-25 02:38:34 +08:00
lzh222333
a467e10974 Merge remote-tracking branch 'microsoft/main' into online_srv 2021-05-24 05:10:15 +00:00
lzh222333
6dfbf00a23 Merge branch 'microsoft_main' into online_srv 2021-05-24 05:07:53 +00:00
lzh222333
b24af7fff6 multiprocessing support 2021-05-24 05:07:38 +00:00
you-n-g
db3aa8b887 Merge pull request #433 from arisliang/patch-1
Update README.md
2021-05-23 23:53:49 +08:00
al
ae32d79549 Update README.md
fix typo
2021-05-23 16:54:14 +08:00
you-n-g
a80369b80a Update README.md 2021-05-22 19:00:43 +08:00
you-n-g
369177acf9 Update README.md 2021-05-22 19:00:14 +08:00
you-n-g
2ac5ceb4de Update README.md 2021-05-22 17:58:21 +08:00
zhupr
602f78b568 add documentation on which storage methods are used in qlib 2021-05-22 08:30:12 +08:00
zhupr
669f6bd6f5 modify exception message hint for storage.py && fix FileFeatureStorage[:] bug 2021-05-22 02:06:15 +08:00
you-n-g
3d71fd1966 Merge pull request #431 from evanzd/fix_get_module
Fix `get_module_by_module_path` to support pickle module loaded from arbitrage source file
2021-05-21 12:53:14 +08:00
zhupr
b887d2ec32 code for formatting storage.py using black(v21.5) 2021-05-21 10:29:39 +08:00
zhupr
8e6c744a1b Merge remote-tracking branch 'microsoft/main' into data_storage 2021-05-21 09:49:29 +08:00
zhupr
9e296a8a4e replace the type of numpy deprecated 2021-05-21 08:56:44 +08:00
zhupr
4ba4512619 add write method to FeatureStorage && remove extend 2021-05-21 08:45:11 +08:00
you-n-g
26d75b71b0 Update sample.py 2021-05-19 15:06:47 +08:00
you-n-g
dda509da0b Update record_temp.py 2021-05-19 15:02:04 +08:00
Dong Zhou
2fa7ef32fb fix picker error on importlib loaded module 2021-05-18 22:37:31 +08:00
Dong Zhou
c72ee9091e fix picker error on importlib loaded module 2021-05-18 22:12:41 +08:00
you-n-g
19eda8f4f0 Update README.md 2021-05-17 17:45:31 +08:00
you-n-g
d08146c30f Merge pull request #290 from you-n-g/online_srv
init version of online serving and rolling
2021-05-17 17:35:29 +08:00
lzh222333
8c3a08b18d Finally! 2021-05-17 07:27:55 +00:00
you-n-g
142a9dca3c Merge pull request #423 from ChengYen-Tang/LightGBM-Hyperparameter
LightGBM hyperparameter
2021-05-16 19:43:59 +08:00
Kenneth Tang
41ab130807 Fix CI lint with black 2021-05-18 00:01:45 +08:00
Kenneth Tang
8f67010b58 Fix CI lint with black 2021-05-17 23:09:42 +08:00
lzh222333
a986379deb bug fixed 2021-05-14 11:31:50 +00:00
bxdd
eaa719df17 optimize rule_strategy performance 2021-05-14 15:50:27 +08:00
lzh222333
aef3f186c1 format code 2021-05-14 06:58:02 +00:00
lzh222333
ebd01e0de5 Online Serving V11 2021-05-14 06:44:16 +00:00
bxdd
ea60e608ba update rule_startegy & add README, notebook for multi-level trading 2021-05-14 01:51:43 +08:00
Kenneth Tang
f51e04a1cc LightGBM hyperparameter 2021-05-13 23:12:29 +08:00
bxdd
de2658a8db fix rule_strategy bug 2021-05-13 22:39:19 +08:00
lzh222333
d71a666904 Online serving V11 2021-05-13 09:43:42 +00:00
you-n-g
8b15ffc027 Merge pull request #419 from Derek-Wds/main
Fix bug and update doc
2021-05-13 16:38:22 +08:00
you-n-g
f15ca39df8 Merge pull request #418 from zhupr/set_global_logger_level
Modify set_global_logger_level use of contextmanager
2021-05-13 16:36:40 +08:00
Jactus
bd37f5d953 Fix bug and update doc 2021-05-13 14:21:54 +08:00
bxdd
c703dabcc7 fix rule_strategy reset method 2021-05-13 00:46:17 +08:00
bxdd
07eaada31e fix comments 2021-05-13 00:33:57 +08:00
zhupr
76c5c5d1b6 Add docstrings to set_global_logger_level 2021-05-12 22:38:50 +08:00
zhupr
b8e64dc526 Modify set_global_logger_level use of contextmanager 2021-05-12 17:58:39 +08:00
you-n-g
df7c882fe3 Merge pull request #416 from zhupr/configurable_dataset
Add configurable dataset to examples
2021-05-12 09:03:56 +08:00
bxdd
621cb243c2 fix some comments and add docstring 2021-05-12 02:17:39 +08:00
zhupr
9bd77bd89f Add configurable dataset to examples 2021-05-11 17:36:55 +08:00
you-n-g
c43a0b208d Merge pull request #413 from Derek-Wds/stale
Stale bot update
2021-05-10 21:15:36 +08:00
Jactus
8ba5e93d04 Skip enhancement in stale bot 2021-05-10 12:33:58 +08:00
lzh222333
370b6aad74 logger & doc 2021-05-09 11:58:06 +00:00
lzh222333
f5ded06a15 Merge remote-tracking branch 'microsoft/main' into online_srv 2021-05-09 10:53:41 +00:00
lzh222333
4c232610f1 Merge branch 'online_srv' of https://github.com/you-n-g/qlib into online_srv 2021-05-09 10:52:07 +00:00
Dingsu Wang
81bd2ca8fb Merge branch 'microsoft:main' into stale 2021-05-09 17:59:46 +08:00
Jactus
143c257fa2 Update stale bot 2021-05-09 17:56:37 +08:00
Jactus
724f9ba8d2 Update stale bot 2021-05-09 17:52:18 +08:00
you-n-g
aa1f9b464b Merge pull request #412 from zhupr/set_global_logger_level
Add set_global_logger_level
2021-05-09 11:25:56 +08:00
zhupr
d2daba99d3 Add set_global_logger_level 2021-05-09 09:05:57 +08:00
you-n-g
1c605e505a Merge pull request #14 from you-n-g/online_srv_blin
Online srv blin
2021-05-07 21:07:47 +08:00
you-n-g
060a32e0f6 Merge branch 'online_srv' into online_srv_blin 2021-05-07 21:07:27 +08:00
binlins
08edb92461 add flt_data doc 2021-05-07 12:56:58 +00:00
binlins
bec65ddf94 add document and reindex 2021-05-07 11:47:47 +00:00
lzh222333
9dfd001f6f online serving v10 2021-05-07 09:59:15 +00:00
you-n-g
95a4a98de8 Update README.md 2021-05-07 10:56:57 +08:00
you-n-g
d4639b7df9 Update README.md
Update high-frequency trading link
2021-05-07 10:46:45 +08:00
bxdd
f7d30960c1 update the internal bar strategy 2021-05-07 00:10:44 +08:00
bxdd
bc3eada02d black format 2021-05-06 21:34:31 +08:00
bxdd
7540ecde11 fix trade time bug 2021-05-06 21:33:33 +08:00
blin
846c64f6c6 fix param 2021-05-06 12:00:41 +00:00
lzh222333
84c56f13bd docs and bug fixed 2021-05-06 04:18:55 +00:00
lzh222333
1c99fb35da Merge remote-tracking branch 'microsoft/main' into online_srv 2021-05-06 02:24:16 +00:00
you-n-g
5bc2b96346 Update data.rst 2021-05-03 12:34:08 +08:00
bxdd
ae339506b3 del old strategy 2021-04-30 23:35:28 +08:00
bxdd
e30df11a0b solve the conflict 2021-04-30 23:23:56 +08:00
bxdd
d297a493b8 fix bugs 2021-04-30 22:56:21 +08:00
you-n-g
ee269b0914 Merge pull request #407 from Derek-Wds/log
Fix logger pickling error
2021-04-30 17:33:42 +08:00
you-n-g
2a2d2cf709 Merge pull request #404 from Derek-Wds/main
Support start exp with given exp & recorder id
2021-04-30 16:46:46 +08:00
Jactus
5eb9dfff16 Remove redundant 2021-04-30 15:28:37 +08:00
Jactus
694ae34027 Update api 2021-04-30 13:27:19 +08:00
Jactus
51b649ec39 Update QlibLogger 2021-04-30 13:13:05 +08:00
bxdd
a109df3f46 fix bug in recorder 2021-04-30 01:06:05 +08:00
Jactus
ca92cb980c Update meta logger 2021-04-29 22:40:52 +08:00
Jactus
f58c61a2e0 Fix logger pickling error 2021-04-29 16:54:51 +08:00
lzh222333
2b7ffa100f Merge remote-tracking branch 'microsoft/main' into online_srv 2021-04-29 05:23:42 +00:00
lzh222333
67c5740c83 OnlineServing V9 2021-04-29 04:30:09 +00:00
bxdd
f404a031f3 black format 2021-04-29 02:29:29 +08:00
bxdd
49cdaf8f5d update port_ana_record 2021-04-29 02:28:22 +08:00
bxdd
86a6f565e8 trade_account support multi bar report 2021-04-29 02:15:34 +08:00
lzh222333
6f669348a8 Merge branch 'online_srv' of https://github.com/you-n-g/qlib into online_srv 2021-04-28 09:23:13 +00:00
lzh222333
40cf83e557 online serving V9 middle status 2021-04-28 09:23:07 +00:00
blin
fa4511cb0a filter 2021-04-28 07:30:22 +00:00
blin
45c6dfc5da filter 2021-04-28 07:25:19 +00:00
blin
36ab078fbd filter 2021-04-28 07:15:59 +00:00
you-n-g
5a7f9ef720 Merge pull request #405 from zhupr/future_trading_date_collector
Add future trading date collector
2021-04-28 10:07:08 +08:00
zhupr
8b8d21107c Add future trading date collector 2021-04-27 21:20:47 +08:00
Jactus
eab19de080 Support start exp with given exp & recorder id 2021-04-27 16:56:07 +08:00
lzh222333
42f510024c update collector 2021-04-27 04:12:08 +00:00
Young
5a7eecabee black formating (black is upgraded in github) 2021-04-27 04:04:43 +00:00
bxdd
8920c1967f del outdate file 2021-04-26 20:54:10 +08:00
lzh222333
0058f7d0dc Online Serving V8 2021-04-26 09:31:47 +00:00
you-n-g
9a74fe34f6 Merge pull request #401 from zhupr/online_fix
Fix online mode bugs
2021-04-26 12:29:55 +08:00
zhupr
e15ea06122 Fix ClientProvider not supporting LocalInstrumentProvider && online using the latest python-socketio 2021-04-25 23:50:29 +08:00
lzh222333
319396c815 online serving V8 2021-04-25 06:26:45 +00:00
bxdd
af0053eb17 fix bug 2021-04-24 22:37:36 +08:00
bxdd
b14efa1129 update trade calendar & backtest workflow 2021-04-24 02:29:42 +08:00
you-n-g
50be7a9171 Merge pull request #393 from Derek-Wds/main
Update qlib logger
2021-04-23 12:41:05 +08:00
Jactus
e410caaa8f Simplify meta class 2021-04-23 10:08:12 +08:00
Jactus
fbff4c271a Remove redundant methods in meta 2021-04-23 00:38:45 +08:00
bxdd
39deb7d27f update env & strategy, add workflow 2021-04-22 22:28:01 +08:00
you-n-g
ee91503973 Merge pull request #399 from Derek-Wds/doc
Update doc
2021-04-22 20:37:40 +08:00
lzh222333
de0a0c083d bug fixed 2021-04-22 08:09:15 +00:00
Jactus
8adfafa6aa Black format 2021-04-22 14:17:25 +08:00
Jactus
aafaff45d2 Update doc 2021-04-22 14:13:36 +08:00
bxdd
8979d786a9 update report & account 2021-04-22 02:04:40 +08:00
bxdd
971d6a2847 update strategy 2021-04-21 16:42:16 +08:00
Jactus
6a05d4e255 Enable IDEs docstrings 2021-04-19 11:36:00 +08:00
Jactus
cbf1fa721e Update 2021-04-17 15:47:49 +08:00
Jactus
4ebf684794 Update workflow logging 2021-04-16 15:35:11 +08:00
Jactus
f4bfe8e619 First trial of adding docstring 2021-04-16 14:35:05 +08:00
lzh222333
cec318fbfe online serving V7 2021-04-16 05:37:13 +00:00
Jactus
78bb8882cd Format 2021-04-16 12:00:18 +08:00
Jactus
848d953226 Update qlib logger 2021-04-16 09:58:55 +08:00
you-n-g
a3a2b5ae0b Merge pull request #358 from javaThonc/high_freq_demp
update high freq demo
2021-04-14 20:05:07 +08:00
Alex Wang
941c980d06 update tabnet 2021-04-14 17:35:19 +08:00
Alex Wang
fe190dec4b update readme 2021-04-14 14:40:28 +08:00
lzh222333
5095b2a470 simulator & examples 2021-04-13 09:45:16 +00:00
zhupr
317357b50d Modify data.storage 2021-04-13 10:47:01 +08:00
Young
b15e5e33fd Fix the multi-processing bug 2021-04-12 06:33:31 +00:00
Young
cca43cf102 Refactor update & modification when running NN 2021-04-11 14:39:19 +00:00
Young
a366c11d67 Update features for hyb nn 2021-04-09 13:48:01 +00:00
Young
18bf4b5477 parameter adjustment 2021-04-08 03:52:58 +00:00
lzh222333
c20eb5c8a6 format code 2021-04-08 03:30:24 +00:00
Young
71605794a2 Merge branch 'online_srv_wd' into online_srv 2021-04-07 05:17:07 +00:00
Young
1dbb561744 Fix some API(for lb nn) 2021-04-07 03:53:56 +00:00
lzh222333
cb42e99bee bug fixed & examples fire 2021-04-07 03:33:27 +00:00
lzh222333
431a9c92c1 online serving v5 2021-04-02 07:09:29 +00:00
lzh222333
bd7a1c11b9 trainer & group & collect & ensemble 2021-04-02 04:27:14 +00:00
zhupr
70fc58104b Modify FileStorage 2021-04-01 12:58:34 +08:00
lzh222333
edcd7b1ff9 bug fixed & code format 2021-03-31 03:08:48 +00:00
lzh222333
3724273d73 Merge remote-tracking branch 'microsoft/qlib/main' into online_srv 2021-03-31 02:54:05 +00:00
lzh222333
544365f3a9 ensemble & get_exp & dataset_pickle 2021-03-31 02:39:14 +00:00
Alex Wang
bed1175e24 update dataset 2021-03-30 19:29:17 +08:00
you-n-g
70c84cbc77 Merge pull request #381 from D-X-Y/main
Fix print issue
2021-03-30 17:25:26 +08:00
you-n-g
da59b35c0a Merge pull request #380 from Derek-Wds/main
Modify get_exp & get_recorder api
2021-03-30 16:54:01 +08:00
lzh222333
eae94d1ee8 Merge remote-tracking branch 'microsoft/qlib/main' into online_srv 2021-03-30 07:16:56 +00:00
lzh222333
1f2d2c9b69 online debug 2021-03-30 06:56:04 +00:00
Jactus
b6df11b6b4 Modify get_exp & get_recorder api 2021-03-30 14:41:56 +08:00
you-n-g
ae57110f64 Merge pull request #374 from bxdd/qlib_loaderhandler
Add DataLoader Based on DataHandler & Add Rolling Process Example & Restructure the Config & Setup_data
2021-03-30 13:37:55 +08:00
bxdd
7a2203f116 update comments 2021-03-30 11:03:07 +08:00
bxdd
023603479c fix readme 2021-03-30 01:00:12 +08:00
bxdd
f8da79b802 fix readme 2021-03-30 00:54:00 +08:00
bxdd
136830bc2b update comments 2021-03-30 00:38:15 +08:00
you-n-g
45f78676ea Merge pull request #379 from zhupr/fix_usinex_collector
Fix us_index collector
2021-03-29 23:54:05 +08:00
bxdd
1074284666 fix docstring 2021-03-29 20:38:09 +08:00
bxdd
d18c367497 update README 2021-03-29 20:34:36 +08:00
bxdd
8743576f72 black format 2021-03-29 20:16:00 +08:00
bxdd
fb7f84f31e fix ubg 2021-03-29 20:15:42 +08:00
bxdd
31bc85bf86 restructure data layer config & setup 2021-03-29 19:49:30 +08:00
D-X-Y
968930e85f Fix print issue 2021-03-29 04:46:38 +00:00
zhupr
4b66304978 Fix us_index collector 2021-03-29 11:25:24 +08:00
you-n-g
253378a44e Merge pull request #378 from D-X-Y/main
Add MultiSegRecord and add segment kwargs in model.pred
2021-03-29 01:06:41 +08:00
D-X-Y
f809f0a063 Remove un-used imports 2021-03-28 10:50:25 +00:00
D-X-Y
0386df7b16 Collect all contrib models in __init__ and add unit tests for init 2021-03-28 10:39:28 +00:00
D-X-Y
8a2e7b62af Add segment args for pred and refine MultiSegRecord 2021-03-28 08:30:16 +00:00
D-X-Y
9d04ae4676 Add MultiSegRecord in contrib.workflow and decouple its tests from test_all_pipeline 2021-03-28 00:33:59 -07:00
zhupr
9b8acd9a82 Fix FileStorage 2021-03-27 01:15:33 +08:00
lzh222333
ee45a7833e Merge branch 'main' into online_srv 2021-03-26 08:20:21 +00:00
zhupr
d395c904f2 Add FileStorage 2021-03-26 16:14:45 +08:00
lzh222333
9bf819e653 Merge branch 'online_srv' of https://github.com/you-n-g/qlib into online_srv 2021-03-26 04:32:20 +00:00
lzh222333
46cd57688e Online Serving V4 2021-03-26 04:20:25 +00:00
you-n-g
0387eaf7ab Merge pull request #373 from lewwang1995/main
debug
2021-03-26 11:59:20 +08:00
bxdd
4ee0240c24 black format 2021-03-25 22:08:39 +08:00
bxdd
5f60d18dfe fix config_data bug 2021-03-25 22:08:23 +08:00
bxdd
194217fb07 fix bug 2021-03-25 21:47:17 +08:00
bxdd
d6ff764bb2 black format 2021-03-25 20:36:45 +08:00
bxdd
9cc3b18e4e fix but 2021-03-25 20:36:07 +08:00
LewenWang
56eaacd931 debug 2021-03-25 20:34:45 +08:00
bxdd
e119c8576c black format 2021-03-25 19:59:22 +08:00
bxdd
68246b3b6d update workflow 2021-03-25 19:58:55 +08:00
bxdd
a04c6bd6c9 balck format 2021-03-25 19:56:22 +08:00
bxdd
efe134e9f4 update workflow 2021-03-25 19:56:04 +08:00
bxdd
4ec300787e update rolling workflow 2021-03-25 19:54:52 +08:00
you-n-g
3886022669 Merge pull request #371 from Derek-Wds/main
Update notebook
2021-03-25 18:13:54 +08:00
zhupr
8264033a72 add data-storage 2021-03-25 17:22:05 +08:00
Jactus
4861552d28 Update notebook 2021-03-25 17:13:52 +08:00
you-n-g
834f9bd9b8 Update README.md 2021-03-25 16:58:35 +08:00
bxdd
f6dc25b229 update rolling process 2021-03-25 16:14:22 +08:00
bxdd
1fcfe8e4ba add rolling process data 2021-03-25 01:37:17 +08:00
bxdd
b1a28358ad black format 2021-03-25 01:30:31 +08:00
bxdd
1ca3c6a61c add DataHandlerDL 2021-03-25 01:29:59 +08:00
Alex Wang
e3739bb980 fix naming and code style 2021-03-24 15:47:26 +08:00
you-n-g
419629e4d2 Merge pull request #365 from Flouse/main
fix docs
2021-03-24 13:12:15 +08:00
Flouse
e490e83a16 fix docs 2021-03-24 11:37:09 +08:00
you-n-g
fda144e66f Merge pull request #362 from D-X-Y/main
Add load_object function for R
2021-03-23 22:47:49 +08:00
you-n-g
4dc10d27e0 Merge pull request #359 from bxdd/doc0
Fix data doc
2021-03-23 21:40:27 +08:00
D-X-Y
0a0c6a3185 Add load_object function for R 2021-03-23 10:10:17 +00:00
lzh222333
d66d4ec93d Merge branch 'main' into online_srv 2021-03-23 11:20:02 +08:00
bxdd
4b56a4e907 fix doc 2021-03-22 18:45:27 +08:00
bxdd
7370d5af9e add label doc 2021-03-22 18:37:44 +08:00
bxdd
c6b67cb8fe fix doc 2021-03-22 18:37:13 +08:00
Alex Wang
3bf6c7f95f update format 2021-03-22 15:37:54 +08:00
Alex Wang
1ad237f89f update high freq demo 2021-03-22 14:20:44 +08:00
you-n-g
2b74b4dfa4 Merge pull request #357 from zhupr/fix_yahoo_collector
Fix yahoo_collector
2021-03-22 12:41:17 +08:00
zhupr
598ee875a0 Fix yahoo_collector 2021-03-22 10:29:07 +08:00
bxdd
d3a1e03a11 add sample & base class 2021-03-20 00:11:19 +08:00
Young
84d5318bda Merge branch 'online_srv_wd' into online_srv 2021-03-19 07:49:16 +00:00
you-n-g
ba56e4071e Merge pull request #292 from wangershi/addFund
Add fund data as an example
2021-03-19 11:05:29 +08:00
wangershi
d3160e9439 remove some useless code 2021-03-18 21:15:45 +08:00
you-n-g
06c90d654d Merge pull request #350 from zhupr/fix_dump_bin
Fix dump_bin.py && check_dump_bin.py
2021-03-18 18:39:40 +08:00
you-n-g
f72771cc81 Merge pull request #351 from wendili-cs/patch-1
Update __init__.py
2021-03-18 18:28:18 +08:00
lzh222333
8abdd63869 online_serving V3 2021-03-18 09:30:01 +00:00
Wendi Li
38f35658e7 Update __init__.py 2021-03-18 13:19:27 +08:00
zhupr
d245242f2f Fix dump_bin.py && check_dump_bin.py 2021-03-18 11:21:25 +08:00
lwwang1995
45f73361e3 add tcts baseline 2021-03-18 11:17:42 +08:00
you-n-g
6ef204f190 Merge pull request #348 from microsoft/you-n-g-patch-1
Update Contact Us Information
2021-03-17 16:29:28 +08:00
Young
dad18074ac update image 2021-03-17 08:27:59 +00:00
you-n-g
3cf84f8859 Update Contact Us Information 2021-03-17 16:16:00 +08:00
you-n-g
0403237232 Update Contact US 2021-03-17 15:41:16 +08:00
you-n-g
689774c6be Merge pull request #340 from Derek-Wds/main
Support resuming recorder
2021-03-17 14:48:59 +08:00
Jactus
d78e42e2fe Update exp base method 2021-03-17 13:37:17 +08:00
you-n-g
4de628c736 Merge pull request #347 from 2young-2simple-sometimes-naive/patch-1
fix bug of consider TURE as boolean instead of stock code
2021-03-17 12:08:57 +08:00
you-n-g
023c1fedfe Merge pull request #280 from yongzhengqi/main
Implement Enhanced Indexing as a Portfolio Optimizer
2021-03-17 12:07:39 +08:00
you-n-g
9be6866972 Update README.md 2021-03-17 12:03:53 +08:00
you-n-g
be55e0e3fe Fix Typos 2021-03-17 12:03:00 +08:00
you-n-g
619a3bb25d Update plan and news on Index Page 2021-03-17 12:02:24 +08:00
you-n-g
4bd2cd4611 Add feature news on index page 2021-03-17 11:36:12 +08:00
you-n-g
aa552fdb20 Merge pull request #345 from D-X-Y/main
Fix errors when SignalRecord is not called before SigAna/PortAna
2021-03-17 10:47:00 +08:00
安阁锐
5520463395 fix bug of consider TURE as boolean instead of stock code 2021-03-16 22:18:11 -04:00
D-X-Y
872ddc6f95 Fix black error 2021-03-16 22:57:26 +08:00
D-X-Y
88b0871c12 Add RMSE for contrib.workflow.record_temp and unit tests 2021-03-16 22:55:28 +08:00
D-X-Y
d4aa681652 Add MSERecord in contrib.workflow 2021-03-16 12:54:12 +00:00
Jactus
34f0be2836 Fix arg error 2021-03-16 17:18:48 +08:00
Jactus
447fed8e54 Update structure for resuming 2021-03-16 17:16:00 +08:00
D-X-Y
4cb74d77d1 add error type for record_temp 2021-03-16 09:01:10 +00:00
D-X-Y
b0fd0d2395 Add tests for SigAnaRecord 2021-03-16 08:30:46 +00:00
D-X-Y
6559d44c7d Add tests for SigAnaRecord 2021-03-16 08:17:13 +00:00
D-X-Y
9f57681032 Fix errors when SignalRecord is not called before SigAna/PortAna 2021-03-16 08:11:05 +00:00
lzh222333
d33041dc24 format example 2021-03-16 02:52:20 +00:00
lzh222333
5953365af3 finished update_online_pred demo 2021-03-16 02:43:12 +00:00
lzh222333
e3730b32d7 more clearly structure 2021-03-16 02:23:28 +00:00
Jactus
08b44ed727 Update docs 2021-03-15 14:12:35 +08:00
Jactus
83fb482f1e Fix Bug 2021-03-15 13:55:57 +08:00
Jactus
734bb9ee3c Support resuming recorder 2021-03-15 13:50:10 +08:00
you-n-g
d47e35d64e Merge pull request #337 from D-X-Y/main
Fix bugs in Ghost BN in TabNet and typos in README
2021-03-15 12:42:48 +08:00
lzh222333
0bc49dab60 add task management to index.rst 2021-03-15 03:58:05 +00:00
lzh222333
646d899f8d update docstring and document 2021-03-15 03:50:43 +00:00
D-X-Y
07434da8b0 Remove unused imports 2021-03-15 03:35:34 +00:00
D-X-Y
53a6b72ce5 Fix black errors 2021-03-15 03:09:52 +00:00
D-X-Y
a51dafcb4c Remove unnecessary codes 2021-03-15 03:07:25 +00:00
Young
8362780e22 fix import bug 2021-03-14 15:16:38 +00:00
D-X-Y
358de88602 Fix typos in README and add TabNet config for Alpha360 2021-03-14 07:42:24 +00:00
D-X-Y
32a7be9964 Fix typos in README 2021-03-14 07:31:18 +00:00
D-X-Y
d5f9395e51 Fix Ghost BN bugs in TabNet and simplify its implementation 2021-03-14 07:25:09 +00:00
wangershi
4e7a147759 use base.py 2021-03-14 14:24:14 +08:00
wangershi
1344c40598 Merge remote-tracking branch 'remoteGit/main' into addFund 2021-03-14 11:19:01 +08:00
you-n-g
1d2b2f4f01 Merge pull request #333 from Rekind1e/main
another typo of docs
2021-03-13 20:05:25 +08:00
Hy
373f6e0900 another typo of docs 2021-03-13 15:47:26 +08:00
you-n-g
ba64758c24 Merge pull request #332 from Rekind1e/main
Fix typo of docs
2021-03-13 14:48:02 +08:00
Hy
abddcfccdf fix typo of docs 2021-03-13 14:32:01 +08:00
you-n-g
6d5381f9b1 Merge pull request #311 from withshubh/main
Fixed code quality issues
2021-03-12 18:31:02 +08:00
Young
e4e8a4abcd fix task name & add cur_path 2021-03-12 10:17:16 +00:00
Shubhendra Singh Chauhan
e41373b8ad revert fix 2021-03-12 14:10:52 +05:30
lzh222333
9d84d389ab format code and add example 2021-03-12 08:24:21 +00:00
lzh222333
6d8aa215d6 the second version of online serving 2021-03-12 08:04:08 +00:00
shubhendra
0969c3e7e0 formatted with black 2021-03-12 13:29:20 +05:30
Young
5de7870f9b Merge branch 'online_srv' of github.com:you-n-g/qlib into online_srv 2021-03-12 07:52:31 +00:00
Young
44a7dc004d update docs and fix duplicated pred bug 2021-03-12 07:50:17 +00:00
Shubhendra Singh Chauhan
5f8d0e0436 Merge branch 'main' into main 2021-03-12 13:08:45 +05:30
shubhendra
4fbb5a03c1 revert fixes that failed unit test 2021-03-12 13:05:48 +05:30
you-n-g
0cffb87cbc Merge pull request #329 from D-X-Y/main
Fix Various Bugs for contrib.pytorch_ models
2021-03-12 12:30:08 +08:00
you-n-g
df56e3bdf9 Merge pull request #324 from zhupr/add_base_collector
Add BaseCollector
2021-03-12 12:20:24 +08:00
D-X-Y
1d435248e2 Add return for use_gpu.. 2021-03-11 19:28:00 -08:00
D-X-Y
593553f573 Fix bug in MLP 2021-03-11 19:15:18 -08:00
D-X-Y
d38b8d6001 Fix bugs in use_gpu 2021-03-11 19:10:32 -08:00
D-X-Y
db59713d36 Add torch.no_grad for evaluation 2021-03-12 02:46:04 +00:00
D-X-Y
67fbdafe76 Fix many bugs in TabNet and use_gpu 2021-03-12 02:42:25 +00:00
zhupr
42be8ac312 Add BaseCollector 2021-03-12 10:30:38 +08:00
lzh222333
0df88c07f6 bug fixed and update collect.py 2021-03-11 16:25:46 +00:00
you-n-g
f6b019dcec Merge pull request #328 from D-X-Y/fshare
Move get_path to get_or_create_path, use the best model of SFM / TabNet
2021-03-11 22:07:20 +08:00
D-X-Y
e626264d5a Merge branch 'main' of github.com:microsoft/qlib into fshare 2021-03-11 12:54:04 +00:00
D-X-Y
b99de068f8 Move save_path to get_or_create_path, and fix bugs in sfm / tabnet 2021-03-11 12:52:26 +00:00
you-n-g
e8beaa5257 Merge pull request #314 from D-X-Y/fshare
(1) Fix /0 bug in double_ensemble, (2) remove _default_uri for R/expm, (3) support model size in pytorch models
2021-03-11 20:51:16 +08:00
D-X-Y
0ef7c8e0e6 Fix bugs for get_local_dir 2021-03-11 03:05:31 +00:00
lzh222333
48f0fc147f first version of online serving 2021-03-11 03:00:30 +00:00
D-X-Y
cda96be8c3 Refine default uri in expm 2021-03-11 02:49:03 +00:00
D-X-Y
f6ed175070 Remove set_log_basic_config, refine count_parameters, rename root_uri as get_local_dir 2021-03-11 02:33:00 +00:00
lzh222333
2ca2071d95 format code 2021-03-10 17:06:08 +00:00
you-n-g
0054a4db2a Merge pull request #322 from Derek-Wds/bug
Fix pytorch ts model loader bug
2021-03-10 19:47:56 +08:00
lzh222333
e2f58274ba update task manager 2021-03-10 10:58:49 +00:00
Jactus
119fe90570 Fix pytorch ts model loader bug 2021-03-10 16:43:32 +08:00
you-n-g
e2817ab87c Merge pull request #319 from Derek-Wds/main
Update Filter doc
2021-03-10 15:38:39 +08:00
you-n-g
2e37033e35 Merge pull request #318 from microsoft/bxdd-patch-2
Fix code in ops
2021-03-10 14:45:35 +08:00
Jactus
105fe1d3ed Remove deprecated warning for numpy>=1.20.0 2021-03-10 10:38:43 +08:00
Jactus
78bc2c8748 Update Filter doc 2021-03-09 17:31:27 +08:00
lzh222333
83dbdfb45e finished document and example 2021-03-09 17:22:36 +08:00
bxdd
81987bb143 Update ops.py 2021-03-09 15:38:04 +08:00
Charles Young
53cf89d7c2 Reformat with black. 2021-03-08 19:43:03 +08:00
Charles Young
8b9065c166 Reformat with black. 2021-03-08 19:32:13 +08:00
Charles Young
6a305c73ae Resolve https://github.com/microsoft/qlib/pull/280\#discussion_r589166529 2021-03-08 19:08:55 +08:00
Charles Young
7022675d00 Resolve https://github.com/microsoft/qlib/pull/280\#discussion_r589169489 2021-03-08 19:07:28 +08:00
Charles Young
2f9af1af8f Resolve https://github.com/microsoft/qlib/pull/280\#discussion_r589169769 2021-03-08 19:02:40 +08:00
Charles Young
fc89fec46d Resolve https://github.com/microsoft/qlib/pull/280\#discussion_r589168764 2021-03-08 18:56:54 +08:00
Charles Young
c6675be792 Resolve https://github.com/microsoft/qlib/pull/280\#discussion_r589166143 2021-03-08 17:51:36 +08:00
Charles Young
351d598c9f Resolve https://github.com/microsoft/qlib/pull/280\#discussion_r589165409 2021-03-08 17:49:59 +08:00
Charles Young
81b86f8022 Update test to cover changes in structured_cov_estimator 2021-03-08 17:18:07 +08:00
Charles Young
4d5a30b30b Resolve https://github.com/microsoft/qlib/pull/280\#discussion_r589167776 2021-03-08 17:14:29 +08:00
Charles Young
79c1142d3e Pass nan_option to structured covariance estimator. 2021-03-08 17:09:33 +08:00
D-X-Y
e061443560 Fix lint error with Black 2021-03-08 08:27:58 +00:00
D-X-Y
03ef918dd8 Fix bugs in count_parameters 2021-03-08 08:24:23 +00:00
D-X-Y
ca48345b29 Simplify count_parameters 2021-03-08 08:16:17 +00:00
lzh222333
def132e140 modified format and added TaskCollector 2021-03-08 16:10:16 +08:00
D-X-Y
7bed3b4c2e Fix python format by black 2021-03-08 06:39:03 +00:00
D-X-Y
4266492a34 Merge branch 'main' of github.com:microsoft/qlib into fshare 2021-03-08 06:12:49 +00:00
you-n-g
91eef93386 Merge pull request #302 from D-X-Y/main
Update repr for dataset/workflow classes and add uri kwarg for QlibRecorder
2021-03-08 14:01:53 +08:00
lzh222333
a244f87f95 modified the comments 2021-03-08 13:25:11 +08:00
wangershi
9df0361262 black 2021-03-07 19:35:50 +08:00
wangershi
6bcd88973b resolve one bug 2021-03-07 19:32:37 +08:00
D-X-Y
d13c9ae018 Avoid dividing zero in model.double_ensemble 2021-03-07 11:25:53 +00:00
wangershi
11412727ef add normalizer 2021-03-07 18:51:38 +08:00
D-X-Y
73b7107ee8 Remove useless verbose kwarg 2021-03-07 00:52:27 -08:00
D-X-Y
91fd53ab4d Add reset_default_uri func for R and expm 2021-03-06 05:33:08 -08:00
shubhendra
aab5c5b311 Refactor the comparison involving not
Signed-off-by: shubhendra <withshubh@gmail.com>
2021-03-06 13:01:35 +05:30
shubhendra
dc86a6abc5 Refactor unnecessary else / elif when if block has a continue statement
Signed-off-by: shubhendra <withshubh@gmail.com>
2021-03-06 13:01:34 +05:30
shubhendra
a62d1a1b36 Use literal syntax to create data structure
Signed-off-by: shubhendra <withshubh@gmail.com>
2021-03-06 13:01:34 +05:30
shubhendra
5015d218ff Remove methods with unnecessary super delegation.
Signed-off-by: shubhendra <withshubh@gmail.com>
2021-03-06 13:01:34 +05:30
shubhendra
6f034ccb5d Remove unnecessary use of comprehension
Signed-off-by: shubhendra <withshubh@gmail.com>
2021-03-06 13:01:33 +05:30
shubhendra
07eef18337 Remove length check in favour of truthiness of the object
Signed-off-by: shubhendra <withshubh@gmail.com>
2021-03-06 13:01:33 +05:30
shubhendra
f277a66582 Add .deepsource.toml
Signed-off-by: shubhendra <withshubh@gmail.com>
2021-03-06 13:01:32 +05:30
D-X-Y
49697b1f15 Show model size for pytorch models 2021-03-05 12:46:41 +00:00
D-X-Y
131f0e2e67 Add count_parameters for pytorch models in contrib 2021-03-05 12:07:43 +00:00
D-X-Y
b14a559a52 Merge branch 'main' of github.com:D-X-Y/qlib into fshare 2021-03-05 07:25:18 +00:00
D-X-Y
b115ca5353 Merge branch 'main' of github.com:microsoft/qlib into main 2021-03-04 23:19:33 -08:00
D-X-Y
b40bfb1ea5 Merge branch 'main' of github.com:microsoft/qlib into fshare 2021-03-05 07:17:09 +00:00
D-X-Y
4f980a0266 Merge branch 'fshare' of github.com:D-X-Y/qlib into fshare 2021-03-05 07:15:46 +00:00
D-X-Y
19d93744f3 Add set_log_basic_config function support re-directing log stream 2021-03-05 07:15:25 +00:00
D-X-Y
e327f404e3 Fix pylint issues 2021-03-04 22:37:58 -08:00
D-X-Y
452fb8f013 Make mlflow client consistant with uri 2021-03-04 22:33:35 -08:00
D-X-Y
c4d6e00470 Fix logic of uri in ExpM and add test 2021-03-04 21:04:01 -08:00
Charles Young
0f3e3d206b Update __init__.py. 2021-03-04 22:47:42 +08:00
Charles Young
83c6e74783 Reindex files. 2021-03-04 22:30:38 +08:00
Charles Young
2bff6eb781 Split classes in riskmodel.py & optimizer.py into seperate files. 2021-03-04 22:08:11 +08:00
D-X-Y
ee7eb79277 Fix unexpected mlruns folder error 2021-03-04 06:15:24 +00:00
D-X-Y
592db903b3 Update repr for Experiment & Recorder 2021-03-04 05:02:56 +00:00
wangershi
34b7da1dd8 add calendar list by threshold 2021-03-03 22:49:48 +08:00
lzh222333
2882929c5d Add an example about workflow using RollingGen. 2021-03-03 16:58:05 +08:00
lzh222333
fd2c1ba1ed Update some hint 2021-03-03 16:36:15 +08:00
lzh222333
05cf0e1edc add task_generator method and update some hint 2021-03-03 15:42:39 +08:00
D-X-Y
229a39d0d3 Fix typos in DataHandler's doc 2021-03-03 07:30:55 +00:00
D-X-Y
a9a70dfddf Update repr for DatasetH and ExpManager 2021-03-03 06:47:52 +00:00
you-n-g
b8cf229b05 Merge pull request #272 from ChengYen-Tang/Fix_collector_doc
Fix collector doc
2021-03-03 14:14:07 +08:00
you-n-g
7258340e0c Merge pull request #300 from bxdd/qlib_2021_03_02
Update FAQ doc & Update ops docstring
2021-03-03 14:11:11 +08:00
lzh222333
b84156fde8 Consider more situations about task_config.
Save the "param" file which is collect.py need.
2021-03-03 11:25:37 +08:00
you-n-g
d1d70616a3 Merge pull request #298 from D-X-Y/main
Update the Wrapper class to have an informative str representation
2021-03-03 11:17:00 +08:00
bxdd
5378d261b4 update ops.py docstring 2021-03-03 00:47:50 +09:00
bxdd
a1fb10f7cf update FAQ doc 2021-03-03 00:44:52 +09:00
D-X-Y
dbc8ca7379 Fix pylint by black -l 120 2021-03-02 22:15:30 +08:00
D-X-Y
c48b4c9971 Make Wrapper with a informative str repr. 2021-03-02 21:06:32 +08:00
you-n-g
b592669d1f Update Index Report 2021-03-02 20:23:27 +08:00
you-n-g
0bcaab3a5a Merge pull request #286 from meng-ustc/main
Add a new method to benchmarks: DoubleEnsemble
2021-03-02 18:34:17 +08:00
meng-ustc
1de4def444 Update parameter names: 'k' and 'base' 2021-03-02 16:14:56 +09:00
meng-ustc
ee4692a355 Merge branch 'main' of https://github.com/meng-ustc/qlib 2021-03-02 12:20:45 +09:00
meng-ustc
6e2ce6f1dc Add the results of DoubleEnsemble 2021-03-02 12:17:05 +09:00
lzh222333
c4733f601f Merge pull request #1 from you-n-g/online_srv
qlib auto init basedon project & black format
2021-03-02 10:06:45 +08:00
wangershi
82353b20e1 black format 2021-03-01 21:10:46 +08:00
wangershi
51baf57b40 Merge remote-tracking branch 'remoteGit/main' into addFund 2021-02-28 19:29:18 +08:00
wangershi
3082f6ac1b ready for dump_bin 2021-02-28 19:06:40 +08:00
wangershi
db80b620d8 ready for collector 2021-02-28 17:03:14 +08:00
wangershi
6e56396217 add crawler 2021-02-28 12:24:26 +08:00
Young
24024d51c7 qlib auto init basedon project & black format 2021-02-27 09:44:01 +00:00
Wendi Li
a96f0c2e5f Update README.md
Typos fixed.
2021-02-27 11:37:45 +08:00
Young
1e5cf1c174 init version of online serving and rolling 2021-02-26 09:14:40 +00:00
wangershi
719074d306 touch file 2021-02-25 19:20:14 +08:00
Meng Dong
70575e8a1c Delete workflow_by_code_lgb_risk_demo.py 2021-02-24 16:10:38 +08:00
meng-ustc
ce60097722 Add README and Formatted 2021-02-24 16:59:31 +09:00
meng-ustc
1a990fdd25 Add Risk Prediction Demo 2021-02-23 19:08:11 +09:00
Charles Young
527718a440 Allow enhanced indexing to generate portfolio without industry related restriction. 2021-02-22 19:04:31 +08:00
Charles Young
d3caea60ee Add unittest for TestStructuredCovEstimator. 2021-02-22 17:32:03 +08:00
Charles Young
f947a2fdef Correct two mistakes in annotation. 2021-02-22 15:15:51 +08:00
Jactus
dc4aa67503 Black format 2021-02-22 11:42:36 +08:00
Charles Young
37871389b9 Format code with the latest version of black. 2021-02-22 11:25:42 +08:00
Charles Young
2f9d45e03a Reformat code with black. 2021-02-22 10:29:29 +08:00
Charles Young
b8647c13c7 Reformat code to follow PEP 8. 2021-02-22 10:20:51 +08:00
Charles Young
164687d54b Add scikit-learn to dependencies. 2021-02-22 10:13:08 +08:00
Charles Young
58f74cfd84 Reformat code to follow PEP 8. 2021-02-22 10:07:03 +08:00
Charles Young
f7d3e56561 Merge optimization related portfolio construction back to portfolio/optimizer. 2021-02-22 09:57:41 +08:00
Charles Young
42f882504e Reformat code to follow PEP 8. 2021-02-22 09:25:48 +08:00
Charles Young
9448a6e2c7 Add a abstract class as the base class for all optimization related portfolio constructions. 2021-02-22 09:23:48 +08:00
Charles Young
2cc057e438 Fix minor mismatches of type hints. 2021-02-22 09:09:03 +08:00
Charles Young
b2e2142594 Applied slight modification to follow PEP 8. 2021-02-22 09:00:12 +08:00
Charles Young
4000518698 Separate specific implementation of Portfolio Optimizer to folder. 2021-02-22 08:41:35 +08:00
you-n-g
fa8f1cba06 Update filter.py 2021-02-19 22:23:22 +08:00
you-n-g
a72911e4f8 Update filter.py 2021-02-19 22:23:22 +08:00
meng-ustc
cd5b721bc6 Update 2021-02-19 11:56:50 +09:00
meng-ustc
42590972e4 Modify run_all_model.py 2021-02-18 19:15:02 +09:00
meng-ustc
d27dc8bab8 Add A New Baseline: DoubleEnsemble 2021-02-18 19:02:33 +09:00
Young
50d5fcf61e yml afe load 2021-02-18 08:43:12 +08:00
Young
77830a546e safe yaml loader 2021-02-18 08:43:12 +08:00
Young
83237ba4ed yml afe load 2021-02-17 05:17:18 +00:00
Young
04b916c8ae safe yaml loader 2021-02-16 15:07:14 +00:00
Kenneth Tang
b90bd66ac6 Merge branch 'main' into Fix_collector_doc 2021-02-16 14:16:53 +08:00
Kenneth Tang
63d05e4a1a Fix typo 2021-02-16 14:08:58 +08:00
lbaiao
0b11dc5167 Update workflow.rst
Corrected an identation problem on the configuration.yaml file.
2021-02-11 10:54:32 +08:00
Charles Young
9c2653f125 Add an implementation of Enhanced Indexing to optimizer.py 2021-02-09 20:31:00 +08:00
Charles Young
7b01c5cae7 Add an implementation of Enhanced Indexing to optimizer.py 2021-02-09 20:30:26 +08:00
Charles Young
988b42e159 Add Structured Covariance Estimator to riskmodel.py 2021-02-09 20:28:42 +08:00
Miae Kim
12c8bfa545 Fix typo in Data Layer
Commit changes
2021-02-08 10:29:37 +08:00
Jactus
c948385e76 Add model saving for qrun and workflow example 2021-02-07 21:32:35 +08:00
bxdd
07b905c153 update 2021-02-05 16:09:06 +08:00
bxdd
0192f28bf4 add docstring & fix code 2021-02-05 16:09:06 +08:00
bxdd
cbf97f56a4 fix market 2021-02-05 16:09:06 +08:00
bxdd
d702c8bcb1 add Cut ops 2021-02-05 16:09:06 +08:00
Jactus
b84686b215 Update models to enable save/load 2021-02-05 13:14:12 +08:00
bxdd
6a670828a5 Update serial.rst 2021-02-05 12:33:47 +08:00
bxdd
ca6c2ffc27 Update serial.rst 2021-02-05 12:33:47 +08:00
bxdd
914637b3ef update index 2021-02-05 12:33:47 +08:00
bxdd
d8da94de10 update docs 2021-02-05 12:33:47 +08:00
bxdd
477a548fe9 update data.rst docs 2021-02-05 12:33:47 +08:00
bxdd
35af9ad954 update docs 2021-02-05 12:33:47 +08:00
bxdd
8a91e7d34d black format 2021-02-05 12:33:47 +08:00
bxdd
4ed8b8e233 add docs & fix reinit of datatset 2021-02-05 12:33:47 +08:00
Jactus
c71b645777 Update docs about record-temp 2021-02-05 12:32:47 +08:00
HUAN-PING SU
f2ffb80a0b Update workflow_by_code.py 2021-02-04 17:01:34 +08:00
HUAN-PING SU
cda1d4be40 Update workflow_by_code.py
Fix typo in workflow_by_code.py
2021-02-04 17:01:34 +08:00
zhupr
fc1431cd4e update 1min docs 2021-02-04 16:49:58 +08:00
Jactus
06158fb621 Update readme and setup.py 2021-02-04 16:09:36 +08:00
Jactus
1e2e02368c Update readme 2021-02-03 14:42:58 +08:00
Jactus
d87d29aca9 Update Windows CI 2021-02-03 14:42:58 +08:00
Jactus
005da6306c Update CI 2021-02-03 14:42:58 +08:00
bxdd
090b68e44e Update workflow.py 2021-02-03 13:12:19 +08:00
Young
bf748ba4b7 update version number to dev 2021-02-03 05:11:39 +00:00
Young
0da9b909f6 update version number 2021-02-02 09:48:41 +00:00
Jactus
5f87fc32ad Fix CI 2021-02-02 17:35:07 +08:00
Young
97d354fa73 update version for releasing 2021-02-02 09:24:33 +00:00
Young
a87fb5a68c fix contrib data freq 2021-02-02 16:52:50 +08:00
Young
835b47a7e7 simplify parameters 2021-02-02 16:52:50 +08:00
Young
802dac81c9 move freq params to dataloader 2021-02-02 16:52:50 +08:00
Wendi Li
bdc70c192a Update pytorch_nn.py 2021-02-02 14:48:12 +08:00
Wendi Li
213f809148 Update pytorch_alstm_ts.py 2021-02-02 14:47:41 +08:00
Wendi Li
f3fd5e0773 Update pytorch_gats.py 2021-02-02 14:47:31 +08:00
Wendi Li
decf74cbdf Update pytorch_gru.py 2021-02-02 14:47:20 +08:00
Wendi Li
b4a92d55f8 Update pytorch_gru_ts.py 2021-02-02 14:47:00 +08:00
Wendi Li
ebc31b9bdb Update pytorch_lstm.py 2021-02-02 14:46:49 +08:00
Wendi Li
56ebe9bf36 Update pytorch_lstm_ts.py 2021-02-02 14:46:21 +08:00
Wendi Li
ddd68fc761 Update pytorch_alstm.py 2021-02-02 14:34:57 +08:00
Meng Dong
fd5c68a7d1 Update workflow_config_doubleensemble_Alpha158.yaml 2021-02-02 12:39:07 +08:00
meng-ustc
8c3ec164ff Add A New Baseline: DoubleEnsemble 2021-02-02 11:46:37 +09:00
meng-ustc
acdc469e39 Add A New Baseline: DoubleEnsemble 2021-02-01 21:05:34 +09:00
bxdd
f50463aca9 Fix bug in alpha360 2021-02-01 18:33:51 +08:00
Jactus
c0e7cbc983 Add filter_pipe API 2021-01-29 12:47:04 +08:00
you-n-g
828993b397 Merge pull request #222 from bxdd/rl-highfreq-include-examples
Qlib Highfreq Support & Highfreq DataHanlder/Operator/Processor Examples
2021-01-29 00:08:10 +08:00
bxdd
8ef89b4fa8 update 2021-01-28 15:01:07 +00:00
bxdd
76cf9dad99 update 2021-01-28 14:30:20 +00:00
bxdd
f3eb02a0bd update docstring 2021-01-28 14:26:30 +00:00
bxdd
ffa68fd010 update 2021-01-28 14:25:55 +00:00
bxdd
f6dd006c35 update 2021-01-28 11:31:15 +00:00
you-n-g
8c29105bca Update cache.py 2021-01-27 19:52:33 +08:00
bxdd
948b829ff4 add get_data in highfreq 2021-01-27 10:34:31 +00:00
Jactus
304a0c3d7a Add paper year 2021-01-27 18:15:52 +08:00
bxdd
02dea2aeb6 update paused 2021-01-27 07:42:00 +00:00
bxdd
6fc4f2b249 fix a bug 2021-01-27 07:02:59 +00:00
bxdd
2a5f06ee9e update dataset test 2021-01-27 06:25:40 +00:00
zhupr
7f9216dc90 Fix the number of minutes on the first and last trading day of high frequency 2021-01-27 10:59:46 +08:00
zhupr
263ccdfe6f US stock code supports Windows 2021-01-27 10:59:46 +08:00
zhupr
1a8f1bfc57 support collecting yahoo 1min data 2021-01-27 10:59:46 +08:00
bxdd
9dc11a9e3c Merge github.com:microsoft/qlib into qlib_register_ops 2021-01-26 17:12:33 +00:00
bxdd
3bdd54308b update some little code 2021-01-26 17:02:30 +00:00
bxdd
1b569d371d simpson vwap 2021-01-26 14:32:08 +00:00
you-n-g
36e5c601de Merge pull request #78 from zhupr/main
Fix the error when the stock code is a number
2021-01-26 21:50:21 +08:00
zhupr
ae45711e2b Merge remote-tracking branch 'qlib/main' into save_inst 2021-01-26 19:42:59 +08:00
you-n-g
bcc47aa4cb Merge pull request #92 from bxdd/qlib_register_ops
Support Register of Custom Feature Operators Easily
2021-01-26 18:53:43 +08:00
bxdd
ee94634b23 black 2021-01-26 08:47:53 +00:00
bxdd
2016ebbbb2 update tests 2021-01-26 08:47:07 +00:00
zhupr
1eaf09cce1 version removed .dev 2021-01-26 16:29:26 +08:00
zhupr
7579f4b4c0 Merge remote-tracking branch 'qlib/main' into save_inst 2021-01-26 16:14:11 +08:00
zhupr
1a1c45981c US stock code supports Windows 2021-01-26 16:06:38 +08:00
bxdd
e4ecea55e4 fix 2021-01-26 07:41:22 +00:00
bxdd
58616fced9 black format 2021-01-26 07:33:50 +00:00
bxdd
8e9ca22b07 del some print 2021-01-26 07:33:26 +00:00
bxdd
6a145df87c fix bug 2021-01-26 07:32:06 +00:00
bxdd
06dbd02b99 black format 2021-01-25 17:59:48 +00:00
bxdd
ffedb6382f add highfreq example 2021-01-25 17:58:45 +00:00
zhupr
3f9f295a87 add register in config 2021-01-24 11:22:02 +08:00
Wendi Li
84d77f4585 Update pytorch_nn.py 2021-01-24 10:40:47 +08:00
you-n-g
afdf58b4fa Update serial.py 2021-01-24 10:36:56 +08:00
Alex Wang
2b6d16feb1 fix naming 2021-01-22 19:16:57 +08:00
Alex Wang
0a86a6f392 update format 2021-01-22 19:16:57 +08:00
Alex Wang
5da5ad4b9f tabnet 2021-01-22 19:16:57 +08:00
you-n-g
dd07810b66 Update README.md 2021-01-22 12:53:05 +08:00
bxdd
a762248d98 update test&docs 2021-01-22 01:06:32 +09:00
bxdd
80c9a47e51 Merge github.com:microsoft/qlib into qlib_register_ops 2021-01-22 00:52:30 +09:00
王雪
784e73bceb black formatting 2021-01-21 00:07:03 +08:00
王雪
5ad1b4cc33 for IDE auto-complete with global Wrapper
R, D, Cal, Inst, FeatureD, ExpressionD, DatasetD, D
2021-01-21 00:07:03 +08:00
王雪
e85646762c Update .gitignore 2021-01-20 22:12:35 +08:00
Young
fc81a39317 Add dataset standalone usage example 2021-01-20 21:14:27 +08:00
you-n-g
d44c5bb2b2 Update README.md 2021-01-20 21:14:03 +08:00
bxdd
c622d3f6f8 Update data.rst 2021-01-20 18:55:30 +08:00
bxdd
6daaa79519 add register ops config 2021-01-20 18:44:53 +09:00
zhupr
3dda2cb379 Merge remote-tracking branch 'qlib/main' into qlib_register_ops 2021-01-20 15:16:06 +08:00
zhupr
4fcfde7cfb Initialization is split into: set_config and config_based_on_C 2021-01-20 15:06:18 +08:00
bxdd
3403c00b6b Update requirements.txt
fix readthedocs cant find cmake error
2021-01-19 20:35:11 +08:00
bxdd
ecdfe49fd1 del custom ops test for check the CI status 2021-01-19 20:39:15 +09:00
bxdd
cc214a3462 black format 2021-01-19 09:14:17 +08:00
bxdd
65d8af41e7 restructure backtest 2021-01-19 09:14:17 +08:00
bxdd
0e0970f06e update backtest 2021-01-19 09:14:17 +08:00
bxdd
917261dbf6 update backtest 2021-01-19 09:14:17 +08:00
bxdd
6a9105e065 add highfreq_backtest 2021-01-19 09:14:17 +08:00
王雪
570bb272eb fix setup error
why required pymongo
2021-01-18 19:37:24 +08:00
Wendi Li
0524a47cf4 Update pytorch_lstm_ts.py 2021-01-18 12:20:40 +08:00
Wendi Li
9abc0b0d4f Update pytorch_gru_ts.py 2021-01-18 12:20:31 +08:00
Wendi Li
fe60e40927 Update pytorch_gats_ts.py 2021-01-18 12:20:20 +08:00
Wendi Li
740c297618 Update pytorch_alstm_ts.py 2021-01-18 12:20:00 +08:00
Anon-Artist
b4a088efe8 Update cli.py 2021-01-14 18:42:33 +08:00
Jactus
b34890772f Make note more clear 2021-01-13 19:19:48 +08:00
Jactus
054ffa29f6 Update readme 2021-01-13 19:19:48 +08:00
Jactus
74e08c9e37 Add deepcopy to config 2021-01-13 19:19:48 +08:00
Jactus
ea96c9e22d Update docs and support Python 3.9 2021-01-13 19:19:48 +08:00
王雪
86e7c44c6b Update initialization.rst
need line changing
2021-01-13 15:28:05 +08:00
you-n-g
64cf2e2df8 Update data.rst 2021-01-12 18:43:05 +08:00
Jactus
4361a4049a Fix create_recorder bug 2021-01-07 18:30:18 +08:00
Zhichong Fang
231f37376b Fix unrecognized config bug 2021-01-07 18:28:17 +08:00
you-n-g
328cdeda4a Update README.md 2021-01-07 11:12:49 +08:00
Zhichong Fang
4dbc8e52ec Update data.py
Fix some typo
2021-01-06 16:36:23 +08:00
Young
ba447d3448 update valute 2021-01-06 14:43:14 +08:00
zhupr
df556532d0 Fix the error when the stock code is a number 2021-01-06 11:21:33 +08:00
Wendi Li
18e040f506 Update workflow_config_gru_Alpha158.yaml
Delete a redundant parameter.
2021-01-04 17:05:21 +08:00
Wendi Li
aefc98b1d7 Update workflow_config_lstm_Alpha158.yaml
Delete a redundant parameter.
2021-01-04 17:05:13 +08:00
Jactus
46c8d791ac Fix doc bugs 2020-12-30 23:51:05 +08:00
Young
afcd91a2d0 black format 2020-12-28 12:04:03 +00:00
Young
4a30d9d1ec update github issue template 2020-12-28 12:02:01 +00:00
you-n-g
2da2e9bd9e Update README.md 2020-12-26 20:21:30 +08:00
you-n-g
3e6877ff0f Update README.md 2020-12-25 22:01:18 +08:00
zhupr
a0f32036a6 Fix the first trading day of the calendar extra in report_df 2020-12-24 11:22:48 +08:00
bxdd
d8f36df7f4 debug on macos 2020-12-23 18:28:05 +00:00
bxdd
cb3b6c5bde black format 2020-12-23 16:41:32 +00:00
bxdd
b11712fa54 fix cant find ops error on Windows 2020-12-23 16:39:17 +00:00
Jactus
660edeb94f Remove fm in recorder 2020-12-23 21:14:53 +08:00
Jactus
95de4088df Fix recorder temp dir bug 2020-12-23 21:14:53 +08:00
hadrianl
e8d7a22651 fix _adjust_size 2020-12-23 17:39:04 +08:00
hadrianl
4a62b929ad add _get_value_size and remove _limit_flag 2020-12-23 17:39:04 +08:00
hadrianl
5efe82fb56 make code cleaner 2020-12-23 17:39:04 +08:00
hadrianl
40bbafcaab black format 2020-12-23 17:39:04 +08:00
hadrianl
4c4f0f3c5e black format 2020-12-23 17:39:04 +08:00
hadrianl
ae0e0eca3d better MemCacheUnit implement 2020-12-23 17:39:04 +08:00
bxdd
7e37fa710a update alpha.rst 2020-12-21 23:31:31 +08:00
bxdd
e0c460c33c Update alpha.rst 2020-12-21 23:31:31 +08:00
bxdd
53f501ac19 del import 2020-12-21 12:44:27 +00:00
bxdd
132df027a5 update format 2020-12-21 12:09:25 +00:00
bxdd
7d97fd39ce update ops register 2020-12-21 12:06:42 +00:00
Young
995fa98fc6 add more doc to PortAnaRecord 2020-12-20 16:11:07 +08:00
Maciej Domagała
824de921d1 fixing typos #4 2020-12-19 11:59:23 +08:00
Maciej Domagała
66d9bd1a68 fixing typos #3
I just randomly find these by the way. Good work on the framework!
2020-12-18 20:16:54 +08:00
you-n-g
1c0bb2f827 Merge pull request #97 from Derek-Wds/main
Update benchmark performance
2020-12-17 17:12:40 +08:00
Maciej Domagała
ea018ed4dc fixing typos #2 2020-12-17 17:12:18 +08:00
hadrianl
f3f1867b14 fix wrong attribute 2020-12-17 15:04:07 +08:00
hadrianl
8bbfd8810c formatting 2020-12-17 15:04:07 +08:00
hadrianl
3f84c3768a Make __getattr__ to raise AttributeError instead of return it.Avoid using try except. 2020-12-17 15:04:07 +08:00
Dingsu Wang
7372a3a598 Merge branch 'main' into main 2020-12-17 14:43:21 +08:00
Jactus
4b4cd38ca6 Update benchmark results 2020-12-17 14:41:12 +08:00
you-n-g
7d40ba753a Update README.md 2020-12-17 00:35:35 +08:00
Young
9b60214e0c make info more friendly 2020-12-16 02:16:06 +00:00
Young
f7e775f941 make message more friendly 2020-12-16 02:14:38 +00:00
Young
aefbf3b5f1 update collect info 2020-12-15 13:24:29 +00:00
G_will
3f85af05e5 Refactor to Python3 style 2020-12-15 20:37:43 +08:00
Jactus
192c2dc5ef Add demo 2020-12-15 20:33:32 +08:00
Jactus
911edd7839 Add stale bot 2020-12-15 20:31:38 +08:00
Maciej Domagała
3d47dd78c8 Typo fix 2020-12-15 20:29:30 +08:00
Jactus
8f6ab0af54 Format 2020-12-14 19:23:43 +08:00
Jactus
cb0b6fcdaa Update CI and script 2020-12-14 19:23:43 +08:00
Yifan Deng (FA Talent)
6b8824dd29 Update Sign in ops.py 2020-12-14 16:55:23 +08:00
Yifan Deng
c217e7c479 Update ops.py
Fix the bug when Sign followed by True/False
2020-12-14 16:55:23 +08:00
you-n-g
ea4fe1577b Update README.md 2020-12-14 13:05:12 +08:00
you-n-g
1bab07e419 Update README.md 2020-12-13 22:45:07 +08:00
bxdd
422d1d8c93 Update README.md 2020-12-12 19:41:16 +08:00
bxdd
c8f9b1162d Update README.md 2020-12-12 19:01:00 +08:00
Young
e2bdef7ffe update version number to dev 2020-12-12 10:09:18 +00:00
Young
e49b590322 Release qlib 0.6.1 2020-12-12 09:51:52 +00:00
bxdd
9d19294f15 update Note 2020-12-12 17:42:23 +08:00
bxdd
b0e7a85601 update readme 2020-12-12 17:42:23 +08:00
you-n-g
8ea45802df Update README.md 2020-12-12 14:04:21 +08:00
Jactus
bba94d72dc Add author names 2020-12-11 17:19:12 +08:00
Jactus
d6dd423dc2 Update benchmark performance 2020-12-11 17:19:12 +08:00
Jactus
c10955d026 Update tft 2020-12-11 14:33:16 +08:00
Jactus
d642c7b6ea Update benchmark performance 2020-12-11 09:55:37 +08:00
G_will
9307bcc8d1 fix typo
fix typo
2020-12-10 20:11:57 +08:00
Jactus
99f3820e42 Update readme 2020-12-10 19:37:18 +08:00
Jactus
b04d2c39c8 Update CI 2020-12-10 19:37:18 +08:00
bxdd
0cdc5e125a update docs 2020-12-10 10:08:29 +00:00
bxdd
2de812f262 update ops docs 2020-12-10 10:04:09 +00:00
bxdd
16450c2876 fix import 2020-12-10 09:54:05 +00:00
bxdd
729b57e4a7 add example script 2020-12-10 09:11:12 +00:00
bxdd
87cc52cd05 black format 2020-12-10 09:02:43 +00:00
bxdd
0be57d51be support register custom feature ops easily 2020-12-10 09:00:00 +00:00
bxdd
9c482ebbe2 black format 2020-12-10 15:50:14 +08:00
bxdd
eb67f1037a update setup 2020-12-10 15:50:14 +08:00
bxdd
59282c8965 fix req 2020-12-10 15:50:14 +08:00
bxdd
03ab67ad5c fix req 2020-12-10 15:50:14 +08:00
bxdd
e2d862bfb2 fix system package 2020-12-10 15:50:14 +08:00
bxdd
936d5abb1f fix docs req 2020-12-10 15:50:14 +08:00
bxdd
7296780149 fix setup 2020-12-10 15:50:14 +08:00
bxdd
97c053ba73 update setup 2020-12-10 15:50:14 +08:00
bxdd
2c5864204e del qlib.readthedocs.yml 2020-12-09 13:58:17 +00:00
bxdd
6562c9aaa4 Merge https://github.com/microsoft/qlib into main 2020-12-09 13:55:56 +00:00
bxdd
85a217c121 update readthedocs 2020-12-09 13:54:22 +00:00
bxdd
f156280a51 Merge pull request #84 from bxdd/qlib_readthedocs
Fix readthedocs
2020-12-09 21:43:51 +08:00
bxdd
e8eb034a97 fix the config of readthedocs 2020-12-09 13:41:18 +00:00
bxdd
7763cf5a5c add the config of readthedocs 2020-12-09 21:27:39 +08:00
bxdd
053736c0ea add the config of readthedocs 2020-12-09 13:23:59 +00:00
Young
74ac230edb rename for pytest 2020-12-09 20:24:56 +08:00
Young
303021cd47 CI updating 2020-12-09 20:24:56 +08:00
Young
c0f1696adb add downcast to save data 2020-12-09 20:24:56 +08:00
Young
361d168890 remove dataloader 2020-12-09 20:24:56 +08:00
lwwang1995
73669de392 Fix code. 2020-12-09 20:24:56 +08:00
Wendi Li
89ec87e45b Add files via upload 2020-12-09 17:20:36 +08:00
Wendi Li
15cdfeb121 Add files via upload 2020-12-09 17:20:36 +08:00
Wendi Li
1bbd026195 Add files via upload 2020-12-09 17:20:36 +08:00
Jactus
a5c098de92 Update tft results 2020-12-09 17:20:36 +08:00
bxdd
a63ba3e819 black format 2020-12-09 17:20:36 +08:00
bxdd
56e579e20f add arg weight_decay 2020-12-09 17:20:36 +08:00
bxdd
2873813562 update mlp model 2020-12-09 17:20:36 +08:00
Jactus
a8ac56a82f Format 2020-12-09 17:20:36 +08:00
Jactus
6ef339b1ec Update mlp results and add doc 2020-12-09 17:20:36 +08:00
Jactus
579caa757c Update readme 2020-12-09 17:20:36 +08:00
Jactus
a1e579ff39 Update readme 2020-12-09 17:20:36 +08:00
Jactus
217019a640 Update benchmark readme 2020-12-09 17:20:36 +08:00
Jactus
c14404afe1 Add benchmark results 2020-12-09 17:20:36 +08:00
lwwang1995
4596a7e000 Delete the setting of SFM on the Alpha158. 2020-12-09 17:20:36 +08:00
lwwang1995
ec40845513 Update settings. 2020-12-09 17:20:36 +08:00
lwwang1995
dcfa8110e8 Fix bugs for Gats model. 2020-12-09 17:20:36 +08:00
lwwang1995
666e1ffcbd Update settings. 2020-12-09 17:20:36 +08:00
lwwang1995
70fb760830 Fix bugs for models. 2020-12-09 17:20:36 +08:00
lwwang1995
4a748525bc Fix bugs of model. 2020-12-09 17:20:36 +08:00
Young
fb4a2e65cc support multi indexing of TSDatasetSample 2020-12-09 17:20:36 +08:00
lwwang1995
71ad651514 Add sample for Gats. 2020-12-09 17:20:36 +08:00
lwwang1995
65a9a72a88 Update models. 2020-12-09 17:20:36 +08:00
lwwang1995
ec0d7838ac Update models. 2020-12-09 17:20:36 +08:00
lwwang1995
752f17e51e Fix SFM bug. 2020-12-09 17:20:36 +08:00
lwwang1995
8d42092a7e Fix models. 2020-12-09 17:20:36 +08:00
lwwang1995
412c9eee2e Update models. 2020-12-09 17:20:36 +08:00
Young
abb90ca2f6 fix sampler performance bug 2020-12-09 17:20:36 +08:00
lwwang1995
a7c6aea386 Update record to support time series dataset. 2020-12-09 17:20:36 +08:00
lwwang1995
a88697151a Test CSRankNorm. 2020-12-09 17:20:36 +08:00
Young
d2107c9957 dataset performance optm 2020-12-09 17:20:36 +08:00
lwwang1995
65902e424c Add filter columns. 2020-12-09 17:20:36 +08:00
lwwang1995
bf8de72605 Update test_dataset 2020-12-09 17:20:36 +08:00
lwwang1995
60f62482b7 Update test_dataset 2020-12-09 17:20:36 +08:00
Young
d2d865fb7a fix bug of workflow 2020-12-09 17:20:36 +08:00
Young
5d5f8c8868 update TimeSeriesDataset 2020-12-09 17:20:36 +08:00
you-n-g
d093afd684 Merge pull request #74 from Derek-Wds/main
Update scripts
2020-12-04 14:30:42 +08:00
Dingsu Wang
46396c229a Update README.md 2020-12-04 14:28:13 +08:00
Jactus
eef90c7901 Update readme 2020-12-04 14:25:26 +08:00
Jactus
895b1e7944 Update CI 2020-12-04 13:10:45 +08:00
Jactus
2fb7774927 Update config names 2020-12-04 13:02:09 +08:00
Jactus
86b0b63771 Update table generator 2020-12-04 12:55:22 +08:00
Jactus
99adc514a5 Update CI 2020-12-04 11:51:45 +08:00
Jactus
07fb9031c6 Update setup 2020-12-04 10:47:20 +08:00
Jactus
f237a344c3 Update 2020-12-04 10:31:50 +08:00
Dingsu Wang
2cb888c8b9 Merge branch 'main' into main 2020-12-04 09:45:00 +08:00
Jactus
ab762b3cd7 Update lightgbm lr 2020-12-02 20:04:00 +08:00
Jactus
703ae5d4aa Update tft and readme 2020-12-02 18:00:26 +08:00
Jactus
91c3dfddf5 Update run_all_model 2020-12-02 17:55:11 +08:00
Jactus
745b93138d Update devices 2020-12-02 13:28:32 +08:00
Jactus
7f385345bb Fix GPU 2020-12-02 13:25:29 +08:00
Jactus
d109d3d44e Fix GPU 2020-12-02 12:23:42 +08:00
Jactus
a2603fe27a Update config 2020-12-02 09:41:24 +08:00
Young
e5590de2a4 udpate header and test docs 2020-12-01 10:11:29 +00:00
Jactus
77884db3a5 Fix and update run_all_model 2020-12-01 11:54:26 +08:00
Jactus
dc54836990 Fix and move to version 0.6.0 2020-12-01 10:52:04 +08:00
Jactus
bb5f3cb33d Fix and move to version 0.6.0 2020-12-01 09:59:46 +08:00
meng-ustc
d488a503b2 Add model_path param to gats 2020-12-01 09:31:22 +08:00
lwwang1995
620e325da1 Update format. 2020-12-01 09:31:22 +08:00
lwwang1995
e0dad0e85a Add random seed. 2020-12-01 09:31:22 +08:00
lwwang1995
d6ff62b48c Delete Alpha360_denoise 2020-12-01 09:31:22 +08:00
Jactus
fa391e9658 Fix trainer 2020-12-01 09:29:43 +08:00
Jactus
29f12e857f Update docs 2020-12-01 09:29:43 +08:00
Young
1877ad8c39 refine docs 2020-12-01 09:29:43 +08:00
you-n-g
4caddb24ad Update README.md 2020-11-30 09:22:01 +08:00
you-n-g
4f61d43d14 Merge pull request #56 from you-n-g/main
Refactor Qlib interface
2020-11-29 21:23:31 +08:00
Young
a939445da3 fix mlflow bug 2020-11-29 13:00:35 +00:00
Young
a3983bba6b Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-29 09:23:37 +00:00
Young
19f9fc1b9b Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-29 09:23:29 +00:00
Dong Zhou
b3657d1c8f add linear model 2020-11-29 17:22:37 +08:00
Young
89f907bf6c set the task base class 2020-11-29 09:21:46 +00:00
Dong Zhou
0fb0109f9c black format 2020-11-29 17:17:03 +08:00
you-n-g
33f50b3cee Merge pull request #9 from wendili-cs/main
Update TFT
2020-11-28 23:01:45 +08:00
v-blin
fdf0f9a182 Update TFT 2020-11-28 14:55:16 +00:00
Wendi Li
30ab4a8d8b Update qlib_Alpha158.py 2020-11-28 22:52:40 +08:00
Wendi Li
e333b78650 Update tft.py 2020-11-28 22:51:22 +08:00
Jactus
1aeff4f1e2 Merge 2020-11-28 16:38:31 +08:00
Jactus
680e8f9260 Update docs 2020-11-28 16:36:51 +08:00
Young
3f47a282cc update version number & model license 2020-11-28 08:17:18 +00:00
Young
05afeb820a Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-28 05:56:19 +00:00
Young
22c3806672 update docs 2020-11-28 05:56:01 +00:00
zhupr
627fc628e0 Fix get_data.py detection 2020-11-28 12:57:00 +08:00
Jactus
ac96dde4c9 Rename DNN 2020-11-28 10:53:24 +08:00
Jactus
eaa9f1a80d Fix tft 2020-11-28 10:50:39 +08:00
lwwang1995
d820d5b8f6 Delete Hats 2020-11-28 10:40:31 +08:00
Dong Zhou
cde5c59b7e fix colab link 2020-11-28 08:38:42 +08:00
Dong Zhou
dc8bf6f077 add colab button 2020-11-28 08:26:18 +08:00
Dong Zhou
4f69ab6ed8 clean up 2020-11-28 08:25:38 +08:00
Hong Zhang
aa2b28386a revised HATS 2020-11-28 02:04:35 +08:00
zhupr
6fc4ff0a62 Fix yahoo collector 2020-11-28 00:36:23 +08:00
lwwang1995
47cbfdc50c Update 2020-11-28 00:10:09 +08:00
lwwang1995
d7fc90ddcd Update readme. 2020-11-27 23:36:29 +08:00
lwwang1995
c52b84b3fe Fix sfm readme. 2020-11-27 22:50:07 +08:00
lwwang1995
1353e81b5b Fix code with block. 2020-11-27 22:44:28 +08:00
zhupr
c5a3b74a96 Fix the target repository of get_data.py in google.colab 2020-11-27 22:33:22 +08:00
lwwang1995
b89c191e6f Delete workflow code for testing baseline. 2020-11-27 22:31:50 +08:00
lwwang1995
bebce24a7c Update all baseline models. 2020-11-27 22:30:05 +08:00
Jactus
7952d79932 Fix script 2020-11-27 22:26:53 +08:00
Jactus
0824e0e65c Fix recorder 2020-11-27 22:21:03 +08:00
Jactus
c49aaacb9b Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-27 22:16:27 +08:00
Jactus
f0454667f3 Fix workflow 2020-11-27 22:16:10 +08:00
zhupr
be2173d839 Fix 2020-11-27 22:08:35 +08:00
Jactus
1b78152715 Fix 2020-11-27 21:20:04 +08:00
Jactus
10747a3219 Fix 2020-11-27 21:19:27 +08:00
Jactus
8b281957b0 Fix fire 2020-11-27 20:21:23 +08:00
Jactus
b3afcc67d4 Add path 2020-11-27 20:03:55 +08:00
Jactus
f05df04320 Fix 2020-11-27 20:00:58 +08:00
zhupr
f8101214eb Fix report, support google colab 2020-11-27 20:00:05 +08:00
Jactus
2311af5e47 Update script 2020-11-27 19:46:52 +08:00
Dong Zhou
e4e730bada update portfolio example 2020-11-27 17:46:41 +08:00
Haoyu Wang
c62f3164a2 update config 2020-11-27 17:17:57 +08:00
Haoyu Wang
a9c1f8c2a0 Update workflow_config_xgboost.yaml 2020-11-27 17:16:35 +08:00
you-n-g
80b01cb6a6 Merge pull request #7 from bxdd/dnn_drop
Update Dnn Model
2020-11-27 14:27:37 +08:00
bxdd
ae757a4b51 black format 2020-11-27 13:09:40 +08:00
bxdd
8b275a6006 fix bug 2020-11-27 13:07:18 +08:00
bxdd
c31bf61278 Merge branch 'main' into dnn_drop 2020-11-26 23:04:34 -06:00
bxdd
a144a9c3c6 update dnn 2020-11-27 13:00:14 +08:00
lwwang1995
c8355f9f18 Fix alstm model. 2020-11-27 11:03:44 +08:00
Dong Zhou
55acac9fd5 black format 2020-11-27 10:42:20 +08:00
Dong Zhou
a4f76b3922 update portfolio strategy 2020-11-27 10:35:22 +08:00
Haoyu Wang
e27290c8a0 Update workflow_config_sfm.yaml 2020-11-27 10:17:11 +08:00
Haoyu Wang
11564f6457 Update pytorch_sfm.py 2020-11-27 10:11:59 +08:00
lwwang1995
6fb19eb58d Update training setting. 2020-11-27 10:09:17 +08:00
Haoyu Wang
13c2c41d23 Update pytorch_sfm.py 2020-11-27 09:59:30 +08:00
Dong Zhou
d5adc4934b add portfolio optimization example (WIP) 2020-11-27 09:01:35 +08:00
Dong Zhou
ad21092375 datahandler support explicit selector & PortAnaRecord support strategy instance 2020-11-27 09:00:43 +08:00
Dong Zhou
6b4156ab9f black format 2020-11-27 08:58:44 +08:00
Hong Zhang
ca0a689362 Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-27 00:19:59 +08:00
Hong Zhang
5796363ecf revise settings 2020-11-27 00:19:23 +08:00
Young
814ecbb488 intro doc & abs cli 2020-11-26 16:00:58 +00:00
Jactus
b0c09c0d6a Fix 2020-11-26 22:48:59 +08:00
Jactus
f5ec219135 Update docs and README 2020-11-26 22:45:40 +08:00
Alex Wang
293c405593 Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-26 22:28:57 +08:00
Alex Wang
e25fc3b243 update config 2020-11-26 22:28:34 +08:00
Dong Zhou
dae28139da black format 2020-11-26 22:22:39 +08:00
Dong Zhou
07c1ca69a7 alpha158 & alpha360 support custom label 2020-11-26 22:20:59 +08:00
lwwang1995
38cfb22cba Update setting for model training. 2020-11-26 21:34:16 +08:00
bxdd
52c7076917 dnn model opz 2020-11-26 21:15:21 +08:00
Young
6b053137fd fix format 2020-11-26 12:42:20 +00:00
Young
47f416f1dc Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-26 12:42:03 +00:00
Young
0fbf401c98 update trainer and README.md 2020-11-26 12:40:50 +00:00
meng-ustc
22dc7139da Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-26 20:23:22 +08:00
meng-ustc
ab98f44345 Remove batchsize and add daily-batch mode 2020-11-26 20:22:51 +08:00
meng-ustc
99efaadd38 Remove batchsize and add daily-batch mode 2020-11-26 20:19:23 +08:00
Jactus
2fd982a98f Update docs and delete estimator 2020-11-26 19:40:41 +08:00
zhupr
0f8f9453bd update readme 2020-11-26 19:07:15 +08:00
zhupr
36b11676bf Update graph 2020-11-26 18:57:38 +08:00
Young
7d092f39c8 data.rst update 2020-11-26 09:15:13 +00:00
Young
3a3937aa42 Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-26 08:43:36 +00:00
Young
e2935f214a fix some typo and bug 2020-11-26 08:42:54 +00:00
Haoyu Wang
f7e375ae68 Update workflow_config_sfm.yaml 2020-11-26 16:08:21 +08:00
Jactus
056951605b Format 2020-11-26 15:50:42 +08:00
meng-ustc
a108f753d5 Update to alstm 2020-11-26 15:22:34 +08:00
meng-ustc
667f69ef8f Update to hats 2020-11-26 15:20:14 +08:00
meng-ustc
50f6ca7df3 Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-26 15:16:02 +08:00
meng-ustc
e04bebde62 Update to hats 2020-11-26 15:15:05 +08:00
minho
96e8ce920a Add files via upload
Add README
2020-11-26 14:51:43 +08:00
Haoyu Wang
191691b61c Update workflow_by_code_sfm.py 2020-11-26 14:49:24 +08:00
Haoyu Wang
1454bb2b0c update format 2020-11-26 14:36:43 +08:00
Alex Wang
7a5153f7c7 Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-26 14:35:35 +08:00
Alex Wang
28b11886dd update 2020-11-26 14:35:16 +08:00
Hong Zhang
305b9372c7 change code style in Catboost and XGboost 2020-11-26 14:15:54 +08:00
Hong Zhang
e8bb5061b0 change code style for gats 2020-11-26 13:58:45 +08:00
Hong Zhang
85f9d5594e Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-26 13:55:35 +08:00
Hong Zhang
f42661f2d4 gat2 2020-11-26 13:55:12 +08:00
Jactus
2a17062421 Update run_all_model and format 2020-11-26 13:49:51 +08:00
Hong Zhang
398f67f8d8 gat1 2020-11-26 13:49:13 +08:00
lwwang1995
5102566aad Update GRU and LSTM model. 2020-11-26 13:35:07 +08:00
Jactus
45192413f9 Fix 2020-11-26 13:11:56 +08:00
Dong Zhou
37cc51465c improve perf of robust zscore processor 2020-11-26 12:25:39 +08:00
Dong Zhou
d0ca52f3fd add robust zscore processor & ALPHA360 support custom processors 2020-11-26 12:04:48 +08:00
Jactus
21eb86e5cb Update run_all_model 2020-11-26 11:54:06 +08:00
Jactus
f185f48185 Update docs 2020-11-26 00:59:48 +08:00
Jactus
87cee85cea Update docs and fix tabnet 2020-11-26 00:55:26 +08:00
Haoyu Wang
5be847909f Update workflow_config_catboost.yaml 2020-11-26 00:29:37 +08:00
Haoyu Wang
991f14a5b9 update freq 2020-11-25 22:19:20 +08:00
lwwang1995
f84cb64332 Update xgb parameters. 2020-11-25 22:05:36 +08:00
meng-ustc
27f19c1f1b Add README.md for GATs 2020-11-25 21:11:56 +08:00
Hong Zhang
d780daaa87 Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-25 21:07:51 +08:00
meng-ustc
b5722a56b4 add README.md 2020-11-25 21:06:15 +08:00
Hong Zhang
8b71127e2b Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-25 21:05:39 +08:00
Young
130a7043dd update setup.py 2020-11-25 13:04:14 +00:00
Young
1f6d6e0e30 Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-25 12:59:16 +00:00
Young
b6726628c4 black format 2020-11-25 12:58:43 +00:00
Hong Zhang
cb6370ba9b hats5 2020-11-25 20:55:10 +08:00
Hong Zhang
515c627659 hats4 2020-11-25 20:44:52 +08:00
Jactus
a371bf757b Update run_all_model script 2020-11-25 20:44:49 +08:00
Young
c516ec89e1 Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-25 12:41:35 +00:00
Jactus
587d92f9ef Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-25 20:41:16 +08:00
Young
0024b43103 Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-25 12:41:12 +00:00
Jactus
6ca72167ee Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-25 20:41:04 +08:00
Haoyu Wang
233ef71775 update parameters 2020-11-25 20:41:04 +08:00
Young
538106f1b8 fix format 2020-11-25 12:40:58 +00:00
Jactus
7201334733 Format 2020-11-25 20:40:45 +08:00
Haoyu Wang
0bb7457520 update hyperparameters 2020-11-25 20:40:32 +08:00
Wendi Li
510be10a87 Delete workflow_by_code_tft.py 2020-11-25 20:36:28 +08:00
Wendi Li
5581cc42bf Update configs.py 2020-11-25 20:36:28 +08:00
Wendi Li
939154b4a5 Delete volatility.py 2020-11-25 20:36:28 +08:00
Wendi Li
65e3ad3779 Delete traffic.py 2020-11-25 20:36:28 +08:00
Wendi Li
f0d7eaf7f4 Delete favorita.py 2020-11-25 20:36:28 +08:00
Wendi Li
2952641d3f Delete electricity.py 2020-11-25 20:36:28 +08:00
Wendi Li
5c1a818488 Update README.md 2020-11-25 20:36:28 +08:00
Young
9d3be6d894 add sys section parser to the workflow config 2020-11-25 20:36:28 +08:00
Wendi Li
1134d58b31 Update qlib_Alpha158.py 2020-11-25 20:36:28 +08:00
Wendi Li
068ad4ba90 Update tft.py 2020-11-25 20:36:28 +08:00
Wendi Li
9b7251d8d4 Create workflow_config_tft.yaml 2020-11-25 20:36:28 +08:00
Wendi Li
e986f2c731 Add files via upload 2020-11-25 20:36:28 +08:00
Wendi Li
c2c96a817f Format TFT 2020-11-25 20:36:28 +08:00
Wendi Li
93323ed6b3 Add TFT benchmark 2020-11-25 20:36:28 +08:00
Young
c897ecac33 fix CI bug 2020-11-25 12:32:39 +00:00
Young
80fb24d8c3 Merge remote-tracking branch 'origin/main' into main 2020-11-25 12:31:45 +00:00
Haoyu Wang
47cf46f0c2 Add copy right 2020-11-25 20:28:00 +08:00
zhupr
25177b6dad Fix dumpmp_bin 2020-11-25 20:11:26 +08:00
Jactus
7f1f86488c Fix config and format 2020-11-25 19:53:22 +08:00
Alex Wang
64b7748033 update 2020-11-25 19:46:48 +08:00
Alex Wang
2c403943b2 Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-25 19:41:25 +08:00
Alex Wang
5c25f97e64 update hyper-parameter 2020-11-25 19:40:57 +08:00
Jactus
a99db6a1dc Add ALSTM config 2020-11-25 19:29:30 +08:00
Don-ustc
05599d1de8 Update about ALSTM 2020-11-25 19:13:53 +08:00
Don-ustc
33a40c290f Update about ALSTM 2020-11-25 19:12:26 +08:00
Hong Zhang
62ea2f89ae hats3 2020-11-25 19:03:16 +08:00
lwwang1995
8c4bc5be65 Add copyright. 2020-11-25 18:44:35 +08:00
lwwang1995
53620d4c08 Add readme for SFM. 2020-11-25 18:38:17 +08:00
Jactus
d3480602c3 Merge 2020-11-25 18:04:54 +08:00
Jactus
b31480a06a Update doc strings and fix 2020-11-25 18:03:52 +08:00
meng-ustc
ca1a0875e4 update 2020-11-25 17:48:12 +08:00
meng-ustc
cd7c81cfd0 add pretrain-mode to gats 2020-11-25 17:46:34 +08:00
zhupr
c14a99a735 Fix TopkDropoutStrategy && dump_bin 2020-11-25 17:35:26 +08:00
LewenWang
88b6fc4818 Add readme. 2020-11-25 17:29:05 +08:00
LewenWang
5ac90f25b3 Add readme for tabnet. 2020-11-25 16:37:19 +08:00
LewenWang
1e46ad2fbe Add readme for tabnet. 2020-11-25 16:35:28 +08:00
Jactus
3520d3b108 Add SFM config 2020-11-25 14:58:23 +08:00
Alex Wang
fcbafde741 update 2020-11-25 14:27:19 +08:00
Alex Wang
6b90c6d066 update 2020-11-25 14:23:12 +08:00
Alex Wang
dad09e91cf update 2020-11-25 14:10:46 +08:00
Alex Wang
e59f9e43a8 workcode for SFM 2020-11-25 14:02:40 +08:00
Alex Wang
610535de51 include SFM model 2020-11-25 14:02:12 +08:00
Jactus
991c6195bd Add TabNet config 2020-11-25 11:16:01 +08:00
lwwang1995
0e2c2fcd7f Add Tabnet. 2020-11-25 10:44:48 +08:00
Young
8ed01d5c8e more friendly error info when benchmark error 2020-11-25 01:11:34 +00:00
Jactus
b4671746c2 Update part of the docs 2020-11-24 23:56:16 +08:00
Dong Zhou
5059bba51e fix static dataloader 2020-11-24 22:52:19 +08:00
Dong Zhou
db9758575b static data loader supports fields_group 2020-11-24 22:43:34 +08:00
Young
dfa8bc10a5 update mlflow version
mlflow 1.11.0 will create a folder name `mlruns` when exist
2020-11-24 13:37:08 +00:00
Dong Zhou
e819879232 fix model when using single feature 2020-11-24 21:03:52 +08:00
bxdd
67e7fdf80b Fix ops bug & add raise comments of Skew Kurt 2020-11-24 20:58:16 +08:00
Dong Zhou
73b280754d auto infer cpu count 2020-11-24 20:50:42 +08:00
Young
de68649eea Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-24 09:20:53 +00:00
Young
e5e402197a delay the creating of mlruns folder 2020-11-24 09:18:30 +00:00
Jactus
93ce9a4cb2 Format 2020-11-24 16:42:32 +08:00
Jactus
acae9087e9 Update model configs 2020-11-24 16:41:10 +08:00
Dong Zhou
e2485bcf2b add CSRankNorm impl 2020-11-24 10:20:29 +08:00
Dong Zhou
641e7f38bc Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-24 10:09:33 +08:00
Dong Zhou
7f9f54faf4 add CSRankNorm processor 2020-11-24 10:09:27 +08:00
Dong Zhou
5729b2242e dataloader support static file or dataframe 2020-11-24 10:08:52 +08:00
Young
0112d06ed5 rename group -> fields_group 2020-11-24 02:05:05 +00:00
Dong Zhou
6ded0d50c7 support long-short analysis 2020-11-24 10:04:13 +08:00
Wendi Li
f536241a5f Update FAQ.rst 2020-11-23 15:19:54 +08:00
Wendi Li
e3a5d1fc50 Update FAQ.rst 2020-11-23 15:19:54 +08:00
Wendi Li
71ba15c097 Update cache.py 2020-11-23 15:19:34 +08:00
Jactus
27b573c7d6 Update run_all_model script 2020-11-23 15:10:14 +08:00
Jactus
0c3f50e426 Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-23 10:53:59 +08:00
Jactus
aed566fa00 Fix get_data bug in workflows 2020-11-23 10:53:26 +08:00
zhupr
bac16060ff fix us instruments 2020-11-22 15:45:06 +08:00
Jactus
8958656222 Update test scipts 2020-11-22 13:38:40 +08:00
Jactus
f11c3ab483 Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-22 12:48:28 +08:00
Young
c8d7d3ea2a fix record_tmp bug 2020-11-22 04:44:56 +00:00
Jactus
f0d75cc189 Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-22 12:39:44 +08:00
Young
ae60546fe9 fix record_tmp bug 2020-11-22 04:19:08 +00:00
Young
220208f28c fix record_tmp bug 2020-11-22 03:20:42 +00:00
Young
89977320e3 black format 2020-11-21 15:34:15 +00:00
Young
e5923333f5 recorder refine; signalTemp; fixbug 2020-11-21 15:20:47 +00:00
Young
a0fe6941d2 Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-21 08:54:27 +00:00
Young
f476ada22d Adjust interface 2020-11-21 08:54:11 +00:00
Jactus
c22bd73f67 Update CI 2020-11-20 17:54:56 +08:00
Jactus
5aa48524d6 Add run_all_model script 2020-11-20 16:09:40 +08:00
lwwang1995
38e76a6e40 Add workflow example. 2020-11-20 14:57:08 +08:00
Jactus
5107d46568 Fix cli 2020-11-20 11:10:44 +08:00
Jactus
3bcb01d45f Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-20 10:59:41 +08:00
Jactus
547697ddc6 Modify cli 2020-11-20 10:59:37 +08:00
zhupr
75d779ebe8 fix report style 2020-11-19 22:48:24 +08:00
Young
0f433571f6 fix bug parameters 2020-11-19 09:29:18 +00:00
Young
6610b7110a Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-19 09:22:55 +00:00
Young
11dc307a96 Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-19 09:18:24 +00:00
Jactus
c91698287a Add catboost config and notebook 2020-11-19 17:18:18 +08:00
Young
aa971e017a fix handler bug 2020-11-19 09:13:05 +00:00
Jactus
df406d58a5 Merge 2020-11-19 16:52:50 +08:00
Jactus
21c0dae03c Init benchmarks 2020-11-19 16:51:09 +08:00
Jactus
a8ad2120c9 Update recordTemp and report 2020-11-19 16:50:16 +08:00
Young
4a0394ce05 Merge remote-tracking branch 'origin/main' into main 2020-11-19 08:27:42 +00:00
zhupr
7152f8321b update dump_bin docs 2020-11-19 16:20:03 +08:00
zhupr
1f62cfe0af update scripts/README.md 2020-11-19 16:20:03 +08:00
zhupr
6f2b51cf55 add get_data.py docs 2020-11-19 16:20:03 +08:00
Young
74f6dc8d02 Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-19 04:09:32 +00:00
Young
afcfa0a478 adjust for SepDataframe 2020-11-19 04:08:05 +00:00
zhupr
d019183af9 update workflows/test.yml 2020-11-19 10:36:14 +08:00
zhupr
00277699c7 update tests && fix typo 2020-11-19 10:36:14 +08:00
zhupr
7b2a9a15e3 add TODO 2020-11-19 10:36:14 +08:00
zhupr
9eb58ad366 fix collector start datetime 2020-11-19 10:36:14 +08:00
zhupr
6be6b95414 fix get_data 2020-11-19 10:36:14 +08:00
zhupr
94407da25f add support us data 2020-11-19 10:36:14 +08:00
zhupr
c6d557c33e support US index 2020-11-19 10:36:14 +08:00
zhupr
ae300592a0 refactor yahoo_collector && support US and 1m 2020-11-19 10:36:14 +08:00
zhupr
77bfeadb65 refactor && support update bin files 2020-11-19 10:36:14 +08:00
zhupr
87bf5cb01a Add script to verify that bin data and csv data are consistent 2020-11-19 10:36:14 +08:00
Dong Zhou
dfc9351096 fix mlflow uri 2020-11-19 09:10:17 +08:00
lwwang1995
e6a902c659 Add LSTM and Gats 2020-11-18 21:53:28 +08:00
Jactus
d8414b949a Update pytorch_nn 2020-11-18 19:17:19 +08:00
Jactus
58bd2339c0 Update expm and exp 2020-11-18 17:55:45 +08:00
Jactus
64ed43b791 Update R and workflow 2020-11-17 22:05:18 +08:00
lwwang1995
a8b46dd41d Delete log. 2020-11-16 23:29:51 +08:00
lwwang1995
0afe57f2fe Update GRU model. 2020-11-16 23:28:11 +08:00
Young
90d41e4022 add finetune example & fix serial bug 2020-11-16 13:11:39 +00:00
Jactus
3e04ded750 Add initial workflow_by_config 2020-11-16 17:29:26 +08:00
Jactus
42867264f3 Update R and workflow 2020-11-16 15:49:50 +08:00
you-n-g
c06914eb39 Merge branch 'main' into main 2020-11-14 17:17:02 +08:00
Young
7a79028a72 fix some small bug 2020-11-14 08:23:19 +00:00
Jactus
ea5f14ce12 Update R related codes 2020-11-13 21:34:13 +08:00
lwwang1995
138ab10c1a Update Dropna function in processor and check model loading and saving with pickle. 2020-11-13 10:55:10 +08:00
Jactus
59745486f5 Update handler 2020-11-12 17:34:43 +08:00
Jactus
4f4a7679ce Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-12 17:06:05 +08:00
Jactus
b32f6a8bb1 Fix handler bug 2020-11-12 17:05:24 +08:00
bxdd
16f2b5d821 simply the logic 2020-11-12 14:33:46 +08:00
bxdd
dc6874a11c del print 2020-11-12 14:33:46 +08:00
bxdd
4f86712579 fix exit not found in ipython & fix re about provider_uri 2020-11-12 14:33:46 +08:00
lwwang1995
54a256d3bc Update processor. 2020-11-12 13:20:49 +08:00
lwwang1995
063bfd4621 Update processor. 2020-11-12 13:17:10 +08:00
lwwang1995
d45aa86fb5 Update GRU model. 2020-11-12 13:11:14 +08:00
Jactus
52c0c4b7a8 Fix processor bug and format 2020-11-11 14:24:04 +08:00
lwwang1995
e2d89f44fb Delete log 2020-11-11 11:35:17 +08:00
lwwang1995
ad6c2e759f Add Xgboost Model 2020-11-11 11:11:36 +08:00
lwwang1995
9c2dbaa94e add time series model GRU 2020-11-11 10:26:28 +08:00
Jactus
b839733ec7 Add black formatter output 2020-11-11 09:50:38 +08:00
Jactus
722655ad13 Update black formatter 2020-11-11 09:34:10 +08:00
Pengrong Zhu
3e0f8571d3 Merge pull request #66 from microsoft/support-non-fullfill-rate
support non-full-fill rate of executor
2020-11-10 20:52:10 +08:00
Young
490910b994 support non-full-fill rate of executor 2020-11-10 12:36:44 +00:00
Dong Zhou
1a8ef55dc7 fix riskmodel 2020-11-10 09:47:59 +08:00
Young
307661398f Merge branch 'main' of github.com:you-n-g/qlib into main 2020-11-10 01:46:01 +00:00
Young
21a24f9893 fix data_loader dict type bug 2020-11-10 01:45:34 +00:00
Jactus
2f42a59c3d Merge 2020-11-10 00:33:54 +08:00
Jactus
004e2f557b Fix recorder related bugs 2020-11-10 00:32:18 +08:00
Young
b1c6b216fe fix Recorder init bug 2020-11-09 15:17:08 +00:00
Jactus
633af182f4 Fix read_bin bug 2020-11-09 22:15:41 +08:00
Jactus
853410c16e Update exp related and pytorch_nn 2020-11-09 16:42:21 +08:00
Young
9a826eefa3 add parallel processor 2020-11-06 10:24:21 +00:00
Haoyu Wang
eead71fcb5 minor fix 2020-11-06 17:47:43 +08:00
Haoyu Wang
1556be6798 Adding Catboost as a model 2020-11-06 16:18:56 +08:00
Young
65a009acb2 remove vwap related feature 2020-11-05 12:30:43 +00:00
Young
e37950d636 update handler & fix some bugs 2020-11-05 10:22:42 +00:00
Jactus
918a2b8a38 Fix few exp bugs 2020-11-05 15:28:31 +08:00
Young
b6867c6161 fix the float conversion bug 2020-11-04 16:09:15 +08:00
Young
8a0135d79a fix data provider init bug 2020-11-02 09:42:07 +00:00
Jactus
371da2a74c Fix 2020-11-02 16:09:21 +08:00
Jactus
661b3bffcc Format with black 2020-11-02 11:09:24 +08:00
Jactus
b077d848f4 Merge branch 'main' of https://github.com/you-n-g/qlib into main 2020-11-02 11:06:02 +08:00
Jactus
5f9c8be33d Add RecordTemp & update 2020-11-02 11:05:40 +08:00
Dong Zhou
91019edcb8 remove abundant api 2020-10-30 14:55:21 +08:00
Dong Zhou
a12ae596ec add riskmodel 2020-10-30 14:55:21 +08:00
Dong Zhou
c59058b47d fix dataloader & add interface to datahandler 2020-10-30 14:55:21 +08:00
Dong Zhou
9dc357bc81 add portfolio module 2020-10-30 14:55:21 +08:00
Dong Zhou
72b5d9abfa fix ops & EMA support alpha 2020-10-30 14:55:21 +08:00
you-n-g
e7657bbd3a Update README.md 2020-10-29 18:29:45 +08:00
Jactus
da9d1c8ac6 Format with black 2020-10-29 13:22:49 +08:00
Jactus
490dbd908b Merge 2020-10-29 13:01:42 +08:00
Jactus
60d0cfcf64 Update Exp related codes 2020-10-29 12:58:52 +08:00
Young
a50c9008b8 pass the whole workflow 2020-10-28 14:08:00 +00:00
Jactus
1a9ee6cef8 Add Recorder and ExpManager 2020-10-27 14:30:24 +08:00
Young
aee507d5dd adjust data and model interface 2020-10-26 13:26:01 +00:00
Young
393584e535 Update handler interface round2 2020-10-23 03:37:10 +00:00
zhupr
5bca9d892a Support csi100 data collection && Fix data collector 2020-10-21 12:01:34 +08:00
Young
10066ecf79 Draft version of refactoring handler 2020-10-17 10:04:02 +00:00
Young
d4091a8711 split code into core and contrib for data&model 2020-10-17 10:04:02 +00:00
Young
77e2f25f7b rename modules 2020-10-17 10:04:02 +00:00
Young
54d5e1fbdc change the init order 2020-10-17 10:04:02 +00:00
Gabriel Luiz Freitas Almeida
59047df699 Fix typo 2020-10-15 08:44:07 +08:00
bxdd
eda0c81bfb update US config to us 2020-10-12 17:41:04 +08:00
bxdd
916d9d363e update model 2020-10-12 17:41:04 +08:00
bxdd
992983ff4c make dnn model compatible with CPU & update docs for init param 2020-10-12 17:41:04 +08:00
you-n-g
cbc9111082 Delete version.py 2020-10-10 13:29:54 +08:00
Jactus
04fbe8d2f8 Update brew install link 2020-10-10 10:13:51 +08:00
Jactus
97164f8f5d Update brew install for MacOS 2020-10-10 10:13:51 +08:00
Jactus
7c6e5e822c Update CI & add black formatter 2020-10-10 10:13:51 +08:00
you-n-g
143f3f985b Update README.md
typo
2020-10-07 14:06:38 +08:00
you-n-g
660847a3c8 Update README.md 2020-10-06 17:13:40 +08:00
Young
c8c3575aab add dev version number 2020-10-06 01:55:25 +00:00
Morris Tai
5256d18c5b fix requirements.txt
Typo "logure", should be "logure", cause in pip install error.
2020-10-03 20:36:17 +08:00
bxdd
d6b1e111d4 Update badges in REAME.md 2020-10-01 16:40:19 +08:00
you-n-g
17db49d0ae Update report.rst 2020-10-01 16:13:48 +08:00
604 changed files with 78648 additions and 10019 deletions

12
.deepsource.toml Normal file
View File

@@ -0,0 +1,12 @@
version = 1
test_patterns = ["tests/test_*.py"]
exclude_patterns = ["examples/**"]
[[analyzers]]
name = "python"
enabled = true
[analyzers.meta]
runtime_version = "3.x.x"

View File

@@ -28,7 +28,8 @@ Steps to reproduce the behavior:
## Environment
**Note**: One could run `python scripts/collect_info.py` under the `qlib` directory to get the following information.
**Note**: User could run `cd scripts && python collect_info.py all` under project directory to get system information
and paste them here directly.
- Qlib version:
- Python version:
@@ -37,4 +38,4 @@ Steps to reproduce the behavior:
## Additional Notes
<!-- Add any other information about the problem here. -->
<!-- Add any other information about the problem here. -->

View File

@@ -8,6 +8,7 @@
<!--- Why is this change required? What problem does it solve? -->
## How Has This Been Tested?
<!--- Put an `x` in all the boxes that apply: --->
- [ ] 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.

649
.github/brew_install.sh vendored Normal file
View File

@@ -0,0 +1,649 @@
#!/bin/bash
set -u
# First check if the OS is Linux.
if [[ "$(uname)" = "Linux" ]]; then
HOMEBREW_ON_LINUX=1
fi
# On macOS, this script installs to /usr/local only.
# On Linux, it installs to /home/linuxbrew/.linuxbrew if you have sudo access
# and ~/.linuxbrew otherwise.
# To install elsewhere (which is unsupported)
# you can untar https://github.com/Homebrew/brew/tarball/master
# anywhere you like.
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
HOMEBREW_PREFIX="/usr/local"
HOMEBREW_REPOSITORY="/usr/local/Homebrew"
HOMEBREW_CACHE="${HOME}/Library/Caches/Homebrew"
STAT="stat -f"
CHOWN="/usr/sbin/chown"
CHGRP="/usr/bin/chgrp"
GROUP="admin"
TOUCH="/usr/bin/touch"
else
HOMEBREW_PREFIX_DEFAULT="/home/linuxbrew/.linuxbrew"
HOMEBREW_CACHE="${HOME}/.cache/Homebrew"
STAT="stat --printf"
CHOWN="/bin/chown"
CHGRP="/bin/chgrp"
GROUP="$(id -gn)"
TOUCH="/bin/touch"
fi
BREW_REPO="https://github.com/Homebrew/brew"
# TODO: bump version when new macOS is released
MACOS_LATEST_SUPPORTED="10.15"
# TODO: bump version when new macOS is released
MACOS_OLDEST_SUPPORTED="10.13"
# For Homebrew on Linux
REQUIRED_RUBY_VERSION=2.6 # https://github.com/Homebrew/brew/pull/6556
REQUIRED_GLIBC_VERSION=2.13 # https://docs.brew.sh/Homebrew-on-Linux#requirements
# no analytics during installation
export HOMEBREW_NO_ANALYTICS_THIS_RUN=1
export HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT=1
# string formatters
if [[ -t 1 ]]; then
tty_escape() { printf "\033[%sm" "$1"; }
else
tty_escape() { :; }
fi
tty_mkbold() { tty_escape "1;$1"; }
tty_underline="$(tty_escape "4;39")"
tty_blue="$(tty_mkbold 34)"
tty_red="$(tty_mkbold 31)"
tty_bold="$(tty_mkbold 39)"
tty_reset="$(tty_escape 0)"
have_sudo_access() {
local -a args
if [[ -n "${SUDO_ASKPASS-}" ]]; then
args=("-A")
fi
if [[ -z "${HAVE_SUDO_ACCESS-}" ]]; then
if [[ -n "${args[*]-}" ]]; then
/usr/bin/sudo "${args[@]}" -l mkdir &>/dev/null
else
/usr/bin/sudo -l mkdir &>/dev/null
fi
HAVE_SUDO_ACCESS="$?"
fi
if [[ -z "${HOMEBREW_ON_LINUX-}" ]] && [[ "$HAVE_SUDO_ACCESS" -ne 0 ]]; then
abort "Need sudo access on macOS (e.g. the user $USER to be an Administrator)!"
fi
return "$HAVE_SUDO_ACCESS"
}
shell_join() {
local arg
printf "%s" "$1"
shift
for arg in "$@"; do
printf " "
printf "%s" "${arg// /\ }"
done
}
chomp() {
printf "%s" "${1/"$'\n'"/}"
}
ohai() {
printf "${tty_blue}==>${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")"
}
warn() {
printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")"
}
abort() {
printf "%s\n" "$1"
exit 1
}
execute() {
if ! "$@"; then
abort "$(printf "Failed during: %s" "$(shell_join "$@")")"
fi
}
execute_sudo() {
local -a args=("$@")
if [[ -n "${SUDO_ASKPASS-}" ]]; then
args=("-A" "${args[@]}")
fi
if have_sudo_access; then
ohai "/usr/bin/sudo" "${args[@]}"
execute "/usr/bin/sudo" "${args[@]}"
else
ohai "${args[@]}"
execute "${args[@]}"
fi
}
getc() {
local save_state
save_state=$(/bin/stty -g)
/bin/stty raw -echo
IFS= read -r -n 1 -d '' "$@"
/bin/stty "$save_state"
}
wait_for_user() {
local c
echo
echo "Press RETURN to continue or any other key to abort"
getc c
# we test for \r and \n because some stuff does \r instead
if ! [[ "$c" == $'\r' || "$c" == $'\n' ]]; then
exit 1
fi
}
major_minor() {
echo "${1%%.*}.$(x="${1#*.}"; echo "${x%%.*}")"
}
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
macos_version="$(major_minor "$(/usr/bin/sw_vers -productVersion)")"
fi
version_gt() {
[[ "${1%.*}" -gt "${2%.*}" ]] || [[ "${1%.*}" -eq "${2%.*}" && "${1#*.}" -gt "${2#*.}" ]]
}
version_ge() {
[[ "${1%.*}" -gt "${2%.*}" ]] || [[ "${1%.*}" -eq "${2%.*}" && "${1#*.}" -ge "${2#*.}" ]]
}
version_lt() {
[[ "${1%.*}" -lt "${2%.*}" ]] || [[ "${1%.*}" -eq "${2%.*}" && "${1#*.}" -lt "${2#*.}" ]]
}
should_install_command_line_tools() {
if [[ -n "${HOMEBREW_ON_LINUX-}" ]]; then
return 1
fi
if version_gt "$macos_version" "10.13"; then
! [[ -e "/Library/Developer/CommandLineTools/usr/bin/git" ]]
else
! [[ -e "/Library/Developer/CommandLineTools/usr/bin/git" ]] ||
! [[ -e "/usr/include/iconv.h" ]]
fi
}
get_permission() {
$STAT "%A" "$1"
}
user_only_chmod() {
[[ -d "$1" ]] && [[ "$(get_permission "$1")" != "755" ]]
}
exists_but_not_writable() {
[[ -e "$1" ]] && ! [[ -r "$1" && -w "$1" && -x "$1" ]]
}
get_owner() {
$STAT "%u" "$1"
}
file_not_owned() {
[[ "$(get_owner "$1")" != "$(id -u)" ]]
}
get_group() {
$STAT "%g" "$1"
}
file_not_grpowned() {
[[ " $(id -G "$USER") " != *" $(get_group "$1") "* ]]
}
# Please sync with 'test_ruby()' in 'Library/Homebrew/utils/ruby.sh' from Homebrew/brew repository.
test_ruby () {
if [[ ! -x $1 ]]
then
return 1
fi
"$1" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt -rrubygems -e \
"abort if Gem::Version.new(RUBY_VERSION.to_s.dup).to_s.split('.').first(2) != \
Gem::Version.new('$REQUIRED_RUBY_VERSION').to_s.split('.').first(2)" 2>/dev/null
}
no_usable_ruby() {
local ruby_exec
IFS=$'\n' # Do word splitting on new lines only
for ruby_exec in $(which -a ruby); do
if test_ruby "$ruby_exec"; then
return 1
fi
done
IFS=$' \t\n' # Restore IFS to its default value
return 0
}
outdated_glibc() {
local glibc_version
glibc_version=$(ldd --version | head -n1 | grep -o '[0-9.]*$' | grep -o '^[0-9]\+\.[0-9]\+')
version_lt "$glibc_version" "$REQUIRED_GLIBC_VERSION"
}
if [[ -n "${HOMEBREW_ON_LINUX-}" ]] && no_usable_ruby && outdated_glibc
then
abort "$(cat <<-EOFABORT
Homebrew requires Ruby $REQUIRED_RUBY_VERSION which was not found on your system.
Homebrew portable Ruby requires Glibc version $REQUIRED_GLIBC_VERSION or newer,
and your Glibc version is too old.
See ${tty_underline}https://docs.brew.sh/Homebrew-on-Linux#requirements${tty_reset}
Install Ruby $REQUIRED_RUBY_VERSION and add its location to your PATH.
EOFABORT
)"
fi
# USER isn't always set so provide a fall back for the installer and subprocesses.
if [[ -z "${USER-}" ]]; then
USER="$(chomp "$(id -un)")"
export USER
fi
# Invalidate sudo timestamp before exiting (if it wasn't active before).
if ! /usr/bin/sudo -n -v 2>/dev/null; then
trap '/usr/bin/sudo -k' EXIT
fi
# Things can fail later if `pwd` doesn't exist.
# Also sudo prints a warning message for no good reason
cd "/usr" || exit 1
####################################################################### script
if ! command -v git >/dev/null; then
abort "$(cat <<EOABORT
You must install Git before installing Homebrew. See:
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
EOABORT
)"
fi
if ! command -v curl >/dev/null; then
abort "$(cat <<EOABORT
You must install cURL before installing Homebrew. See:
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
EOABORT
)"
fi
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
have_sudo_access
else
if [[ -n "${CI-}" ]] || [[ -w "$HOMEBREW_PREFIX_DEFAULT" ]] || [[ -w "/home/linuxbrew" ]] || [[ -w "/home" ]]; then
HOMEBREW_PREFIX="$HOMEBREW_PREFIX_DEFAULT"
else
trap exit SIGINT
if [[ $(/usr/bin/sudo -n -l mkdir 2>&1) != *"mkdir"* ]]; then
ohai "Select the Homebrew installation directory"
echo "- ${tty_bold}Enter your password${tty_reset} to install to ${tty_underline}${HOMEBREW_PREFIX_DEFAULT}${tty_reset} (${tty_bold}recommended${tty_reset})"
echo "- ${tty_bold}Press Control-D${tty_reset} to install to ${tty_underline}$HOME/.linuxbrew${tty_reset}"
echo "- ${tty_bold}Press Control-C${tty_reset} to cancel installation"
fi
if have_sudo_access; then
HOMEBREW_PREFIX="$HOMEBREW_PREFIX_DEFAULT"
else
HOMEBREW_PREFIX="$HOME/.linuxbrew"
fi
trap - SIGINT
fi
HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}/Homebrew"
fi
if [[ "$UID" == "0" ]]; then
abort "Don't run this as root!"
elif [[ -d "$HOMEBREW_PREFIX" && ! -x "$HOMEBREW_PREFIX" ]]; then
abort "$(cat <<EOABORT
The Homebrew prefix, ${HOMEBREW_PREFIX}, exists but is not searchable. If this is
not intentional, please restore the default permissions and try running the
installer again:
sudo chmod 775 ${HOMEBREW_PREFIX}
EOABORT
)"
fi
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
if version_lt "$macos_version" "10.7"; then
abort "$(cat <<EOABORT
Your Mac OS X version is too old. See:
${tty_underline}https://github.com/mistydemeo/tigerbrew${tty_reset}
EOABORT
)"
elif version_lt "$macos_version" "10.10"; then
abort "Your OS X version is too old"
elif version_gt "$macos_version" "$MACOS_LATEST_SUPPORTED" || \
version_lt "$macos_version" "$MACOS_OLDEST_SUPPORTED"; then
who="We"
what=""
if version_gt "$macos_version" "$MACOS_LATEST_SUPPORTED"; then
what="pre-release version"
else
who+=" (and Apple)"
what="old version"
fi
ohai "You are using macOS ${macos_version}."
ohai "${who} do not provide support for this ${what}."
echo "$(cat <<EOS
This installation may not succeed.
After installation, you will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew\'s GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience while you are running this ${what}.
EOS
)
"
fi
fi
ohai "This script will install:"
echo "${HOMEBREW_PREFIX}/bin/brew"
echo "${HOMEBREW_PREFIX}/share/doc/homebrew"
echo "${HOMEBREW_PREFIX}/share/man/man1/brew.1"
echo "${HOMEBREW_PREFIX}/share/zsh/site-functions/_brew"
echo "${HOMEBREW_PREFIX}/etc/bash_completion.d/brew"
echo "${HOMEBREW_REPOSITORY}"
# Keep relatively in sync with
# https://github.com/Homebrew/brew/blob/master/Library/Homebrew/keg.rb
directories=(bin etc include lib sbin share opt var
Frameworks
etc/bash_completion.d lib/pkgconfig
share/aclocal share/doc share/info share/locale share/man
share/man/man1 share/man/man2 share/man/man3 share/man/man4
share/man/man5 share/man/man6 share/man/man7 share/man/man8
var/log var/homebrew var/homebrew/linked
bin/brew)
group_chmods=()
for dir in "${directories[@]}"; do
if exists_but_not_writable "${HOMEBREW_PREFIX}/${dir}"; then
group_chmods+=("${HOMEBREW_PREFIX}/${dir}")
fi
done
# zsh refuses to read from these directories if group writable
directories=(share/zsh share/zsh/site-functions)
zsh_dirs=()
for dir in "${directories[@]}"; do
zsh_dirs+=("${HOMEBREW_PREFIX}/${dir}")
done
directories=(bin etc include lib sbin share var opt
share/zsh share/zsh/site-functions
var/homebrew var/homebrew/linked
Cellar Caskroom Homebrew Frameworks)
mkdirs=()
for dir in "${directories[@]}"; do
if ! [[ -d "${HOMEBREW_PREFIX}/${dir}" ]]; then
mkdirs+=("${HOMEBREW_PREFIX}/${dir}")
fi
done
user_chmods=()
if [[ "${#zsh_dirs[@]}" -gt 0 ]]; then
for dir in "${zsh_dirs[@]}"; do
if user_only_chmod "${dir}"; then
user_chmods+=("${dir}")
fi
done
fi
chmods=()
if [[ "${#group_chmods[@]}" -gt 0 ]]; then
chmods+=("${group_chmods[@]}")
fi
if [[ "${#user_chmods[@]}" -gt 0 ]]; then
chmods+=("${user_chmods[@]}")
fi
chowns=()
chgrps=()
if [[ "${#chmods[@]}" -gt 0 ]]; then
for dir in "${chmods[@]}"; do
if file_not_owned "${dir}"; then
chowns+=("${dir}")
fi
if file_not_grpowned "${dir}"; then
chgrps+=("${dir}")
fi
done
fi
if [[ "${#group_chmods[@]}" -gt 0 ]]; then
ohai "The following existing directories will be made group writable:"
printf "%s\n" "${group_chmods[@]}"
fi
if [[ "${#user_chmods[@]}" -gt 0 ]]; then
ohai "The following existing directories will be made writable by user only:"
printf "%s\n" "${user_chmods[@]}"
fi
if [[ "${#chowns[@]}" -gt 0 ]]; then
ohai "The following existing directories will have their owner set to ${tty_underline}${USER}${tty_reset}:"
printf "%s\n" "${chowns[@]}"
fi
if [[ "${#chgrps[@]}" -gt 0 ]]; then
ohai "The following existing directories will have their group set to ${tty_underline}${GROUP}${tty_reset}:"
printf "%s\n" "${chgrps[@]}"
fi
if [[ "${#mkdirs[@]}" -gt 0 ]]; then
ohai "The following new directories will be created:"
printf "%s\n" "${mkdirs[@]}"
fi
if should_install_command_line_tools; then
ohai "The Xcode Command Line Tools will be installed."
fi
if [[ -t 0 && -z "${CI-}" ]]; then
wait_for_user
fi
if [[ -d "${HOMEBREW_PREFIX}" ]]; then
if [[ "${#chmods[@]}" -gt 0 ]]; then
execute_sudo "/bin/chmod" "u+rwx" "${chmods[@]}"
fi
if [[ "${#group_chmods[@]}" -gt 0 ]]; then
execute_sudo "/bin/chmod" "g+rwx" "${group_chmods[@]}"
fi
if [[ "${#user_chmods[@]}" -gt 0 ]]; then
execute_sudo "/bin/chmod" "755" "${user_chmods[@]}"
fi
if [[ "${#chowns[@]}" -gt 0 ]]; then
execute_sudo "$CHOWN" "$USER" "${chowns[@]}"
fi
if [[ "${#chgrps[@]}" -gt 0 ]]; then
execute_sudo "$CHGRP" "$GROUP" "${chgrps[@]}"
fi
else
execute_sudo "/bin/mkdir" "-p" "${HOMEBREW_PREFIX}"
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
execute_sudo "$CHOWN" "root:wheel" "${HOMEBREW_PREFIX}"
else
execute_sudo "$CHOWN" "$USER:$GROUP" "${HOMEBREW_PREFIX}"
fi
fi
if [[ "${#mkdirs[@]}" -gt 0 ]]; then
execute_sudo "/bin/mkdir" "-p" "${mkdirs[@]}"
execute_sudo "/bin/chmod" "g+rwx" "${mkdirs[@]}"
execute_sudo "$CHOWN" "$USER" "${mkdirs[@]}"
execute_sudo "$CHGRP" "$GROUP" "${mkdirs[@]}"
fi
if ! [[ -d "${HOMEBREW_CACHE}" ]]; then
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
execute_sudo "/bin/mkdir" "-p" "${HOMEBREW_CACHE}"
else
execute "/bin/mkdir" "-p" "${HOMEBREW_CACHE}"
fi
fi
if exists_but_not_writable "${HOMEBREW_CACHE}"; then
execute_sudo "/bin/chmod" "g+rwx" "${HOMEBREW_CACHE}"
fi
if file_not_owned "${HOMEBREW_CACHE}"; then
execute_sudo "$CHOWN" "$USER" "${HOMEBREW_CACHE}"
fi
if file_not_grpowned "${HOMEBREW_CACHE}"; then
execute_sudo "$CHGRP" "$GROUP" "${HOMEBREW_CACHE}"
fi
if [[ -d "${HOMEBREW_CACHE}" ]]; then
execute "$TOUCH" "${HOMEBREW_CACHE}/.cleaned"
fi
if should_install_command_line_tools && version_ge "$macos_version" "10.13"; then
ohai "Searching online for the Command Line Tools"
# This temporary file prompts the 'softwareupdate' utility to list the Command Line Tools
clt_placeholder="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress"
execute_sudo "$TOUCH" "$clt_placeholder"
clt_label_command="/usr/sbin/softwareupdate -l |
grep -B 1 -E 'Command Line Tools' |
awk -F'*' '/^ *\\*/ {print \$2}' |
sed -e 's/^ *Label: //' -e 's/^ *//' |
sort -V |
tail -n1"
clt_label="$(chomp "$(/bin/bash -c "$clt_label_command")")"
if [[ -n "$clt_label" ]]; then
ohai "Installing $clt_label"
execute_sudo "/usr/sbin/softwareupdate" "-i" "$clt_label"
execute_sudo "/bin/rm" "-f" "$clt_placeholder"
execute_sudo "/usr/bin/xcode-select" "--switch" "/Library/Developer/CommandLineTools"
fi
fi
# Headless install may have failed, so fallback to original 'xcode-select' method
if should_install_command_line_tools && test -t 0; then
ohai "Installing the Command Line Tools (expect a GUI popup):"
execute_sudo "/usr/bin/xcode-select" "--install"
echo "Press any key when the installation has completed."
getc
execute_sudo "/usr/bin/xcode-select" "--switch" "/Library/Developer/CommandLineTools"
fi
if [[ -z "${HOMEBREW_ON_LINUX-}" ]] && ! output="$(/usr/bin/xcrun clang 2>&1)" && [[ "$output" == *"license"* ]]; then
abort "$(cat <<EOABORT
You have not agreed to the Xcode license.
Before running the installer again please agree to the license by opening
Xcode.app or running:
sudo xcodebuild -license
EOABORT
)"
fi
ohai "Downloading and installing Homebrew..."
(
cd "${HOMEBREW_REPOSITORY}" >/dev/null || return
# we do it in four steps to avoid merge errors when reinstalling
execute "git" "init" "-q"
# "git remote add" will fail if the remote is defined in the global config
execute "git" "config" "remote.origin.url" "${BREW_REPO}"
execute "git" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*"
# ensure we don't munge line endings on checkout
execute "git" "config" "core.autocrlf" "false"
execute "git" "fetch" "origin" "--force"
execute "git" "fetch" "origin" "--tags" "--force"
execute "git" "reset" "--hard" "origin/master"
execute "ln" "-sf" "${HOMEBREW_REPOSITORY}/bin/brew" "${HOMEBREW_PREFIX}/bin/brew"
) || exit 1
if [[ ":${PATH}:" != *":${HOMEBREW_PREFIX}/bin:"* ]]; then
warn "${HOMEBREW_PREFIX}/bin is not in your PATH."
fi
ohai "Installation successful!"
echo
# Use the shell's audible bell.
if [[ -t 1 ]]; then
printf "\a"
fi
# Use an extra newline and bold to avoid this being missed.
ohai "Homebrew has enabled anonymous aggregate formulae and cask analytics."
echo "$(cat <<EOS
${tty_bold}Read the analytics documentation (and how to opt-out) here:
${tty_underline}https://docs.brew.sh/Analytics${tty_reset}
No analytics data has been sent yet (or will be during this \`install\` run).
EOS
)
"
ohai "Homebrew is run entirely by unpaid volunteers. Please consider donating:"
echo "$(cat <<EOS
${tty_underline}https://github.com/Homebrew/brew#donations${tty_reset}
EOS
)
"
(
cd "${HOMEBREW_REPOSITORY}" >/dev/null || return
execute "git" "config" "--replace-all" "homebrew.analyticsmessage" "true"
execute "git" "config" "--replace-all" "homebrew.caskanalyticsmessage" "true"
) || exit 1
ohai "Next steps:"
echo "- Run \`brew help\` to get started"
echo "- Further documentation: "
echo " ${tty_underline}https://docs.brew.sh${tty_reset}"
if [[ -n "${HOMEBREW_ON_LINUX-}" ]]; then
case "$SHELL" in
*/bash*)
if [[ -r "$HOME/.bash_profile" ]]; then
shell_profile="$HOME/.bash_profile"
else
shell_profile="$HOME/.profile"
fi
;;
*/zsh*)
shell_profile="$HOME/.zprofile"
;;
*)
shell_profile="$HOME/.profile"
;;
esac
echo "- Install the Homebrew dependencies if you have sudo access:"
if [[ $(command -v apt-get) ]]; then
echo " sudo apt-get install build-essential"
elif [[ $(command -v yum) ]]; then
echo " sudo yum groupinstall 'Development Tools'"
elif [[ $(command -v pacman) ]]; then
echo " sudo pacman -S base-devel"
elif [[ $(command -v apk) ]]; then
echo " sudo apk add build-base"
fi
cat <<EOS
See ${tty_underline}https://docs.brew.sh/linux${tty_reset} for more information
- Add Homebrew to your ${tty_bold}PATH${tty_reset} in ${tty_underline}${shell_profile}${tty_reset}:
echo 'eval \$(${HOMEBREW_PREFIX}/bin/brew shellenv)' >> ${shell_profile}
eval \$(${HOMEBREW_PREFIX}/bin/brew shellenv)
- We recommend that you install GCC:
brew install gcc
EOS
fi

6
.github/labeler.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
documentation:
- 'docs/**/*'
- '**/*.md'
waiting for triage:
- any: ['**/*', '!docs/**/*', '!**/*.md']

View File

@@ -14,6 +14,9 @@ categories:
label:
- 'doc'
- 'documentation'
- title: '🧹 Maintenance'
label:
- 'maintenance'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
@@ -30,4 +33,4 @@ version-resolver:
template: |
## Changes
$CHANGES
$CHANGES

14
.github/workflows/labeler.yml vendored Normal file
View File

@@ -0,0 +1,14 @@
name: "Add label automatically"
on:
- pull_request_target
jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

View File

@@ -12,12 +12,31 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest]
python-version: [3.6, 3.7, 3.8]
os: [windows-latest, macos-11]
# FIXME: macos-latest will raise error now.
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
python-version: [3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python
# This is because on macos systems you can install pyqlib using
# `pip install pyqlib` installs, it does not recognize the
# `pyqlib-<version>-cp38-cp38-macosx_11_0_x86_64.whl` and `pyqlib-<veresion>-cp38-cp37m-macosx_11_0_x86_64.whl`.
# So we limit the version of python, in order to generate a version of qlib that is usable for macos: `pyqlib-<veresion>-cp38-cp37m
# `pyqlib-<version>-cp38-cp38-macosx_10_15_x86_64.whl` and `pyqlib-<veresion>-cp38-cp37m-macosx_10_15_x86_64.whl`.
# Python 3.7.16, 3.8.16 can build macosx_10_15. But Python 3.7.17, 3.8.17 can build macosx_11_0
- name: Set up Python ${{ matrix.python-version }}
if: matrix.os == 'macos-11' && matrix.python-version == '3.7'
uses: actions/setup-python@v2
with:
python-version: "3.7.16"
- name: Set up Python ${{ matrix.python-version }}
if: matrix.os == 'macos-11' && matrix.python-version == '3.8'
uses: actions/setup-python@v2
with:
python-version: "3.8.16"
- name: Set up Python ${{ matrix.python-version }}
if: matrix.os != 'macos-11'
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
@@ -25,18 +44,18 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build wheel on Windows
- name: Build wheel on ${{ matrix.os }}
run: |
pip install numpy
pip install cython
python setup.py bdist_wheel
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/*
deploy_with_manylinux:
runs-on: ubuntu-latest
steps:
@@ -44,7 +63,8 @@ jobs:
- name: Build wheel on Linux
uses: RalfG/python-wheels-manylinux-build@v0.3.1-manylinux2010_x86_64
with:
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38'
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
python-versions: 'cp37-cp37m cp38-cp38'
build-requirements: 'numpy cython'
- name: Set up Python
uses: actions/setup-python@v2
@@ -52,10 +72,10 @@ jobs:
python-version: 3.7
- name: Install dependencies
run: |
pip install twine
pip install twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/pyqlib-*-manylinux*.whl

View File

@@ -6,8 +6,14 @@ on:
branches:
- main
permissions:
contents: read
jobs:
update_release_draft:
permissions:
contents: write
pull-requests: read
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"

25
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,25 @@
name: Mark stale issues and pull requests
on:
schedule:
- cron: "0 0/3 * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open for three months with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days'
stale-pr-message: 'This PR is stale because it has been open for a year with no activity. Remove the stale label or comment on the PR otherwise this will be closed in 5 days'
stale-issue-label: 'stale'
stale-pr-label: 'stale'
days-before-stale: 90
days-before-pr-stale: 365
days-before-close: 5
operations-per-run: 100
exempt-issue-labels: 'bug,enhancement'
remove-stale-when-updated: true

View File

@@ -1,60 +0,0 @@
name: Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-16.04, ubuntu-18.04, macos-latest]
python-version: [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
python setup.py install
- name: Install Lightgbm for MacOS
if: runner.os == 'macOS'
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install lightgbm
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
- 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: Unit tests with Pytest
run: |
cd tests
pytest . --durations=0
- 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 --to html

View File

@@ -0,0 +1,69 @@
name: Test qlib from pip
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
timeout-minutes: 120
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,
# so we limit the macos version to macos-12.
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-11, macos-12]
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
python-version: [3.7, 3.8]
steps:
- name: Test qlib from pip
uses: actions/checkout@v3
# Since version 3.7 of python for MacOS is installed in CI, version 3.7.17, this version causes "_bz not found error".
# So we make the version number of python 3.7 for MacOS more specific.
# refs: https://github.com/actions/setup-python/issues/682
- name: Set up Python ${{ matrix.python-version }}
if: (matrix.os == 'macos-latest' && matrix.python-version == '3.7') || (matrix.os == 'macos-11' && matrix.python-version == '3.7')
uses: actions/setup-python@v4
with:
python-version: "3.7.16"
- name: Set up Python ${{ matrix.python-version }}
if: (matrix.os != 'macos-latest' || matrix.python-version != '3.7') && (matrix.os != 'macos-11' || matrix.python-version != '3.7')
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: Qlib installation test
run: |
python -m pip install pyqlib
- name: Install Lightgbm for MacOS
if: ${{ matrix.os == 'macos-11' || matrix.os == 'macos-latest' }}
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: Downloads dependencies data
run: |
cd ..
python -m qlib.run.get_data qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
cd qlib
- name: Test workflow by config
run: |
qrun examples/benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml

View File

@@ -0,0 +1,178 @@
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:
# 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,
# so we limit the macos version to macos-12.
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-11, macos-12]
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
python-version: [3.7, 3.8]
steps:
- name: Test qlib from source
uses: actions/checkout@v3
# Since version 3.7 of python for MacOS is installed in CI, version 3.7.17, this version causes "_bz not found error".
# So we make the version number of python 3.7 for MacOS more specific.
# refs: https://github.com/actions/setup-python/issues/682
- name: Set up Python ${{ matrix.python-version }}
if: (matrix.os == 'macos-latest' && matrix.python-version == '3.7') || (matrix.os == 'macos-11' && matrix.python-version == '3.7')
uses: actions/setup-python@v4
with:
python-version: "3.7.16"
- name: Set up Python ${{ matrix.python-version }}
if: (matrix.os != 'macos-latest' || matrix.python-version != '3.7') && (matrix.os != 'macos-11' || matrix.python-version != '3.7')
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-11' || matrix.os == 'macos-latest' }}
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: |
python -m pip install --upgrade cython
python -m pip install -e .[dev]
- name: Lint with Black
# Python 3.7 will use a black with low level. So we use python with higher version for black check
if: (matrix.python-version != '3.7')
run: |
pip install -U black # follow the latest version of black, previous Qlib dependency will downgrade black
black . -l 120 --check --diff
- name: Make html with sphinx
run: |
cd docs
sphinx-build -W --keep-going -b html . _build
cd ..
# Check Qlib with pylint
# TODO: These problems we will solve in the future. Important among them are: W0221, W0223, W0237, E1102
# C0103: invalid-name
# C0209: consider-using-f-string
# R0402: consider-using-from-import
# R1705: no-else-return
# R1710: inconsistent-return-statements
# R1725: super-with-arguments
# R1735: use-dict-literal
# W0102: dangerous-default-value
# W0212: protected-access
# W0221: arguments-differ
# W0223: abstract-method
# W0231: super-init-not-called
# W0237: arguments-renamed
# W0612: unused-variable
# W0621: redefined-outer-name
# W0622: redefined-builtin
# FIXME: specify exception type
# W0703: broad-except
# W1309: f-string-without-interpolation
# E1102: not-callable
# E1136: unsubscriptable-object
# References for parameters: https://github.com/PyCQA/pylint/issues/4577#issuecomment-1000245962
# We use sys.setrecursionlimit(2000) to make the recursion depth larger to ensure that pylint works properly (the default recursion depth is 1000).
- name: Check Qlib with pylint
run: |
pylint --disable=C0104,C0114,C0115,C0116,C0301,C0302,C0411,C0413,C1802,R0401,R0801,R0902,R0903,R0911,R0912,R0913,R0914,R0915,R1720,W0105,W0123,W0201,W0511,W0613,W1113,W1514,E0401,E1121,C0103,C0209,R0402,R1705,R1710,R1725,R1735,W0102,W0212,W0221,W0223,W0231,W0237,W0612,W0621,W0622,W0703,W1309,E1102,E1136 --const-rgx='[a-z_][a-z0-9_]{2,30}$' qlib --init-hook "import astroid; astroid.context.InferenceContext.max_inferred = 500; import sys; sys.setrecursionlimit(2000)"
pylint --disable=C0104,C0114,C0115,C0116,C0301,C0302,C0411,C0413,C1802,R0401,R0801,R0902,R0903,R0911,R0912,R0913,R0914,R0915,R1720,W0105,W0123,W0201,W0511,W0613,W1113,W1514,E0401,E1121,C0103,C0209,R0402,R1705,R1710,R1725,R1735,W0102,W0212,W0221,W0223,W0231,W0237,W0246,W0612,W0621,W0622,W0703,W1309,E1102,E1136 --const-rgx='[a-z_][a-z0-9_]{2,30}$' scripts --init-hook "import astroid; astroid.context.InferenceContext.max_inferred = 500; import sys; sys.setrecursionlimit(2000)"
# The following flake8 error codes were ignored:
# E501 line too long
# Description: We have used black to limit the length of each line to 120.
# F541 f-string is missing placeholders
# Description: The same thing is done when using pylint for detection.
# E266 too many leading '#' for block comment
# Description: To make the code more readable, a lot of "#" is used.
# This error code appears centrally in:
# qlib/backtest/executor.py
# qlib/data/ops.py
# qlib/utils/__init__.py
# E402 module level import not at top of file
# Description: There are times when module level import is not available at the top of the file.
# W503 line break before binary operator
# Description: Since black formats the length of each line of code, it has to perform a line break when a line of arithmetic is too long.
# E731 do not assign a lambda expression, use a def
# Description: Restricts the use of lambda expressions, but at some point lambda expressions are required.
# E203 whitespace before ':'
# Description: If there is whitespace before ":", it cannot pass the black check.
- name: Check Qlib with flake8
run: |
flake8 --ignore=E501,F541,E266,E402,W503,E731,E203 --per-file-ignores="__init__.py:F401,F403" qlib
# https://github.com/python/mypy/issues/10600
- name: Check Qlib with mypy
run: |
mypy qlib --install-types --non-interactive || true
mypy qlib --verbose
- name: Check Qlib ipynb with nbqa
run: |
nbqa black . -l 120 --check --diff
nbqa pylint . --disable=C0104,C0114,C0115,C0116,C0301,C0302,C0411,C0413,C1802,R0401,R0801,R0902,R0903,R0911,R0912,R0913,R0914,R0915,R1720,W0105,W0123,W0201,W0511,W0613,W1113,W1514,E0401,E1121,C0103,C0209,R0402,R1705,R1710,R1725,R1735,W0102,W0212,W0221,W0223,W0231,W0237,W0612,W0621,W0622,W0703,W1309,E1102,E1136,W0719,W0104,W0404,C0412,W0611,C0410 --const-rgx='[a-z_][a-z0-9_]{2,30}$'
- 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-11' || matrix.os == 'macos-latest' }}
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
# Run after data downloads
- name: Check Qlib ipynb with nbconvert
run: |
# add more ipynb files in future
jupyter nbconvert --to notebook --execute examples/workflow_by_code.ipynb
- 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

View File

@@ -0,0 +1,71 @@
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:
# 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,
# so we limit the macos version to macos-12.
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-11, macos-12]
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
python-version: [3.7, 3.8]
steps:
- name: Test qlib from source slow
uses: actions/checkout@v3
# Since version 3.7 of python for MacOS is installed in CI, version 3.7.17, this version causes "_bz not found error".
# So we make the version number of python 3.7 for MacOS more specific.
# refs: https://github.com/actions/setup-python/issues/682
- name: Set up Python ${{ matrix.python-version }}
if: (matrix.os == 'macos-latest' && matrix.python-version == '3.7') || (matrix.os == 'macos-11' && matrix.python-version == '3.7')
uses: actions/setup-python@v4
with:
python-version: "3.7.16"
- name: Set up Python ${{ matrix.python-version }}
if: (matrix.os != 'macos-latest' || matrix.python-version != '3.7') && (matrix.os != 'macos-11' || matrix.python-version != '3.7')
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up Python tools
run: |
python -m pip install --upgrade pip
pip install --upgrade cython numpy
pip install -e .[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-11' || matrix.os == 'macos-latest' }}
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

18
.gitignore vendored
View File

@@ -2,6 +2,7 @@
__pycache__/
*.pyc
*.pyd
*.so
*.ipynb
.ipynb_checkpoints
@@ -9,7 +10,6 @@ _build
build/
dist/
*.pkl
*.hd5
*.csv
@@ -19,12 +19,22 @@ dist/
.nvimrc
.vscode
qlib/VERSION.txt
qlib/data/_libs/expanding.cpp
qlib/data/_libs/rolling.cpp
examples/estimator/estimator_example/
examples/rl/data/
examples/rl/checkpoints/
examples/rl/outputs/
examples/rl_order_execution/data/
examples/rl_order_execution/outputs/
*.egg-info/
# test related
test-output.xml
.output
.data
# special software
mlruns/
@@ -32,4 +42,10 @@ mlruns/
tags
.pytest_cache/
.mypy_cache/
.vscode/
*.swp
./pretrain
.idea/

17
.mypy.ini Normal file
View File

@@ -0,0 +1,17 @@
[mypy]
exclude = (?x)(
^qlib/backtest/high_performance_ds\.py$
| ^qlib/contrib
| ^qlib/data
| ^qlib/model
| ^qlib/strategy
| ^qlib/tests
| ^qlib/utils
| ^qlib/workflow
| ^qlib/config\.py$
| ^qlib/log\.py$
| ^qlib/__init__\.py$
)
ignore_missing_imports = true
disallow_incomplete_defs = true
follow_imports = skip

12
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
args: ["qlib", "-l 120"]
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
args: ["--ignore=E501,F541,E266,E402,W503,E731,E203"]

5
.pylintrc Normal file
View File

@@ -0,0 +1,5 @@
[TYPECHECK]
# https://stackoverflow.com/a/53572939
# List of members which are set dynamically and missed by Pylint inference
# system, and so shouldn't trigger E1101 when accessed.
generated-members=numpy.*, torch.*

26
.readthedocs.yaml Normal file
View File

@@ -0,0 +1,26 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.7"
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
# Build all formats
formats: all
# Optionally set the version of Python and requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .

View File

@@ -1,63 +1,63 @@
Changelog
====================
=========
Here you can see the full list of changes between each QLib release.
Version 0.1.0
--------------------
-------------
This is the initial release of QLib library.
Version 0.1.1
--------------------
-------------
Performance optimize. Add more features and operators.
Version 0.1.2
--------------------
- Support operator syntax. Now ``High() - Low()`` is equivalent to ``Sub(High(), Low())``.
-------------
- Support operator syntax. Now ``High() - Low()`` is equivalent to ``Sub(High(), Low())``.
- Add more technical indicators.
Version 0.1.3
--------------------
-------------
Bug fix and add instruments filtering mechanism.
Version 0.2.0
--------------------
-------------
- Redesign ``LocalProvider`` database format for performance improvement.
- Support load features as string fields.
- Add scripts for database construction.
- More operators and technical indicators.
Version 0.2.1
--------------------
-------------
- Support registering user-defined ``Provider``.
- Support use operators in string format, e.g. ``['Ref($close, 1)']`` is valid field format.
- Support dynamic fields in ``$some_field`` format. And exising fields like ``Close()`` may be deprecated in the future.
- Support dynamic fields in ``$some_field`` format. And existing fields like ``Close()`` may be deprecated in the future.
Version 0.2.2
--------------------
-------------
- Add ``disk_cache`` for reusing features (enabled by default).
- Add ``qlib.contrib`` for experimental model construction and evaluation.
Version 0.2.3
--------------------
-------------
- Add ``backtest`` module
- Decoupling the Strategy, Account, Position, Exchange from the backtest module
Version 0.2.4
--------------------
-------------
- Add ``profit attribution`` module
- Add ``rick_control`` and ``cost_control`` strategies
Version 0.3.0
--------------------
-------------
- Add ``estimator`` module
Version 0.3.1
--------------------
-------------
- Add ``filter`` module
Version 0.3.2
--------------------
-------------
- Add real price trading, if the ``factor`` field in the data set is incomplete, use ``adj_price`` trading
- Refactor ``handler`` ``launcher`` ``trainer`` code
- Support ``backtest`` configuration parameters in the configuration file
@@ -65,27 +65,27 @@ Version 0.3.2
- Fix bug of ``filter`` module
Version 0.3.3
-------------------
-------------
- Fix bug of ``filter`` module
Version 0.3.4
--------------------
-------------
- Support for ``finetune model``
- Refactor ``fetcher`` code
Version 0.3.5
--------------------
-------------
- Support multi-label training, you can provide multiple label in ``handler``. (But LightGBM doesn't support due to the algorithm itself)
- Refactor ``handler`` code, dataset.py is no longer used, and you can deploy your own labels and features in ``feature_label_config``
- Handler only offer DataFrame. Also, ``trainer`` and model.py only receive DataFrame
- Change ``split_rolling_data``, we roll the data on market calender now, not on normal date
- Change ``split_rolling_data``, we roll the data on market calendar now, not on normal date
- Move some date config from ``handler`` to ``trainer``
Version 0.4.0
--------------------
-------------
- Add `data` package that holds all data-related codes
- Reform the data provider structure
- Create a server for data centralized management `qlib-server<https://amc-msra.visualstudio.com/trading-algo/_git/qlib-server>`_
- Create a server for data centralized management `qlib-server <https://amc-msra.visualstudio.com/trading-algo/_git/qlib-server>`_
- Add a `ClientProvider` to work with server
- Add a pluggable cache mechanism
- Add a recursive backtracking algorithm to inspect the furthest reference date for an expression
@@ -100,7 +100,7 @@ Version 0.4.0
Version 0.4.1
--------------------
-------------
- Add support Windows
- Fix ``instruments`` type bug
- Fix ``features`` is empty bug(It will cause failure in updating)
@@ -112,19 +112,19 @@ Version 0.4.1
Version 0.4.2
--------------------
-------------
- Refactor DataHandler
- Add ``ALPHA360`` DataHandler
- Add ``Alpha360`` DataHandler
Version 0.4.3
--------------------
-------------
- Implementing Online Inference and Trading Framework
- Refactoring The interfaces of backtest and strategy module.
Version 0.4.4
--------------------
-------------
- Optimize cache generation performance
- Add report module
- Fix bug when using ``ServerDatasetCache`` offline.
@@ -138,7 +138,7 @@ Version 0.4.4
Version 0.4.5
--------------------
-------------
- Add multi-kernel implementation for both client and server.
- Support a new way to load data from client which skips dataset cache.
- Change the default dataset method from single kernel implementation to multi kernel implementation.
@@ -146,19 +146,34 @@ Version 0.4.5
- Support a new method to write config file by using dict.
Version 0.4.6
--------------------
-------------
- Some bugs are fixed
- The default config in `Version 0.4.5` is not friendly to daily frequency data.
- Backtest error in TopkWeightStrategy when `WithInteract=True`.
Version 0.5.0
--------------------
-------------
- First opensource version
- Refine the docs, code
- Add baselines
- public data crawler
Version greater than Version 0.5.0
----------------------------------
Version 0.8.0
-------------
- The backtest is greatly refactored.
- Nested decision execution framework is supported
- There are lots of changes for daily trading, it is hard to list all of them. But a few important changes could be noticed
- The trading limitation is more accurate;
- In `previous version <https://github.com/microsoft/qlib/blob/v0.7.2/qlib/contrib/backtest/exchange.py#L160>`__, longing and shorting actions share the same action.
- In `current version <https://github.com/microsoft/qlib/blob/7c31012b507a3823117bddcc693fc64899460b2a/qlib/backtest/exchange.py#L304>`__, the trading limitation is different between logging and shorting action.
- The constant is different when calculating annualized metrics.
- `Current version <https://github.com/microsoft/qlib/blob/7c31012b507a3823117bddcc693fc64899460b2a/qlib/contrib/evaluate.py#L42>`_ uses more accurate constant than `previous version <https://github.com/microsoft/qlib/blob/v0.7.2/qlib/contrib/evaluate.py#L22>`__
- `A new version <https://github.com/microsoft/qlib/blob/7c31012b507a3823117bddcc693fc64899460b2a/qlib/tests/data.py#L17>`__ of data is released. Due to the unstability of Yahoo data source, the data may be different after downloading data again.
- Users could check out the backtesting results between `Current version <https://github.com/microsoft/qlib/tree/7c31012b507a3823117bddcc693fc64899460b2a/examples/benchmarks>`__ and `previous version <https://github.com/microsoft/qlib/tree/v0.7.2/examples/benchmarks>`__
Other Versions
--------------
Please refer to `Github release Notes <https://github.com/microsoft/qlib/releases>`_

1
MANIFEST.in Normal file
View File

@@ -0,0 +1 @@
include qlib/VERSION.txt

441
README.md
View File

@@ -1,74 +1,160 @@
[![Python Versions](https://img.shields.io/pypi/pyversions/pyqlib.svg?logo=python&logoColor=white)](https://pypi.org/project/pyqlib/#files)
[![Platform](https://img.shields.io/badge/platform-linux%20%7C%20windows%20%7C%20macos-lightgrey)](https://pypi.org/project/pyqlib/#files)
[![PypI Versions](https://img.shields.io/pypi/v/pyqlib)](https://pypi.org/project/pyqlib/#files)
[![PypI Versions](https://img.shields.io/pypi/v/pyqlib)](https://pypi.org/project/pyqlib/#history)
[![Upload Python Package](https://github.com/microsoft/qlib/workflows/Upload%20Python%20Package/badge.svg)](https://pypi.org/project/pyqlib/)
[![Github Actions Test Status](https://github.com/microsoft/qlib/workflows/Test/badge.svg?branch=main)](https://github.com/microsoft/qlib/actions)
[![Documentation Status](https://readthedocs.org/projects/qlib/badge/?version=latest)](https://qlib.readthedocs.io/en/latest/?badge=latest)
![Upload Python Package](https://github.com/microsoft/qlib/workflows/Upload%20Python%20Package/badge.svg)
[![License](https://img.shields.io/pypi/l/pyqlib)](LICENSE)
[![Join the chat at https://gitter.im/Microsoft/qlib](https://badges.gitter.im/Microsoft/qlib.svg)](https://gitter.im/Microsoft/qlib?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## :newspaper: **What's NEW!** &nbsp; :sparkling_heart:
Recent released features
| Feature | Status |
| -- | ------ |
| KRNN and Sandwich models | :chart_with_upwards_trend: [Released](https://github.com/microsoft/qlib/pull/1414/) on May 26, 2023 |
| Release Qlib v0.9.0 | :octocat: [Released](https://github.com/microsoft/qlib/releases/tag/v0.9.0) on Dec 9, 2022 |
| RL Learning Framework | :hammer: :chart_with_upwards_trend: Released on Nov 10, 2022. [#1332](https://github.com/microsoft/qlib/pull/1332), [#1322](https://github.com/microsoft/qlib/pull/1322), [#1316](https://github.com/microsoft/qlib/pull/1316),[#1299](https://github.com/microsoft/qlib/pull/1299),[#1263](https://github.com/microsoft/qlib/pull/1263), [#1244](https://github.com/microsoft/qlib/pull/1244), [#1169](https://github.com/microsoft/qlib/pull/1169), [#1125](https://github.com/microsoft/qlib/pull/1125), [#1076](https://github.com/microsoft/qlib/pull/1076)|
| HIST and IGMTF models | :chart_with_upwards_trend: [Released](https://github.com/microsoft/qlib/pull/1040) on Apr 10, 2022 |
| Qlib [notebook tutorial](https://github.com/microsoft/qlib/tree/main/examples/tutorial) | 📖 [Released](https://github.com/microsoft/qlib/pull/1037) on Apr 7, 2022 |
| Ibovespa index data | :rice: [Released](https://github.com/microsoft/qlib/pull/990) on Apr 6, 2022 |
| Point-in-Time database | :hammer: [Released](https://github.com/microsoft/qlib/pull/343) on Mar 10, 2022 |
| Arctic Provider Backend & Orderbook data example | :hammer: [Released](https://github.com/microsoft/qlib/pull/744) on Jan 17, 2022 |
| Meta-Learning-based framework & DDG-DA | :chart_with_upwards_trend: :hammer: [Released](https://github.com/microsoft/qlib/pull/743) on Jan 10, 2022 |
| Planning-based portfolio optimization | :hammer: [Released](https://github.com/microsoft/qlib/pull/754) on Dec 28, 2021 |
| Release Qlib v0.8.0 | :octocat: [Released](https://github.com/microsoft/qlib/releases/tag/v0.8.0) on Dec 8, 2021 |
| ADD model | :chart_with_upwards_trend: [Released](https://github.com/microsoft/qlib/pull/704) on Nov 22, 2021 |
| ADARNN model | :chart_with_upwards_trend: [Released](https://github.com/microsoft/qlib/pull/689) on Nov 14, 2021 |
| TCN model | :chart_with_upwards_trend: [Released](https://github.com/microsoft/qlib/pull/668) on Nov 4, 2021 |
| Nested Decision Framework | :hammer: [Released](https://github.com/microsoft/qlib/pull/438) on Oct 1, 2021. [Example](https://github.com/microsoft/qlib/blob/main/examples/nested_decision_execution/workflow.py) and [Doc](https://qlib.readthedocs.io/en/latest/component/highfreq.html) |
| Temporal Routing Adaptor (TRA) | :chart_with_upwards_trend: [Released](https://github.com/microsoft/qlib/pull/531) on July 30, 2021 |
| Transformer & Localformer | :chart_with_upwards_trend: [Released](https://github.com/microsoft/qlib/pull/508) on July 22, 2021 |
| Release Qlib v0.7.0 | :octocat: [Released](https://github.com/microsoft/qlib/releases/tag/v0.7.0) on July 12, 2021 |
| TCTS Model | :chart_with_upwards_trend: [Released](https://github.com/microsoft/qlib/pull/491) on July 1, 2021 |
| Online serving and automatic model rolling | :hammer: [Released](https://github.com/microsoft/qlib/pull/290) on May 17, 2021 |
| DoubleEnsemble Model | :chart_with_upwards_trend: [Released](https://github.com/microsoft/qlib/pull/286) on Mar 2, 2021 |
| High-frequency data processing example | :hammer: [Released](https://github.com/microsoft/qlib/pull/257) on Feb 5, 2021 |
| High-frequency trading example | :chart_with_upwards_trend: [Part of code released](https://github.com/microsoft/qlib/pull/227) on Jan 28, 2021 |
| High-frequency data(1min) | :rice: [Released](https://github.com/microsoft/qlib/pull/221) on Jan 27, 2021 |
| Tabnet Model | :chart_with_upwards_trend: [Released](https://github.com/microsoft/qlib/pull/205) on Jan 22, 2021 |
Features released before 2021 are not listed here.
<p align="center">
<img src="http://fintech.msra.cn/images/logo/1.png" />
<img src="http://fintech.msra.cn/images_v070/logo/1.png" />
</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 AI-oriented quantitative investment platform, which aims to realize the potential, empower the research, and create the value of AI technologies in quantitative investment.
With Qlib, you can easily try your ideas to create better Quant investment strategies.
An increasing number of SOTA Quant research works/papers in diverse paradigms are being released in Qlib to collaboratively solve key challenges in quantitative investment. For example, 1) using supervised learning to mine the market's complex non-linear patterns from rich and heterogeneous financial data, 2) modeling the dynamic nature of the financial market using adaptive concept drift technology, and 3) using reinforcement learning to model continuous investment decisions and assist investors in optimizing their trading strategies.
It contains the full ML pipeline of data processing, model training, back-testing; and covers the entire chain of quantitative investment: alpha seeking, risk modeling, portfolio optimization, and order execution.
For more details, please refer to our paper ["Qlib: An AI-oriented Quantitative Investment Platform"](https://arxiv.org/abs/2009.11189).
- [Framework of Qlib](#framework-of-qlib)
- [Quick Start](#quick-start)
- [Installation](#installation)
- [Data Preparation](#data-preparation)
- [Auto Quant Research Workflow](#auto-quant-research-workflow)
- [Building Customized Quant Research Workflow by Code](#building-customized-quant-research-workflow-by-code)
- [Quant Model Zoo](#quant-model-zoo)
- [Quant Dataset Zoo](#quant-dataset-zoo)
- [More About Qlib](#more-about-qlib)
- [Offline Mode and Online Mode](#offline-mode-and-online-mode)
- [Performance of Qlib Data Server](#performance-of-qlib-data-server)
- [Contributing](#contributing)
<table>
<tbody>
<tr>
<th>Frameworks, Tutorial, Data & DevOps</th>
<th>Main Challenges & Solutions in Quant Research</th>
</tr>
<tr>
<td>
<li><a href="#plans"><strong>Plans</strong></a></li>
<li><a href="#framework-of-qlib">Framework of Qlib</a></li>
<li><a href="#quick-start">Quick Start</a></li>
<ul dir="auto">
<li type="circle"><a href="#installation">Installation</a> </li>
<li type="circle"><a href="#data-preparation">Data Preparation</a></li>
<li type="circle"><a href="#auto-quant-research-workflow">Auto Quant Research Workflow</a></li>
<li type="circle"><a href="#building-customized-quant-research-workflow-by-code">Building Customized Quant Research Workflow by Code</a></li></ul>
<li><a href="#quant-dataset-zoo"><strong>Quant Dataset Zoo</strong></a></li>
<li><a href="#learning-framework">Learning Framework</a></li>
<li><a href="#more-about-qlib">More About Qlib</a></li>
<li><a href="#offline-mode-and-online-mode">Offline Mode and Online Mode</a>
<ul>
<li type="circle"><a href="#performance-of-qlib-data-server">Performance of Qlib Data Server</a></li></ul>
<li><a href="#related-reports">Related Reports</a></li>
<li><a href="#contact-us">Contact Us</a></li>
<li><a href="#contributing">Contributing</a></li>
</td>
<td valign="baseline">
<li><a href="#main-challenges--solutions-in-quant-research">Main Challenges &amp; Solutions in Quant Research</a>
<ul>
<li type="circle"><a href="#forecasting-finding-valuable-signalspatterns">Forecasting: Finding Valuable Signals/Patterns</a>
<ul>
<li type="disc"><a href="#quant-model-paper-zoo"><strong>Quant Model (Paper) Zoo</strong></a>
<ul>
<li type="circle"><a href="#run-a-single-model">Run a Single Model</a></li>
<li type="circle"><a href="#run-multiple-models">Run Multiple Models</a></li>
</ul>
</li>
</ul>
</li>
<li type="circle"><a href="#adapting-to-market-dynamics">Adapting to Market Dynamics</a></li>
<li type="circle"><a href="#reinforcement-learning-modeling-continuous-decisions">Reinforcement Learning: modeling continuous decisions</a></li>
</ul>
</li>
</td>
</tr>
</tbody>
</table>
# Plans
New features under development(order by estimated release time).
Your feedbacks about the features are very important.
<!-- | Feature | Status | -->
<!-- | -- | ------ | -->
# Framework of Qlib
<div style="align: center">
<img src="http://fintech.msra.cn/images/framework.png" />
<img src="docs/_static/img/framework-abstract.jpg" />
</div>
The high-level framework of Qlib can be found above(users can find the [detailed framework](https://qlib.readthedocs.io/en/latest/introduction/introduction.html#framework) of Qlib's design when getting into nitty gritty).
The components are designed as loose-coupled modules, and each component could be used stand-alone.
At the module level, Qlib is a platform that consists of the above components. The components are designed as loose-coupled modules and each component could be used stand-alone.
| Name | Description |
| ------ | ----- |
| `Data layer` | `DataServer` focuses on providing high-performance infrastructure for users to manage and retrieve raw data. `DataEnhancement` will preprocess the data and provide the best dataset to be fed into the models. |
| `Interday Model` | `Interday model` focuses on producing prediction scores (aka. _alpha_). Models are trained by `Model Creator` and managed by `Model Manager`. Users could choose one or multiple models for prediction. Multiple models could be combined with `Ensemble` module. |
| `Interday Strategy` | `Portfolio Generator` will take prediction scores as input and output the orders based on the current position to achieve the target portfolio. |
| `Intraday Trading` | `Order Executor` is responsible for executing orders output by `Interday Strategy` and returning the executed results. |
| `Analysis` | Users could get a detailed analysis report of forecasting signals and portfolios in this part. |
* The modules with hand-drawn style are under development and will be released in the future.
* The modules with dashed borders are highly user-customizable and extendible.
Qlib provides a strong infrastructure to support Quant research. [Data](https://qlib.readthedocs.io/en/latest/component/data.html) is always an important part.
A strong learning framework is designed to support diverse learning paradigms (e.g. [reinforcement learning](https://qlib.readthedocs.io/en/latest/component/rl.html), [supervised learning](https://qlib.readthedocs.io/en/latest/component/workflow.html#model-section)) and patterns at different levels(e.g. [market dynamic modeling](https://qlib.readthedocs.io/en/latest/component/meta.html)).
By modeling the market, [trading strategies](https://qlib.readthedocs.io/en/latest/component/strategy.html) will generate trade decisions that will be executed. Multiple trading strategies and executors in different levels or granularities can be [nested to be optimized and run together](https://qlib.readthedocs.io/en/latest/component/highfreq.html).
At last, a comprehensive [analysis](https://qlib.readthedocs.io/en/latest/component/report.html) will be provided and the model can be [served online](https://qlib.readthedocs.io/en/latest/component/online.html) in a low cost.
# Quick Start
This quick start guide tries to demonstrate
1. It's very easy to build a complete Quant research workflow and try your ideas with _Qlib_.
1. Though with *public data* and *simple models*, machine learning technologies **work very well** in practical Quant investment.
2. Though with *public data* and *simple models*, machine learning technologies **work very well** in practical Quant investment.
Here is a quick **[demo](https://terminalizer.com/view/3f24561a4470)** shows how to install ``Qlib``, and run LightGBM with ``qrun``. **But**, please make sure you have already prepared the data following the [instruction](#data-preparation).
## Installation
Users can easily install ``Qlib`` by pip according to the following command
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 | :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.
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.
```bash
pip install pyqlib
```
Also, Users can install ``Qlib`` by the source code according to the following steps:
**Note**: pip will install the latest stable qlib. However, the main branch of qlib is in active development. If you want to test the latest scripts or functions in the main branch. Please install qlib with the methods below.
### Install from source
Also, users can install the latest dev version ``Qlib`` by the source code according to the following steps:
* Before installing ``Qlib`` from source, users need to install some dependencies:
@@ -77,25 +163,73 @@ Also, Users can install ``Qlib`` by the source code according to the following s
pip install --upgrade cython
```
* Clone the repository and install ``Qlib``:
* Clone the repository and install ``Qlib`` as follows.
```bash
git clone https://github.com/microsoft/qlib.git && cd qlib
pip install .
```
**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**.
```bash
git clone https://github.com/microsoft/qlib.git && cd qlib
python setup.py install
```
**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.
**Tips for Mac**: If you are using Mac with M1, you might encounter issues in building the wheel for LightGBM, which is due to missing dependencies from OpenMP. To solve the problem, install openmp first with ``brew install libomp`` and then run ``pip install .`` to build it successfully.
## Data Preparation
Load and prepare data by running the following code:
### Get with module
```bash
python scripts/get_data.py qlib_data_cn --target_dir ~/.qlib/qlib_data/cn_data
# get 1d data
python -m qlib.run.get_data qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
# get 1min data
python -m qlib.run.get_data qlib_data --target_dir ~/.qlib/qlib_data/cn_data_1min --region cn --interval 1min
```
### Get from source
```bash
# get 1d data
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
# get 1min data
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data_1min --region cn --interval 1min
```
This dataset is created by public data collected by [crawler scripts](scripts/data_collector/), which have been released in
the same repository.
Users could create the same dataset with it.
Users could create the same dataset with it. [Description of dataset](https://github.com/microsoft/qlib/tree/main/scripts/data_collector#description-of-dataset)
*Please pay **ATTENTION** that the data is collected from [Yahoo Finance](https://finance.yahoo.com/lookup), and the data might not be perfect.
We recommend users to prepare their own data if they have a high-quality dataset. For more information, users can refer to the [related document](https://qlib.readthedocs.io/en/latest/component/data.html#converting-csv-format-into-qlib-format)*.
### Automatic update of daily frequency data (from yahoo finance)
> This step is *Optional* if users only want to try their models and strategies on history data.
>
> It is recommended that users update the data manually once (--trading_date 2021-05-25) and then set it to update automatically.
>
> **NOTE**: Users can't incrementally update data based on the offline data provided by Qlib(some fields are removed to reduce the data size). Users should use [yahoo collector](https://github.com/microsoft/qlib/tree/main/scripts/data_collector/yahoo#automatic-update-of-daily-frequency-datafrom-yahoo-finance) to download Yahoo data from scratch and then incrementally update it.
>
> For more information, please refer to: [yahoo collector](https://github.com/microsoft/qlib/tree/main/scripts/data_collector/yahoo#automatic-update-of-daily-frequency-datafrom-yahoo-finance)
* Automatic update of data to the "qlib" directory each trading day(Linux)
* use *crontab*: `crontab -e`
* set up timed tasks:
```
* * * * 1-5 python <script path> update_data_to_bin --qlib_data_1d_dir <user data dir>
```
* **script path**: *scripts/data_collector/yahoo/collector.py*
* Manual update of data
```
python scripts/data_collector/yahoo/collector.py update_data_to_bin --qlib_data_1d_dir <user data dir> --trading_date <start date> --end_date <end date>
```
* *trading_date*: start of trading day
* *end_date*: end of trading day(not included)
*Please pay **ATTENTION** that the data is collected from [Yahoo Finance](https://finance.yahoo.com/lookup) and the data might not be perfect. We recommend users to prepare their own data if they have high-quality dataset. For more information, users can refer to the [related document](https://qlib.readthedocs.io/en/latest/component/data.html#converting-csv-format-into-qlib-format)*.
<!--
- Run the initialization code and get stock data:
@@ -103,7 +237,7 @@ Users could create the same dataset with it.
```python
import qlib
from qlib.data import D
from qlib.config import REG_CN
from qlib.constant import REG_CN
# Initialization
mount_path = "~/.qlib/qlib_data/cn_data" # target_dir
@@ -125,50 +259,54 @@ Users could create the same dataset with it.
-->
## Auto Quant Research Workflow
Qlib provides a tool named `Estimator` to run the whole workflow automatically (including building dataset, training models, backtest and evaluation). You can start an auto quant research workflow and have a graphical reports analysis according to the following steps:
Qlib provides a tool named `qrun` to run the whole workflow automatically (including building dataset, training models, backtest and evaluation). You can start an auto quant research workflow and have a graphical reports analysis according to the following steps:
1. Quant Research Workflow: Run `Estimator` with [estimator_config.yaml](examples/estimator/estimator_config.yaml) as following. (*Please note that this may **not work** under MacOS with Python 3.8 due to the incompatibility of the `sacred` package we use with Python 3.8. We will fix this bug in the future.*)
1. Quant Research Workflow: Run `qrun` with lightgbm workflow config ([workflow_config_lightgbm_Alpha158.yaml](examples/benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml) as following.
```bash
cd examples # Avoid running program under the directory contains `qlib`
estimator -c estimator/estimator_config.yaml
qrun benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml
```
The result of `Estimator` is as follows, please refer to please refer to [Intraday Trading](https://qlib.readthedocs.io/en/latest/component/backtest.html) for more details about the result.
If users want to use `qrun` under debug mode, please use the following command:
```bash
python -m pdb qlib/workflow/cli.py examples/benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml
```
The result of `qrun` is as follows, please refer to [Intraday Trading](https://qlib.readthedocs.io/en/latest/component/backtest.html) for more details about the result.
```bash
risk
excess_return_without_cost mean 0.000675
std 0.005456
annualized_return 0.170077
information_ratio 1.963824
max_drawdown -0.063646
excess_return_with_cost mean 0.000479
std 0.005453
annualized_return 0.120776
information_ratio 1.395116
max_drawdown -0.071216
'The following are analysis results of the excess return without cost.'
risk
mean 0.000708
std 0.005626
annualized_return 0.178316
information_ratio 1.996555
max_drawdown -0.081806
'The following are analysis results of the excess return with cost.'
risk
mean 0.000512
std 0.005626
annualized_return 0.128982
information_ratio 1.444287
max_drawdown -0.091078
```
Here are detailed documents for [Estimator](https://qlib.readthedocs.io/en/latest/component/estimator.html).
Here are detailed documents for `qrun` and [workflow](https://qlib.readthedocs.io/en/latest/component/workflow.html).
2. Graphical Reports Analysis: Run `examples/estimator/analyze_from_estimator.ipynb` with `jupyter notebook` to get graphical reports
2. Graphical Reports Analysis: Run `examples/workflow_by_code.ipynb` with `jupyter notebook` to get graphical reports
- Forecasting signal (model prediction) analysis
- Cumulative Return of groups
![Cumulative Return](http://fintech.msra.cn/images/analysis/analysis_model_cumulative_return.png?v=0.1)
![Cumulative Return](http://fintech.msra.cn/images_v070/analysis/analysis_model_cumulative_return.png?v=0.1)
- Return distribution
![long_short](http://fintech.msra.cn/images/analysis/analysis_model_long_short.png?v=0.1)
![long_short](http://fintech.msra.cn/images_v070/analysis/analysis_model_long_short.png?v=0.1)
- Information Coefficient (IC)
![Information Coefficient](http://fintech.msra.cn/images/analysis/analysis_model_IC.png?v=0.1)
![Monthly IC](http://fintech.msra.cn/images/analysis/analysis_model_monthly_IC.png?v=0.1)
![IC](http://fintech.msra.cn/images/analysis/analysis_model_NDQ.png?v=0.1)
![Information Coefficient](http://fintech.msra.cn/images_v070/analysis/analysis_model_IC.png?v=0.1)
![Monthly IC](http://fintech.msra.cn/images_v070/analysis/analysis_model_monthly_IC.png?v=0.1)
![IC](http://fintech.msra.cn/images_v070/analysis/analysis_model_NDQ.png?v=0.1)
- Auto Correlation of forecasting signal (model prediction)
![Auto Correlation](http://fintech.msra.cn/images/analysis/analysis_model_auto_correlation.png?v=0.1)
![Auto Correlation](http://fintech.msra.cn/images_v070/analysis/analysis_model_auto_correlation.png?v=0.1)
- Portfolio analysis
- Backtest return
![Report](http://fintech.msra.cn/images/analysis/report.png?v=0.1)
![Report](http://fintech.msra.cn/images_v070/analysis/report.png?v=0.1)
<!--
- Score IC
![Score IC](docs/_static/img/score_ic.png)
@@ -179,28 +317,120 @@ Qlib provides a tool named `Estimator` to run the whole workflow automatically (
- Rank Label
![Rank Label](docs/_static/img/rank_label.png)
-->
- [Explanation](https://qlib.readthedocs.io/en/latest/component/report.html) of above results
## Building Customized Quant Research Workflow by Code
The automatic workflow may not suite the research workflow of all Quant researchers. To support a flexible Quant research workflow, Qlib also provides a modularized interface to allow researchers to build their own workflow by code. [Here](examples/train_backtest_analyze.ipynb) is a demo for customized Quant research workflow by code
The automatic workflow may not suit the research workflow of all Quant researchers. To support a flexible Quant research workflow, Qlib also provides a modularized interface to allow researchers to build their own workflow by code. [Here](examples/workflow_by_code.ipynb) is a demo for customized Quant research workflow by code.
# Main Challenges & Solutions in Quant Research
Quant investment is a very unique scenario with lots of key challenges to be solved.
Currently, Qlib provides some solutions for several of them.
## Forecasting: Finding Valuable Signals/Patterns
Accurate forecasting of the stock price trend is a very important part to construct profitable portfolios.
However, huge amount of data with various formats in the financial market which make it challenging to build forecasting models.
An increasing number of SOTA Quant research works/papers, which focus on building forecasting models to mine valuable signals/patterns in complex financial data, are released in `Qlib`
# Quant Model Zoo
### [Quant Model (Paper) Zoo](examples/benchmarks)
Here is a list of models build on `Qlib`.
- [GBDT based on lightgbm](qlib/contrib/model/gbdt.py)
- [MLP based on pytroch](qlib/contrib/model/pytorch_nn.py)
Here is a list of models built on `Qlib`.
- [GBDT based on XGBoost (Tianqi Chen, et al. KDD 2016)](examples/benchmarks/XGBoost/)
- [GBDT based on LightGBM (Guolin Ke, et al. NIPS 2017)](examples/benchmarks/LightGBM/)
- [GBDT based on Catboost (Liudmila Prokhorenkova, et al. NIPS 2018)](examples/benchmarks/CatBoost/)
- [MLP based on pytorch](examples/benchmarks/MLP/)
- [LSTM based on pytorch (Sepp Hochreiter, et al. Neural computation 1997)](examples/benchmarks/LSTM/)
- [GRU based on pytorch (Kyunghyun Cho, et al. 2014)](examples/benchmarks/GRU/)
- [ALSTM based on pytorch (Yao Qin, et al. IJCAI 2017)](examples/benchmarks/ALSTM)
- [GATs based on pytorch (Petar Velickovic, et al. 2017)](examples/benchmarks/GATs/)
- [SFM based on pytorch (Liheng Zhang, et al. KDD 2017)](examples/benchmarks/SFM/)
- [TFT based on tensorflow (Bryan Lim, et al. International Journal of Forecasting 2019)](examples/benchmarks/TFT/)
- [TabNet based on pytorch (Sercan O. Arik, et al. AAAI 2019)](examples/benchmarks/TabNet/)
- [DoubleEnsemble based on LightGBM (Chuheng Zhang, et al. ICDM 2020)](examples/benchmarks/DoubleEnsemble/)
- [TCTS based on pytorch (Xueqing Wu, et al. ICML 2021)](examples/benchmarks/TCTS/)
- [Transformer based on pytorch (Ashish Vaswani, et al. NeurIPS 2017)](examples/benchmarks/Transformer/)
- [Localformer based on pytorch (Juyong Jiang, et al.)](examples/benchmarks/Localformer/)
- [TRA based on pytorch (Hengxu, Dong, et al. KDD 2021)](examples/benchmarks/TRA/)
- [TCN based on pytorch (Shaojie Bai, et al. 2018)](examples/benchmarks/TCN/)
- [ADARNN based on pytorch (YunTao Du, et al. 2021)](examples/benchmarks/ADARNN/)
- [ADD based on pytorch (Hongshun Tang, et al.2020)](examples/benchmarks/ADD/)
- [IGMTF based on pytorch (Wentao Xu, et al.2021)](examples/benchmarks/IGMTF/)
- [HIST based on pytorch (Wentao Xu, et al.2021)](examples/benchmarks/HIST/)
- [KRNN based on pytorch](examples/benchmarks/KRNN/)
- [Sandwich based on pytorch](examples/benchmarks/Sandwich/)
Your PR of new Quant models is highly welcomed.
# Quant Dataset Zoo
Dataset plays a very important role in Quant. Here is a list of the datasets build on `Qlib`.
- [Alpha360](./qlib/contrib/estimator/handler.py)
- [Alpha158](./qlib/contrib/estimator/handler.py)
The performance of each model on the `Alpha158` and `Alpha360` datasets can be found [here](examples/benchmarks/README.md).
Here is a tutorial to build dataset with `Qlib`.
### Run a single model
All the models listed above are runnable with ``Qlib``. Users can find the config files we provide and some details about the model through the [benchmarks](examples/benchmarks) folder. More information can be retrieved at the model files listed above.
`Qlib` provides three different ways to run a single model, users can pick the one that fits their cases best:
- Users can use the tool `qrun` mentioned above to run a model's workflow based from a config file.
- Users can create a `workflow_by_code` python script based on the [one](examples/workflow_by_code.py) listed in the `examples` folder.
- Users can use the script [`run_all_model.py`](examples/run_all_model.py) listed in the `examples` folder to run a model. Here is an example of the specific shell command to be used: `python run_all_model.py run --models=lightgbm`, where the `--models` arguments can take any number of models listed above(the available models can be found in [benchmarks](examples/benchmarks/)). For more use cases, please refer to the file's [docstrings](examples/run_all_model.py).
- **NOTE**: Each baseline has different environment dependencies, please make sure that your python version aligns with the requirements(e.g. TFT only supports Python 3.6~3.7 due to the limitation of `tensorflow==1.15.0`)
### Run multiple models
`Qlib` also provides a script [`run_all_model.py`](examples/run_all_model.py) which can run multiple models for several iterations. (**Note**: the script only support *Linux* for now. Other OS will be supported in the future. Besides, it doesn't support parallel running the same model for multiple times as well, and this will be fixed in the future development too.)
The script will create a unique virtual environment for each model, and delete the environments after training. Thus, only experiment results such as `IC` and `backtest` results will be generated and stored.
Here is an example of running all the models for 10 iterations:
```python
python run_all_model.py run 10
```
It also provides the API to run specific models at once. For more use cases, please refer to the file's [docstrings](examples/run_all_model.py).
## [Adapting to Market Dynamics](examples/benchmarks_dynamic)
Due to the non-stationary nature of the environment of the financial market, the data distribution may change in different periods, which makes the performance of models build on training data decays in the future test data.
So adapting the forecasting models/strategies to market dynamics is very important to the model/strategies' performance.
Here is a list of solutions built on `Qlib`.
- [Rolling Retraining](examples/benchmarks_dynamic/baseline/)
- [DDG-DA on pytorch (Wendi, et al. AAAI 2022)](examples/benchmarks_dynamic/DDG-DA/)
## Reinforcement Learning: modeling continuous decisions
Qlib now supports reinforcement learning, a feature designed to model continuous investment decisions. This functionality assists investors in optimizing their trading strategies by learning from interactions with the environment to maximize some notion of cumulative reward.
Here is a list of solutions built on `Qlib` categorized by scenarios.
### [RL for order execution](examples/rl_order_execution)
[Here](https://qlib.readthedocs.io/en/latest/component/rl/overall.html#order-execution) is the introduction of this scenario. All the methods below are compared [here](examples/rl_order_execution).
- [TWAP](examples/rl_order_execution/exp_configs/backtest_twap.yml)
- [PPO: "An End-to-End Optimal Trade Execution Framework based on Proximal Policy Optimization", IJCAL 2020](examples/rl_order_execution/exp_configs/backtest_ppo.yml)
- [OPDS: "Universal Trading for Order Execution with Oracle Policy Distillation", AAAI 2021](examples/rl_order_execution/exp_configs/backtest_opds.yml)
# Quant Dataset Zoo
Dataset plays a very important role in Quant. Here is a list of the datasets built on `Qlib`:
| Dataset | US Market | China Market |
| -- | -- | -- |
| [Alpha360](./qlib/contrib/data/handler.py) | √ | √ |
| [Alpha158](./qlib/contrib/data/handler.py) | √ | √ |
[Here](https://qlib.readthedocs.io/en/latest/advanced/alpha.html) is a tutorial to build dataset with `Qlib`.
Your PR to build new Quant dataset is highly welcomed.
# Learning Framework
Qlib is high customizable and a lot of its components are learnable.
The learnable components are instances of `Forecast Model` and `Trading Agent`. They are learned based on the `Learning Framework` layer and then applied to multiple scenarios in `Workflow` layer.
The learning framework leverages the `Workflow` layer as well(e.g. sharing `Information Extractor`, creating environments based on `Execution Env`).
Based on learning paradigms, they can be categorized into reinforcement learning and supervised learning.
- For supervised learning, the detailed docs can be found [here](https://qlib.readthedocs.io/en/latest/component/model.html).
- For reinforcement learning, the detailed docs can be found [here](https://qlib.readthedocs.io/en/latest/component/rl.html). Qlib's RL learning framework leverages `Execution Env` in `Workflow` layer to create environments. It's worth noting that `NestedExecutor` is supported as well. This empowers users to optimize different level of strategies/models/agents together (e.g. optimizing an order execution strategy for a specific portfolio management strategy).
# More About Qlib
If you want to have a quick glance at the most frequently used components of qlib, you can try notebooks [here](examples/tutorial/).
The detailed documents are organized in [docs](docs/).
[Sphinx](http://www.sphinx-doc.org) and the readthedocs theme is required to build the documentation in html formats.
```bash
@@ -237,17 +467,62 @@ which creates a dataset (14 features/factors) from the basic OHLCV daily data of
* `+(-)E` indicates with (out) `ExpressionCache`
* `+(-)D` indicates with (out) `DatasetCache`
Most general-purpose databases take too much time on loading data. After looking into the underlying implementation, we find that data go through too many layers of interfaces and unnecessary format transformations in general-purpose database solutions.
Most general-purpose databases take too much time to load data. After looking into the underlying implementation, we find that data go through too many layers of interfaces and unnecessary format transformations in general-purpose database solutions.
Such overheads greatly slow down the data loading process.
Qlib data are stored in a compact format, which is efficient to be combined into arrays for scientific computation.
# Related Reports
- [Guide To Qlib: Microsofts AI Investment Platform](https://analyticsindiamag.com/qlib/)
- [微软也搞AI量化平台还是开源的](https://mp.weixin.qq.com/s/47bP5YwxfTp2uTHjUBzJQQ)
- [微矿Qlib业内首个AI量化投资开源平台](https://mp.weixin.qq.com/s/vsJv7lsgjEi-ALYUz4CvtQ)
# Contact Us
- If you have any issues, please create issue [here](https://github.com/microsoft/qlib/issues/new/choose) or send messages in [gitter](https://gitter.im/Microsoft/qlib).
- If you want to make contributions to `Qlib`, please [create pull requests](https://github.com/microsoft/qlib/compare).
- For other reasons, you are welcome to contact us by email([qlib@microsoft.com](mailto:qlib@microsoft.com)).
- We are recruiting new members(both FTEs and interns), your resumes are welcome!
Join IM discussion groups:
|[Gitter](https://gitter.im/Microsoft/qlib)|
|----|
|![image](http://fintech.msra.cn/images_v070/qrcode/gitter_qr.png)|
# Contributing
We appreciate all contributions and thank all the contributors!
<a href="https://github.com/microsoft/qlib/graphs/contributors"><img src="https://contrib.rocks/image?repo=microsoft/qlib" /></a>
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Before we released Qlib as an open-source project on Github in Sep 2020, Qlib is an internal project in our group. Unfortunately, the internal commit history is not kept. A lot of members in our group have also contributed a lot to Qlib, which includes Ruihua Wang, Yinda Zhang, Haisu Yu, Shuyu Wang, Bochen Pang, and [Dong Zhou](https://github.com/evanzd/evanzd). Especially thanks to [Dong Zhou](https://github.com/evanzd/evanzd) due to his initial version of Qlib.
## Guidance
This project welcomes contributions and suggestions.
**Here are some
[code standards and development guidance](docs/developer/code_standard_and_dev_guide.rst) for submiting a pull request.**
Making contributions is not a hard thing. Solving an issue(maybe just answering a question raised in [issues list](https://github.com/microsoft/qlib/issues) or [gitter](https://gitter.im/Microsoft/qlib)), fixing/issuing a bug, improving the documents and even fixing a typo are important contributions to Qlib.
For example, if you want to contribute to Qlib's document/code, you can follow the steps in the figure below.
<p align="center">
<img src="https://github.com/demon143/qlib/blob/main/docs/_static/img/change%20doc.gif" />
</p>
If you don't know how to start to contribute, you can refer to the following examples.
| Type | Examples |
| -- | -- |
| Solving issues | [Answer a question](https://github.com/microsoft/qlib/issues/749); [issuing](https://github.com/microsoft/qlib/issues/765) or [fixing](https://github.com/microsoft/qlib/pull/792) a bug |
| Docs | [Improve docs quality](https://github.com/microsoft/qlib/pull/797/files) ; [Fix a typo](https://github.com/microsoft/qlib/pull/774) |
| Feature | Implement a [requested feature](https://github.com/microsoft/qlib/projects) like [this](https://github.com/microsoft/qlib/pull/754); [Refactor interfaces](https://github.com/microsoft/qlib/pull/539/files) |
| Dataset | [Add a dataset](https://github.com/microsoft/qlib/pull/733) |
| Models | [Implement a new model](https://github.com/microsoft/qlib/pull/689), [some instructions to contribute models](https://github.com/microsoft/qlib/tree/main/examples/benchmarks#contributing) |
[Good first issues](https://github.com/microsoft/qlib/labels/good%20first%20issue) are labelled to indicate that they are easy to start your contributions.
You can find some impefect implementation in Qlib by `rg 'TODO|FIXME' qlib`
If you would like to become one of Qlib's maintainers to contribute more (e.g. help merge PR, triage issues), please contact us by email([qlib@microsoft.com](mailto:qlib@microsoft.com)). We are glad to help to upgrade your permission.
## Licence
Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the right to use your contribution. For details, visit https://cla.opensource.microsoft.com.

View File

@@ -3,7 +3,7 @@ Qlib FAQ
############
Qlib Frequently Asked Questions
================================
===============================
.. contents::
:depth: 1
:local:
@@ -13,7 +13,7 @@ Qlib Frequently Asked Questions
1. RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase...
------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------
.. code-block:: console
@@ -52,7 +52,7 @@ This is caused by the limitation of multiprocessing under windows OS. Please ref
2. qlib.data.cache.QlibCacheException: It sees the key(...) of the redis lock has existed in your redis db now.
-----------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
It sees the key of the redis lock has existed in your redis db now. You can use the following command to clear your redis keys and rerun your commands
@@ -62,6 +62,7 @@ It sees the key of the redis lock has existed in your redis db now. You can use
> select 1
> flushdb
If the issue is not resolved, use ``keys *`` to find if multiple keys exist. If so, try using ``flushall`` to clear all the keys.
.. note::
@@ -69,3 +70,84 @@ It sees the key of the redis lock has existed in your redis db now. You can use
Also, feel free to post a new issue in our GitHub repository. We always check each issue carefully and try our best to solve them.
3. ModuleNotFoundError: No module named 'qlib.data._libs.rolling'
-----------------------------------------------------------------
.. code-block:: python
#### Do not import qlib package in the repository directory in case of importing qlib from . without compiling #####
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "qlib/qlib/__init__.py", line 19, in init
from .data.cache import H
File "qlib/qlib/data/__init__.py", line 8, in <module>
from .data import (
File "qlib/qlib/data/data.py", line 20, in <module>
from .cache import H
File "qlib/qlib/data/cache.py", line 36, in <module>
from .ops import Operators
File "qlib/qlib/data/ops.py", line 19, in <module>
from ._libs.rolling import rolling_slope, rolling_rsquare, rolling_resi
ModuleNotFoundError: No module named 'qlib.data._libs.rolling'
- If the error occurs when importing ``qlib`` package with ``PyCharm`` IDE, users can execute the following command in the project root folder to compile Cython files and generate executable files:
.. code-block:: bash
python setup.py build_ext --inplace
- If the error occurs when importing ``qlib`` package with command ``python`` , users need to change the running directory to ensure that the script does not run in the project directory.
4. BadNamespaceError: / is not a connected namespace
----------------------------------------------------
.. code-block:: python
File "qlib_online.py", line 35, in <module>
cal = D.calendar()
File "e:\code\python\microsoft\qlib_latest\qlib\qlib\data\data.py", line 973, in calendar
return Cal.calendar(start_time, end_time, freq, future=future)
File "e:\code\python\microsoft\qlib_latest\qlib\qlib\data\data.py", line 798, in calendar
self.conn.send_request(
File "e:\code\python\microsoft\qlib_latest\qlib\qlib\data\client.py", line 101, in send_request
self.sio.emit(request_type + "_request", request_content)
File "G:\apps\miniconda\envs\qlib\lib\site-packages\python_socketio-5.3.0-py3.8.egg\socketio\client.py", line 369, in emit
raise exceptions.BadNamespaceError(
BadNamespaceError: / is not a connected namespace.
- The version of ``python-socketio`` in qlib needs to be the same as the version of ``python-socketio`` in qlib-server:
.. code-block:: bash
pip install -U python-socketio==<qlib-server python-socketio version>
5. TypeError: send() got an unexpected keyword argument 'binary'
----------------------------------------------------------------
.. code-block:: python
File "qlib_online.py", line 35, in <module>
cal = D.calendar()
File "e:\code\python\microsoft\qlib_latest\qlib\qlib\data\data.py", line 973, in calendar
return Cal.calendar(start_time, end_time, freq, future=future)
File "e:\code\python\microsoft\qlib_latest\qlib\qlib\data\data.py", line 798, in calendar
self.conn.send_request(
File "e:\code\python\microsoft\qlib_latest\qlib\qlib\data\client.py", line 101, in send_request
self.sio.emit(request_type + "_request", request_content)
File "G:\apps\miniconda\envs\qlib\lib\site-packages\socketio\client.py", line 263, in emit
self._send_packet(packet.Packet(packet.EVENT, namespace=namespace,
File "G:\apps\miniconda\envs\qlib\lib\site-packages\socketio\client.py", line 339, in _send_packet
self.eio.send(ep, binary=binary)
TypeError: send() got an unexpected keyword argument 'binary'
- The ``python-engineio`` version needs to be compatible with the ``python-socketio`` version, reference: https://github.com/miguelgrinberg/python-socketio#version-compatibility
.. code-block:: bash
pip install -U python-engineio==<compatible python-socketio version>
# or
pip install -U python-socketio==3.1.2 python-engineio==3.13.2

View File

@@ -17,4 +17,5 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
pip install -r requirements.txt
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

12
docs/_static/demo.sh vendored Normal file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
git clone https://github.com/microsoft/qlib.git
cd qlib
ls
pip install pyqlib
# or
# pip install numpy
# pip install --upgrade cython
# python setup.py install
cd examples
ls
qrun benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml

BIN
docs/_static/img/QlibRL_framework.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

BIN
docs/_static/img/RL_framework.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 93 KiB

BIN
docs/_static/img/change doc.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
docs/_static/img/framework-abstract.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

After

Width:  |  Height:  |  Size: 208 KiB

4
docs/_static/img/framework.svg vendored Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 144 KiB

BIN
docs/_static/img/online_serving.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 KiB

BIN
docs/_static/img/qrcode/gitter_qr.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

136
docs/advanced/PIT.rst Normal file
View File

@@ -0,0 +1,136 @@
.. _pit:
============================
(P)oint-(I)n-(T)ime Database
============================
.. currentmodule:: qlib
Introduction
------------
Point-in-time data is a very important consideration when performing any sort of historical market analysis.
For example, lets say we are backtesting a trading strategy and we are using the past five years of historical data as our input.
Our model is assumed to trade once a day, at the market close, and well say we are calculating the trading signal for 1 January 2020 in our backtest. At that point, we should only have data for 1 January 2020, 31 December 2019, 30 December 2019 etc.
In financial data (especially financial reports), the same piece of data may be amended for multiple times overtime. If we only use the latest version for historical backtesting, data leakage will happen.
Point-in-time database is designed for solving this problem to make sure user get the right version of data at any historical timestamp. It will keep the performance of online trading and historical backtesting the same.
Data Preparation
----------------
Qlib provides a crawler to help users to download financial data and then a converter to dump the data in Qlib format.
Please follow `scripts/data_collector/pit/README.md <https://github.com/microsoft/qlib/tree/main/scripts/data_collector/pit/>`_ to download and convert data.
Besides, you can find some additional usage examples there.
File-based design for PIT data
------------------------------
Qlib provides a file-based storage for PIT data.
For each feature, it contains 4 columns, i.e. date, period, value, _next.
Each row corresponds to a statement.
The meaning of each feature with filename like `XXX_a.data`:
- `date`: the statement's date of publication.
- `period`: the period of the statement. (e.g. it will be quarterly frequency in most of the markets)
- If it is an annual period, it will be an integer corresponding to the year
- If it is an quarterly periods, it will be an integer like `<year><index of quarter>`. The last two decimal digits represents the index of quarter. Others represent the year.
- `value`: the described value
- `_next`: the byte index of the next occurance of the field.
Besides the feature data, an index `XXX_a.index` is included to speed up the querying performance
The statements are soted by the `date` in ascending order from the beginning of the file.
.. code-block:: python
# the data format from XXXX.data
array([(20070428, 200701, 0.090219 , 4294967295),
(20070817, 200702, 0.13933 , 4294967295),
(20071023, 200703, 0.24586301, 4294967295),
(20080301, 200704, 0.3479 , 80),
(20080313, 200704, 0.395989 , 4294967295),
(20080422, 200801, 0.100724 , 4294967295),
(20080828, 200802, 0.24996801, 4294967295),
(20081027, 200803, 0.33412001, 4294967295),
(20090325, 200804, 0.39011699, 4294967295),
(20090421, 200901, 0.102675 , 4294967295),
(20090807, 200902, 0.230712 , 4294967295),
(20091024, 200903, 0.30072999, 4294967295),
(20100402, 200904, 0.33546099, 4294967295),
(20100426, 201001, 0.083825 , 4294967295),
(20100812, 201002, 0.200545 , 4294967295),
(20101029, 201003, 0.260986 , 4294967295),
(20110321, 201004, 0.30739301, 4294967295),
(20110423, 201101, 0.097411 , 4294967295),
(20110831, 201102, 0.24825101, 4294967295),
(20111018, 201103, 0.318919 , 4294967295),
(20120323, 201104, 0.4039 , 420),
(20120411, 201104, 0.403925 , 4294967295),
(20120426, 201201, 0.112148 , 4294967295),
(20120810, 201202, 0.26484701, 4294967295),
(20121026, 201203, 0.370487 , 4294967295),
(20130329, 201204, 0.45004699, 4294967295),
(20130418, 201301, 0.099958 , 4294967295),
(20130831, 201302, 0.21044201, 4294967295),
(20131016, 201303, 0.30454299, 4294967295),
(20140325, 201304, 0.394328 , 4294967295),
(20140425, 201401, 0.083217 , 4294967295),
(20140829, 201402, 0.16450299, 4294967295),
(20141030, 201403, 0.23408499, 4294967295),
(20150421, 201404, 0.319612 , 4294967295),
(20150421, 201501, 0.078494 , 4294967295),
(20150828, 201502, 0.137504 , 4294967295),
(20151023, 201503, 0.201709 , 4294967295),
(20160324, 201504, 0.26420501, 4294967295),
(20160421, 201601, 0.073664 , 4294967295),
(20160827, 201602, 0.136576 , 4294967295),
(20161029, 201603, 0.188062 , 4294967295),
(20170415, 201604, 0.244385 , 4294967295),
(20170425, 201701, 0.080614 , 4294967295),
(20170728, 201702, 0.15151 , 4294967295),
(20171026, 201703, 0.25416601, 4294967295),
(20180328, 201704, 0.32954201, 4294967295),
(20180428, 201801, 0.088887 , 4294967295),
(20180802, 201802, 0.170563 , 4294967295),
(20181029, 201803, 0.25522 , 4294967295),
(20190329, 201804, 0.34464401, 4294967295),
(20190425, 201901, 0.094737 , 4294967295),
(20190713, 201902, 0. , 1040),
(20190718, 201902, 0.175322 , 4294967295),
(20191016, 201903, 0.25581899, 4294967295)],
dtype=[('date', '<u4'), ('period', '<u4'), ('value', '<f8'), ('_next', '<u4')])
# - each row contains 20 byte
# The data format from XXXX.index. It consists of two parts
# 1) the start index of the data. So the first part of the info will be like
2007
# 2) the remain index data will be like information below
# - The data indicate the **byte index** of first data update of a period.
# - e.g. Because the info at both byte 80 and 100 corresponds to 200704. The byte index of first occurance (i.e. 100) is recorded in the data.
array([ 0, 20, 40, 60, 100,
120, 140, 160, 180, 200,
220, 240, 260, 280, 300,
320, 340, 360, 380, 400,
440, 460, 480, 500, 520,
540, 560, 580, 600, 620,
640, 660, 680, 700, 720,
740, 760, 780, 800, 820,
840, 860, 880, 900, 920,
940, 960, 980, 1000, 1020,
1060, 4294967295], dtype=uint32)
Known limitations:
- Currently, the PIT database is designed for quarterly or annually factors, which can handle fundamental data of financial reports in most markets.
- Qlib leverage the file name to identify the type of the data. File with name like `XXX_q.data` corresponds to quarterly data. File with name like `XXX_a.data` corresponds to annual data.
- The caclulation of PIT is not performed in the optimal way. There is great potential to boost the performance of PIT data calcuation.

View File

@@ -1,11 +1,12 @@
.. _alpha:
===========================
Building Formulaic Alphas
===========================
=========================
Building Formulaic Alphas
=========================
.. currentmodule:: qlib
Introduction
===================
============
In quantitative trading practice, designing novel factors that can explain and predict future asset returns are of vital importance to the profitability of a strategy. Such factors are usually called alpha factors, or alphas in short.
@@ -14,30 +15,30 @@ A formulaic alpha, as the name suggests, is a kind of alpha that can be presente
Building Formulaic Alphas in ``Qlib``
======================================
=====================================
In ``Qlib``, users can easily build formulaic alphas.
Example
-----------------
-------
`MACD`, short for moving average convergence/divergence, is a formulaic alpha used in technical analysis of stock prices. It is designed to reveal changes in the strength, direction, momentum, and duration of a trend in a stock's price.
`MACD` can be presented as the following formula:
.. math::
.. math::
MACD = 2\times (DIF-DEA)
.. note::
`DIF` means Differential value, which is 12-period EMA minus 26-period EMA.
.. math::
DIF = \frac{EMA(CLOSE, 12) - EMA(CLOSE, 26)}{CLOSE}
DIF = \frac{EMA(CLOSE, 12) - EMA(CLOSE, 26)}{CLOSE}
`DEA`means a 9-period EMA of the DIF.
`DEA` means a 9-period EMA of the DIF.
.. math::
@@ -49,57 +50,37 @@ Users can use ``Data Handler`` to build formulaic alphas `MACD` in qlib:
.. code-block:: python
>> from qlib.contrib.estimator.handler import QLibDataHandler
>> from qlib.data.dataset.loader import QlibDataLoader
>> MACD_EXP = '(EMA($close, 12) - EMA($close, 26))/$close - EMA((EMA($close, 12) - EMA($close, 26))/$close, 9)/$close'
>> fields = [MACD_EXP] # MACD
>> names = ['MACD']
>> labels = ['$close'] # label
>> labels = ['Ref($close, -2)/Ref($close, -1) - 1'] # label
>> label_names = ['LABEL']
>> data_handler = QLibDataHandler(start_date='2010-01-01', end_date='2017-12-31', fields=fields, names=names, labels=labels, label_names=label_names)
>> TRAINER_CONFIG = {
.. "train_start_date": "2007-01-01",
.. "train_end_date": "2014-12-31",
.. "validate_start_date": "2015-01-01",
.. "validate_end_date": "2016-12-31",
.. "test_start_date": "2017-01-01",
.. "test_end_date": "2020-08-01",
>> data_loader_config = {
.. "feature": (fields, names),
.. "label": (labels, label_names)
.. }
>> feature_train, label_train, feature_validate, label_validate, feature_test, label_test = data_handler.get_split_data(**TRAINER_CONFIG)
>> print(feature_train, label_train)
MACD
instrument datetime
SH600000 2010-01-04 -0.008625
2010-01-05 -0.007234
2010-01-06 -0.007693
2010-01-07 -0.009633
2010-01-08 -0.009891
... ...
SZ300251 2014-12-25 0.043072
2014-12-26 0.041345
2014-12-29 0.042733
2014-12-30 0.042066
2014-12-31 0.036299
[322025 rows x 1 columns]
LABEL
instrument datetime
SH600000 2010-01-04 4.260015
2010-01-05 4.292182
2010-01-06 4.207747
2010-01-07 4.113258
2010-01-08 4.159496
... ...
SZ300251 2014-12-25 4.343212
2014-12-26 4.470587
2014-12-29 4.762474
2014-12-30 4.369748
2014-12-31 4.182222
[322025 rows x 1 columns]
>> data_loader = QlibDataLoader(config=data_loader_config)
>> df = data_loader.load(instruments='csi300', start_time='2010-01-01', end_time='2017-12-31')
>> print(df)
feature label
MACD LABEL
datetime instrument
2010-01-04 SH600000 -0.011547 -0.019672
SH600004 0.002745 -0.014721
SH600006 0.010133 0.002911
SH600008 -0.001113 0.009818
SH600009 0.025878 -0.017758
... ... ...
2017-12-29 SZ300124 0.007306 -0.005074
SZ300136 -0.013492 0.056352
SZ300144 -0.000966 0.011853
SZ300251 0.004383 0.021739
SZ300315 -0.030557 0.012455
Reference
===========
=========
To learn more about ``Data Handler``, please refer to `Data Handler <../component/data.html>`_
To learn more about ``Data Loader``, please refer to `Data Loader <../component/data.html#data-loader>`_
To learn more about ``Data API``, please refer to `Data API <../component/data.html>`_

45
docs/advanced/serial.rst Normal file
View File

@@ -0,0 +1,45 @@
.. _serial:
=============
Serialization
=============
.. currentmodule:: qlib
Introduction
============
``Qlib`` supports dumping the state of ``DataHandler``, ``DataSet``, ``Processor`` and ``Model``, etc. into a disk and reloading them.
Serializable Class
==================
``Qlib`` provides a base class ``qlib.utils.serial.Serializable``, whose state can be dumped into or loaded from disk in `pickle` format.
When users dump the state of a ``Serializable`` instance, the attributes of the instance whose name **does not** start with `_` will be saved on the disk.
However, users can use ``config`` method or override ``default_dump_all`` attribute to prevent this feature.
Users can also override ``pickle_backend`` attribute to choose a pickle backend. The supported value is "pickle" (default and common) and "dill" (dump more things such as function, more information in `here <https://pypi.org/project/dill/>`_).
Example
=======
``Qlib``'s serializable class includes ``DataHandler``, ``DataSet``, ``Processor`` and ``Model``, etc., which are subclass of ``qlib.utils.serial.Serializable``.
Specifically, ``qlib.data.dataset.DatasetH`` is one of them. Users can serialize ``DatasetH`` as follows.
.. code-block:: Python
##=============dump dataset=============
dataset.to_pickle(path="dataset.pkl") # dataset is an instance of qlib.data.dataset.DatasetH
##=============reload dataset=============
with open("dataset.pkl", "rb") as file_dataset:
dataset = pickle.load(file_dataset)
.. note::
Only state of ``DatasetH`` should be saved on the disk, such as some `mean` and `variance` used for data normalization, etc.
After reloading the ``DatasetH``, users need to reinitialize it. It means that users can reset some states of ``DatasetH`` or ``QlibDataHandler`` such as `instruments`, `start_time`, `end_time` and `segments`, etc., and generate new data according to the states (data is not state and should not be saved on the disk).
A more detailed example is in this `link <https://github.com/microsoft/qlib/tree/main/examples/highfreq>`_.
API
===
Please refer to `Serializable API <../reference/api.html#module-qlib.utils.serial.Serializable>`_.

View File

@@ -1,14 +1,15 @@
.. _server:
=================================
=============================
``Online`` & ``Offline`` mode
=================================
=============================
.. currentmodule:: qlib
Introduction
=============
============
``Qlib`` supports ``Online`` mode and ``Offline`` mode. Only the ``Offline`` mode is introduced in this document.
``Qlib`` supports ``Online`` mode and ``Offline`` mode. Only the ``Offline`` mode is introduced in this document.
The ``Online`` mode is designed to solve the following problems:
@@ -17,12 +18,12 @@ The ``Online`` mode is designed to solve the following problems:
- Make the data can be accessed in a remote way.
Qlib-Server
===============
===========
``Qlib-Server`` is the assorted server system for ``Qlib``, which utilizes ``Qlib`` for basic calculations and provides extensive server system and cache mechanism. With QLibServer, the data provided for ``Qlib`` can be managed in a centralized manner. With ``Qlib-Server``, users can use ``Qlib`` in ``Online`` mode.
``Qlib-Server`` is the assorted server system for ``Qlib``, which utilizes ``Qlib`` for basic calculations and provides extensive server system and cache mechanism. With QLibServer, the data provided for ``Qlib`` can be managed in a centralized manner. With ``Qlib-Server``, users can use ``Qlib`` in ``Online`` mode.
Reference
=================
If users are interested in ``Qlib-Server`` and ``Online`` mode, please refer to `Qlib-Server Project <https://github.com/microsoft/qlib-server>`_ and `Qlib-Server Document <https://qlib-server.readthedocs.io/en/latest/>`_.
=========
If users are interested in ``Qlib-Server`` and ``Online`` mode, please refer to `Qlib-Server Project <https://github.com/microsoft/qlib-server>`_ and `Qlib-Server Document <https://qlib-server.readthedocs.io/en/latest/>`_.

View File

@@ -0,0 +1,100 @@
.. _task_management:
===============
Task Management
===============
.. currentmodule:: qlib
Introduction
============
The `Workflow <../component/introduction.html>`_ part introduces how to run research workflow in a loosely-coupled way. But it can only execute one ``task`` when you use ``qrun``.
To automatically generate and execute different tasks, ``Task Management`` provides a whole process including `Task Generating`_, `Task Storing`_, `Task Training`_ and `Task Collecting`_.
With this module, users can run their ``task`` automatically at different periods, in different losses, or even by different models.The processes of task generation, model training and combine and collect data are shown in the following figure.
.. image:: ../_static/img/Task-Gen-Recorder-Collector.svg
:align: center
This whole process can be used in `Online Serving <../component/online.html>`_.
An example of the entire process is shown `here <https://github.com/microsoft/qlib/tree/main/examples/model_rolling/task_manager_rolling.py>`__.
Task Generating
===============
A ``task`` consists of `Model`, `Dataset`, `Record`, or anything added by users.
The specific task template can be viewed in
`Task Section <../component/workflow.html#task-section>`_.
Even though the task template is fixed, users can customize their ``TaskGen`` to generate different ``task`` by task template.
Here is the base class of ``TaskGen``:
.. autoclass:: qlib.workflow.task.gen.TaskGen
:members:
:noindex:
``Qlib`` provides a class `RollingGen <https://github.com/microsoft/qlib/tree/main/qlib/workflow/task/gen.py>`_ to generate a list of ``task`` of the dataset in different date segments.
This class allows users to verify the effect of data from different periods on the model in one experiment. More information is `here <../reference/api.html#TaskGen>`__.
Task Storing
============
To achieve higher efficiency and the possibility of cluster operation, ``Task Manager`` will store all tasks in `MongoDB <https://www.mongodb.com/>`_.
``TaskManager`` can fetch undone tasks automatically and manage the lifecycle of a set of tasks with error handling.
Users **MUST** finish the configuration of `MongoDB <https://www.mongodb.com/>`_ when using this module.
Users need to provide the MongoDB URL and database name for using ``TaskManager`` in `initialization <../start/initialization.html#Parameters>`_ or make a statement like this.
.. code-block:: python
from qlib.config import C
C["mongo"] = {
"task_url" : "mongodb://localhost:27017/", # your MongoDB url
"task_db_name" : "rolling_db" # database name
}
.. autoclass:: qlib.workflow.task.manage.TaskManager
:members:
:noindex:
More information of ``Task Manager`` can be found in `here <../reference/api.html#TaskManager>`__.
Task Training
=============
After generating and storing those ``task``, it's time to run the ``task`` which is in the *WAITING* status.
``Qlib`` provides a method called ``run_task`` to run those ``task`` in task pool, however, users can also customize how tasks are executed.
An easy way to get the ``task_func`` is using ``qlib.model.trainer.task_train`` directly.
It will run the whole workflow defined by ``task``, which includes *Model*, *Dataset*, *Record*.
.. autofunction:: qlib.workflow.task.manage.run_task
:noindex:
Meanwhile, ``Qlib`` provides a module called ``Trainer``.
.. autoclass:: qlib.model.trainer.Trainer
:members:
:noindex:
``Trainer`` will train a list of tasks and return a list of model recorders.
``Qlib`` offer two kinds of Trainer, TrainerR is the simplest way and TrainerRM is based on TaskManager to help manager tasks lifecycle automatically.
If you do not want to use ``Task Manager`` to manage tasks, then use TrainerR to train a list of tasks generated by ``TaskGen`` is enough.
`Here <../reference/api.html#Trainer>`_ are the details about different ``Trainer``.
Task Collecting
===============
Before collecting model training results, you need to use the ``qlib.init`` to specify the path of mlruns.
To collect the results of ``task`` after training, ``Qlib`` provides `Collector <../reference/api.html#Collector>`_, `Group <../reference/api.html#Group>`_ and `Ensemble <../reference/api.html#Ensemble>`_ to collect the results in a readable, expandable and loosely-coupled way.
`Collector <../reference/api.html#Collector>`_ can collect objects from everywhere and process them such as merging, grouping, averaging and so on. It has 2 step action including ``collect`` (collect anything in a dict) and ``process_collect`` (process collected dict).
`Group <../reference/api.html#Group>`_ also has 2 steps including ``group`` (can group a set of object based on `group_func` and change them to a dict) and ``reduce`` (can make a dict become an ensemble based on some rule).
For example: {(A,B,C1): object, (A,B,C2): object} ---``group``---> {(A,B): {C1: object, C2: object}} ---``reduce``---> {(A,B): object}
`Ensemble <../reference/api.html#Ensemble>`_ can merge the objects in an ensemble.
For example: {C1: object, C2: object} ---``Ensemble``---> object.
You can set the ensembles you want in the ``Collector``'s process_list.
Common ensembles include ``AverageEnsemble`` and ``RollingEnsemble``. Average ensemble is used to ensemble the results of different models in the same time period. Rollingensemble is used to ensemble the results of different models in the same time period
So the hierarchy is ``Collector``'s second step corresponds to ``Group``. And ``Group``'s second step correspond to ``Ensemble``.
For more information, please see `Collector <../reference/api.html#Collector>`_, `Group <../reference/api.html#Group>`_ and `Ensemble <../reference/api.html#Ensemble>`_, or the `example <https://github.com/microsoft/qlib/tree/main/examples/model_rolling/task_manager_rolling.py>`_.

View File

@@ -1,2 +1 @@
.. include:: ../../CHANGES.rst

View File

@@ -1,113 +0,0 @@
.. _backtest:
============================================
Intraday Trading: Model&Strategy Testing
============================================
.. currentmodule:: qlib
Introduction
===================
``Intraday Trading`` is designed to test models and strategies, which help users to check the performance of a custom model/strategy.
.. note::
``Intraday Trading`` uses ``Order Executor`` to trade and execute orders output by ``Interday Strategy``. ``Order Executor`` is a component in `Qlib Framework <../introduction/introduction.html#framework>`_, which can execute orders. ``Vwap Executor`` and ``Close Executor`` is supported by ``Qlib`` now. In the future, ``Qlib`` will support ``HighFreq Executor`` also.
Example
===========================
Users need to generate a `prediction score`(a pandas DataFrame) with MultiIndex<instrument, datetime> and a `score` column. And users need to assign a strategy used in backtest, if strategy is not assigned,
a `TopkDropoutStrategy` strategy with `(topk=50, n_drop=5, risk_degree=0.95, limit_threshold=0.0095)` will be used.
If ``Strategy`` module is not users' interested part, `TopkDropoutStrategy` is enough.
The simple example of the default strategy is as follows.
.. code-block:: python
from qlib.contrib.evaluate import backtest
# pred_score is the prediction score
report, positions = backtest(pred_score, topk=50, n_drop=0.5, verbose=False, limit_threshold=0.0095)
To know more about backtesting with a specific ``Strategy``, please refer to `Strategy <strategy.html>`_.
To know more about the prediction score `pred_score` output by ``Interday Model``, please refer to `Interday Model: Model Training & Prediction <model.html>`_.
Prediction Score
-----------------
The `prediction score` is a pandas DataFrame. Its index is <instrument(str), datetime(pd.Timestamp)> and it must
contains a `score` column.
A prediction sample is shown as follows.
.. code-block:: python
instrument datetime score
SH600000 2019-01-04 -0.505488
SZ002531 2019-01-04 -0.320391
SZ000999 2019-01-04 0.583808
SZ300569 2019-01-04 0.819628
SZ001696 2019-01-04 -0.137140
... ...
SZ000996 2019-04-30 -1.027618
SH603127 2019-04-30 0.225677
SH603126 2019-04-30 0.462443
SH603133 2019-04-30 -0.302460
SZ300760 2019-04-30 -0.126383
``Interday Model`` module can make predictions, please refer to `Interday Model: Model Training & Prediction <model.html>`_.
Backtest Result
------------------
The backtest results are in the following form:
.. code-block:: python
risk
excess_return_without_cost mean 0.000605
std 0.005481
annualized_return 0.152373
information_ratio 1.751319
max_drawdown -0.059055
excess_return_with_cost mean 0.000410
std 0.005478
annualized_return 0.103265
information_ratio 1.187411
max_drawdown -0.075024
- `excess_return_without_cost`
- `mean`
Mean value of the `CAR` (cumulative abnormal return) without cost
- `std`
The `Standard Deviation` of `CAR` (cumulative abnormal return) without cost.
- `annualized_return`
The `Annualized Rate` of `CAR` (cumulative abnormal return) without cost.
- `information_ratio`
The `Information Ratio` without cost. please refer to `Information Ratio IR <https://www.investopedia.com/terms/i/informationratio.asp>`_.
- `max_drawdown`
The `Maximum Drawdown` of `CAR` (cumulative abnormal return) without cost, please refer to `Maximum Drawdown (MDD) <https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp>`_.
- `excess_return_with_cost`
- `mean`
Mean value of the `CAR` (cumulative abnormal return) series with cost
- `std`
The `Standard Deviation` of `CAR` (cumulative abnormal return) series with cost.
- `annualized_return`
The `Annualized Rate` of `CAR` (cumulative abnormal return) with cost.
- `information_ratio`
The `Information Ratio` with cost. please refer to `Information Ratio IR <https://www.investopedia.com/terms/i/informationratio.asp>`_.
- `max_drawdown`
The `Maximum Drawdown` of `CAR` (cumulative abnormal return) with cost, please refer to `Maximum Drawdown (MDD) <https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp>`_.
Reference
==============
To know more about ``Intraday Trading``, please refer to `Intraday Trading <../reference/api.html#module-qlib.contrib.evaluate>`_.

View File

@@ -1,12 +1,13 @@
.. _data:
================================
Data Layer: Data Framework&Usage
================================
==================================
Data Layer: Data Framework & Usage
==================================
Introduction
============================
============
``Data Layer`` provides user-friendly APIs to manage and retrieve data. It provides high-performance data infrastructure.
``Data Layer`` provides user-friendly APIs to manage and retrieve data. It provides high-performance data infrastructure.
It is designed for quantitative investment. For example, users could build formulaic alphas with ``Data Layer`` easily. Please refer to `Building Formulaic Alphas <../advanced/alpha.html>`_ for more details.
@@ -14,109 +15,249 @@ The introduction of ``Data Layer`` includes the following parts.
- Data Preparation
- Data API
- Data Loader
- Data Handler
- Dataset
- Cache
- Data and Cache File Structure
Here is a typical example of Qlib data workflow
- Users download data and converting data into Qlib format(with filename suffix `.bin`). In this step, typically only some basic data are stored on disk(such as OHLCV).
- Creating some basic features based on Qlib's expression Engine(e.g. "Ref($close, 60) / $close", the return of last 60 trading days). Supported operators in the expression engine can be found `here <https://github.com/microsoft/qlib/blob/main/qlib/data/ops.py>`__. This step is typically implemented in Qlib's `Data Loader <https://qlib.readthedocs.io/en/latest/component/data.html#data-loader>`_ which is a component of `Data Handler <https://qlib.readthedocs.io/en/latest/component/data.html#data-handler>`_ .
- If users require more complicated data processing (e.g. data normalization), `Data Handler <https://qlib.readthedocs.io/en/latest/component/data.html#data-handler>`_ support user-customized processors to process data(some predefined processors can be found `here <https://github.com/microsoft/qlib/blob/main/qlib/data/dataset/processor.py>`__). The processors are different from operators in expression engine. It is designed for some complicated data processing methods which is hard to supported in operators in expression engine.
- At last, `Dataset <https://qlib.readthedocs.io/en/latest/component/data.html#dataset>`_ is responsible to prepare model-specific dataset from the processed data of Data Handler
Data Preparation
============================
================
Qlib Format Data
------------------
----------------
We've specially designed a data structure to manage financial data, please refer to the `File storage design section in Qlib paper <https://arxiv.org/abs/2009.11189>`_ for detailed information.
Such data will be stored with filename suffix `.bin` (We'll call them `.bin` file, `.bin` format, or qlib format). `.bin` file is designed for scientific computing on finance data
Such data will be stored with filename suffix `.bin` (We'll call them `.bin` file, `.bin` format, or qlib format). `.bin` file is designed for scientific computing on finance data.
``Qlib`` provides two different off-the-shelf datasets, which can be accessed through this `link <https://github.com/microsoft/qlib/blob/main/qlib/contrib/data/handler.py>`__:
======================== ================= ================
Dataset US Market China Market
======================== ================= ================
Alpha360 √ √
Alpha158 √ √
======================== ================= ================
Also, ``Qlib`` provides a high-frequency dataset. Users can run a high-frequency dataset example through this `link <https://github.com/microsoft/qlib/tree/main/examples/highfreq>`__.
Qlib Format Dataset
--------------------
``Qlib`` has provided an off-the-shelf dataset in `.bin` format, users could use the script ``scripts/get_data.py`` to download the dataset as follows.
-------------------
``Qlib`` has provided an off-the-shelf dataset in `.bin` format, users could use the script ``scripts/get_data.py`` to download the China-Stock dataset as follows. User can also use numpy to load `.bin` file to validate data.
The price volume data look different from the actual dealing price because of they are **adjusted** (`adjusted price <https://www.investopedia.com/terms/a/adjusted_closing_price.asp>`_). And then you may find that the adjusted price may be different from different data sources. This is because different data sources may vary in the way of adjusting prices. Qlib normalize the price on first trading day of each stock to 1 when adjusting them.
Users can leverage `$factor` to get the original trading price (e.g. `$close / $factor` to get the original close price).
Here are some discussions about the price adjusting of Qlib.
- https://github.com/microsoft/qlib/issues/991#issuecomment-1075252402
.. code-block:: bash
python scripts/get_data.py qlib_data_cn --target_dir ~/.qlib/qlib_data/cn_data
# download 1d
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
After running the above command, users can find china-stock data in Qlib format in the ``~/.qlib/csv_data/cn_data`` directory.
# download 1min
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/qlib_cn_1min --region cn --interval 1min
In addition to China-Stock data, ``Qlib`` also includes a US-Stock dataset, which can be downloaded with the following command:
.. code-block:: bash
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/us_data --region us
After running the above command, users can find china-stock and us-stock data in ``Qlib`` format in the ``~/.qlib/qlib_data/cn_data`` directory and ``~/.qlib/qlib_data/us_data`` directory respectively.
``Qlib`` also provides the scripts in ``scripts/data_collector`` to help users crawl the latest data on the Internet and convert it to qlib format.
When ``Qlib`` is initialized with this dataset, users could build and evaluate their own models with it. Please refer to `Initialization <../start/initialization.html>`_ for more details.
Automatic update of daily frequency data
----------------------------------------
**It is recommended that users update the data manually once (\-\-trading_date 2021-05-25) and then set it to update automatically.**
For more information refer to: `yahoo collector <https://github.com/microsoft/qlib/tree/main/scripts/data_collector/yahoo#Automatic-update-of-daily-frequency-data>`_
- Automatic update of data to the "qlib" directory each trading day(Linux)
- use *crontab*: `crontab -e`
- set up timed tasks:
.. code-block:: bash
* * * * 1-5 python <script path> update_data_to_bin --qlib_data_1d_dir <user data dir>
- **script path**: *scripts/data_collector/yahoo/collector.py*
- Manual update of data
.. code-block:: bash
python scripts/data_collector/yahoo/collector.py update_data_to_bin --qlib_data_1d_dir <user data dir> --trading_date <start date> --end_date <end date>
- *trading_date*: start of trading day
- *end_date*: end of trading day(not included)
Converting CSV Format into Qlib Format
-------------------------------------------
--------------------------------------
``Qlib`` has provided the script ``scripts/dump_bin.py`` to convert data in CSV format into `.bin` files (Qlib format).
``Qlib`` has provided the script ``scripts/dump_bin.py`` to convert **any** data in CSV format into `.bin` files (``Qlib`` format) as long as they are in the correct format.
Besides downloading the prepared demo data, users could download demo data directly from the Collector as follows for reference to the CSV format.
Here are some example:
Users can download the china-stock data in CSV format as follows for reference to the CSV format.
for daily data:
.. code-block:: bash
.. code-block:: bash
python scripts/get_data.py download_data --file_name csv_data_cn.zip --target_dir ~/.qlib/csv_data/cn_data
python scripts/get_data.py csv_data_cn --target_dir ~/.qlib/csv_data/cn_data
for 1min data:
.. code-block:: bash
python scripts/data_collector/yahoo/collector.py download_data --source_dir ~/.qlib/stock_data/source/cn_1min --region CN --start 2021-05-20 --end 2021-05-23 --delay 0.1 --interval 1min --limit_nums 10
Users can also provide their own data in CSV format. However, the CSV data **must satisfies** following criterions:
- CSV file is named after a specific stock *or* the CSV file includes a column of the stock name
- Name the CSV file after a stock: `SH600000.csv`, `AAPL.csv` (not case sensitive).
- CSV file includes a column of the stock name. User **must** specify the column name when dumping the data. Here is an example:
.. code-block:: bash
python scripts/dump_bin.py dump_all ... --symbol_field_name symbol
where the data are in the following format:
+-----------+-------+
| symbol | close |
+===========+=======+
| SH600000 | 120 |
+-----------+-------+
- CSV file **must** include a column for the date, and when dumping the data, user must specify the date column name. Here is an example:
.. code-block:: bash
python scripts/dump_bin.py dump_all ... --date_field_name date
where the data are in the following format:
+---------+------------+-------+------+----------+
| symbol | date | close | open | volume |
+=========+============+=======+======+==========+
| SH600000| 2020-11-01 | 120 | 121 | 12300000 |
+---------+------------+-------+------+----------+
| SH600000| 2020-11-02 | 123 | 120 | 12300000 |
+---------+------------+-------+------+----------+
Supposed that users prepare their CSV format data in the directory ``~/.qlib/csv_data/my_data``, they can run the following command to start the conversion.
.. code-block:: bash
python scripts/dump_bin.py dump --csv_path ~/.qlib/csv_data/my_data --qlib_dir ~/.qlib/qlib_data/my_data --include_fields open,close,high,low,volume,factor
python scripts/dump_bin.py dump_all --csv_path ~/.qlib/csv_data/my_data --qlib_dir ~/.qlib/qlib_data/my_data --include_fields open,close,high,low,volume,factor
For other supported parameters when dumping the data into `.bin` file, users can refer to the information by running the following commands:
.. code-block:: bash
python dump_bin.py dump_all --help
After conversion, users can find their Qlib format data in the directory `~/.qlib/qlib_data/my_data`.
.. note::
The arguments of `--include_fields` should correspond with the column names of CSV files. The columns names of dataset provided by ``Qlib`` should include open, close, high, low, volume and factor at least.
- `open`
The opening price
The adjusted opening price
- `close`
The closing price
The adjusted closing price
- `high`
The highest price
The adjusted highest price
- `low`
The lowest price
The adjusted lowest price
- `volume`
The trading volume
The adjusted trading volume
- `factor`
The Restoration factor
The Restoration factor. Normally, ``factor = adjusted_price / original_price``, `adjusted price` reference: `split adjusted <https://www.investopedia.com/terms/s/splitadjusted.asp>`_
In the convention of `Qlib` data processing, `open, close, high, low, volume, money and factor` will be set to NaN if the stock is suspended.
In the convention of `Qlib` data processing, `open, close, high, low, volume, money and factor` will be set to NaN if the stock is suspended.
If you want to use your own alpha-factor which can't be calculate by OCHLV, like PE, EPS and so on, you could add it to the CSV files with OHCLV together and then dump it to the Qlib format data.
China-Stock Mode & US-Stock Mode
--------------------------------
Stock Pool (Market)
-------------------
``Qlib`` defines `stock pool <https://github.com/microsoft/qlib/blob/main/examples/benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml#L4>`_ as stock list and their date ranges. Predefined stock pools (e.g. csi300) may be imported as follows.
.. code-block:: bash
python collector.py --index_name CSI300 --qlib_dir <user qlib data dir> --method parse_instruments
Multiple Stock Modes
--------------------
``Qlib`` now provides two different stock modes for users: China-Stock Mode & US-Stock Mode. Here are some different settings of these two modes:
============== ================= ================
Region Trade Unit Limit Threshold
============== ================= ================
China 100 0.099
US 1 None
============== ================= ================
The `trade unit` defines the unit number of stocks can be used in a trade, and the `limit threshold` defines the bound set to the percentage of ups and downs of a stock.
- If users use ``Qlib`` in china-stock mode, china-stock data is required. Users can use ``Qlib`` in china-stock mode according to the following steps:
- Download china-stock in qlib format, please refer to section `Qlib Format Dataset <#qlib-format-dataset>`_.
- Initialize ``Qlib`` in china-stock mode
Supposed that users download their Qlib format data in the directory ``~/.qlib/csv_data/cn_data``. Users only need to initialize ``Qlib`` as follows.
Supposed that users download their Qlib format data in the directory ``~/.qlib/qlib_data/cn_data``. Users only need to initialize ``Qlib`` as follows.
.. code-block:: python
from qlib.config import REG_CN
from qlib.constant import REG_CN
qlib.init(provider_uri='~/.qlib/qlib_data/cn_data', region=REG_CN)
- If users use ``Qlib`` in US-stock mode, US-stock data is required. ``Qlib`` does not provide a script to download US-stock data. Users can use ``Qlib`` in US-stock mode according to the following steps:
- Prepare data in CSV format
- Convert data from CSV format to Qlib format, please refer to section `Converting CSV Format into Qlib Format <#converting-csv-format-into-qlib-format>`_.
- If users use ``Qlib`` in US-stock mode, US-stock data is required. ``Qlib`` also provides a script to download US-stock data. Users can use ``Qlib`` in US-stock mode according to the following steps:
- Download us-stock in qlib format, please refer to section `Qlib Format Dataset <#qlib-format-dataset>`_.
- Initialize ``Qlib`` in US-stock mode
Supposed that users prepare their Qlib format data in the directory ``~/.qlib/csv_data/us_data``. Users only need to initialize ``Qlib`` as follows.
Supposed that users prepare their Qlib format data in the directory ``~/.qlib/qlib_data/us_data``. Users only need to initialize ``Qlib`` as follows.
.. code-block:: python
from qlib.config import REG_US
qlib.init(provider_uri='~/.qlib/qlib_data/us_data', region=REG_US)
.. note::
PRs for new data source are highly welcome! Users could commit the code to crawl data as a PR like `the examples here <https://github.com/microsoft/qlib/tree/main/scripts>`_. And then we will use the code to create data cache on our server which other users could use directly.
Data API
========================
========
Data Retrieval
---------------
--------------
Users can use APIs in ``qlib.data`` to retrieve data, please refer to `Data Retrieval <../start/getdata.html>`_.
Feature
------------------
-------
``Qlib`` provides `Feature` and `ExpressionOps` to fetch the features according to users' needs.
@@ -126,11 +267,12 @@ Feature
- `ExpressionOps`
`ExpressionOps` will use operator for feature construction.
To know more about ``Operator``, please refer to `Operator API <../reference/api.html#module-qlib.data.ops>`_.
Also, ``Qlib`` supports users to define their own custom ``Operator``, an example has been given in ``tests/test_register_ops.py``.
To know more about ``Feature``, please refer to `Feature API <../reference/api.html#module-qlib.data.base>`_.
Filter
-------------------
------
``Qlib`` provides `NameDFilter` and `ExpressionDFilter` to filter the instruments according to users' needs.
- `NameDFilter`
@@ -138,140 +280,211 @@ Filter
- `ExpressionDFilter`
Expression dynamic instrument filter. Filter the instruments based on a certain expression. An expression rule indicating a certain feature field is required.
- `basic features filter`: rule_expression = '$close/$open>5'
- `cross-sectional features filter` : rule_expression = '$rank($close)<10'
- `cross-sectional features filter` \: rule_expression = '$rank($close)<10'
- `time-sequence features filter`: rule_expression = '$Ref($close, 3)>100'
Here is a simple example showing how to use filter in a basic ``Qlib`` workflow configuration file:
.. code-block:: yaml
filter: &filter
filter_type: ExpressionDFilter
rule_expression: "Ref($close, -2) / Ref($close, -1) > 1"
filter_start_time: 2010-01-01
filter_end_time: 2010-01-07
keep: False
data_handler_config: &data_handler_config
start_time: 2010-01-01
end_time: 2021-01-22
fit_start_time: 2010-01-01
fit_end_time: 2015-12-31
instruments: *market
filter_pipe: [*filter]
To know more about ``Filter``, please refer to `Filter API <../reference/api.html#module-qlib.data.filter>`_.
Reference
-------------
---------
To know more about ``Data API``, please refer to `Data API <../reference/api.html#data>`_.
Data Handler
=================
Users can use ``Data Handler`` in an automatic workflow by ``Estimator``, refer to `Estimator: Workflow Management <estimator.html>`_ for more details.
Data Loader
===========
Also, ``Data Handler`` can be used as an independent module, by which users can easily preprocess data(standardization, remove NaN, etc.) and build datasets. It is a subclass of ``qlib.contrib.estimator.handler.BaseDataHandler``, which provides some interfaces as follows.
``Data Loader`` in ``Qlib`` is designed to load raw data from the original data source. It will be loaded and used in the ``Data Handler`` module.
Base Class & Interface
----------------------
Qlib provides a base class `qlib.contrib.estimator.BaseDataHandler <../reference/api.html#qlib.contrib.estimator.handler.BaseDataHandler>`_, which provides the following interfaces:
- `setup_feature`
Implement the interface to load the data features.
- `setup_label`
Implement the interface to load the data labels and calculate the users' labels.
- `setup_processed_data`
Implement the interface for data preprocessing, such as preparing feature columns, discarding blank lines, and so on.
Qlib also provides two functions to help users init the data handler, users can override them for users' needs.
- `_init_kwargs`
Users can init the kwargs of the data handler in this function, some kwargs may be used when init the raw df.
Kwargs are the other attributes in data.args, like dropna_label, dropna_feature
- `_init_raw_df`
Users can init the raw df, feature names, and label names of data handler in this function.
If the index of feature df and label df are not the same, users need to override this method to merge them (e.g. inner, left, right merge).
If users want to load features and labels by config, users can inherit ``qlib.contrib.estimator.handler.ConfigDataHandler``, ``Qlib`` also provides some preprocess method in this subclass.
If users want to use qlib data, `QLibDataHandler` is recommended. Users can inherit their custom class from `QLibDataHandler`, which is also a subclass of `ConfigDataHandler`.
Usage
QlibDataLoader
--------------
``Data Handler`` can be used as a single module, which provides the following mehtods:
The ``QlibDataLoader`` class in ``Qlib`` is such an interface that allows users to load raw data from the ``Qlib`` data source.
- `get_split_data`
- According to the start and end dates, return features and labels of the pandas DataFrame type used for the 'Model'
StaticDataLoader
----------------
- `get_rolling_data`
- According to the start and end dates, and `rolling_period`, an iterator is returned, which can be used to traverse the features and labels used for rolling.
The ``StaticDataLoader`` class in ``Qlib`` is such an interface that allows users to load raw data from file or as provided.
Interface
---------
Here are some interfaces of the ``QlibDataLoader`` class:
.. autoclass:: qlib.data.dataset.loader.DataLoader
:members:
:noindex:
API
---
To know more about ``Data Loader``, please refer to `Data Loader API <../reference/api.html#module-qlib.data.dataset.loader>`_.
Data Handler
============
The ``Data Handler`` module in ``Qlib`` is designed to handler those common data processing methods which will be used by most of the models.
Users can use ``Data Handler`` in an automatic workflow by ``qrun``, refer to `Workflow: Workflow Management <workflow.html>`_ for more details.
DataHandlerLP
-------------
In addition to use ``Data Handler`` in an automatic workflow with ``qrun``, ``Data Handler`` can be used as an independent module, by which users can easily preprocess data (standardization, remove NaN, etc.) and build datasets.
In order to achieve so, ``Qlib`` provides a base class `qlib.data.dataset.DataHandlerLP <../reference/api.html#qlib.data.dataset.handler.DataHandlerLP>`_. The core idea of this class is that: we will have some learnable ``Processors`` which can learn the parameters of data processing(e.g., parameters for zscore normalization). When new data comes in, these `trained` ``Processors`` can then process the new data and thus processing real-time data in an efficient way becomes possible. More information about ``Processors`` will be listed in the next subsection.
Interface
---------
Here are some important interfaces that ``DataHandlerLP`` provides:
.. autoclass:: qlib.data.dataset.handler.DataHandlerLP
:members: __init__, fetch, get_cols
:noindex:
If users want to load features and labels by config, users can define a new handler and call the static method `parse_config_to_fields` of ``qlib.contrib.data.handler.Alpha158``.
Also, users can pass ``qlib.contrib.data.processor.ConfigSectionProcessor`` that provides some preprocess methods for features defined by config into the new handler.
Processor
---------
The ``Processor`` module in ``Qlib`` is designed to be learnable and it is responsible for handling data processing such as `normalization` and `drop none/nan features/labels`.
``Qlib`` provides the following ``Processors``:
- ``DropnaProcessor``: `processor` that drops N/A features.
- ``DropnaLabel``: `processor` that drops N/A labels.
- ``TanhProcess``: `processor` that uses `tanh` to process noise data.
- ``ProcessInf``: `processor` that handles infinity values, it will be replaces by the mean of the column.
- ``Fillna``: `processor` that handles N/A values, which will fill the N/A value by 0 or other given number.
- ``MinMaxNorm``: `processor` that applies min-max normalization.
- ``ZscoreNorm``: `processor` that applies z-score normalization.
- ``RobustZScoreNorm``: `processor` that applies robust z-score normalization.
- ``CSZScoreNorm``: `processor` that applies cross sectional z-score normalization.
- ``CSRankNorm``: `processor` that applies cross sectional rank normalization.
- ``CSZFillna``: `processor` that fills N/A values in a cross sectional way by the mean of the column.
Users can also create their own `processor` by inheriting the base class of ``Processor``. Please refer to the implementation of all the processors for more information (`Processor Link <https://github.com/microsoft/qlib/blob/main/qlib/data/dataset/processor.py>`_).
To know more about ``Processor``, please refer to `Processor API <../reference/api.html#module-qlib.data.dataset.processor>`_.
Example
--------------
-------
``Data Handler`` can be run with ``estimator`` by modifying the configuration file, and can also be used as a single module.
``Data Handler`` can be run with ``qrun`` by modifying the configuration file, and can also be used as a single module.
Know more about how to run ``Data Handler`` with ``Estimator``, please refer to `Estimator: Workflow Management <estimator.html>`_
Know more about how to run ``Data Handler`` with ``qrun``, please refer to `Workflow: Workflow Management <workflow.html>`_
Qlib provides implemented data handler `Alpha158`. The following example shows how to run `Alpha158` as a single module.
.. note:: Users need to initialize ``Qlib`` with `qlib.init` first, please refer to `initialization <../start/initialization.html>`_.
.. code-block:: Python
from qlib.contrib.estimator.handler import Alpha158
from qlib.contrib.model.gbdt import LGBModel
import qlib
from qlib.contrib.data.handler import Alpha158
DATA_HANDLER_CONFIG = {
"dropna_label": True,
"start_date": "2007-01-01",
"end_date": "2020-08-01",
"market": "csi300",
data_handler_config = {
"start_time": "2008-01-01",
"end_time": "2020-08-01",
"fit_start_time": "2008-01-01",
"fit_end_time": "2014-12-31",
"instruments": "csi300",
}
TRAINER_CONFIG = {
"train_start_date": "2007-01-01",
"train_end_date": "2014-12-31",
"validate_start_date": "2015-01-01",
"validate_end_date": "2016-12-31",
"test_start_date": "2017-01-01",
"test_end_date": "2020-08-01",
}
if __name__ == "__main__":
qlib.init()
h = Alpha158(**data_handler_config)
exampleDataHandler = Alpha158(**DATA_HANDLER_CONFIG)
# get all the columns of the data
print(h.get_cols())
# example of 'get_split_data'
x_train, y_train, x_validate, y_validate, x_test, y_test = exampleDataHandler.get_split_data(**TRAINER_CONFIG)
# fetch all the labels
print(h.fetch(col_set="label"))
# example of 'get_rolling_data'
for (x_train, y_train, x_validate, y_validate, x_test, y_test) in exampleDataHandler.get_rolling_data(**TRAINER_CONFIG):
print(x_train, y_train, x_validate, y_validate, x_test, y_test)
# fetch all the features
print(h.fetch(col_set="feature"))
.. note:: (x_train, y_train, x_validate, y_validate, x_test, y_test) can be used as arguments for the `fit`, `predic``, and `score` methods of the ``Interday Model`` , please refer to `Model <model.html#base-class-interface>`_.
Also, the above example has been given in ``examples.estimator.train_backtest_analyze.ipynb``.
.. note:: In the ``Alpha158``, ``Qlib`` uses the label `Ref($close, -2)/Ref($close, -1) - 1` that means the change from T+1 to T+2, rather than `Ref($close, -1)/$close - 1`, of which the reason is that when getting the T day close price of a china stock, the stock can be bought on T+1 day and sold on T+2 day.
API
---------
---
To know more about ``Data Handler``, please refer to `Data Handler API <../reference/api.html#module-qlib.data.dataset.handler>`_.
Dataset
=======
The ``Dataset`` module in ``Qlib`` aims to prepare data for model training and inferencing.
The motivation of this module is that we want to maximize the flexibility of different models to handle data that are suitable for themselves. This module gives the model the flexibility to process their data in an unique way. For instance, models such as ``GBDT`` may work well on data that contains `nan` or `None` value, while neural networks such as ``MLP`` will break down on such data.
If user's model need process its data in a different way, user could implement his own ``Dataset`` class. If the model's
data processing is not special, ``DatasetH`` can be used directly.
The ``DatasetH`` class is the `dataset` with `Data Handler`. Here is the most important interface of the class:
.. autoclass:: qlib.data.dataset.__init__.DatasetH
:members:
:noindex:
API
---
To know more about ``Dataset``, please refer to `Dataset API <../reference/api.html#dataset>`_.
To know more about ``Data Handler``, please refer to `Data Handler API <../reference/api.html#module-qlib.contrib.estimator.handler>`_.
Cache
==========
=====
``Cache`` is an optional module that helps accelerate providing data by saving some frequently-used data as cache file. ``Qlib`` provides a `Memcache` class to cache the most-frequently-used data in memory, an inheritable `ExpressionCache` class, and an inheritable `DatasetCache` class.
Global Memory Cache
---------------------
-------------------
`Memcache` is a global memory cache mechanism that composes of three `MemCacheUnit` instances to cache **Calendar**, **Instruments**, and **Features**. The `MemCache` is defined globally in `cache.py` as `H`. Users can use `H['c'], H['i'], H['f']` to get/set `memcache`.
.. autoclass:: qlib.data.cache.MemCacheUnit
:members:
:noindex:
.. autoclass:: qlib.data.cache.MemCache
:members:
:noindex:
ExpressionCache
-----------------
---------------
`ExpressionCache` is a cache mechanism that saves expressions such as **Mean($close, 5)**. Users can inherit this base class to define their own cache mechanism that saves expressions according to the following steps.
@@ -282,11 +495,12 @@ The following shows the details about the interfaces:
.. autoclass:: qlib.data.cache.ExpressionCache
:members:
:noindex:
``Qlib`` has currently provided implemented disk cache `DiskExpressionCache` which inherits from `ExpressionCache` . The expressions data will be stored in the disk.
DatasetCache
-----------------
------------
`DatasetCache` is a cache mechanism that saves datasets. A certain dataset is regulated by a stock pool configuration (or a series of instruments, though not recommended), a list of expressions or static feature fields, the start time, and end time for the collected features and the frequency. Users can inherit this base class to define their own cache mechanism that saves datasets according to the following steps.
@@ -297,17 +511,18 @@ The following shows the details about the interfaces:
.. autoclass:: qlib.data.cache.DatasetCache
:members:
:noindex:
``Qlib`` has currently provided implemented disk cache `DiskDatasetCache` which inherits from `DatasetCache` . The datasets' data will be stored in the disk.
Data and Cache File Structure
==================================
=============================
We've specially designed a file structure to manage data and cache, please refer to the `File storage design section in Qlib paper <https://arxiv.org/abs/2009.11189>`_ for detailed information. The file structure of data and cache is listed as follows.
.. code-block:: json
.. code-block::
- data/
[raw data] updated by data providers
@@ -336,4 +551,3 @@ We've specially designed a file structure to manage data and cache, please refer
- .meta : an assorted meta file recording the stockpool config, field names and visit times
- .index : an assorted index file recording the line index of all calendars
- ...

View File

@@ -1,692 +0,0 @@
.. _estimator:
=================================
Estimator: Workflow Management
=================================
.. currentmodule:: qlib
Introduction
===================
The components in `Qlib Framework <../introduction/introduction.html#framework>`_ are designed in a loosely-coupled way. Users could build their own Quant research workflow with these components like `Example <https://github.com/microsoft/qlib/blob/main/examples/train_and_backtest.py>`_
Besides, ``Qlib`` provides more user-friendly interfaces named ``Estimator`` to automatically run the whole workflow defined by configuration. A concrete execution of the whole workflow is called an `experiment`.
With ``Estimator``, user can easily run an `experiment`, which includes the following steps:
- Data
- Loading
- Processing
- Slicing
- Model
- Training and inference(static or rolling)
- Saving & loading
- Evaluation(Back-testing)
For each `experiment`, ``Qlib`` will capture the model training details, performance evaluation results and basic information (e.g. names, ids). The captured data will be stored in backend-storage (disk or database).
Complete Example
===================
Before getting into details, here is a complete example of ``Estimator``, which defines the workflow in typical Quant research.
Below is a typical config file of ``Estimator``.
.. code-block:: YAML
experiment:
name: estimator_example
observer_type: file_storage
mode: train
model:
class: LGBModel
module_path: qlib.contrib.model.gbdt
args:
loss: mse
colsample_bytree: 0.8879
learning_rate: 0.0421
subsample: 0.8789
lambda_l1: 205.6999
lambda_l2: 580.9768
max_depth: 8
num_leaves: 210
num_threads: 20
data:
class: Alpha158
args:
dropna_label: True
filter:
market: csi500
trainer:
class: StaticTrainer
args:
rolling_period: 360
train_start_date: 2007-01-01
train_end_date: 2014-12-31
validate_start_date: 2015-01-01
validate_end_date: 2016-12-31
test_start_date: 2017-01-01
test_end_date: 2020-08-01
strategy:
class: TopkDropoutStrategy
args:
topk: 50
n_drop: 5
backtest:
normal_backtest_args:
verbose: False
limit_threshold: 0.095
account: 100000000
benchmark: SH000905
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
qlib_data:
# when testing, please modify the following parameters according to the specific environment
provider_uri: "~/.qlib/qlib_data/cn_data"
region: "cn"
After saving the config into `configuration.yaml`, users could start the workflow and test their ideas with a single command below.
.. code-block:: bash
estimator -c configuration.yaml
.. note:: `estimator` will be placed in your $PATH directory when installing ``Qlib``.
Configuration File
===================
Let's get into details of ``Estimator`` in this section.
Before using ``estimator``, users need to prepare a configuration file. The following content shows how to prepare each part of the configuration file.
Experiment Section
--------------------
At first, the configuration file needs to contain a section named `experiment` about the basic information. This section describes how `estimator` tracks and persists current `experiment`. ``Qlib`` used `sacred`, a lightweight open-source tool, to configure, organize, generate logs, and manage experiment results. Partial behaviors of `sacred` will base on the `experiment` section.
Following files will be saved by `sacred` after `estimator` finish an `experiment`:
- `model.bin`, model binary file
- `pred.pkl`, model prediction result file
- `analysis.pkl`, backtest performance analysis file
- `positions.pkl`, backtest position records file
- `run`, the experiment information object, usually contains some meta information such as the experiment name, experiment date, etc.
Here is the typical configuration of `experiment section`
.. code-block:: YAML
experiment:
name: test_experiment
observer_type: mongo
mongo_url: mongodb://MONGO_URL
db_name: public
finetune: false
exp_info_path: /home/test_user/exp_info.json
mode: test
loader:
id: 677
The meaning of each field is as follows:
- `name`
The experiment name, str type, `sacred <https://github.com/IDSIA/sacred>_` will use this experiment name as an identifier for some important internal processes. Users can find this field in `run` object of `sacred`. The default value is `test_experiment`.
- `observer_type`
Observer type, str type, there are two choices which include `file_storage` and `mongo` respectively. If `file_storage` is selected, all the above-mentioned managed contents will be stored in the `dir` directory, separated by the number of times of experiments as a subfolder. If it is `mongo`, the content will be stored in the database. The default is `file_storage`.
- For `file_storage` observer.
- `dir`
Directory URL, str type, directory for `file_storage` observer type, files captured and managed by sacred with `file_storage` observer will be saved to this directory, which is the same directory as `config.json` by default.
- For `mongo` observer.
- `mongo_url`
Database URL, str type, required if the observer type is `mongo`.
- `db_name`
Database name, str type, required if the observer type is `mongo`.
- `finetune`
``Estimator``'s behaviors to train models will base on this flag.
If you just want to train models from scratch each time instead of based on existing models, please leave `finetune=false`. Otherwise please read the
details below.
The following table is the processing logic for different situations.
========== =========================================== ==================================== =========================================== ==========================================
. Static Rolling
. finetune:true finetune:false finetune:true finetune:false
========== =========================================== ==================================== =========================================== ==========================================
Train - Need to provide model (Static or Rolling) - No need to provide model - Need to provide model (Static or Rolling) - Need to provide model (Static or Rolling)
- The args in model section will be - The args in model section will be - The args in model section will be - The args in model section will be
used for finetuning used for training used for finetuning used for finetuning
- Update based on the provided model - Train model from scratch - Update based on the provided model - Based on the provided model update
and parameters and parameters - Train model from scratch
- **Each rolling time slice is based on** - **Train each rolling time slice**
**a model updated from the previous** **separately**
**time**
Test - Model must exist, otherwise an exception will be raised.
- For `StaticTrainer`, users need to train a model and record 'exp_info' for 'Test'.
- For `RollingTrainer`, users need to train a set of models until the latest time, and record 'exp_info' for 'Test'.
========== =============================================================================================================================================================================
.. note::
1. finetune parameters: share model.args parameters.
2. provide model: from `loader.model_index`, load the index of the model(starting from 0).
3. If `loader.model_index` is None:
- In 'Static Finetune=True', if provide 'Rolling', use the last model to update.
- For `RollingTrainer` with Finetune=True.
- If `StaticTrainer` is used in loader, the model will be used for initialization for finetuning.
- If `RollingTrainer` is used in loader, the existing models will be used without any modification and the new models will be initialized with the model in the last period and finetune one by one.
- `exp_info_path`
save path of experiment info, str type, save the experiment info and model `prediction score` after the experiment is finished. Optional parameter, the default value is `<config_file_dir>/ex_name/exp_info.json`.
- `mode`
`train` or `test`, str type.
- `test mode` is designed for inference. Under `test mode`, it will load the model according to the parameters of `loader` and skip model training.
- `train model` is the default value. It will train new models by default and
Please note that when it fails to load model, it will fall back to `fit` model.
.. note::
if users choose ` test mode`, they need to make sure:
- The loader of `test_start_date` must be less than or equal to the current `test_start_date`.
- If other parameters of the `loader` model args are different, a warning will appear.
- `loader`
If you just want to train models from scratch each time instead of based on existing models, please ignore `loader` section. Otherwise please read the
details below.
The `loader` section only works when the `mode` is `test` or `finetune` is `true`.
- `model_index`
Model index, int type. The index of the loaded model in loader_models (starting at 0) for the first `finetune`. The default value is None.
- `exp_info_path`
Loader model experiment info path, str type. If the field exists, the following parameters will be parsed from `exp_info_path`, and the following parameters will not work. One of this field and `id` must exist at least .
- `id`
The experiment id of the model that needs to be loaded, int type. If the `mode` is `test`, this value is required. This field and `exp_info_path` must exist one.
- `name`
The experiment name of the model that needs to be loaded, str type. The default value is the current experiment `name`.
- `observer_type`
The experiment observer type of the model that needs to be loaded, str type. The default value is the current experiment `observer_type`.
.. note:: The observer type is a concept of the `sacred` module, which determines how files, standard input, and output which are managed by sacred are stored.
- `file_storage`
If `observer_type` is `file_storage`, the config may be as follows.
.. code-block:: YAML
experiment:
name: test_experiment
dir: <path to a directory> # default is dir of `config.yml`
observer_type: file_storage
- `mongo`
If `observer_type` is `mongo`, the config may be as follows.
.. code-block:: YAML
experiment:
name: test_experiment
observer_type: mongo
mongo_url: mongodb://MONGO_URL
db_name: public
Users need to indicate `mongo_url` and `db_name` for a mongo observer.
.. note::
If users choose the mongo observer, they need to make sure:
- Have an environment with the mongodb installed and a mongo database dedicated to storing the results of the experiments.
- The python environment (the version of python and package) to run the experiments and the one to fetch the results are consistent.
Model Section
-----------------
Users can use a specified model by configuration with hyper-parameters.
Custom Models
~~~~~~~~~~~~~~~~~
Qlib supports custom models, but it must be a subclass of the `qlib.contrib.model.Model`, the config for a custom model may be as following.
.. code-block:: YAML
model:
class: SomeModel
module_path: /tmp/my_experment/custom_model.py
args:
loss: binary
The class `SomeModel` should be in the module `custom_model`, and ``Qlib`` could parse the `module_path` to load the class.
To know more about ``Interday Model``, please refer to `Interday Model: Training & Prediction <model.html>`_.
Data Section
-----------------
``Data Handler`` can be used to load raw data, prepare features and label columns, preprocess data (standardization, remove NaN, etc.), split training, validation, and test sets. It is a subclass of `qlib.contrib.estimator.handler.BaseDataHandler`.
Users can use the specified data handler by config as follows.
.. code-block:: YAML
data:
class: Alpha158
args:
start_date: 2005-01-01
end_date: 2018-04-30
dropna_label: True
filter:
market: csi500
filter_pipeline:
-
class: NameDFilter
module_path: qlib.filter
args:
name_rule_re: S(?!Z3)
fstart_time: 2018-01-01
fend_time: 2018-12-11
-
class: ExpressionDFilter
module_path: qlib.filter
args:
rule_expression: $open/$factor<=45
fstart_time: 2018-01-01
fend_time: 2018-12-11
- `class`
Data handler class, str type, which should be a subclass of `qlib.contrib.estimator.handler.BaseDataHandler`, and implements 5 important interfaces for loading features, loading raw data, preprocessing raw data, slicing train, validation, and test data. The default value is `ALPHA360`. If users want to write a data handler to retrieve the data in ``Qlib``, `QlibDataHandler` is suggested.
- `module_path`
The module path, str type, absolute url is also supported, indicates the path of the `class` implementation of the data processor class. The default value is `qlib.contrib.estimator.handler`.
- `args`
Parameters used for ``Data Handler`` initialization.
- `train_start_date`
Training start time, str type, the default value is `2005-01-01`.
- `start_date`
Data start date, str type.
- `end_date`
Data end date, str type. the data from start_date to end_date decides which part of data will be loaded in `datahandler`, users can only use these data in the following parts.
- `dropna_feature` (Optional in args)
Drop Nan feature, bool type, the default value is False.
- `dropna_label` (Optional in args)
Drop Nan label, bool type, the default value is True. Some multi-label tasks will use this.
- `normalize_method` (Optional in args)
Normalize data by a given method. str type. ``Qlib`` gives two normalizing methods, `MinMax` and `Std`.
If users want to build their own method, please override `_process_normalize_feature`.
- `filter`
Dynamically filtering the stocks based on the filter pipeline.
- `market`
index name, str type, the default value is `csi500`.
- `filter_pipeline`
Filter rule list, list type, the default value is []. Can be customized according to users' needs.
- `class`
Filter class name, str type.
- `module_path`
The module path, str type.
- `args`
The filter class parameters, these parameters are set according to the `class`, and all the parameters as kwargs to `class`.
Custom Data Handler
~~~~~~~~~~~~~~~~~~~~~~
Qlib support custom data handler, but it must be a subclass of the ``qlib.contrib.estimator.handler.BaseDataHandler``, the config for custom data handler may be as follows.
.. code-block:: YAML
data:
class: SomeDataHandler
module_path: /tmp/my_experment/custom_data_handler.py
args:
start_date: 2005-01-01
end_date: 2018-04-30
The class `SomeDataHandler` should be in the module `custom_data_handler`, and ``Qlib`` could parse the `module_path` to load the class.
If users want to load features and labels by config, they can inherit ``qlib.contrib.estimator.handler.ConfigDataHandler``, ``Qlib`` also has provided some preprocess methods in this subclass.
If users want to use qlib data, `QLibDataHandler` is recommended, from which users can inherit the custom class. `QLibDataHandler` is also a subclass of `ConfigDataHandler`.
To know more about ``Data Handler``, please refer to `Data Framework&Usage <data.html>`_.
Trainer Section
-----------------
Users can specify the trainer ``Trainer`` by the config file, which is a subclass of ``qlib.contrib.estimator.trainer.BaseTrainer`` and implement three important interfaces for training the model, restoring the model, and getting model predictions as follows.
- `train`
Implement this interface to train the model.
- `load`
Implement this interface to recover the model from disk.
- `get_pred`
Implement this interface to get model prediction results.
Qlib have provided two implemented trainer,
- `StaticTrainer`
The static trainer will be trained using the training, validation, and test data of the data processor static slicing.
- `RollingTrainer`
The rolling trainer will use the rolling iterator of the data processor to split data for rolling training.
Users can specify `trainer` with the configuration file:
.. code-block:: YAML
trainer:
class: StaticTrainer # or RollingTrainer
args:
rolling_period: 360
train_start_date: 2005-01-01
train_end_date: 2014-12-31
validate_start_date: 2015-01-01
validate_end_date: 2016-06-30
test_start_date: 2016-07-01
test_end_date: 2017-07-31
- `class`
Trainer class, which should be a subclass of `qlib.contrib.estimator.trainer.BaseTrainer`, and needs to implement three important interfaces, the default value is `StaticTrainer`.
- `module_path`
The module path, str type, absolute url is also supported, indicates the path of the trainer class implementation.
- `args`
Parameters used for ``Trainer`` initialization.
- `rolling_period`
The rolling period, integer type, indicates how many time steps need rolling when rolling the data. The default value is `60`. Only used in `RollingTrainer`.
- `train_start_date`
Training start time, str type.
- `train_end_date`
Training end time, str type.
- `validate_start_date`
Validation start time, str type.
- `validate_end_date`
Validation end time, str type.
- `test_start_date`
Test start time, str type.
- `test_end_date`
Test end time, str type. If `test_end_date` is `-1` or greater than the last date of the data, the last date of the data will be used as `test_end_date`.
Custom Trainer
~~~~~~~~~~~~~~~~~~
Qlib supports custom trainer, but it must be a subclass of the `qlib.contrib.estimator.trainer.BaseTrainer`, the config for a custom trainer may be as following:
.. code-block:: YAML
trainer:
class: SomeTrainer
module_path: /tmp/my_experment/custom_trainer.py
args:
train_start_date: 2005-01-01
train_end_date: 2014-12-31
validate_start_date: 2015-01-01
validate_end_date: 2016-06-30
test_start_date: 2016-07-01
test_end_date: 2017-07-31
The class `SomeTrainer` should be in the module `custom_trainer`, and ``Qlib`` could parse the `module_path` to load the class.
Strategy Section
-----------------
Users can specify strategy through a config file, for example:
.. code-block:: YAML
strategy :
class: TopkDropoutStrategy
args:
topk: 50
n_drop: 5
- `class`
The strategy class, str type, should be a subclass of `qlib.contrib.strategy.strategy.BaseStrategy`. The default value is `TopkDropoutStrategy`.
- `module_path`
The module location, str type, absolute url is also supported, and absolute path is also supported, indicates the location of the policy class implementation.
- `args`
Parameters used for ``Trainer`` initialization.
- `topk`
The number of stocks in the portfolio
- `n_drop`
Number of stocks to be replaced in each trading date
Custom Strategy
^^^^^^^^^^^^^^^^^^^
Qlib supports custom strategy, but it must be a subclass of the ``qlib.contrib.strategy.strategy.BaseStrategy``, the config for custom strategy may be as following:
.. code-block:: YAML
strategy :
class: SomeStrategy
module_path: /tmp/my_experment/custom_strategy.py
The class `SomeStrategy` should be in the module `custom_strategy`, and ``Qlib`` could parse the `module_path` to load the class.
To know more about ``Strategy``, please refer to `Strategy <strategy.html>`_.
Backtest Section
-----------------
Users can specify `backtest` through a config file, for example:
.. code-block:: YAML
backtest :
normal_backtest_args:
topk: 50
benchmark: SH000905
account: 500000
deal_price: close
min_cost: 5
subscribe_fields:
- $close
- $change
- $factor
- `normal_backtest_args`
Normal backtest parameters. All the parameters in this section will be passed to the ``qlib.contrib.evaluate.backtest`` function in the form of `**kwargs`.
- `benchmark`
Stock index symbol, str, or list type, the default value is `None`.
.. note::
* If `benchmark` is None, it will use the average change of the day of all stocks in 'pred' as the 'bench'.
* If `benchmark` is list, it will use the daily average change of the stock pool in the list as the 'bench'.
* If `benchmark` is str, it will use the daily change as the 'bench'.
- `account`
Backtest initial cash, integer type. The `account` in `strategy` section is deprecated. It only works when `account` is not set in `backtest` section. It will be overridden by `account` in the `backtest` section. The default value is 1e9.
- `deal_price`
Order transaction price field, str type, the default value is close.
- `min_cost`
Min transaction cost, float type, the default value is 5.
- `subscribe_fields`
Subscribe quote fields, array type, the default value is [`deal_price`, $close, $change, $factor].
Qlib Data Section
--------------------
The `qlib_data` field describes the parameters of qlib initialization.
.. code-block:: YAML
qlib_data:
# when testing, please modify the following parameters according to the specific environment
provider_uri: "~/.qlib/qlib_data/cn_data"
region: "cn"
- `provider_uri`
The local directory where the data loaded by 'get_data.py' is stored.
- `region`
- If region == ``qlib.config.REG_CN``, 'qlib' will be initialized in US-stock mode.
- If region == ``qlib.config.REG_US``, 'qlib' will be initialized in china-stock mode.
Please refer to `Initialization <../start/initialization.html>`_.
Experiment Result
===================
Form of Experimental Result
----------------------------
The result of the experiment is also the result of the ``Intraday Trading(Backtest)``, please refer to `Intraday Trading: Model&Strategy Testing <backtest.html>`_.
Get Experiment Result
----------------------------
Base Class & Interface
~~~~~~~~~~~~~~~~~~~~~~~
Users can check the experiment results from file storage directly, or check the experiment results from the database, or get the experiment results through two interfaces of a base class `Fetcher` provided by ``Qlib``.
The `Fetcher` provides the following interface
- `get_experiments(self, exp_name=None):`
The interface takes one parameters. The `exp_name` is the experiment name, the default is all experiments. Users can get the returned dictionary with a list of ids and test end date as follows.
.. code-block:: JSON
{
"ex_a": [
{
"id": 1,
"test_end_date": "2017-01-01"
}
],
"ex_b": [
...
]
}
- `get_experiment(exp_name, exp_id, fields=None)`
The interface takes three parameters. The first parameter is the experiment name, the second parameter is the experiment id, and the third parameter is a list of fields. The default value of `fields` is None, which means all fields.
.. note::
Currently supported fields:
['model', 'analysis', 'positions', 'report_normal', 'pred', 'task_config', 'label']
Users can get the returned dictionary as follows.
.. code-block:: JSON
{
'analysis': analysis_df,
'pred': pred_df,
'positions': positions_dic,
'report_normal': report_normal_df,
}
Implemented `Fetcher` s & Examples
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``Qlib`` provides two implemented `Fetcher` s as follows.
`FileFetcher`
^^^^^^^^^^^^^^^
The `FileFetcher` is a subclass of `Fetcher`, which could fetch files from `file_storage` observer. The following is an example:
.. code-block:: python
>>> from qlib.contrib.estimator.fetcher import FileFetcher
>>> f = FileFetcher(experiments_dir=r'./')
>>> print(f.get_experiments())
{
'test_experiment': [
{
'id': '1',
'config': ...
},
{
'id': '2',
'config': ...
},
{
'id': '3',
'config': ...
}
]
}
>>> print(f.get_experiment('test_experiment', '1'))
risk
excess_return_without_cost mean 0.000605
std 0.005481
annualized_return 0.152373
information_ratio 1.751319
max_drawdown -0.059055
excess_return_with_cost mean 0.000410
std 0.005478
annualized_return 0.103265
information_ratio 1.187411
max_drawdown -0.075024
`MongoFetcher`
^^^^^^^^^^^^^^^
The `FileFetcher` is a subclass of `Fetcher`, which could fetch files from `mongo` observer. Users should initialize the fetcher with `mongo_url`. The following is an example:
.. code-block:: python
>>> from qlib.contrib.estimator.fetcher import MongoFetcher
>>> f = MongoFetcher(mongo_url=..., db_name=...)

View File

@@ -0,0 +1,40 @@
.. _highfreq:
========================================================================
Design of Nested Decision Execution Framework for High-Frequency Trading
========================================================================
.. currentmodule:: qlib
Introduction
============
Daily trading (e.g. portfolio management) and intraday trading (e.g. orders execution) are two hot topics in Quant investment and are usually studied separately.
To get the join trading performance of daily and intraday trading, they must interact with each other and run backtest jointly.
In order to support the joint backtest strategies at multiple levels, a corresponding framework is required. None of the publicly available high-frequency trading frameworks considers multi-level joint trading, which makes the backtesting aforementioned inaccurate.
Besides backtesting, the optimization of strategies from different levels is not standalone and can be affected by each other.
For example, the best portfolio management strategy may change with the performance of order executions(e.g. a portfolio with higher turnover may become a better choice when we improve the order execution strategies).
To achieve overall good performance, it is necessary to consider the interaction of strategies at a different levels.
Therefore, building a new framework for trading on multiple levels becomes necessary to solve the various problems mentioned above, for which we designed a nested decision execution framework that considers the interaction of strategies.
.. image:: ../_static/img/framework.svg
The design of the framework is shown in the yellow part in the middle of the figure above. Each level consists of ``Trading Agent`` and ``Execution Env``. ``Trading Agent`` has its own data processing module (``Information Extractor``), forecasting module (``Forecast Model``) and decision generator (``Decision Generator``). The trading algorithm generates the decisions by the ``Decision Generator`` based on the forecast signals output by the ``Forecast Module``, and the decisions generated by the trading algorithm are passed to the ``Execution Env``, which returns the execution results.
The frequency of the trading algorithm, decision content and execution environment can be customized by users (e.g. intraday trading, daily-frequency trading, weekly-frequency trading), and the execution environment can be nested with finer-grained trading algorithm and execution environment inside (i.e. sub-workflow in the figure, e.g. daily-frequency orders can be turned into finer-grained decisions by splitting orders within the day). The flexibility of the nested decision execution framework makes it easy for users to explore the effects of combining different levels of trading strategies and break down the optimization barriers between different levels of the trading algorithm.
The optimization for the nested decision execution framework can be implemented with the support of `QlibRL <https://qlib.readthedocs.io/en/latest/component/rl.html>`_. To know more about how to use the QlibRL, go to API Reference: `RL API <../reference/api.html#rl>`_.
Example
=======
An example of a nested decision execution framework for high-frequency can be found `here <https://github.com/microsoft/qlib/blob/main/examples/nested_decision_execution/workflow.py>`_.
Besides, the above examples, here are some other related works about high-frequency trading in Qlib.
- `Prediction with high-frequency data <https://github.com/microsoft/qlib/tree/main/examples/highfreq#benchmarks-performance-predicting-the-price-trend-in-high-frequency-data>`_
- `Examples <https://github.com/microsoft/qlib/blob/main/examples/orderbook_data/>`_ to extract features from high-frequency data without fixed frequency.
- `A paper <https://github.com/microsoft/qlib/tree/high-freq-execution#high-frequency-execution>`_ for high-frequency trading.

68
docs/component/meta.rst Normal file
View File

@@ -0,0 +1,68 @@
.. _meta:
======================================================
Meta Controller: Meta-Task & Meta-Dataset & Meta-Model
======================================================
.. currentmodule:: qlib
Introduction
============
``Meta Controller`` provides guidance to ``Forecast Model``, which aims to learn regular patterns among a series of forecasting tasks and use learned patterns to guide forthcoming forecasting tasks. Users can implement their own meta-model instance based on ``Meta Controller`` module.
Meta Task
=========
A `Meta Task` instance is the basic element in the meta-learning framework. It saves the data that can be used for the `Meta Model`. Multiple `Meta Task` instances may share the same `Data Handler`, controlled by `Meta Dataset`. Users should use `prepare_task_data()` to obtain the data that can be directly fed into the `Meta Model`.
.. autoclass:: qlib.model.meta.task.MetaTask
:members:
Meta Dataset
============
`Meta Dataset` controls the meta-information generating process. It is on the duty of providing data for training the `Meta Model`. Users should use `prepare_tasks` to retrieve a list of `Meta Task` instances.
.. autoclass:: qlib.model.meta.dataset.MetaTaskDataset
:members:
Meta Model
==========
General Meta Model
------------------
`Meta Model` instance is the part that controls the workflow. The usage of the `Meta Model` includes:
1. Users train their `Meta Model` with the `fit` function.
2. The `Meta Model` instance guides the workflow by giving useful information via the `inference` function.
.. autoclass:: qlib.model.meta.model.MetaModel
:members:
Meta Task Model
---------------
This type of meta-model may interact with task definitions directly. Then, the `Meta Task Model` is the class for them to inherit from. They guide the base tasks by modifying the base task definitions. The function `prepare_tasks` can be used to obtain the modified base task definitions.
.. autoclass:: qlib.model.meta.model.MetaTaskModel
:members:
Meta Guide Model
----------------
This type of meta-model participates in the training process of the base forecasting model. The meta-model may guide the base forecasting models during their training to improve their performances.
.. autoclass:: qlib.model.meta.model.MetaGuideModel
:members:
Example
=======
``Qlib`` provides an implementation of ``Meta Model`` module, ``DDG-DA``,
which adapts to the market dynamics.
``DDG-DA`` includes four steps:
1. Calculate meta-information and encapsulate it into ``Meta Task`` instances. All the meta-tasks form a ``Meta Dataset`` instance.
2. Train ``DDG-DA`` based on the training data of the meta-dataset.
3. Do the inference of the ``DDG-DA`` to get guide information.
4. Apply guide information to the forecasting models to improve their performances.
The `above example <https://github.com/microsoft/qlib/tree/main/examples/benchmarks_dynamic/DDG-DA>`_ can be found in ``examples/benchmarks_dynamic/DDG-DA/workflow.py``.

View File

@@ -1,178 +1,122 @@
.. _model:
============================================
Interday Model: Model Training & Prediction
============================================
===========================================
Forecast Model: Model Training & Prediction
===========================================
Introduction
===================
============
``Interday Model`` is designed to make the `prediction score` about stocks. Users can use the ``Interday Model`` in an automatic workflow by ``Estimator``, please refer to `Estimator: Workflow Management <estimator.html>`_.
``Forecast Model`` is designed to make the `prediction score` about stocks. Users can use the ``Forecast Model`` in an automatic workflow by ``qrun``, please refer to `Workflow: Workflow Management <workflow.html>`_.
Because the components in ``Qlib`` are designed in a loosely-coupled way, ``Interday Model`` can be used as an independent module also.
Because the components in ``Qlib`` are designed in a loosely-coupled way, ``Forecast Model`` can be used as an independent module also.
Base Class & Interface
======================
``Qlib`` provides a base class `qlib.contrib.model.base.Model <../reference/api.html#module-qlib.contrib.model.base>`_ from which all models should inherit.
``Qlib`` provides a base class `qlib.model.base.Model <../reference/api.html#module-qlib.model.base>`_ from which all models should inherit.
The base class provides the following interfaces:
- `__init__(**kwargs)`
- Initialization.
- If users use ``Estimator`` to start an `experiment`, the parameter of `__init__` method shoule be consistent with the hyperparameters in the configuration file.
.. autoclass:: qlib.model.base.Model
:members:
:noindex:
- `fit(self, x_train, y_train, x_valid, y_valid, w_train=None, w_valid=None, **kwargs)`
- Train model.
- Parameter:
- `x_train`, pd.DataFrame type, train feature
The following example explains the value of `x_train`:
``Qlib`` also provides a base class `qlib.model.base.ModelFT <../reference/api.html#qlib.model.base.ModelFT>`_, which includes the method for finetuning the model.
.. code-block:: YAML
KMID KLEN KMID2 KUP KUP2
instrument datetime
SH600004 2012-01-04 0.000000 0.017685 0.000000 0.012862 0.727275
2012-01-05 -0.006473 0.025890 -0.250001 0.012945 0.499998
2012-01-06 0.008117 0.019481 0.416666 0.008117 0.416666
2012-01-09 0.016051 0.025682 0.624998 0.006421 0.250001
2012-01-10 0.017323 0.026772 0.647057 0.003150 0.117648
... ... ... ... ... ...
SZ300273 2014-12-25 -0.005295 0.038697 -0.136843 0.016293 0.421052
2014-12-26 -0.022486 0.041701 -0.539215 0.002453 0.058824
2014-12-29 -0.031526 0.039092 -0.806451 0.000000 0.000000
2014-12-30 -0.010000 0.032174 -0.310811 0.013913 0.432433
2014-12-31 0.010917 0.020087 0.543479 0.001310 0.065216
`x_train` is a pandas DataFrame, whose index is MultiIndex <instrument(str), datetime(pd.Timestamp)>. Each column of `x_train` corresponds to a feature, and the column name is the feature name.
.. note::
The number and names of the columns are determined by the data handler, please refer to `Data Handler <data.html#data-handler>`_ and `Estimator Data Section <estimator.html#data-section>`_.
- `y_train`, pd.DataFrame type, train label
The following example explains the value of `y_train`:
.. code-block:: YAML
LABEL
instrument datetime
SH600004 2012-01-04 -0.798456
2012-01-05 -1.366716
2012-01-06 -0.491026
2012-01-09 0.296900
2012-01-10 0.501426
... ...
SZ300273 2014-12-25 -0.465540
2014-12-26 0.233864
2014-12-29 0.471368
2014-12-30 0.411914
2014-12-31 1.342723
`y_train` is a pandas DataFrame, whose index is MultiIndex <instrument(str), datetime(pd.Timestamp)>. The `LABEL` column represents the value of train label.
.. note::
The number and names of the columns are determined by the ``Data Handler``, please refer to `Data Handler <data.html#data-handler>`_.
- `x_valid`, pd.DataFrame type, validation feature
The format of `x_valid` is same as `x_train`
- `y_valid`, pd.DataFrame type, validation label
The format of `y_valid` is same as `y_train`
- `w_train`(Optional args, default is None), pd.DataFrame type, train weight
`w_train` is a pandas DataFrame, whose shape and index is same as `x_train`. The float value in `w_train` represents the weight of the feature at the same position in `x_train`.
- `w_train`(Optional args, default is None), pd.DataFrame type, validation weight
`w_train` is a pandas DataFrame, whose shape and index is the same as `x_valid`. The float value in `w_train` represents the weight of the feature at the same position in `x_train`.
- `predict(self, x_test, **kwargs)`
- Predict test data 'x_test'
- Parameter:
- `x_test`, pd.DataFrame type, test features
The form of `x_test` is same as `x_train` in 'fit' method.
- Return:
- `label`, np.ndarray type, test label
The label of `x_test` that predicted by model.
- `score(self, x_test, y_test, w_test=None, **kwargs)`
- Evaluate model with test feature/label
- Parameter:
- `x_test`, pd.DataFrame type, test feature
The format of `x_test` is same as `x_train` in `fit` method.
- `x_test`, pd.DataFrame type, test label
The format of `y_test` is same as `y_train` in `fit` method.
- `w_test`, pd.DataFrame type, test weight
The format of `w_test` is same as `w_train` in `fit` method.
- Return: float type, evaluation score
For other interfaces such as `save`, `load`, `finetune`, please refer to `Model API <../reference/api.html#module-qlib.contrib.model.base>`_.
For other interfaces such as `finetune`, please refer to `Model API <../reference/api.html#module-qlib.model.base>`_.
Example
==================
=======
``Qlib`` provides ``LightGBM`` and ``DNN`` models as the baseline, the following steps show how to run`` LightGBM`` as an independent module.
``Qlib``'s `Model Zoo` includes models such as ``LightGBM``, ``MLP``, ``LSTM``, etc.. These models are treated as the baselines of ``Forecast Model``. The following steps show how to run`` LightGBM`` as an independent module.
- Initialize ``Qlib`` with `qlib.init` first, please refer to `Initialization <../start/initialization.html>`_.
- Run the following code to get the `prediction score` `pred_score`
.. code-block:: Python
from qlib.contrib.estimator.handler import Alpha158
from qlib.contrib.model.gbdt import LGBModel
from qlib.contrib.data.handler import Alpha158
from qlib.utils import init_instance_by_config, flatten_dict
from qlib.workflow import R
from qlib.workflow.record_temp import SignalRecord, PortAnaRecord
DATA_HANDLER_CONFIG = {
"dropna_label": True,
"start_date": "2007-01-01",
"end_date": "2020-08-01",
"market": MARKET,
market = "csi300"
benchmark = "SH000300"
data_handler_config = {
"start_time": "2008-01-01",
"end_time": "2020-08-01",
"fit_start_time": "2008-01-01",
"fit_end_time": "2014-12-31",
"instruments": market,
}
TRAINER_CONFIG = {
"train_start_date": "2007-01-01",
"train_end_date": "2014-12-31",
"validate_start_date": "2015-01-01",
"validate_end_date": "2016-12-31",
"test_start_date": "2017-01-01",
"test_end_date": "2020-08-01",
task = {
"model": {
"class": "LGBModel",
"module_path": "qlib.contrib.model.gbdt",
"kwargs": {
"loss": "mse",
"colsample_bytree": 0.8879,
"learning_rate": 0.0421,
"subsample": 0.8789,
"lambda_l1": 205.6999,
"lambda_l2": 580.9768,
"max_depth": 8,
"num_leaves": 210,
"num_threads": 20,
},
},
"dataset": {
"class": "DatasetH",
"module_path": "qlib.data.dataset",
"kwargs": {
"handler": {
"class": "Alpha158",
"module_path": "qlib.contrib.data.handler",
"kwargs": data_handler_config,
},
"segments": {
"train": ("2008-01-01", "2014-12-31"),
"valid": ("2015-01-01", "2016-12-31"),
"test": ("2017-01-01", "2020-08-01"),
},
},
},
}
x_train, y_train, x_validate, y_validate, x_test, y_test = Alpha158(
**DATA_HANDLER_CONFIG
).get_split_data(**TRAINER_CONFIG)
# model initiaiton
model = init_instance_by_config(task["model"])
dataset = init_instance_by_config(task["dataset"])
# start exp
with R.start(experiment_name="workflow"):
# train
R.log_params(**flatten_dict(task))
model.fit(dataset)
MODEL_CONFIG = {
"loss": "mse",
"colsample_bytree": 0.8879,
"learning_rate": 0.0421,
"subsample": 0.8789,
"lambda_l1": 205.6999,
"lambda_l2": 580.9768,
"max_depth": 8,
"num_leaves": 210,
"num_threads": 20,
}
# use default model
model = LGBModel(**MODEL_CONFIG)
model.fit(x_train, y_train, x_validate, y_validate)
_pred = model.predict(x_test)
pred_score = pd.DataFrame(index=_pred.index)
pred_score["score"] = _pred.iloc(axis=1)[0]
# prediction
recorder = R.get_recorder()
sr = SignalRecord(model, dataset, recorder)
sr.generate()
.. note:: `Alpha158` is the data handler provided by ``Qlib``, please refer to `Data Handler <data.html#data-handler>`_.
.. note::
`Alpha158` is the data handler provided by ``Qlib``, please refer to `Data Handler <data.html#data-handler>`_.
`SignalRecord` is the `Record Template` in ``Qlib``, please refer to `Workflow <recorder.html#record-template>`_.
Also, the above example has been given in ``examples/train_backtest_analyze.ipynb``.
Technically, the meaning of the model prediction depends on the label setting designed by user.
By default, the meaning of the score is normally the rating of the instruments by the forecasting model. The higher the score, the more profit the instruments.
Custom Model
===================
============
Qlib supports custom models. If users are interested in customizing their own models and integrating the models into ``Qlib``, please refer to `Custom Model Integration <../start/integration.html>`_.
API
===================
Please refer to `Model API <../reference/api.html#module-qlib.contrib.model.base>`_.
===
Please refer to `Model API <../reference/api.html#module-qlib.model.base>`_.

56
docs/component/online.rst Normal file
View File

@@ -0,0 +1,56 @@
.. _online_serving:
==============
Online Serving
==============
.. currentmodule:: qlib
Introduction
============
.. image:: ../_static/img/online_serving.png
:align: center
In addition to backtesting, one way to test a model is effective is to make predictions in real market conditions or even do real trading based on those predictions.
``Online Serving`` is a set of modules for online models using the latest data,
which including `Online Manager <#Online Manager>`_, `Online Strategy <#Online Strategy>`_, `Online Tool <#Online Tool>`_, `Updater <#Updater>`_.
`Here <https://github.com/microsoft/qlib/tree/main/examples/online_srv>`_ are several examples for reference, which demonstrate different features of ``Online Serving``.
If you have many models or `task` needs to be managed, please consider `Task Management <../advanced/task_management.html>`_.
The `examples <https://github.com/microsoft/qlib/tree/main/examples/online_srv>`_ are based on some components in `Task Management <../advanced/task_management.html>`_ such as ``TrainerRM`` or ``Collector``.
**NOTE**: User should keep his data source updated to support online serving. For example, Qlib provides `a batch of scripts <https://github.com/microsoft/qlib/blob/main/scripts/data_collector/yahoo/README.md#automatic-update-of-daily-frequency-datafrom-yahoo-finance>`_ to help users update Yahoo daily data.
Known limitations currently
- Currently, the daily updating prediction for the next trading day is supported. But generating orders for the next trading day is not supported due to the `limitations of public data <https://github.com/microsoft/qlib/issues/215#issuecomment-766293563>_`
Online Manager
==============
.. automodule:: qlib.workflow.online.manager
:members:
:noindex:
Online Strategy
===============
.. automodule:: qlib.workflow.online.strategy
:members:
:noindex:
Online Tool
===========
.. automodule:: qlib.workflow.online.utils
:members:
:noindex:
Updater
=======
.. automodule:: qlib.workflow.online.update
:members:
:noindex:

154
docs/component/recorder.rst Normal file
View File

@@ -0,0 +1,154 @@
.. _recorder:
====================================
Qlib Recorder: Experiment Management
====================================
.. currentmodule:: qlib
Introduction
============
``Qlib`` contains an experiment management system named ``QlibRecorder``, which is designed to help users handle experiment and analyse results in an efficient way.
There are three components of the system:
- `ExperimentManager`
a class that manages experiments.
- `Experiment`
a class of experiment, and each instance of it is responsible for a single experiment.
- `Recorder`
a class of recorder, and each instance of it is responsible for a single run.
Here is a general view of the structure of the system:
.. code-block::
ExperimentManager
- Experiment 1
- Recorder 1
- Recorder 2
- ...
- Experiment 2
- Recorder 1
- Recorder 2
- ...
- ...
This experiment management system defines a set of interface and provided a concrete implementation ``MLflowExpManager``, which is based on the machine learning platform: ``MLFlow`` (`link <https://mlflow.org/>`_).
If users set the implementation of ``ExpManager`` to be ``MLflowExpManager``, they can use the command `mlflow ui` to visualize and check the experiment results. For more information, please refer to the related documents `here <https://www.mlflow.org/docs/latest/cli.html#mlflow-ui>`_.
Qlib Recorder
=============
``QlibRecorder`` provides a high level API for users to use the experiment management system. The interfaces are wrapped in the variable ``R`` in ``Qlib``, and users can directly use ``R`` to interact with the system. The following command shows how to import ``R`` in Python:
.. code-block:: Python
from qlib.workflow import R
``QlibRecorder`` includes several common API for managing `experiments` and `recorders` within a workflow. For more available APIs, please refer to the following section about `Experiment Manager`, `Experiment` and `Recorder`.
Here are the available interfaces of ``QlibRecorder``:
.. autoclass:: qlib.workflow.__init__.QlibRecorder
:members:
Experiment Manager
==================
The ``ExpManager`` module in ``Qlib`` is responsible for managing different experiments. Most of the APIs of ``ExpManager`` are similar to ``QlibRecorder``, and the most important API will be the ``get_exp`` method. User can directly refer to the documents above for some detailed information about how to use the ``get_exp`` method.
.. autoclass:: qlib.workflow.expm.ExpManager
:members: get_exp, list_experiments
:noindex:
For other interfaces such as `create_exp`, `delete_exp`, please refer to `Experiment Manager API <../reference/api.html#experiment-manager>`_.
Experiment
==========
The ``Experiment`` class is solely responsible for a single experiment, and it will handle any operations that are related to an experiment. Basic methods such as `start`, `end` an experiment are included. Besides, methods related to `recorders` are also available: such methods include `get_recorder` and `list_recorders`.
.. autoclass:: qlib.workflow.exp.Experiment
:members: get_recorder, list_recorders
:noindex:
For other interfaces such as `search_records`, `delete_recorder`, please refer to `Experiment API <../reference/api.html#experiment>`_.
``Qlib`` also provides a default ``Experiment``, which will be created and used under certain situations when users use the APIs such as `log_metrics` or `get_exp`. If the default ``Experiment`` is used, there will be related logged information when running ``Qlib``. Users are able to change the name of the default ``Experiment`` in the config file of ``Qlib`` or during ``Qlib``'s `initialization <../start/initialization.html#parameters>`_, which is set to be '`Experiment`'.
Recorder
========
The ``Recorder`` class is responsible for a single recorder. It will handle some detailed operations such as ``log_metrics``, ``log_params`` of a single run. It is designed to help user to easily track results and things being generated during a run.
Here are some important APIs that are not included in the ``QlibRecorder``:
.. autoclass:: qlib.workflow.recorder.Recorder
:members: list_artifacts, list_metrics, list_params, list_tags
:noindex:
For other interfaces such as `save_objects`, `load_object`, please refer to `Recorder API <../reference/api.html#recorder>`_.
Record Template
===============
The ``RecordTemp`` class is a class that enables generate experiment results such as IC and backtest in a certain format. We have provided three different `Record Template` class:
- ``SignalRecord``: This class generates the `prediction` results of the model.
- ``SigAnaRecord``: This class generates the `IC`, `ICIR`, `Rank IC` and `Rank ICIR` of the model.
Here is a simple example of what is done in ``SigAnaRecord``, which users can refer to if they want to calculate IC, Rank IC, Long-Short Return with their own prediction and label.
.. code-block:: Python
from qlib.contrib.eva.alpha import calc_ic, calc_long_short_return
ic, ric = calc_ic(pred.iloc[:, 0], label.iloc[:, 0])
long_short_r, long_avg_r = calc_long_short_return(pred.iloc[:, 0], label.iloc[:, 0])
- ``PortAnaRecord``: This class generates the results of `backtest`. The detailed information about `backtest` as well as the available `strategy`, users can refer to `Strategy <../component/strategy.html>`_ and `Backtest <../component/backtest.html>`_.
Here is a simple example of what is done in ``PortAnaRecord``, which users can refer to if they want to do backtest based on their own prediction and label.
.. code-block:: Python
from qlib.contrib.strategy.strategy import TopkDropoutStrategy
from qlib.contrib.evaluate import (
backtest as normal_backtest,
risk_analysis,
)
# backtest
STRATEGY_CONFIG = {
"topk": 50,
"n_drop": 5,
}
BACKTEST_CONFIG = {
"limit_threshold": 0.095,
"account": 100000000,
"benchmark": BENCHMARK,
"deal_price": "close",
"open_cost": 0.0005,
"close_cost": 0.0015,
"min_cost": 5,
}
strategy = TopkDropoutStrategy(**STRATEGY_CONFIG)
report_normal, positions_normal = normal_backtest(pred_score, strategy=strategy, **BACKTEST_CONFIG)
# analysis
analysis = dict()
analysis["excess_return_without_cost"] = risk_analysis(report_normal["return"] - report_normal["bench"])
analysis["excess_return_with_cost"] = risk_analysis(report_normal["return"] - report_normal["bench"] - report_normal["cost"])
analysis_df = pd.concat(analysis) # type: pd.DataFrame
print(analysis_df)
For more information about the APIs, please refer to `Record Template API <../reference/api.html#module-qlib.workflow.record_temp>`_.
Known Limitations
=================
- The Python objects are saved based on pickle, which may results in issues when the environment dumping objects and loading objects are different.

View File

@@ -1,12 +1,13 @@
.. _report:
==========================================
Aanalysis: Evaluation & Results Analysis
==========================================
=======================================
Analysis: Evaluation & Results Analysis
=======================================
Introduction
===================
============
``Aanalysis`` is designed to show the graphical reports of ``Intraday Trading`` , which helps users to evaluate and analyse investment portfolios visually. The following are some graphics to view:
``Analysis`` is designed to show the graphical reports of ``Intraday Trading`` , which helps users to evaluate and analyse investment portfolios visually. The following are some graphics to view:
- analysis_position
- report_graph
@@ -19,8 +20,11 @@ Introduction
- model_performance_graph
All of the accumulated profit metrics(e.g. return, max drawdown) in Qlib are calculated by summation.
This avoids the metrics or the plots being skewed exponentially over time.
Graphical Reports
===================
=================
Users can run the following code to get all supported reports.
@@ -37,24 +41,25 @@ Users can run the following code to get all supported reports.
Usage & Example
===================
===============
Usage of `analysis_position.report`
-----------------------------------
API
~~~~~~~~~~~~~~~~
~~~
.. automodule:: qlib.contrib.report.analysis_position.report
:members:
:noindex:
Graphical Result
~~~~~~~~~~~~~~~~
.. note::
.. note::
- Axis X: Trading day
- Axis Y:
- Axis Y:
- `cum bench`
Cumulative returns series of benchmark
- `cum return wo cost`
@@ -78,34 +83,35 @@ Graphical Result
- The shaded part above: Maximum drawdown corresponding to `cum return wo cost`
- The shaded part below: Maximum drawdown corresponding to `cum ex return wo cost`
.. image:: ../_static/img/analysis/report.png
.. image:: ../_static/img/analysis/report.png
Usage of `analysis_position.score_ic`
-------------------------------------
API
~~~~~~~~~~~~~~~~
~~~
.. automodule:: qlib.contrib.report.analysis_position.score_ic
:members:
:noindex:
Graphical Result
~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~
.. note::
.. note::
- Axis X: Trading day
- Axis Y:
- Axis Y:
- `ic`
The `Pearson correlation coefficient` series between `label` and `prediction score`.
In the above example, the `label` is formulated as `Ref($close, -1)/$close - 1`. Please refer to `Data Featrue <data.html#feature>`_ for more details.
In the above example, the `label` is formulated as `Ref($close, -2)/Ref($close, -1)-1`. Please refer to `Data Feature <data.html#feature>`_ for more details.
- `rank_ic`
The `Spearman's rank correlation coefficient` series between `label` and `prediction score`.
.. image:: ../_static/img/analysis/score_ic.png
.. image:: ../_static/img/analysis/score_ic.png
.. Usage of `analysis_position.cumulative_return`
@@ -120,7 +126,7 @@ Graphical Result
.. Graphical Result
.. ~~~~~~~~~~~~~~~~~
..
.. .. note::
.. .. note::
..
.. - Axis X: Trading day
.. - Axis Y:
@@ -130,27 +136,28 @@ Graphical Result
.. - In the **buy_minus_sell** graph, the **y** value of the **weight** graph at the bottom is `buy_weight + sell_weight`.
.. - In each graph, the **red line** in the histogram on the right represents the average.
..
.. .. image:: ../_static/img/analysis/cumulative_return_buy.png
.. .. image:: ../_static/img/analysis/cumulative_return_buy.png
..
.. .. image:: ../_static/img/analysis/cumulative_return_sell.png
.. .. image:: ../_static/img/analysis/cumulative_return_sell.png
..
.. .. image:: ../_static/img/analysis/cumulative_return_buy_minus_sell.png
.. .. image:: ../_static/img/analysis/cumulative_return_buy_minus_sell.png
..
.. .. image:: ../_static/img/analysis/cumulative_return_hold.png
.. .. image:: ../_static/img/analysis/cumulative_return_hold.png
Usage of `analysis_position.risk_analysis`
----------------------------------------------
------------------------------------------
API
~~~~~~~~~~~~~~~~
~~~
.. automodule:: qlib.contrib.report.analysis_position.risk_analysis
:members:
:noindex:
Graphical Result
~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~
.. note::
@@ -170,6 +177,7 @@ Graphical Result
The `Information Ratio` without cost.
- `excess_return_with_cost`
The `Information Ratio` with cost.
To know more about `Information Ratio`, please refer to `Information Ratio IR <https://www.investopedia.com/terms/i/informationratio.asp>`_.
- `max_drawdown`
- `excess_return_without_cost`
@@ -206,7 +214,7 @@ Graphical Result
The `Standard Deviation` series of monthly `CAR` (cumulative abnormal return) without cost.
- `excess_return_with_cost_max_drawdown`
The `Standard Deviation` series of monthly `CAR` (cumulative abnormal return) with cost.
.. image:: ../_static/img/analysis/risk_analysis_annualized_return.png
:align: center
@@ -217,58 +225,59 @@ Graphical Result
.. image:: ../_static/img/analysis/risk_analysis_information_ratio.png
:align: center
.. image:: ../_static/img/analysis/risk_analysis_std.png
.. image:: ../_static/img/analysis/risk_analysis_std.png
:align: center
..
.. Usage of `analysis_position.rank_label`
.. ----------------------------------------------
.. ---------------------------------------
..
.. API
.. ~~~~~
.. ~~~
..
.. .. automodule:: qlib.contrib.report.analysis_position.rank_label
.. :members:
..
..
.. Graphical Result
.. ~~~~~~~~~~~~~~~~~
.. ~~~~~~~~~~~~~~~~
..
.. .. note::
.. .. note::
..
.. - hold/sell/buy graphics:
.. - Axis X: Trading day
.. - Axis Y:
.. - Axis Y:
.. Average `ranking ratio`of `label` for stocks that is held/sold/bought on the trading day.
..
.. In the above example, the `label` is formulated as `Ref($close, -1)/$close - 1`. The `ranking ratio` can be formulated as follows.
.. .. math::
..
..
.. ranking\ ratio = \frac{Ascending\ Ranking\ of\ label}{Number\ of\ Stocks\ in\ the\ Portfolio}
..
.. .. image:: ../_static/img/analysis/rank_label_hold.png
.. .. image:: ../_static/img/analysis/rank_label_hold.png
.. :align: center
..
.. .. image:: ../_static/img/analysis/rank_label_buy.png
.. .. image:: ../_static/img/analysis/rank_label_buy.png
.. :align: center
..
.. .. image:: ../_static/img/analysis/rank_label_sell.png
.. .. image:: ../_static/img/analysis/rank_label_sell.png
.. :align: center
..
..
Usage of `analysis_model.analysis_model_performance`
-----------------------------------------------------
----------------------------------------------------
API
~~~~~
~~~
.. automodule:: qlib.contrib.report.analysis_model.analysis_model_performance
:members:
:noindex:
Graphical Results
~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~
.. note::
@@ -287,13 +296,13 @@ Graphical Results
The Difference series between `Cumulative Return` of `Group1` and of `Group5`
- `long-average`
The Difference series between `Cumulative Return` of `Group1` and average `Cumulative Return` for all stocks.
The `ranking ratio` can be formulated as follows.
.. math::
ranking\ ratio = \frac{Ascending\ Ranking\ of\ label}{Number\ of\ Stocks\ in\ the\ Portfolio}
.. image:: ../_static/img/analysis/analysis_model_cumulative_return.png
.. image:: ../_static/img/analysis/analysis_model_cumulative_return.png
:align: center
.. note::
@@ -301,7 +310,7 @@ Graphical Results
The distribution of long-short/long-average returns on each trading day
.. image:: ../_static/img/analysis/analysis_model_long_short.png
.. image:: ../_static/img/analysis/analysis_model_long_short.png
:align: center
.. TODO: ask xiao yang for detial
@@ -311,14 +320,14 @@ Graphical Results
- The `Pearson correlation coefficient` series between `labels` and `prediction scores` of stocks in portfolio.
- The graphics reports can be used to evaluate the `prediction scores`.
.. image:: ../_static/img/analysis/analysis_model_IC.png
.. image:: ../_static/img/analysis/analysis_model_IC.png
:align: center
.. note::
- Monthly IC
Monthly average of the `Information Coefficient`
.. image:: ../_static/img/analysis/analysis_model_monthly_IC.png
.. image:: ../_static/img/analysis/analysis_model_monthly_IC.png
:align: center
.. note::
@@ -327,14 +336,14 @@ Graphical Results
- IC Normal Dist. Q-Q
The `Quantile-Quantile Plot` is used for the normal distribution of `Information Coefficient` on each trading day.
.. image:: ../_static/img/analysis/analysis_model_NDQ.png
.. image:: ../_static/img/analysis/analysis_model_NDQ.png
:align: center
.. note::
- Auto Correlation
- The `Pearson correlation coefficient` series between the latest `prediction scores` and the `prediction scores` `lag` days ago of stocks in portfolio on each trading day.
- The `Pearson correlation coefficient` series between the latest `prediction scores` and the `prediction scores` `lag` days ago of stocks in portfolio on each trading day.
- The graphics reports can be used to estimate the turnover rate.
.. image:: ../_static/img/analysis/analysis_model_auto_correlation.png
.. image:: ../_static/img/analysis/analysis_model_auto_correlation.png
:align: center

View File

@@ -0,0 +1,49 @@
The Framework of QlibRL
=======================
QlibRL contains a full set of components that cover the entire lifecycle of an RL pipeline, including building the simulator of the market, shaping states & actions, training policies (strategies), and backtesting strategies in the simulated environment.
QlibRL is basically implemented with the support of Tianshou and Gym frameworks. The high-level structure of QlibRL is demonstrated below:
.. image:: ../../_static/img/QlibRL_framework.png
:width: 600
:align: center
Here, we briefly introduce each component in the figure.
EnvWrapper
------------
EnvWrapper is the complete capsulation of the simulated environment. It receives actions from outside (policy/strategy/agent), simulates the changes in the market, and then replies rewards and updated states, thus forming an interaction loop.
In QlibRL, EnvWrapper is a subclass of gym.Env, so it implements all necessary interfaces of gym.Env. Any classes or pipelines that accept gym.Env should also accept EnvWrapper. Developers do not need to implement their own EnvWrapper to build their own environment. Instead, they only need to implement 4 components of the EnvWrapper:
- `Simulator`
The simulator is the core component responsible for the environment simulation. Developers could implement all the logic that is directly related to the environment simulation in the Simulator in any way they like. In QlibRL, there are already two implementations of Simulator for single asset trading: 1) ``SingleAssetOrderExecution``, which is built based on Qlib's backtest toolkits and hence considers a lot of practical trading details but is slow. 2) ``SimpleSingleAssetOrderExecution``, which is built based on a simplified trading simulator, which ignores a lot of details (e.g. trading limitations, rounding) but is quite fast.
- `State interpreter`
The state interpreter is responsible for "interpret" states in the original format (format provided by the simulator) into states in a format that the policy could understand. For example, transform unstructured raw features into numerical tensors.
- `Action interpreter`
The action interpreter is similar to the state interpreter. But instead of states, it interprets actions generated by the policy, from the format provided by the policy to the format that is acceptable to the simulator.
- `Reward function`
The reward function returns a numerical reward to the policy after each time the policy takes an action.
EnvWrapper will organically organize these components. Such decomposition allows for better flexibility in development. For example, if the developers want to train multiple types of policies in the same environment, they only need to design one simulator and design different state interpreters/action interpreters/reward functions for different types of policies.
QlibRL has well-defined base classes for all these 4 components. All the developers need to do is define their own components by inheriting the base classes and then implementing all interfaces required by the base classes. The API for the above base components can be found `here <../../reference/api.html#module-qlib.rl>`__.
Policy
------------
QlibRL directly uses Tianshou's policy. Developers could use policies provided by Tianshou off the shelf, or implement their own policies by inheriting Tianshou's policies.
Training Vessel & Trainer
-------------------------
As stated by their names, training vessels and trainers are helper classes used in training. A training vessel is a ship that contains a simulator/interpreters/reward function/policy, and it controls algorithm-related parts of training. Correspondingly, the trainer is responsible for controlling the runtime parts of training.
As you may have noticed, a training vessel itself holds all the required components to build an EnvWrapper rather than holding an instance of EnvWrapper directly. This allows the training vessel to create duplicates of EnvWrapper dynamically when necessary (for example, under parallel training).
With a training vessel, the trainer could finally launch the training pipeline by simple, Scikit-learn-like interfaces (i.e., ``trainer.fit()``).
The API for Trainer and TrainingVessel and can be found `here <../../reference/api.html#module-qlib.rl.trainer>`__.
The RL module is designed in a loosely-coupled way. Currently, RL examples are integrated with concrete business logic.
But the core part of RL is much simpler than what you see.
To demonstrate the simple core of RL, `a dedicated notebook <https://github.com/microsoft/qlib/tree/main/examples/rl/simple_example.ipynb>`__ for RL without business loss is created.

View File

@@ -0,0 +1,32 @@
========
Guidance
========
.. currentmodule:: qlib
QlibRL can help users quickly get started and conveniently implement quantitative strategies based on reinforcement learning(RL) algorithms. For different user groups, we recommend the following guidance to use QlibRL.
Beginners to Reinforcement Learning Algorithms
==============================================
Whether you are a quantitative researcher who wants to understand what RL can do in trading or a learner who wants to get started with RL algorithms in trading scenarios, if you have limited knowledge of RL and want to shield various detailed settings to quickly get started with RL algorithms, we recommend the following sequence to learn qlibrl:
- Learn the fundamentals of RL in `part1 <https://qlib.readthedocs.io/en/latest/component/rl/overall.html#reinforcement-learning>`_.
- Understand the trading scenarios where RL methods can be applied in `part2 <https://qlib.readthedocs.io/en/latest/component/rl/overall.html#potential-application-scenarios-in-quantitative-trading>`_.
- Run the examples in `part3 <https://qlib.readthedocs.io/en/latest/component/rl/quickstart.html>`_ to solve trading problems using RL.
- If you want to further explore QlibRL and make some customizations, you need to first understand the framework of QlibRL in `part4 <https://qlib.readthedocs.io/en/latest/component/rl/framework.html>`_ and rewrite specific components according to your needs.
Reinforcement Learning Algorithm Researcher
==============================================
If you are already familiar with existing RL algorithms and dedicated to researching RL algorithms but lack domain knowledge in the financial field, and you want to validate the effectiveness of your algorithms in financial trading scenarios, we recommend the following steps to get started with QlibRL:
- Understand the trading scenarios where RL methods can be applied in `part2 <https://qlib.readthedocs.io/en/latest/component/rl/overall.html#potential-application-scenarios-in-quantitative-trading>`_.
- Choose an RL application scenario (currently, QlibRL has implemented two scenario examples: order execution and algorithmic trading). Run the example in `part3 <https://qlib.readthedocs.io/en/latest/component/rl/quickstart.html>`_ to get it working.
- Modify the `policy <https://github.com/microsoft/qlib/blob/main/qlib/rl/order_execution/policy.py>`_ part to incorporate your own RL algorithm.
Quantitative Researcher
=======================
If you have a certain level of financial domain knowledge and coding skills, and you want to explore the application of RL algorithms in the investment field, we recommend the following steps to explore QlibRL:
- Learn the fundamentals of RL in `part1 <https://qlib.readthedocs.io/en/latest/component/rl/overall.html#reinforcement-learning>`_.
- Understand the trading scenarios where RL methods can be applied in `part2 <https://qlib.readthedocs.io/en/latest/component/rl/overall.html#potential-application-scenarios-in-quantitative-trading>`_.
- Run the examples in `part3 <https://qlib.readthedocs.io/en/latest/component/rl/quickstart.html>`_ to solve trading problems using RL.
- Understand the framework of QlibRL in `part4 <https://qlib.readthedocs.io/en/latest/component/rl/framework.html>`_.
- Choose a suitable RL algorithm based on the characteristics of the problem you want to solve (currently, QlibRL supports PPO and DQN algorithms based on tianshou).
- Design the MDP (Markov Decision Process) process based on market trading rules and the problem you want to solve. Refer to the example in order execution and make corresponding modifications to the following modules: `State <https://github.com/microsoft/qlib/blob/main/qlib/rl/order_execution/state.py#L70>`_, `Metrics <https://github.com/microsoft/qlib/blob/main/qlib/rl/order_execution/state.py#L18>`_, `ActionInterpreter <https://github.com/microsoft/qlib/blob/main/qlib/rl/order_execution/interpreter.py#L199>`_, `StateInterpreter <https://github.com/microsoft/qlib/blob/main/qlib/rl/order_execution/interpreter.py#L68>`_, `Reward <https://github.com/microsoft/qlib/blob/main/qlib/rl/order_execution/reward.py>`_, `Observation <https://github.com/microsoft/qlib/blob/main/qlib/rl/order_execution/interpreter.py#L44>`_, `Simulator <https://github.com/microsoft/qlib/blob/main/qlib/rl/order_execution/simulator_simple.py>`_.

View File

@@ -0,0 +1,70 @@
=====================================================
Reinforcement Learning in Quantitative Trading
=====================================================
Reinforcement Learning
======================
Different from supervised learning tasks such as classification tasks and regression tasks. Another important paradigm in machine learning is Reinforcement Learning(RL),
which attempts to optimize an accumulative numerical reward signal by directly interacting with the environment under a few assumptions such as Markov Decision Process(MDP).
As demonstrated in the following figure, an RL system consists of four elements, 1)the agent 2) the environment the agent interacts with 3) the policy that the agent follows to take actions on the environment and 4)the reward signal from the environment to the agent.
In general, the agent can perceive and interpret its environment, take actions and learn through reward, to seek long-term and maximum overall reward to achieve an optimal solution.
.. image:: ../../_static/img/RL_framework.png
:width: 300
:align: center
RL attempts to learn to produce actions by trial and error.
By sampling actions and then observing which one leads to our desired outcome, a policy is obtained to generate optimal actions.
In contrast to supervised learning, RL learns this not from a label but from a time-delayed label called a reward.
This scalar value lets us know whether the current outcome is good or bad.
In a word, the target of RL is to take actions to maximize reward.
The Qlib Reinforcement Learning toolkit (QlibRL) is an RL platform for quantitative investment, which provides support to implement the RL algorithms in Qlib.
Potential Application Scenarios in Quantitative Trading
=======================================================
RL methods have demonstrated remarkable achievements in various applications, including game playing, resource allocation, recommendation systems, marketing, and advertising.
In the context of investment, which involves continuous decision-making, let's consider the example of the stock market. Investors strive to optimize their investment returns by effectively managing their positions and stock holdings through various buying and selling behaviors.
Furthermore, investors carefully evaluate market conditions and stock-specific information before making each buying or selling decision. From an investor's perspective, this process can be viewed as a continuous decision-making process driven by interactions with the market. RL algorithms offer a promising approach to tackle such challenges.
Here are several scenarios where RL holds potential for application in quantitative investment.
Order Execution
---------------
The order execution task is to execute orders efficiently while considering multiple factors, including optimal prices, minimizing trading costs, reducing market impact, maximizing order fullfill rates, and achieving execution within a specified time frame. RL can be applied to such tasks by incorporating these objectives into the reward function and action selection process. Specifically, the RL agent interacts with the market environment, observes the state from market information, and makes decisions on next step execution. The RL algorithm learns an optimal execution strategy through trial and error, aiming to maximize the expected cumulative reward, which incorporates the desired objectives.
- General Setting
- Environment: The environment represents the financial market where order execution takes place. It encompasses variables such as the order book dynamics, liquidity, price movements, and market conditions.
- State: The state refers to the information available to the RL agent at a given time step. It typically includes features such as the current order book state (bid-ask spread, order depth), historical price data, historical trading volume, market volatility, and any other relevant information that can aid in decision-making.
- Action: The action is the decision made by the RL agent based on the observed state. In order execution, actions can include selecting the order size, price, and timing of execution.
- Reward: The reward is a scalar signal that indicates the performance of the RL agent's action in the environment. The reward function is designed to encourage actions that lead to efficient and cost-effective order execution. It typically considers multiple objectives, such as maximizing price advantages, minimizing trading costs (including transaction fees and slippage), reducing market impact (the effect of the order on the market price) and maximizing order fullfill rates.
- Scenarios
- Single-asset order execution: Single-asset order execution focuses on the task of executing a single order for a specific asset, such as a stock or a cryptocurrency. The primary objective is to execute the order efficiently while considering factors such as maximizing price advantages, minimizing trading costs, reducing market impact, and achieving a high fullfill rate. The RL agent interacts with the market environment and makes decisions on order size, price, and timing of execution for that particular asset. The goal is to learn an optimal execution strategy for the single asset, maximizing the expected cumulative reward while considering the specific dynamics and characteristics of that asset.
- Multi-asset order execution: Multi-asset order execution expands the order execution task to involve multiple assets or securities. It typically involves executing a portfolio of orders across different assets simultaneously or sequentially. Unlike single-asset order execution, the focus is not only on the execution of individual orders but also on managing the interactions and dependencies between different assets within the portfolio. The RL agent needs to make decisions on the order sizes, prices, and timings for each asset in the portfolio, considering their interdependencies, cash constraints, market conditions, and transaction costs. The goal is to learn an optimal execution strategy that balances the execution efficiency for each asset while considering the overall performance and objectives of the portfolio as a whole.
The choice of settings and RL algorithm depends on the specific requirements of the task, available data, and desired performance objectives.
Portfolio Construction
----------------------
Portfolio construction is a process of selecting and allocating assets in an investment portfolio. RL provides a framework to optimize portfolio management decisions by learning from interactions with the market environment and maximizing long-term returns while considering risk management.
- General Setting
- State: The state represents the current information about the market and the portfolio. It typically includes historical prices and volumes, technical indicators, and other relevant data.
- Action: The action corresponds to the decision of allocating capital to different assets in the portfolio. It determines the weights or proportions of investments in each asset.
- Reward: The reward is a metric that evaluates the performance of the portfolio. It can be defined in various ways, such as total return, risk-adjusted return, or other objectives like maximizing Sharpe ratio or minimizing drawdown.
- Scenarios
- Stock market: RL can be used to construct portfolios of stocks, where the agent learns to allocate capital among different stocks.
- Cryptocurrency market: RL can be applied to construct portfolios of cryptocurrencies, where the agent learns to make allocation decisions.
- Foreign exchange (Forex) market: RL can be used to construct portfolios of currency pairs, where the agent learns to allocate capital across different currencies based on exchange rate data, economic indicators, and other factors.
Similarly, the choice of basic setting and algorithm depends on the specific requirements of the problem and the characteristics of the market.

View File

@@ -0,0 +1,175 @@
Quick Start
============
.. currentmodule:: qlib
QlibRL provides an example of an implementation of a single asset order execution task and the following is an example of the config file to train with QlibRL.
.. code-block:: yaml
simulator:
# Each step contains 30mins
time_per_step: 30
# Upper bound of volume, should be null or a float between 0 and 1, if it is a float, represent upper bound is calculated by the percentage of the market volume
vol_limit: null
env:
# Concurrent environment workers.
concurrency: 1
# dummy or subproc or shmem. Corresponding to `parallelism in tianshou <https://tianshou.readthedocs.io/en/master/api/tianshou.env.html#vectorenv>`_.
parallel_mode: dummy
action_interpreter:
class: CategoricalActionInterpreter
kwargs:
# Candidate actions, it can be a list with length L: [a_1, a_2,..., a_L] or an integer n, in which case the list of length n+1 is auto-generated, i.e., [0, 1/n, 2/n,..., n/n].
values: 14
# Total number of steps (an upper-bound estimation)
max_step: 8
module_path: qlib.rl.order_execution.interpreter
state_interpreter:
class: FullHistoryStateInterpreter
kwargs:
# Number of dimensions in data.
data_dim: 6
# Equal to the total number of records. For example, in SAOE per minute, data_ticks is the length of the day in minutes.
data_ticks: 240
# The total number of steps (an upper-bound estimation). For example, 390min / 30min-per-step = 13 steps.
max_step: 8
# Provider of the processed data.
processed_data_provider:
class: PickleProcessedDataProvider
module_path: qlib.rl.data.pickle_styled
kwargs:
data_dir: ./data/pickle_dataframe/feature
module_path: qlib.rl.order_execution.interpreter
reward:
class: PAPenaltyReward
kwargs:
# The penalty for a large volume in a short time.
penalty: 100.0
module_path: qlib.rl.order_execution.reward
data:
source:
order_dir: ./data/training_order_split
data_dir: ./data/pickle_dataframe/backtest
# number of time indexes
total_time: 240
# start time index
default_start_time: 0
# end time index
default_end_time: 240
proc_data_dim: 6
num_workers: 0
queue_size: 20
network:
class: Recurrent
module_path: qlib.rl.order_execution.network
policy:
class: PPO
kwargs:
lr: 0.0001
module_path: qlib.rl.order_execution.policy
runtime:
seed: 42
use_cuda: false
trainer:
max_epoch: 2
# Number of episodes collected in each training iteration
repeat_per_collect: 5
earlystop_patience: 2
# Episodes per collect at training.
episode_per_collect: 20
batch_size: 16
# Perform validation every n iterations
val_every_n_epoch: 1
checkpoint_path: ./checkpoints
checkpoint_every_n_iters: 1
And the config file for backtesting:
.. code-block:: yaml
order_file: ./data/backtest_orders.csv
start_time: "9:45"
end_time: "14:44"
qlib:
provider_uri_1min: ./data/bin
feature_root_dir: ./data/pickle
# feature generated by today's information
feature_columns_today: [
"$open", "$high", "$low", "$close", "$vwap", "$volume",
]
# feature generated by yesterday's information
feature_columns_yesterday: [
"$open_v1", "$high_v1", "$low_v1", "$close_v1", "$vwap_v1", "$volume_v1",
]
exchange:
# the expression for buying and selling stock limitation
limit_threshold: ['$close == 0', '$close == 0']
# deal price for buying and selling
deal_price: ["If($close == 0, $vwap, $close)", "If($close == 0, $vwap, $close)"]
volume_threshold:
# volume limits are both buying and selling, "cum" means that this is a cumulative value over time
all: ["cum", "0.2 * DayCumsum($volume, '9:45', '14:44')"]
# the volume limits of buying
buy: ["current", "$close"]
# the volume limits of selling, "current" means that this is a real-time value and will not accumulate over time
sell: ["current", "$close"]
strategies:
30min:
class: TWAPStrategy
module_path: qlib.contrib.strategy.rule_strategy
kwargs: {}
1day:
class: SAOEIntStrategy
module_path: qlib.rl.order_execution.strategy
kwargs:
state_interpreter:
class: FullHistoryStateInterpreter
module_path: qlib.rl.order_execution.interpreter
kwargs:
max_step: 8
data_ticks: 240
data_dim: 6
processed_data_provider:
class: PickleProcessedDataProvider
module_path: qlib.rl.data.pickle_styled
kwargs:
data_dir: ./data/pickle_dataframe/feature
action_interpreter:
class: CategoricalActionInterpreter
module_path: qlib.rl.order_execution.interpreter
kwargs:
values: 14
max_step: 8
network:
class: Recurrent
module_path: qlib.rl.order_execution.network
kwargs: {}
policy:
class: PPO
module_path: qlib.rl.order_execution.policy
kwargs:
lr: 1.0e-4
# Local path to the latest model. The model is generated during training, so please run training first if you want to run backtest with a trained policy. You could also remove this parameter file to run backtest with a randomly initialized policy.
weight_file: ./checkpoints/latest.pth
# Concurrent environment workers.
concurrency: 5
With the above config files, you can start training the agent by the following command:
.. code-block:: console
$ python -m qlib.rl.contrib.train_onpolicy.py --config_path train_config.yml
After the training, you can backtest with the following command:
.. code-block:: console
$ python -m qlib.rl.contrib.backtest.py --config_path backtest_config.yml
In that case, :class:`~qlib.rl.order_execution.simulator_qlib.SingleAssetOrderExecution` and :class:`~qlib.rl.order_execution.simulator_simple.SingleAssetOrderExecutionSimple` as examples for simulator, :class:`qlib.rl.order_execution.interpreter.FullHistoryStateInterpreter` and :class:`qlib.rl.order_execution.interpreter.CategoricalActionInterpreter` as examples for interpreter, :class:`qlib.rl.order_execution.policy.PPO` as an example for policy, and :class:`qlib.rl.order_execution.reward.PAPenaltyReward` as an example for reward.
For the single asset order execution task, if developers have already defined their simulator/interpreters/reward function/policy, they could launch the training and backtest pipeline by simply modifying the corresponding settings in the config files.
The details about the example can be found `here <https://github.com/microsoft/qlib/blob/main/examples/rl/README.md>`_.
In the future, we will provide more examples for different scenarios such as RL-based portfolio construction.

View File

@@ -0,0 +1,11 @@
.. _rl:
========================================================================
Reinforcement Learning in Quantitative Trading
========================================================================
.. toctree::
Guidance <guidance>
Overall <overall>
Quick Start <quickstart>
Framework <framework>

View File

@@ -1,43 +1,46 @@
.. _strategy:
========================================
Interday Strategy: Portfolio Management
Portfolio Strategy: Portfolio Management
========================================
.. currentmodule:: qlib
Introduction
===================
============
``Interday Strategy`` is designed to adopt different trading strategies, which means that users can adopt different algorithms to generate investment portfolios based on the prediction scores of the ``Interday Model``. Users can use the ``Interday Strategy`` in an automatic workflow by ``Estimator``, please refer to `Estimator: Workflow Management <estimator.html>`_.
``Portfolio Strategy`` is designed to adopt different portfolio strategies, which means that users can adopt different algorithms to generate investment portfolios based on the prediction scores of the ``Forecast Model``. Users can use the ``Portfolio Strategy`` in an automatic workflow by ``Workflow`` module, please refer to `Workflow: Workflow Management <workflow.html>`_.
Because the components in ``Qlib`` are designed in a loosely-coupled way, ``Interday Strategy`` can be used as an independent module also.
Because the components in ``Qlib`` are designed in a loosely-coupled way, ``Portfolio Strategy`` can be used as an independent module also.
``Qlib`` provides several implemented trading strategies. Also, ``Qlib`` supports custom strategy, users can customize strategies according to their own needs.
``Qlib`` provides several implemented portfolio strategies. Also, ``Qlib`` supports custom strategy, users can customize strategies according to their own requirements.
After users specifying the models(forecasting signals) and strategies, running backtest will help users to check the performance of a custom model(forecasting signals)/strategy.
Base Class & Interface
======================
BaseStrategy
------------------
------------
Qlib provides a base class ``qlib.contrib.strategy.BaseStrategy``. All strategy classes need to inherit the base class and implement its interface.
Qlib provides a base class ``qlib.strategy.base.BaseStrategy``. All strategy classes need to inherit the base class and implement its interface.
- `get_risk_degree`
Return the proportion of your total value you will use in investment. Dynamically risk_degree will result in Market timing.
- `generate_order_list`
Rerturn the order list.
- `generate_trade_decision`
generate_trade_decision is a key interface that generates trade decisions in each trading bar.
The frequency to call this method depends on the executor frequency("time_per_step"="day" by default). But the trading frequency can be decided by users' implementation.
For example, if the user wants to trading in weekly while the `time_per_step` is "day" in executor, user can return non-empty TradeDecision weekly(otherwise return empty like `this <https://github.com/microsoft/qlib/blob/main/qlib/contrib/strategy/signal_strategy.py#L132>`_ ).
Users can inherit `BaseStrategy` to customize their strategy class.
WeightStrategyBase
--------------------
------------------
Qlib alse provides a class ``qlib.contrib.strategy.WeightStrategyBase`` that is a subclass of `BaseStrategy`.
Qlib also provides a class ``qlib.contrib.strategy.WeightStrategyBase`` that is a subclass of `BaseStrategy`.
`WeightStrategyBase` only focuses on the target positions, and automatically generates an order list based on positions. It provides the `generate_target_weight_position` interface.
- `generate_target_weight_position`
- According to the current position and trading date to generate the target position. The cash is not considered.
- According to the current position and trading date to generate the target position. The cash is not considered in
the output weight distribution.
- Return the target position.
.. note::
@@ -57,64 +60,253 @@ Implemented Strategy
Qlib provides a implemented strategy classes named `TopkDropoutStrategy`.
TopkDropoutStrategy
------------------
-------------------
`TopkDropoutStrategy` is a subclass of `BaseStrategy` and implement the interface `generate_order_list` whose process is as follows.
- Adopt the ``Topk-Drop`` algorithm to calculate the target amount of each stock
.. note::
``Topk-Drop`` algorithm
There are two parameters for the ``Topk-Drop`` algorithm:
- `Topk`: The number of stocks held
- `Drop`: The number of stocks sold on each trading day
Currently, the number of held stocks is `Topk`.
On each trading day, the `Drop` number of held stocks with the worst `prediction score` will be sold, and the same number of unheld stocks with the best `prediction score` will be bought.
In general, the number of stocks currently held is `Topk`, with the exception of being zero at the beginning period of trading.
For each trading day, let $d$ be the number of the instruments currently held and with a rank $\gt K$ when ranked by the prediction scores from high to low.
Then `d` number of stocks currently held with the worst `prediction score` will be sold, and the same number of unheld stocks with the best `prediction score` will be bought.
In general, $d=$`Drop`, especially when the pool of the candidate instruments is large, $K$ is large, and `Drop` is small.
In most cases, ``TopkDrop`` algorithm sells and buys `Drop` stocks every trading day, which yields a turnover rate of 2$\times$`Drop`/$K$.
The following images illustrate a typical scenario.
.. image:: ../_static/img/topk_drop.png
:alt: Topk-Drop
``TopkDrop`` algorithm sells `Drop` stocks every trading day, which guarantees a fixed turnover rate.
- Generate the order list from the target amount
EnhancedIndexingStrategy
------------------------
`EnhancedIndexingStrategy` Enhanced indexing combines the arts of active management and passive management,
with the aim of outperforming a benchmark index (e.g., S&P 500) in terms of portfolio return while controlling
the risk exposure (a.k.a. tracking error).
For more information, please refer to `qlib.contrib.strategy.signal_strategy.EnhancedIndexingStrategy`
and `qlib.contrib.strategy.optimizer.enhanced_indexing.EnhancedIndexingOptimizer`.
Usage & Example
====================
``Interday Strategy`` can be specified in the ``Intraday Trading(Backtest)``, the example is as follows.
===============
First, user can create a model to get trading signals(the variable name is ``pred_score`` in following cases).
Prediction Score
----------------
The `prediction score` is a pandas DataFrame. Its index is <datetime(pd.Timestamp), instrument(str)> and it must
contains a `score` column.
A prediction sample is shown as follows.
.. code-block:: python
from qlib.contrib.strategy.strategy import TopkDropoutStrategy
from qlib.contrib.evaluate import backtest
STRATEGY_CONFIG = {
"topk": 50,
"n_drop": 5,
}
BACKTEST_CONFIG = {
"verbose": False,
"limit_threshold": 0.095,
"account": 100000000,
"benchmark": BENCHMARK,
"deal_price": "close",
"open_cost": 0.0005,
"close_cost": 0.0015,
"min_cost": 5,
}
# use default strategy
strategy = TopkDropoutStrategy(**STRATEGY_CONFIG)
datetime instrument score
2019-01-04 SH600000 -0.505488
2019-01-04 SZ002531 -0.320391
2019-01-04 SZ000999 0.583808
2019-01-04 SZ300569 0.819628
2019-01-04 SZ001696 -0.137140
... ...
2019-04-30 SZ000996 -1.027618
2019-04-30 SH603127 0.225677
2019-04-30 SH603126 0.462443
2019-04-30 SH603133 -0.302460
2019-04-30 SZ300760 -0.126383
# pred_score is the `prediction score` output by Model
report_normal, positions_normal = backtest(
pred_score, strategy=strategy, **BACKTEST_CONFIG
)
``Forecast Model`` module can make predictions, please refer to `Forecast Model: Model Training & Prediction <model.html>`_.
Also, the above example has been given in ``examples\train_backtest_analyze.ipynb``.
Normally, the prediction score is the output of the models. But some models are learned from a label with a different scale. So the scale of the prediction score may be different from your expectation(e.g. the return of instruments).
To know more about the `prediction score` `pred_score` output by ``Interday Model``, please refer to `Interday Model: Model Training & Prediction <model.html>`_.
Qlib didn't add a step to scale the prediction score to a unified scale due to the following reasons.
- Because not every trading strategy cares about the scale(e.g. TopkDropoutStrategy only cares about the order). So the strategy is responsible for rescaling the prediction score(e.g. some portfolio-optimization-based strategies may require a meaningful scale).
- The model has the flexibility to define the target, loss, and data processing. So we don't think there is a silver bullet to rescale it back directly barely based on the model's outputs. If you want to scale it back to some meaningful values(e.g. stock returns.), an intuitive solution is to create a regression model for the model's recent outputs and your recent target values.
Running backtest
----------------
- In most cases, users could backtest their portfolio management strategy with ``backtest_daily``.
.. code-block:: python
from pprint import pprint
import qlib
import pandas as pd
from qlib.utils.time import Freq
from qlib.utils import flatten_dict
from qlib.contrib.evaluate import backtest_daily
from qlib.contrib.evaluate import risk_analysis
from qlib.contrib.strategy import TopkDropoutStrategy
# init qlib
qlib.init(provider_uri=<qlib data dir>)
CSI300_BENCH = "SH000300"
STRATEGY_CONFIG = {
"topk": 50,
"n_drop": 5,
# pred_score, pd.Series
"signal": pred_score,
}
strategy_obj = TopkDropoutStrategy(**STRATEGY_CONFIG)
report_normal, positions_normal = backtest_daily(
start_time="2017-01-01", end_time="2020-08-01", strategy=strategy_obj
)
analysis = dict()
# default frequency will be daily (i.e. "day")
analysis["excess_return_without_cost"] = risk_analysis(report_normal["return"] - report_normal["bench"])
analysis["excess_return_with_cost"] = risk_analysis(report_normal["return"] - report_normal["bench"] - report_normal["cost"])
analysis_df = pd.concat(analysis) # type: pd.DataFrame
pprint(analysis_df)
- If users would like to control their strategies in a more detailed(e.g. users have a more advanced version of executor), user could follow this example.
.. code-block:: python
from pprint import pprint
import qlib
import pandas as pd
from qlib.utils.time import Freq
from qlib.utils import flatten_dict
from qlib.backtest import backtest, executor
from qlib.contrib.evaluate import risk_analysis
from qlib.contrib.strategy import TopkDropoutStrategy
# init qlib
qlib.init(provider_uri=<qlib data dir>)
CSI300_BENCH = "SH000300"
# Benchmark is for calculating the excess return of your strategy.
# Its data format will be like **ONE normal instrument**.
# For example, you can query its data with the code below
# `D.features(["SH000300"], ["$close"], start_time='2010-01-01', end_time='2017-12-31', freq='day')`
# It is different from the argument `market`, which indicates a universe of stocks (e.g. **A SET** of stocks like csi300)
# For example, you can query all data from a stock market with the code below.
# ` D.features(D.instruments(market='csi300'), ["$close"], start_time='2010-01-01', end_time='2017-12-31', freq='day')`
FREQ = "day"
STRATEGY_CONFIG = {
"topk": 50,
"n_drop": 5,
# pred_score, pd.Series
"signal": pred_score,
}
EXECUTOR_CONFIG = {
"time_per_step": "day",
"generate_portfolio_metrics": True,
}
backtest_config = {
"start_time": "2017-01-01",
"end_time": "2020-08-01",
"account": 100000000,
"benchmark": CSI300_BENCH,
"exchange_kwargs": {
"freq": FREQ,
"limit_threshold": 0.095,
"deal_price": "close",
"open_cost": 0.0005,
"close_cost": 0.0015,
"min_cost": 5,
},
}
# strategy object
strategy_obj = TopkDropoutStrategy(**STRATEGY_CONFIG)
# executor object
executor_obj = executor.SimulatorExecutor(**EXECUTOR_CONFIG)
# backtest
portfolio_metric_dict, indicator_dict = backtest(executor=executor_obj, strategy=strategy_obj, **backtest_config)
analysis_freq = "{0}{1}".format(*Freq.parse(FREQ))
# backtest info
report_normal, positions_normal = portfolio_metric_dict.get(analysis_freq)
# analysis
analysis = dict()
analysis["excess_return_without_cost"] = risk_analysis(
report_normal["return"] - report_normal["bench"], freq=analysis_freq
)
analysis["excess_return_with_cost"] = risk_analysis(
report_normal["return"] - report_normal["bench"] - report_normal["cost"], freq=analysis_freq
)
analysis_df = pd.concat(analysis) # type: pd.DataFrame
# log metrics
analysis_dict = flatten_dict(analysis_df["risk"].unstack().T.to_dict())
# print out results
pprint(f"The following are analysis results of benchmark return({analysis_freq}).")
pprint(risk_analysis(report_normal["bench"], freq=analysis_freq))
pprint(f"The following are analysis results of the excess return without cost({analysis_freq}).")
pprint(analysis["excess_return_without_cost"])
pprint(f"The following are analysis results of the excess return with cost({analysis_freq}).")
pprint(analysis["excess_return_with_cost"])
Result
------
The backtest results are in the following form:
.. code-block:: python
risk
excess_return_without_cost mean 0.000605
std 0.005481
annualized_return 0.152373
information_ratio 1.751319
max_drawdown -0.059055
excess_return_with_cost mean 0.000410
std 0.005478
annualized_return 0.103265
information_ratio 1.187411
max_drawdown -0.075024
- `excess_return_without_cost`
- `mean`
Mean value of the `CAR` (cumulative abnormal return) without cost
- `std`
The `Standard Deviation` of `CAR` (cumulative abnormal return) without cost.
- `annualized_return`
The `Annualized Rate` of `CAR` (cumulative abnormal return) without cost.
- `information_ratio`
The `Information Ratio` without cost. please refer to `Information Ratio IR <https://www.investopedia.com/terms/i/informationratio.asp>`_.
- `max_drawdown`
The `Maximum Drawdown` of `CAR` (cumulative abnormal return) without cost, please refer to `Maximum Drawdown (MDD) <https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp>`_.
- `excess_return_with_cost`
- `mean`
Mean value of the `CAR` (cumulative abnormal return) series with cost
- `std`
The `Standard Deviation` of `CAR` (cumulative abnormal return) series with cost.
- `annualized_return`
The `Annualized Rate` of `CAR` (cumulative abnormal return) with cost.
- `information_ratio`
The `Information Ratio` with cost. please refer to `Information Ratio IR <https://www.investopedia.com/terms/i/informationratio.asp>`_.
- `max_drawdown`
The `Maximum Drawdown` of `CAR` (cumulative abnormal return) with cost, please refer to `Maximum Drawdown (MDD) <https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp>`_.
To know more about ``Intraday Trading``, please refer to `Intraday Trading: Model&Strategy Testing <backtest.html>`_.
Reference
===================
To know more about ``Interday Strategy``, please refer to `Strategy API <../reference/api.html#module-qlib.contrib.strategy.strategy>`_.
=========
To know more about the `prediction score` `pred_score` output by ``Forecast Model``, please refer to `Forecast Model: Model Training & Prediction <model.html>`_.

307
docs/component/workflow.rst Normal file
View File

@@ -0,0 +1,307 @@
.. _workflow:
=============================
Workflow: Workflow Management
=============================
.. currentmodule:: qlib
Introduction
============
The components in `Qlib Framework <../introduction/introduction.html#framework>`_ are designed in a loosely-coupled way. Users could build their own Quant research workflow with these components like `Example <https://github.com/microsoft/qlib/blob/main/examples/workflow_by_code.py>`_.
Besides, ``Qlib`` provides more user-friendly interfaces named ``qrun`` to automatically run the whole workflow defined by configuration. Running the whole workflow is called an `execution`.
With ``qrun``, user can easily start an `execution`, which includes the following steps:
- Data
- Loading
- Processing
- Slicing
- Model
- Training and inference
- Saving & loading
- Evaluation
- Forecast signal analysis
- Backtest
For each `execution`, ``Qlib`` has a complete system to tracking all the information as well as artifacts generated during training, inference and evaluation phase. For more information about how ``Qlib`` handles this, please refer to the related document: `Recorder: Experiment Management <../component/recorder.html>`_.
Complete Example
================
Before getting into details, here is a complete example of ``qrun``, which defines the workflow in typical Quant research.
Below is a typical config file of ``qrun``.
.. code-block:: YAML
qlib_init:
provider_uri: "~/.qlib/qlib_data/cn_data"
region: cn
market: &market csi300
benchmark: &benchmark SH000300
data_handler_config: &data_handler_config
start_time: 2008-01-01
end_time: 2020-08-01
fit_start_time: 2008-01-01
fit_end_time: 2014-12-31
instruments: *market
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy.strategy
kwargs:
topk: 50
n_drop: 5
signal: <PRED>
backtest:
limit_threshold: 0.095
account: 100000000
benchmark: *benchmark
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: LGBModel
module_path: qlib.contrib.model.gbdt
kwargs:
loss: mse
colsample_bytree: 0.8879
learning_rate: 0.0421
subsample: 0.8789
lambda_l1: 205.6999
lambda_l2: 580.9768
max_depth: 8
num_leaves: 210
num_threads: 20
dataset:
class: DatasetH
module_path: qlib.data.dataset
kwargs:
handler:
class: Alpha158
module_path: qlib.contrib.data.handler
kwargs: *data_handler_config
segments:
train: [2008-01-01, 2014-12-31]
valid: [2015-01-01, 2016-12-31]
test: [2017-01-01, 2020-08-01]
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs: {}
- class: PortAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
config: *port_analysis_config
After saving the config into `configuration.yaml`, users could start the workflow and test their ideas with a single command below.
.. code-block:: bash
qrun configuration.yaml
If users want to use ``qrun`` under debug mode, please use the following command:
.. code-block:: bash
python -m pdb qlib/workflow/cli.py examples/benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml
.. note::
`qrun` will be placed in your $PATH directory when installing ``Qlib``.
.. note::
The symbol `&` in `yaml` file stands for an anchor of a field, which is useful when another fields include this parameter as part of the value. Taking the configuration file above as an example, users can directly change the value of `market` and `benchmark` without traversing the entire configuration file.
Configuration File
==================
Let's get into details of ``qrun`` in this section.
Before using ``qrun``, users need to prepare a configuration file. The following content shows how to prepare each part of the configuration file.
The design logic of the configuration file is very simple. It predefines fixed workflows and provide this yaml interface to users to define how to initialize each component.
It follow the design of `init_instance_by_config <https://github.com/microsoft/qlib/blob/2aee9e0145decc3e71def70909639b5e5a6f4b58/qlib/utils/__init__.py#L264>`_ . It defines the initialization of each component of Qlib, which typically include the class and the initialization arguments.
For example, the following yaml and code are equivalent.
.. code-block:: YAML
model:
class: LGBModel
module_path: qlib.contrib.model.gbdt
kwargs:
loss: mse
colsample_bytree: 0.8879
learning_rate: 0.0421
subsample: 0.8789
lambda_l1: 205.6999
lambda_l2: 580.9768
max_depth: 8
num_leaves: 210
num_threads: 20
.. code-block:: python
from qlib.contrib.model.gbdt import LGBModel
kwargs = {
"loss": "mse" ,
"colsample_bytree": 0.8879,
"learning_rate": 0.0421,
"subsample": 0.8789,
"lambda_l1": 205.6999,
"lambda_l2": 580.9768,
"max_depth": 8,
"num_leaves": 210,
"num_threads": 20,
}
LGBModel(kwargs)
Qlib Init Section
-----------------
At first, the configuration file needs to contain several basic parameters which will be used for qlib initialization.
.. code-block:: YAML
provider_uri: "~/.qlib/qlib_data/cn_data"
region: cn
The meaning of each field is as follows:
- `provider_uri`
Type: str. The URI of the Qlib data. For example, it could be the location where the data loaded by ``get_data.py`` are stored.
- `region`
- If `region` == "us", ``Qlib`` will be initialized in US-stock mode.
- If `region` == "cn", ``Qlib`` will be initialized in China-stock mode.
.. note::
The value of `region` should be aligned with the data stored in `provider_uri`.
Task Section
------------
The `task` field in the configuration corresponds to a `task`, which contains the parameters of three different subsections: `Model`, `Dataset` and `Record`.
Model Section
~~~~~~~~~~~~~
In the `task` field, the `model` section describes the parameters of the model to be used for training and inference. For more information about the base ``Model`` class, please refer to `Qlib Model <../component/model.html>`_.
.. code-block:: YAML
model:
class: LGBModel
module_path: qlib.contrib.model.gbdt
kwargs:
loss: mse
colsample_bytree: 0.8879
learning_rate: 0.0421
subsample: 0.8789
lambda_l1: 205.6999
lambda_l2: 580.9768
max_depth: 8
num_leaves: 210
num_threads: 20
The meaning of each field is as follows:
- `class`
Type: str. The name for the model class.
- `module_path`
Type: str. The path for the model in qlib.
- `kwargs`
The keywords arguments for the model. Please refer to the specific model implementation for more information: `models <https://github.com/microsoft/qlib/blob/main/qlib/contrib/model>`_.
.. note::
``Qlib`` provides a util named: ``init_instance_by_config`` to initialize any class inside ``Qlib`` with the configuration includes the fields: `class`, `module_path` and `kwargs`.
Dataset Section
~~~~~~~~~~~~~~~
The `dataset` field describes the parameters for the ``Dataset`` module in ``Qlib`` as well those for the module ``DataHandler``. For more information about the ``Dataset`` module, please refer to `Qlib Data <../component/data.html#dataset>`_.
The keywords arguments configuration of the ``DataHandler`` is as follows:
.. code-block:: YAML
data_handler_config: &data_handler_config
start_time: 2008-01-01
end_time: 2020-08-01
fit_start_time: 2008-01-01
fit_end_time: 2014-12-31
instruments: *market
Users can refer to the document of `DataHandler <../component/data.html#datahandler>`_ for more information about the meaning of each field in the configuration.
Here is the configuration for the ``Dataset`` module which will take care of data preprocessing and slicing during the training and testing phase.
.. code-block:: YAML
dataset:
class: DatasetH
module_path: qlib.data.dataset
kwargs:
handler:
class: Alpha158
module_path: qlib.contrib.data.handler
kwargs: *data_handler_config
segments:
train: [2008-01-01, 2014-12-31]
valid: [2015-01-01, 2016-12-31]
test: [2017-01-01, 2020-08-01]
Record Section
~~~~~~~~~~~~~~
The `record` field is about the parameters the ``Record`` module in ``Qlib``. ``Record`` is responsible for tracking training process and results such as `information Coefficient (IC)` and `backtest` in a standard format.
The following script is the configuration of `backtest` and the `strategy` used in `backtest`:
.. code-block:: YAML
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy.strategy
kwargs:
topk: 50
n_drop: 5
signal: <PRED>
backtest:
limit_threshold: 0.095
account: 100000000
benchmark: *benchmark
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
For more information about the meaning of each field in configuration of `strategy` and `backtest`, users can look up the documents: `Strategy <../component/strategy.html>`_ and `Backtest <../component/backtest.html>`_.
Here is the configuration details of different `Record Template` such as ``SignalRecord`` and ``PortAnaRecord``:
.. code-block:: YAML
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs: {}
- class: PortAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
config: *port_analysis_config
For more information about the ``Record`` module in ``Qlib``, user can refer to the related document: `Record <../component/recorder.html#record-template>`_.

View File

@@ -53,11 +53,10 @@ source_suffix = ".rst"
master_doc = "index"
# General information about the project.
project = u"QLib"
copyright = u"Microsoft"
author = u"Microsoft"
project = "QLib"
copyright = "Microsoft"
author = "Microsoft"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -78,7 +77,7 @@ language = "en_US"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "hidden"]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
@@ -104,8 +103,7 @@ todo_include_todos = True
#
html_theme = "sphinx_rtd_theme"
html_logo = '_static/img/logo/1.png'
html_logo = "_static/img/logo/1.png"
# Theme options are theme-specific and customize the look and feel of a theme
@@ -126,7 +124,7 @@ html_theme_options = {
"logo_only": True,
"collapse_navigation": False,
"display_version": False,
"navigation_depth": 3,
"navigation_depth": 4,
}
# Add any paths that contain custom static files (such as style sheets) here,
@@ -161,15 +159,12 @@ latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
@@ -179,7 +174,7 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "qlib.tex", u"QLib Documentation", u"Microsoft", "manual"),
(master_doc, "qlib.tex", "QLib Documentation", "Microsoft", "manual"),
]
@@ -187,7 +182,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "qlib", u"QLib Documentation", [author], 1)]
man_pages = [(master_doc, "qlib", "QLib Documentation", [author], 1)]
# -- Options for Texinfo output -------------------------------------------
@@ -199,7 +194,7 @@ texinfo_documents = [
(
master_doc,
"QLib",
u"QLib Documentation",
"QLib Documentation",
author,
"QLib",
"One line description of project.",
@@ -231,3 +226,8 @@ epub_exclude_files = ["search.html"]
autodoc_member_order = "bysource"
autodoc_default_flags = ["members"]
autodoc_default_options = {
"members": True,
"member-order": "bysource",
"special-members": "__init__",
}

View File

@@ -0,0 +1,63 @@
.. _code_standard:
=============
Code Standard
=============
Docstring
=========
Please use the `Numpydoc Style <https://stackoverflow.com/a/24385103>`_.
Continuous Integration
======================
Continuous Integration (CI) tools help you stick to the quality standards by running tests every time you push a new commit and reporting the results to a pull request.
When you submit a PR request, you can check whether your code passes the CI tests in the "check" section at the bottom of the web page.
1. Qlib will check the code format with black. The PR will raise error if your code does not align to the standard of Qlib(e.g. a common error is the mixed use of space and tab).
You can fix the bug by inputting the following code in the command line.
.. code-block:: bash
pip install black
python -m black . -l 120
2. Qlib will check your code style pylint. The checking command is implemented in [github action workflow](https://github.com/microsoft/qlib/blob/0e8b94a552f1c457cfa6cd2c1bb3b87ebb3fb279/.github/workflows/test.yml#L66).
Sometime pylint's restrictions are not that reasonable. You can ignore specific errors like this
.. code-block:: python
return -ICLoss()(pred, target, index) # pylint: disable=E1130
3. Qlib will check your code style flake8. The checking command is implemented in [github action workflow](https://github.com/microsoft/qlib/blob/0e8b94a552f1c457cfa6cd2c1bb3b87ebb3fb279/.github/workflows/test.yml#L73).
You can fix the bug by inputing the following code in the command line.
.. code-block:: bash
flake8 --ignore E501,F541,E402,F401,W503,E741,E266,E203,E302,E731,E262,F523,F821,F811,F841,E713,E265,W291,E712,E722,W293 qlib
4. Qlib has integrated pre-commit, which will make it easier for developers to format their code.
Just run the following two commands, and the code will be automatically formatted using black and flake8 when the git commit command is executed.
.. code-block:: bash
pip install -e .[dev]
pre-commit install
=================================
Development Guidance
=================================
As a developer, you often want make changes to `Qlib` and hope it would reflect directly in your environment without reinstalling it. You can install `Qlib` in editable mode with following command.
The `[dev]` option will help you to install some related packages when developing `Qlib` (e.g. pytest, sphinx)
.. code-block:: bash
pip install -e .[dev]

View File

@@ -1,12 +1,12 @@
.. _client:
Qlib Client-Server Framework
===================
============================
.. currentmodule:: qlib
Introduction
-----------
------------
Client-Server is designed to solve following problems
- Manage the data in a centralized way. Users don't have to manage data of different versions.
@@ -81,6 +81,7 @@ If running on Windows, open **NFS** features and write correct **mount_path**, i
* Open ``Programs and Features``.
* Click ``Turn Windows features on or off``.
* Scroll down and check the option ``Services for NFS``, then click OK
Reference address: https://graspingtech.com/mount-nfs-share-windows-10/
2.config correct mount_path
* In windows, mount path must be not exist path and root path,
@@ -159,13 +160,11 @@ Limitations
2. The rolling operation expression with parameter `0` can not be updated rightly under mechanism of the client-server framework.
API
********************
***
The client is based on `python-socketio<https://python-socketio.readthedocs.io>`_ which is a framework that supports WebSocket client for Python language. The client can only propose requests and receive results, which do not include any calculating procedure.
The client is based on `python-socketio <https://python-socketio.readthedocs.io>`_ which is a framework that supports WebSocket client for Python language. The client can only propose requests and receive results, which do not include any calculating procedure.
Class
--------------------
-----
.. automodule:: qlib.data.client

View File

@@ -1,11 +1,11 @@
.. _online:
Online
===================
======
.. currentmodule:: qlib
Introduction
-------------------
------------
Welcome to use Online, this module simulates what will be like if we do the real trading use our model and strategy.
@@ -31,11 +31,11 @@ The file structure can be viewed at fileStruct_.
Example
-------------------
-------
Let's take an example,
.. note:: Make sure you have the latest version of `qlib` installed.
.. note:: Make sure you have the latest version of `qlib` installed.
If you want to use the models and data provided by `qlib`, you only need to do as follows.
@@ -93,7 +93,7 @@ If Your account was saved in "./user_data/", you can see the performance of your
Here 'SH000905' represents csi500 and 'SH000300' represents csi300
Manage your account
--------------------
-------------------
Any account processed by `online` should be saved in a folder. you can use commands
defined to manage your accounts.
@@ -161,7 +161,7 @@ be called at each trading date.
>> online update -date 2019-10-16 -path ./user_data/
API
------------------
---
All those operations are based on defined in `qlib.contrib.online.operator`
@@ -170,7 +170,7 @@ All those operations are based on defined in `qlib.contrib.online.operator`
.. _fileStruct:
File structure
------------------
--------------
'user_data' indicates the root of folder.
Name that bold indicates its a folder, otherwise its a document.
@@ -214,7 +214,7 @@ Configuration file
The configure file used in `online` should contain the model and strategy information.
About the model
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~
First, your configuration file needs to have a field about the model,
this field and its contents determine the model we used when generating score at predict date.
@@ -243,7 +243,7 @@ contains 2 methods used in `online` module.
About the strategy
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~
Your need define the strategy used to generate the order list at predict date.
@@ -259,7 +259,7 @@ Followings are two examples for a TopkAmountStrategy
n_drop: 10
Generated files
------------------
---------------
The 'online_generate' command will create the order list at {folder_path}/{user_id}/temp/,
the name of that is orderlist_{YYYY-MM-DD}.json, YYYY-MM-DD is the date that those orders to be executed.

View File

@@ -1,11 +1,11 @@
.. _tuner:
Tuner
===================
=====
.. currentmodule:: qlib
Introduction
-------------------
------------
Welcome to use Tuner, this document is based on that you can use Estimator proficiently and correctly.
@@ -31,7 +31,7 @@ Let's see an example,
First make sure you have the latest version of `qlib` installed.
Then, you need to privide a configuration to setup the experiment.
Then, you need to provide a configuration to setup the experiment.
We write a simple configuration example as following,
.. code-block:: YAML
@@ -41,19 +41,19 @@ We write a simple configuration example as following,
tuner_class: QLibTuner
qlib_client:
auto_mount: False
logging_level: INFO
logging_level: INFO
optimization_criteria:
report_type: model
report_factor: model_score
optim_type: max
tuner_pipeline:
-
model:
-
model:
class: SomeModel
space: SomeModelSpace
trainer:
trainer:
class: RollingTrainer
strategy:
strategy:
class: TopkAmountStrategy
space: TopkAmountStrategySpace
max_evals: 2
@@ -93,7 +93,6 @@ We write a simple configuration example as following,
fend_time: 2018-12-11
backtest:
normal_backtest_args:
verbose: False
limit_threshold: 0.095
account: 500000
benchmark: SH000905
@@ -167,13 +166,13 @@ Also, there are some optional fields. The meaning of each field is as follows:
The class of tuner, str type, must be an already implemented model, such as `QLibTuner` in `qlib`, or a custom tuner, but it must be a subclass of `qlib.contrib.tuner.Tuner`, the default value is `QLibTuner`.
- `tuner_module_path`
The module path, str type, absolute url is also supported, indicates the path of the implementation of tuner. The default value is `qlib.contrib.tuner.tuner`
The module path, str type, absolute url is also supported, indicates the path of the implementation of tuner. The default value is `qlib.contrib.tuner.tuner`
About the optimization criteria
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You need to designate a factor to optimize, for tuner need a factor to decide which case is better than other cases.
Usually, we use the result of `estimator`, such as backtest results and the score of model.
Usually, we use the result of `estimator`, such as backtest results and the score of model.
This part needs contain these fields:
@@ -204,13 +203,13 @@ The tuner pipeline contains different tuners, and the `tuner` program will proce
.. code-block:: YAML
tuner_pipeline:
-
model:
-
model:
class: SomeModel
space: SomeModelSpace
trainer:
trainer:
class: RollingTrainer
strategy:
strategy:
class: TopkAmountStrategy
space: TopkAmountStrategySpace
max_evals: 2
@@ -218,13 +217,13 @@ The tuner pipeline contains different tuners, and the `tuner` program will proce
Each part represents a tuner, and its modules which are to be tuned. Space in each part is the hyper-parameters' space of a certain module, you need to create your searching space and modify it in `/qlib/contrib/tuner/space.py`. We use `hyperopt` package to help us to construct the space, you can see the detail of how to use it in https://github.com/hyperopt/hyperopt/wiki/FMin .
- model
You need to provide the `class` and the `space` of the model. If the model is user's own implementation, you need to privide the `module_path`.
You need to provide the `class` and the `space` of the model. If the model is user's own implementation, you need to provide the `module_path`.
- trainer
You need to proveide the `class` of the trainer. If the trainer is user's own implementation, you need to privide the `module_path`.
You need to provide the `class` of the trainer. If the trainer is user's own implementation, you need to provide the `module_path`.
- strategy
You need to provide the `class` and the `space` of the strategy. If the strategy is user's own implementation, you need to privide the `module_path`.
You need to provide the `class` and the `space` of the strategy. If the strategy is user's own implementation, you need to provide the `module_path`.
- data_label
The label of the data, you can search which kinds of labels will lead to a better result. This part is optional, and you only need to provide `space`.
@@ -250,31 +249,31 @@ You need to use the same dataset to evaluate your different `estimator` experime
test_start_date: 2016-07-01
test_end_date: 2018-04-30
- `rolling_period`
- `rolling_period`
The rolling period, integer type, indicates how many time steps need rolling when rolling the data. The default value is `60`. If you use `RollingTrainer`, this config will be used, or it will be ignored.
- `train_start_date`
Training start time, str type.
- `train_end_date`
- `train_end_date`
Training end time, str type.
- `validate_start_date`
- `validate_start_date`
Validation start time, str type.
- `validate_end_date`
- `validate_end_date`
Validation end time, str type.
- `test_start_date`
- `test_start_date`
Test start time, str type.
- `test_end_date`
- `test_end_date`
Test end time, str type. If `test_end_date` is `-1` or greater than the last date of the data, the last date of the data will be used as `test_end_date`.
About the data and backtest
~~~~~~~~~~~~~~~~~~~~~~~~~~~
`data` and `backtest` are all same in the whole `tuner` experiment. Different `estimator` experiments must use the same data and backtest method. So, these two parts of config are same with that in `estimator` configuration. You can see the precise defination of these parts in `estimator` introduction. We only provide an example here.
`data` and `backtest` are all same in the whole `tuner` experiment. Different `estimator` experiments must use the same data and backtest method. So, these two parts of config are same with that in `estimator` configuration. You can see the precise definition of these parts in `estimator` introduction. We only provide an example here.
.. code-block:: YAML
@@ -306,7 +305,6 @@ About the data and backtest
fend_time: 2018-12-11
backtest:
normal_backtest_args:
verbose: False
limit_threshold: 0.095
account: 500000
benchmark: SH000905
@@ -317,11 +315,10 @@ About the data and backtest
Experiment Result
-----------------
All the results are stored in experiment file directly, you can check them directly in the corresponding files.
All the results are stored in experiment file directly, you can check them directly in the corresponding files.
What we save are as following:
- Global optimal parameters
- Local optimal parameters of each tuner
- Config file of this `tuner` experiment
- Every `estimator` experiments result in the process

View File

@@ -1,6 +1,6 @@
============================================================
======================
``Qlib`` Documentation
============================================================
======================
``Qlib`` is an AI-oriented quantitative investment platform, which aims to realize the potential, empower the research, and create the value of AI technologies in quantitative investment.
@@ -24,30 +24,44 @@ Document Structure
.. toctree::
:maxdepth: 3
:caption: FIRST STEPS:
Installation <start/installation.rst>
Initialization <start/initialization.rst>
Data Retrieval <start/getdata.rst>
Custom Model Integration <start/integration.rst>
.. toctree::
:maxdepth: 3
:caption: COMPONENTS:
:caption: MAIN COMPONENTS:
Estimator: Workflow Management <component/estimator.rst>
Data Layer: Data Framework&Usage <component/data.rst>
Interday Model: Model Training & Prediction <component/model.rst>
Interday Strategy: Portfolio Management <component/strategy.rst>
Intraday Trading: Model&Strategy Testing <component/backtest.rst>
Aanalysis: Evaluation & Results Analysis <component/report.rst>
Workflow: Workflow Management <component/workflow.rst>
Data Layer: Data Framework & Usage <component/data.rst>
Forecast Model: Model Training & Prediction <component/model.rst>
Portfolio Management and Backtest <component/strategy.rst>
Nested Decision Execution: High-Frequency Trading <component/highfreq.rst>
Meta Controller: Meta-Task & Meta-Dataset & Meta-Model <component/meta.rst>
Qlib Recorder: Experiment Management <component/recorder.rst>
Analysis: Evaluation & Results Analysis <component/report.rst>
Online Serving: Online Management & Strategy & Tool <component/online.rst>
Reinforcement Learning <component/rl/toctree>
.. toctree::
:maxdepth: 3
:caption: ADVANCED TOPICS:
:caption: OTHER COMPONENTS/FEATURES/TOPICS:
Building Formulaic Alphas <advanced/alpha.rst>
Online & Offline mode <advanced/server.rst>
Serialization <advanced/serial.rst>
Task Management <advanced/task_management.rst>
Point-In-Time database <advanced/PIT.rst>
.. toctree::
:maxdepth: 3
:caption: FOR DEVELOPERS:
Code Standard & Development Guidance <developer/code_standard_and_dev_guide.rst>
.. toctree::
:maxdepth: 3
:caption: REFERENCE:

View File

@@ -3,7 +3,7 @@
===============================
Introduction
===================
============
.. image:: ../_static/img/logo/white_bg_rec+word.png
:align: center
@@ -13,35 +13,58 @@ Introduction
With ``Qlib``, users can easily try their ideas to create better Quant investment strategies.
Framework
===================
.. image:: ../_static/img/framework.png
=========
.. image:: ../_static/img/framework.svg
:align: center
At the module level, Qlib is a platform that consists of above components. The components are designed as loose-coupled modules and each component could be used stand-alone.
====================== ==============================================================================
Name Description
====================== ==============================================================================
`Data layer` `DataServer` focuses on providing high-performance infrastructure for users to
manage and retrieve raw data. `DataEnhancement` will preprocess the data and
provide the best dataset to be fed into the models.
This framework may be intimidating for new users to Qlib. It tries to accurately include a lot of details of Qlib's design.
For users new to Qlib, you can skip it first and read it later.
`Interday Model` `Interday model` focuses on producing prediction scores (aka. `alpha`). Models
are trained by `Model Creator` and managed by `Model Manager`. Users could
choose one or multiple models for prediction. Multiple models could be combined
with `Ensemble` module.
`Interday Strategy` `Portfolio Generator` will take prediction scores as input and output the
orders based on the current position to achieve the target portfolio.
`Intraday Trading` `Order Executor` is responsible for executing orders output by
`Interday Strategy` and returning the executed results.
=========================== ==============================================================================
Name Description
=========================== ==============================================================================
`Infrastructure` layer `Infrastructure` layer provides underlying support for Quant research.
`DataServer` provides high-performance infrastructure for users to manage
and retrieve raw data. `Trainer` provides flexible interface to control
the training process of models which enable algorithms controlling the
training process.
`Analysis` Users could get a detailed analysis report of forecasting signals and portfolios
in this part.
====================== ==============================================================================
`Learning Framework` layer The `Forecast Model` and `Trading Agent` are trainable. They are trained
based on the `Learning Framework` layer and then applied to multiple scenarios
in `Workflow` layer. The supported learning paradigms can be categorized into
reinforcement learning and supervised learning. The learning framework
leverages the `Workflow` layer as well(e.g. sharing `Information Extractor`,
creating environments based on `Execution Env`).
`Workflow` layer `Workflow` layer covers the whole workflow of quantitative investment.
Both supervised-learning-based strategies and RL-based Strategies
are supported.
`Information Extractor` extracts data for models. `Forecast Model` focuses
on producing all kinds of forecast signals (e.g. *alpha*, risk) for other
modules. With these signals `Decision Generator` will generate the target
trading decisions(i.e. portfolio, orders)
If RL-based Strategies are adopted, the `Policy` is learned in a end-to-end way,
the trading decisions are generated directly.
Decisions will be executed by `Execution Env`
(i.e. the trading market). There may be multiple levels of `Strategy`
and `Executor` (e.g. an *order executor trading strategy and intraday order executor*
could behave like an interday trading loop and be nested in
*daily portfolio management trading strategy and interday trading executor*
trading loop)
`Interface` layer `Interface` layer tries to present a user-friendly interface for the underlying
system. `Analyser` module will provide users detailed analysis reports of
forecasting signals, portfolios and execution results
=========================== ==============================================================================
- The modules with hand-drawn style are under development and will be released in the future.
- The modules with dashed borders are highly user-customizable and extendible.
(p.s. framework image is created with https://draw.io/)

View File

@@ -1,10 +1,10 @@
===============================
===========
Quick Start
===============================
===========
Introduction
==============
============
This ``Quick Start`` guide tries to demonstrate
@@ -14,13 +14,14 @@ This ``Quick Start`` guide tries to demonstrate
Installation
==================
============
Users can easily intsall ``Qlib`` according to the following steps:
Users can easily install ``Qlib`` according to the following steps:
- Before installing ``Qlib`` from source, users need to install some dependencies:
.. code-block::
pip install numpy
pip install --upgrade cython
@@ -31,39 +32,40 @@ Users can easily intsall ``Qlib`` according to the following steps:
git clone https://github.com/microsoft/qlib.git && cd qlib
python setup.py install
To kown more about `installation`, please refer to `Qlib Installation <../start/installation.html>`_.
To known more about `installation`, please refer to `Qlib Installation <../start/installation.html>`_.
Prepare Data
==============
============
Load and prepare data by running the following code:
.. code-block::
python scripts/get_data.py qlib_data_cn --target_dir ~/.qlib/qlib_data/cn_data
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
This dataset is created by public data collected by crawler scripts in ``scripts/data_collector/``, which have been released in the same repository. Users could create the same dataset with it.
To kown more about `prepare data`, please refer to `Data Preparation <../component/data.html#data-preparation>`_.
To known more about `prepare data`, please refer to `Data Preparation <../component/data.html#data-preparation>`_.
Auto Quant Research Workflow
====================================
============================
``Qlib`` provides a tool named ``Estimator`` to run the whole workflow automatically (including building dataset, training models, backtest and evaluation). Users can start an auto quant research workflow and have a graphical reports analysis according to the following steps:
``Qlib`` provides a tool named ``qrun`` to run the whole workflow automatically (including building dataset, training models, backtest and evaluation). Users can start an auto quant research workflow and have a graphical reports analysis according to the following steps:
- Quant Research Workflow:
- Run ``Estimator`` with `estimator_config.yaml` as following.
.. code-block::
- Quant Research Workflow:
- Run ``qrun`` with a config file of the LightGBM model `workflow_config_lightgbm.yaml` as following.
.. code-block::
cd examples # Avoid running program under the directory contains `qlib`
estimator -c estimator/estimator_config.yaml
qrun benchmarks/LightGBM/workflow_config_lightgbm.yaml
- Estimator result
The result of ``Estimator`` is as follows, which is also the result of ``Intraday Trading``. Please refer to `Intraday Trading <../component/backtest.html>`_. for more details about the result.
- Workflow result
The result of ``qrun`` is as follows, which is also the typical result of ``Forecast model(alpha)``. Please refer to `Intraday Trading <../component/backtest.html>`_. for more details about the result.
.. code-block:: python
risk
excess_return_without_cost mean 0.000605
std 0.005481
@@ -76,18 +78,18 @@ Auto Quant Research Workflow
information_ratio 1.187411
max_drawdown -0.075024
To know more about `Estimator`, please refer to `Estimator: Workflow Management <../component/estimator.html>`_.
To know more about `workflow` and `qrun`, please refer to `Workflow: Workflow Management <../component/workflow.html>`_.
- Graphical Reports Analysis:
- Run ``examples/estimator/analyze_from_estimator.ipynb`` with jupyter notebook
Users can have portfolio analysis or prediction score (model prediction) analysis by run ``examples/estimator/analyze_from_estimator.ipynb``.
- Run ``examples/workflow_by_code.ipynb`` with jupyter notebook
Users can have portfolio analysis or prediction score (model prediction) analysis by run ``examples/workflow_by_code.ipynb``.
- Graphical Reports
Users can get graphical reports about the analysis, please refer to `Aanalysis: Evaluation & Results Analysis <../component/report.html>`_ for more details.
Users can get graphical reports about the analysis, please refer to `Analysis: Evaluation & Results Analysis <../component/report.html>`_ for more details.
Custom Model Integration
===============================================
========================
``Qlib`` provides ``lightGBM`` and ``Dnn`` model as the baseline of ``Interday Model``. In addition to the default model, users can integrate their own custom models into ``Qlib``. If users are interested in the custom model, please refer to `Custom Model Integration <../start/integration.html>`_.
``Qlib`` provides a batch of models (such as ``lightGBM`` and ``MLP`` models) as examples of ``Forecast Model``. In addition to the default model, users can integrate their own custom models into ``Qlib``. If users are interested in the custom model, please refer to `Custom Model Integration <../start/integration.html>`_.

35
docs/make.bat Normal file
View File

@@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
if "%1" == "" goto help
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

View File

@@ -1,7 +1,8 @@
.. _api:
================================
=============
API Reference
================================
=============
@@ -9,35 +10,32 @@ Here you can find all ``Qlib`` interfaces.
Data
====================
====
Provider
--------------------
--------
.. automodule:: qlib.data.data
:members:
Filter
--------------------
------
.. automodule:: qlib.data.filter
:members:
Feature
--------------------
Class
~~~~~~~~~~~~~~~~~~~~
-----
.. automodule:: qlib.data.base
:members:
Operator
~~~~~~~~~~~~~~~~~~~~
--------
.. automodule:: qlib.data.ops
:members:
Cache
----------------
-----
.. autoclass:: qlib.data.cache.MemCacheUnit
:members:
@@ -57,35 +55,80 @@ Cache
:members:
Contrib
====================
Data Handler
---------------
.. automodule:: qlib.contrib.estimator.handler
Storage
-------
.. autoclass:: qlib.data.storage.storage.BaseStorage
:members:
.. autoclass:: qlib.data.storage.storage.CalendarStorage
:members:
.. autoclass:: qlib.data.storage.storage.InstrumentStorage
:members:
.. autoclass:: qlib.data.storage.storage.FeatureStorage
:members:
.. autoclass:: qlib.data.storage.file_storage.FileStorageMixin
:members:
.. autoclass:: qlib.data.storage.file_storage.FileCalendarStorage
:members:
.. autoclass:: qlib.data.storage.file_storage.FileInstrumentStorage
:members:
.. autoclass:: qlib.data.storage.file_storage.FileFeatureStorage
:members:
Dataset
-------
Dataset Class
~~~~~~~~~~~~~
.. automodule:: qlib.data.dataset.__init__
:members:
Data Loader
~~~~~~~~~~~
.. automodule:: qlib.data.dataset.loader
:members:
Data Handler
~~~~~~~~~~~~
.. automodule:: qlib.data.dataset.handler
:members:
Processor
~~~~~~~~~
.. automodule:: qlib.data.dataset.processor
:members:
Contrib
=======
Model
--------------------
.. automodule:: qlib.contrib.model.base
-----
.. automodule:: qlib.model.base
:members:
Strategy
-------------------
--------
.. automodule:: qlib.contrib.strategy.strategy
.. automodule:: qlib.contrib.strategy
:members:
Evaluate
-----------------
--------
.. automodule:: qlib.contrib.evaluate
:members:
Report
-----------------
------
.. automodule:: qlib.contrib.report.analysis_position.report
:members:
@@ -116,3 +159,134 @@ Report
:members:
Workflow
========
Experiment Manager
------------------
.. autoclass:: qlib.workflow.expm.ExpManager
:members:
Experiment
----------
.. autoclass:: qlib.workflow.exp.Experiment
:members:
Recorder
--------
.. autoclass:: qlib.workflow.recorder.Recorder
:members:
Record Template
---------------
.. automodule:: qlib.workflow.record_temp
:members:
Task Management
===============
TaskGen
-------
.. automodule:: qlib.workflow.task.gen
:members:
TaskManager
-----------
.. automodule:: qlib.workflow.task.manage
:members:
Trainer
-------
.. automodule:: qlib.model.trainer
:members:
Collector
---------
.. automodule:: qlib.workflow.task.collect
:members:
Group
-----
.. automodule:: qlib.model.ens.group
:members:
Ensemble
--------
.. automodule:: qlib.model.ens.ensemble
:members:
Utils
-----
.. automodule:: qlib.workflow.task.utils
:members:
Online Serving
==============
Online Manager
--------------
.. automodule:: qlib.workflow.online.manager
:members:
Online Strategy
---------------
.. automodule:: qlib.workflow.online.strategy
:members:
Online Tool
-----------
.. automodule:: qlib.workflow.online.utils
:members:
RecordUpdater
-------------
.. automodule:: qlib.workflow.online.update
:members:
Utils
=====
Serializable
------------
.. automodule:: qlib.utils.serial
:members:
RL
==============
Base Component
--------------
.. automodule:: qlib.rl
:members:
:imported-members:
Strategy
--------
.. automodule:: qlib.rl.strategy
:members:
:imported-members:
Trainer
-------
.. automodule:: qlib.rl.trainer
:members:
:imported-members:
Order Execution
---------------
.. automodule:: qlib.rl.order_execution
:members:
:imported-members:
Utils
---------------
.. automodule:: qlib.rl.utils
:members:
:imported-members:

View File

@@ -1 +1,7 @@
Cython==0.29.21
Cython
cmake
numpy
scipy
scikit-learn
pandas
tianshou

View File

@@ -1,17 +1,18 @@
.. _getdata:
=============================
==============
Data Retrieval
=============================
==============
.. currentmodule:: qlib
Introduction
====================
============
Users can get stock data with ``Qlib``. The following examples demonstrate the basic user interface.
Examples
====================
========
``QLib`` Initialization:
@@ -29,7 +30,7 @@ If users followed steps in `initialization <initialization.html>`_ and downloade
Load trading calendar with given time range and frequency:
.. code-block:: python
>> from qlib.data import D
>> D.calendar(start_time='2010-01-01', end_time='2017-12-31', freq='day')[:2]
[Timestamp('2010-01-04 00:00:00'), Timestamp('2010-01-05 00:00:00')]
@@ -45,7 +46,7 @@ Parse a given market name into a stock pool config:
Load instruments of certain stock pool in the given time range:
.. code-block:: python
>> from qlib.data import D
>> instruments = D.instruments(market='csi300')
>> D.list_instruments(instruments=instruments, start_time='2010-01-01', end_time='2017-12-31', as_list=True)[:6]
@@ -78,19 +79,18 @@ For more details about filter, please refer `Filter API <../component/data.html>
Load features of certain instruments in a given time range:
.. code-block:: python
>> from qlib.data import D
>> instruments = ['SH600000']
>> fields = ['$close', '$volume', 'Ref($close, 1)', 'Mean($close, 3)', '$high-$low']
>> D.features(instruments, fields, start_time='2010-01-01', end_time='2017-12-31', freq='day').head()
$close $volume Ref($close, 1) Mean($close, 3) $high-$low
instrument datetime
SH600000 2010-01-04 86.778313 16162960.0 88.825928 88.061483 2.907631
2010-01-05 87.433578 28117442.0 86.778313 87.679273 3.235252
2010-01-06 85.713585 23632884.0 87.433578 86.641825 1.720009
2010-01-07 83.788803 20813402.0 85.713585 85.645322 3.030487
2010-01-08 84.730675 16044853.0 83.788803 84.744354 2.047623
>> D.features(instruments, fields, start_time='2010-01-01', end_time='2017-12-31', freq='day').head().to_string()
' $close $volume Ref($close, 1) Mean($close, 3) $high-$low
... instrument datetime
... SH600000 2010-01-04 86.778313 16162960.0 88.825928 88.061483 2.907631
... 2010-01-05 87.433578 28117442.0 86.778313 87.679273 3.235252
... 2010-01-06 85.713585 23632884.0 87.433578 86.641825 1.720009
... 2010-01-07 83.788803 20813402.0 85.713585 85.645322 3.030487
... 2010-01-08 84.730675 16044853.0 83.788803 84.744354 2.047623'
Load features of certain stock pool in a given time range:
@@ -104,21 +104,46 @@ Load features of certain stock pool in a given time range:
>> expressionDFilter = ExpressionDFilter(rule_expression='$close>Ref($close,1)')
>> instruments = D.instruments(market='csi300', filter_pipe=[nameDFilter, expressionDFilter])
>> fields = ['$close', '$volume', 'Ref($close, 1)', 'Mean($close, 3)', '$high-$low']
>> D.features(instruments, fields, start_time='2010-01-01', end_time='2017-12-31', freq='day').head()
$close $volume Ref($close, 1) Mean($close, 3) $high-$low
instrument datetime
SH600655 2010-01-04 2699.567383 158193.328125 2619.070312 2626.097738 124.580566
2010-01-08 2612.359619 77501.406250 2584.567627 2623.220133 83.373047
2010-01-11 2712.982422 160852.390625 2612.359619 2636.636556 146.621582
2010-01-12 2788.688232 164587.937500 2712.982422 2704.676758 128.413818
2010-01-13 2790.604004 145460.453125 2788.688232 2764.091553 128.413818
>> D.features(instruments, fields, start_time='2010-01-01', end_time='2017-12-31', freq='day').head().to_string()
' $close $volume Ref($close, 1) Mean($close, 3) $high-$low
... instrument datetime
... SH600655 2010-01-04 2699.567383 158193.328125 2619.070312 2626.097738 124.580566
... 2010-01-08 2612.359619 77501.406250 2584.567627 2623.220133 83.373047
... 2010-01-11 2712.982422 160852.390625 2612.359619 2636.636556 146.621582
... 2010-01-12 2788.688232 164587.937500 2712.982422 2704.676758 128.413818
... 2010-01-13 2790.604004 145460.453125 2788.688232 2764.091553 128.413818'
For more details about features, please refer `Feature API <../component/data.html>`_.
.. note:: When calling `D.features()` at the client, use parameter `disk_cache=0` to skip dataset cache, use `disk_cache=1` to generate and use dataset cache. In addition, when calling at the server, users can use `disk_cache=2` to update the dataset cache.
When you are building complicated expressions, implementing all the expressions in a single string may not be easy.
For example, it looks quite long and complicated:
.. code-block:: python
>> from qlib.data import D
>> data = D.features(["sh600519"], ["(($high / $close) + ($open / $close)) * (($high / $close) + ($open / $close)) / (($high / $close) + ($open / $close))"], start_time="20200101")
But using string is not the only way to implement the expression. You can also implement expression by code.
Here is an exmaple which does the same thing as above examples.
.. code-block:: python
>> from qlib.data.ops import *
>> f1 = Feature("high") / Feature("close")
>> f2 = Feature("open") / Feature("close")
>> f3 = f1 + f2
>> f4 = f3 * f3 / f3
>> data = D.features(["sh600519"], [f4], start_time="20200101")
>> data.head()
API
====================
===
To know more about how to use the Data, go to API Reference: `Data API <../reference/api.html#data>`_

View File

@@ -1,60 +1,97 @@
.. _initialization:
====================
===================
Qlib Initialization
====================
===================
.. currentmodule:: qlib
Initialization
=========================
==============
Please follow the steps below to initialize ``Qlib``.
- Download and prepare the Data: execute the following command to download stock data. Please pay `attention` that the data is collected from `Yahoo Finance <https://finance.yahoo.com/lookup>`_ and the data might not be perfect. We recommend users to prepare their own data if they have high-quality datasets. Please refer to `Data <../component/data.html#converting-csv-format-into-qlib-format>` for more information about customized dataset.
Download and prepare the Data: execute the following command to download stock data. Please pay `attention` that the data is collected from `Yahoo Finance <https://finance.yahoo.com/lookup>`_ and the data might not be perfect. We recommend users to prepare their own data if they have high-quality datasets. Please refer to `Data <../component/data.html#converting-csv-format-into-qlib-format>`_ for more information about customized dataset.
.. code-block:: bash
python scripts/get_data.py qlib_data_cn --target_dir ~/.qlib/qlib_data/cn_data
Please refer to `Data Preparation <../component/data.html#data-preparation>`_ for more information about `get_data.py`,
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
Please refer to `Data Preparation <../component/data.html#data-preparation>`_ for more information about `get_data.py`,
- Initialize Qlib before calling other APIs: run following code in python.
Initialize Qlib before calling other APIs: run following code in python.
.. code-block:: Python
import qlib
# region in [REG_CN, REG_US]
from qlib.config import REG_CN
from qlib.constant import REG_CN
provider_uri = "~/.qlib/qlib_data/cn_data" # target_dir
qlib.init(provider_uri=provider_uri, region=REG_CN)
.. note::
Do not import qlib package in the repository directory of ``Qlib``, otherwise, errors may occur.
Parameters
-------------------
Besides `provider_uri` and `region`, `qlib.init` has other parameters. The following are several important parameters of `qlib.init`:
Besides `provider_uri` and `region`, `qlib.init` has other parameters.
The following are several important parameters of `qlib.init` (`Qlib` has a lot of config. Only part of parameters are limited here. More detailed setting can be found `here <https://github.com/microsoft/qlib/blob/main/qlib/config.py>`_):
- `provider_uri`
Type: str. The URI of the Qlib data. For example, it could be the location where the data loaded by ``get_data.py`` are stored.
- `region`
Type: str, optional parameter(default: `qlib.config.REG_CN`).
Currently: ``qlib.config.REG_US`` ('us') and ``qlib.config.REG_CN`` ('cn') is supported. Different value of `region` will result in different stock market mode.
- ``qlib.config.REG_US``: US stock market.
- ``qlib.config.REG_CN``: China stock market.
Type: str, optional parameter(default: `qlib.constant.REG_CN`).
Currently: ``qlib.constant.REG_US`` ('us') and ``qlib.constant.REG_CN`` ('cn') is supported. Different value of `region` will result in different stock market mode.
- ``qlib.constant.REG_US``: US stock market.
- ``qlib.constant.REG_CN``: China stock market.
Different modse will result in different trading limitations and costs.
Different modes will result in different trading limitations and costs.
The region is just `shortcuts for defining a batch of configurations <https://github.com/microsoft/qlib/blob/528f74af099bf6156e9480bcd2bb28e453231212/qlib/config.py#L249>`_, which include minimal trading order unit (``trade_unit``), trading limitation (``limit_threshold``) , etc. It is not a necessary part and users can set the key configurations manually if the existing region setting can't meet their requirements.
- `redis_host`
Type: str, optional parameter(default: "127.0.0.1"), host of `redis`
The lock and cache mechanism relies on redis.
- `redis_port`
Type: int, optional parameter(default: 6379), port of `redis`
.. note::
.. note::
The value of `region` should be aligned with the data stored in `provider_uri`. Currently, ``scripts/get_data.py`` only provides China stock market data. If users want to use the US stock market data, they should prepare their own US-stock data in `provider_uri` and switch to US-stock mode.
.. note::
If Qlib fails to connect redis via `redis_host` and `redis_port`, cache mechanism will not be used! Please refer to `Cache <../component/data.html#cache>`_ for details.
- `exp_manager`
Type: dict, optional parameter, the setting of `experiment manager` to be used in qlib. Users can specify an experiment manager class, as well as the tracking URI for all the experiments. However, please be aware that we only support input of a dictionary in the following style for `exp_manager`. For more information about `exp_manager`, users can refer to `Recorder: Experiment Management <../component/recorder.html>`_.
.. code-block:: Python
# For example, if you want to set your tracking_uri to a <specific folder>, you can initialize qlib below
qlib.init(provider_uri=provider_uri, region=REG_CN, exp_manager= {
"class": "MLflowExpManager",
"module_path": "qlib.workflow.expm",
"kwargs": {
"uri": "python_execution_path/mlruns",
"default_exp_name": "Experiment",
}
})
- `mongo`
Type: dict, optional parameter, the setting of `MongoDB <https://www.mongodb.com/>`_ which will be used in some features such as `Task Management <../advanced/task_management.html>`_, with high performance and clustered processing.
Users need to follow the steps in `installation <https://www.mongodb.com/try/download/community>`_ to install MongoDB firstly and then access it via a URI.
Users can access mongodb with credential by setting "task_url" to a string like `"mongodb://%s:%s@%s" % (user, pwd, host + ":" + port)`.
.. code-block:: Python
# For example, you can initialize qlib below
qlib.init(provider_uri=provider_uri, region=REG_CN, mongo={
"task_url": "mongodb://localhost:27017/", # your mongo url
"task_db_name": "rolling_db", # the database name of Task Management
})
- `logging_level`
The logging level for the system.
- `kernels`
The number of processes used when calculating features in Qlib's expression engine. It is very helpful to set it to 1 when you are debuggin an expression calculating exception

View File

@@ -1,7 +1,8 @@
.. _installation:
====================
============
Installation
====================
============
.. currentmodule:: qlib
@@ -23,7 +24,7 @@ Also, Users can install ``Qlib`` by the source code according to the following s
- Enter the root directory of ``Qlib``, in which the file ``setup.py`` exists.
- Then, please execute the following command to install the environment dependencies and install ``Qlib``:
.. code-block:: bash
$ pip install numpy
@@ -33,7 +34,7 @@ Also, Users can install ``Qlib`` by the source code according to the following s
.. note::
It's recommended to use anaconda/miniconda to setup the environment. ``Qlib`` needs lightgbm and pytorch packages, use pip to install them.
Use the following code to make sure the installation successful:
@@ -43,6 +44,3 @@ Use the following code to make sure the installation successful:
>>> import qlib
>>> qlib.__version__
<LATEST VERSION>
=====================

View File

@@ -1,146 +1,149 @@
=========================================
========================
Custom Model Integration
=========================================
========================
Introduction
===================
============
``Qlib`` provides ``lightGBM`` and ``Dnn`` model as the baseline of ``Interday Model``. In addition to the default model, users can integrate their own custom models into ``Qlib``.
``Qlib``'s `Model Zoo` includes models such as ``LightGBM``, ``MLP``, ``LSTM``, etc.. These models are examples of ``Forecast Model``. In addition to the default models ``Qlib`` provide, users can integrate their own custom models into ``Qlib``.
Users can integrate their own custom models according to the following steps.
- Define a custom model class, which should be a subclass of the `qlib.contrib.model.base.Model <../reference/api.html#module-qlib.contrib.model.base>`_.
- Define a custom model class, which should be a subclass of the `qlib.model.base.Model <../reference/api.html#module-qlib.model.base>`_.
- Write a configuration file that describes the path and parameters of the custom model.
- Test the custom model.
Custom Model Class
===========================
The Custom models need to inherit `qlib.contrib.model.base.Model <../reference/api.html#module-qlib.contrib.model.base>`_ and override the methods in it.
==================
The Custom models need to inherit `qlib.model.base.Model <../reference/api.html#module-qlib.model.base>`_ and override the methods in it.
- Override the `__init__` method
- ``Qlib`` passes the initialized parameters to the \_\_init\_\_ method.
- The parameter must be consistent with the hyperparameters in the configuration file.
- Code Example: In the following example, the hyperparameter filed of the configuration file should contain parameters such as `loss:mse`.
.. code-block:: Python
- The hyperparameters of model in the configuration must be consistent with those defined in the `__init__` method.
- Code Example: In the following example, the hyperparameters of model in the configuration file should contain parameters such as `loss:mse`.
def __init__(self, loss='mse', **kwargs):
if loss not in {'mse', 'binary'}:
raise NotImplementedError
self._scorer = mean_squared_error if loss == 'mse' else roc_auc_score
self._params.update(objective=loss, **kwargs)
self._model = None
.. code-block:: Python
def __init__(self, loss='mse', **kwargs):
if loss not in {'mse', 'binary'}:
raise NotImplementedError
self._scorer = mean_squared_error if loss == 'mse' else roc_auc_score
self._params.update(objective=loss, **kwargs)
self._model = None
- Override the `fit` method
- ``Qlib`` calls the fit method to train the model
- The parameters must include training feature `x_train`, training label `y_train`, test feature `x_valid`, test label `y_valid` at least.
- The parameters could include some optional parameters with default values, such as train weight `w_train`, test weight `w_valid` and `num_boost_round = 1000`.
- ``Qlib`` calls the fit method to train the model.
- The parameters must include training feature `dataset`, which is designed in the interface.
- The parameters could include some `optional` parameters with default values, such as `num_boost_round = 1000` for `GBDT`.
- Code Example: In the following example, `num_boost_round = 1000` is an optional parameter.
.. code-block:: Python
def fit(self, x_train:pd.DataFrame, y_train:pd.DataFrame, x_valid:pd.DataFrame, y_valid:pd.DataFrame,
w_train:pd.DataFrame = None, w_valid:pd.DataFrame = None, num_boost_round = 1000, **kwargs):
# Lightgbm need 1D array as its label
if y_train.values.ndim == 2 and y_train.values.shape[1] == 1:
y_train_1d, y_valid_1d = np.squeeze(y_train.values), np.squeeze(y_valid.values)
else:
raise ValueError('LightGBM doesn\'t support multi-label training')
.. code-block:: Python
w_train_weight = None if w_train is None else w_train.values
w_valid_weight = None if w_valid is None else w_valid.values
def fit(self, dataset: DatasetH, num_boost_round = 1000, **kwargs):
dtrain = lgb.Dataset(x_train.values, label=y_train_1d, weight=w_train_weight)
dvalid = lgb.Dataset(x_valid.values, label=y_valid_1d, weight=w_valid_weight)
self._model = lgb.train(
self._params,
dtrain,
num_boost_round=num_boost_round,
valid_sets=[dtrain, dvalid],
valid_names=['train', 'valid'],
**kwargs
)
# prepare dataset for lgb training and evaluation
df_train, df_valid = dataset.prepare(
["train", "valid"], col_set=["feature", "label"], data_key=DataHandlerLP.DK_L
)
x_train, y_train = df_train["feature"], df_train["label"]
x_valid, y_valid = df_valid["feature"], df_valid["label"]
# Lightgbm need 1D array as its label
if y_train.values.ndim == 2 and y_train.values.shape[1] == 1:
y_train, y_valid = np.squeeze(y_train.values), np.squeeze(y_valid.values)
else:
raise ValueError("LightGBM doesn't support multi-label training")
dtrain = lgb.Dataset(x_train.values, label=y_train)
dvalid = lgb.Dataset(x_valid.values, label=y_valid)
# fit the model
self.model = lgb.train(
self.params,
dtrain,
num_boost_round=num_boost_round,
valid_sets=[dtrain, dvalid],
valid_names=["train", "valid"],
early_stopping_rounds=early_stopping_rounds,
verbose_eval=verbose_eval,
evals_result=evals_result,
**kwargs
)
- Override the `predict` method
- The parameters include the test features.
- The parameters must include the parameter `dataset`, which will be userd to get the test dataset.
- Return the `prediction score`.
- Please refer to `Model API <../reference/api.html#module-qlib.contrib.model.base>`_ for the parameter types of the fit method.
- Code Example: In the following example, users need to use dnn to predict the label(such as `preds`) of test data `x_test` and return it.
.. code-block:: Python
- Please refer to `Model API <../reference/api.html#module-qlib.model.base>`_ for the parameter types of the fit method.
- Code Example: In the following example, users need to use `LightGBM` to predict the label(such as `preds`) of test data `x_test` and return it.
def predict(self, x_test:pd.DataFrame, **kwargs)-> numpy.ndarray:
if self._model is None:
raise ValueError('model is not fitted yet!')
return self._model.predict(x_test.values)
.. code-block:: Python
- Override the `save` method & `load` method
- The `save` method parameter includes the a `filename` that represents an absolute path, user need to save model into the path.
- The `load` method parameter includes the a `buffer` read from the `filename` passed in the `save` method, users need to load model from the `buffer`.
- Code Example:
.. code-block:: Python
def predict(self, dataset: DatasetH, **kwargs)-> pandas.Series:
if self.model is None:
raise ValueError("model is not fitted yet!")
x_test = dataset.prepare("test", col_set="feature", data_key=DataHandlerLP.DK_I)
return pd.Series(self.model.predict(x_test.values), index=x_test.index)
def save(self, filename):
if self._model is None:
raise ValueError('model is not fitted yet!')
self._model.save_model(filename)
- Override the `finetune` method (Optional)
- This method is optional to the users. When users want to use this method on their own models, they should inherit the ``ModelFT`` base class, which includes the interface of `finetune`.
- The parameters must include the parameter `dataset`.
- Code Example: In the following example, users will use `LightGBM` as the model and finetune it.
def load(self, buffer):
self._model = lgb.Booster(params={'model_str': buffer.decode('utf-8')})
.. code-block:: Python
.. Without tuner, this part will not be used
.. - Override the `score` method(This step is optional)
.. - The parameters include the test features and test labels.
.. - Return the evaluation score of the model. It's recommended to adopt the loss between labels and `prediction score`.
.. - Code Example: In the following example, users need to calculate the weighted loss with test data `x_test`, test label `y_test` and the weight `w_test`.
.. .. code-block:: Python
..
.. def score(self, x_test:pd.Dataframe, y_test:pd.Dataframe, w_test:pd.DataFrame = None) -> float:
.. # Remove rows from x, y and w, which contain Nan in any columns in y_test.
.. x_test, y_test, w_test = drop_nan_by_y_index(x_test, y_test, w_test)
.. preds = self.predict(x_test)
.. w_test_weight = None if w_test is None else w_test.values
.. scorer = mean_squared_error if self.loss_type == 'mse' else roc_auc_score
.. return scorer(y_test.values, preds, sample_weight=w_test_weight)
def finetune(self, dataset: DatasetH, num_boost_round=10, verbose_eval=20):
# Based on existing model and finetune by train more rounds
dtrain, _ = self._prepare_data(dataset)
self.model = lgb.train(
self.params,
dtrain,
num_boost_round=num_boost_round,
init_model=self.model,
valid_sets=[dtrain],
valid_names=["train"],
verbose_eval=verbose_eval,
)
Configuration File
=======================
==================
The configuration file is described in detail in the `estimator <../component/estimator.html#complete-example>`_ document. In order to integrate the custom model into ``Qlib``, users need to modify the "model" field in the configuration file.
The configuration file is described in detail in the `Workflow <../component/workflow.html#complete-example>`_ document. In order to integrate the custom model into ``Qlib``, users need to modify the "model" field in the configuration file. The configuration describes which models to use and how we can initialize it.
- Example: The following example describes the `model` field of configuration file about the custom lightgbm model mentioned above, where `module_path` is the module path, `class` is the class name, and `args` is the hyperparameter passed into the __init__ method. All parameters in the field is passed to `self._params` by `\*\*kwargs` in `__init__` except `loss = mse`.
- Example: The following example describes the `model` field of configuration file about the custom lightgbm model mentioned above, where `module_path` is the module path, `class` is the class name, and `args` is the hyperparameter passed into the __init__ method. All parameters in the field is passed to `self._params` by `\*\*kwargs` in `__init__` except `loss = mse`.
.. code-block:: YAML
model:
class: LGBModel
module_path: qlib.contrib.model.gbdt
args:
loss: mse
colsample_bytree: 0.8879
learning_rate: 0.0421
subsample: 0.8789
lambda_l1: 205.6999
lambda_l2: 580.9768
max_depth: 8
num_leaves: 210
num_threads: 20
.. code-block:: YAML
Users could find configuration file of the baseline of the ``Model`` in ``qlib/examples/estimator/estimator_config.yaml`` and ``qlib/examples/estimator/estimator_config_dnn.yaml``
model:
class: LGBModel
module_path: qlib.contrib.model.gbdt
args:
loss: mse
colsample_bytree: 0.8879
learning_rate: 0.0421
subsample: 0.8789
lambda_l1: 205.6999
lambda_l2: 580.9768
max_depth: 8
num_leaves: 210
num_threads: 20
Users could find configuration file of the baselines of the ``Model`` in ``examples/benchmarks``. All the configurations of different models are listed under the corresponding model folder.
Model Testing
=====================
Assuming that the configuration file is ``examples/estimator/estimator_config.yaml``, users can run the following command to test the custom model:
=============
Assuming that the configuration file is ``examples/benchmarks/LightGBM/workflow_config_lightgbm.yaml``, users can run the following command to test the custom model:
.. code-block:: bash
cd examples # Avoid running program under the directory contains `qlib`
estimator -c estimator/estimator_config.yaml
qrun benchmarks/LightGBM/workflow_config_lightgbm.yaml
.. note:: ``estimator`` is a built-in command of ``Qlib``.
.. note:: ``qrun`` is a built-in command of ``Qlib``.
Also, ``Model`` can also be tested as a single module. An example has been given in ``examples/train_backtest_analyze.ipynb``.
Also, ``Model`` can also be tested as a single module. An example has been given in ``examples/workflow_by_code.ipynb``.
Reference
=====================
=========
To know more about ``Interday Model``, please refer to `Interday Model: Model Training & Prediction <../component/model.html>`_ and `Model API <../reference/api.html#module-qlib.contrib.model.base>`_.
To know more about ``Forecast Model``, please refer to `Forecast Model: Model Training & Prediction <../component/model.html>`_ and `Model API <../reference/api.html#module-qlib.model.base>`_.

View File

@@ -1,6 +1,6 @@
# Requirements
Here is the minimal hardware requirements to run the example.
Here is the minimal hardware requirements to run the `workflow_by_code` example.
- Memory: 16G
- Free Disk: 5G

View File

@@ -0,0 +1,4 @@
# AdaRNN
* Code: [https://github.com/jindongwang/transferlearning/tree/master/code/deep/adarnn](https://github.com/jindongwang/transferlearning/tree/master/code/deep/adarnn)
* Paper: [AdaRNN: Adaptive Learning and Forecasting for Time Series](https://arxiv.org/pdf/2108.04443.pdf).

View File

@@ -0,0 +1,4 @@
pandas==1.1.2
numpy==1.21.0
scikit_learn==0.23.2
torch==1.7.0

View File

@@ -0,0 +1,87 @@
qlib_init:
provider_uri: "~/.qlib/qlib_data/cn_data"
region: cn
market: &market csi300
benchmark: &benchmark SH000300
data_handler_config: &data_handler_config
start_time: 2008-01-01
end_time: 2020-08-01
fit_start_time: 2008-01-01
fit_end_time: 2014-12-31
instruments: *market
infer_processors:
- class: RobustZScoreNorm
kwargs:
fields_group: feature
clip_outlier: true
- class: Fillna
kwargs:
fields_group: feature
learn_processors:
- class: DropnaLabel
- class: CSRankNorm
kwargs:
fields_group: label
label: ["Ref($close, -2) / Ref($close, -1) - 1"]
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy
kwargs:
signal: <PRED>
topk: 50
n_drop: 5
backtest:
start_time: 2017-01-01
end_time: 2020-08-01
account: 100000000
benchmark: *benchmark
exchange_kwargs:
limit_threshold: 0.095
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: ADARNN
module_path: qlib.contrib.model.pytorch_adarnn
kwargs:
d_feat: 6
hidden_size: 64
num_layers: 2
dropout: 0.0
n_epochs: 200
lr: 1e-3
early_stop: 20
batch_size: 800
metric: loss
loss: mse
GPU: 0
dataset:
class: DatasetH
module_path: qlib.data.dataset
kwargs:
handler:
class: Alpha360
module_path: qlib.contrib.data.handler
kwargs: *data_handler_config
segments:
train: [2008-01-01, 2014-12-31]
valid: [2015-01-01, 2016-12-31]
test: [2017-01-01, 2020-08-01]
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs:
model: <MODEL>
dataset: <DATASET>
- class: SigAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
ana_long_short: False
ann_scaler: 252
- class: PortAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
config: *port_analysis_config

View File

@@ -0,0 +1,3 @@
# ADD
* Paper: [ADD: Augmented Disentanglement Distillation Framework for Improving Stock Trend Forecasting](https://arxiv.org/abs/2012.06289).

View File

@@ -0,0 +1,4 @@
numpy==1.21.0
pandas==1.1.2
scikit_learn==0.23.2
torch==1.7.0

View File

@@ -0,0 +1,92 @@
qlib_init:
provider_uri: "~/.qlib/qlib_data/cn_data"
region: cn
market: &market csi300
benchmark: &benchmark SH000300
data_handler_config: &data_handler_config
start_time: 2008-01-01
end_time: 2020-08-01
fit_start_time: 2008-01-01
fit_end_time: 2014-12-31
instruments: *market
infer_processors:
- class: RobustZScoreNorm
kwargs:
fields_group: feature
clip_outlier: true
- class: Fillna
kwargs:
fields_group: feature
learn_processors:
- class: DropnaLabel
- class: CSRankNorm
kwargs:
fields_group: label
label: ["Ref($close, -2) / Ref($close, -1) - 1"]
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy
kwargs:
signal: <PRED>
topk: 50
n_drop: 5
backtest:
start_time: 2017-01-01
end_time: 2020-08-01
account: 100000000
benchmark: *benchmark
exchange_kwargs:
limit_threshold: 0.095
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: ADD
module_path: qlib.contrib.model.pytorch_add
kwargs:
d_feat: 6
hidden_size: 64
num_layers: 2
dropout: 0.1
dec_dropout: 0.0
n_epochs: 200
lr: 1e-3
early_stop: 20
batch_size: 5000
metric: ic
base_model: GRU
gamma: 0.1
gamma_clip: 0.2
optimizer: adam
mu: 0.2
GPU: 0
dataset:
class: DatasetH
module_path: qlib.data.dataset
kwargs:
handler:
class: Alpha360
module_path: qlib.contrib.data.handler
kwargs: *data_handler_config
segments:
train: [2008-01-01, 2014-12-31]
valid: [2015-01-01, 2016-12-31]
test: [2017-01-01, 2020-08-01]
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs:
model: <MODEL>
dataset: <DATASET>
- class: SigAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
ana_long_short: False
ann_scaler: 252
- class: PortAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
config: *port_analysis_config

View File

@@ -0,0 +1,9 @@
# ALSTM
- ALSTM contains a temporal attentive aggregation layer based on normal LSTM.
- Paper: A dual-stage attention-based recurrent neural network for time series prediction.
[https://www.ijcai.org/Proceedings/2017/0366.pdf](https://www.ijcai.org/Proceedings/2017/0366.pdf)
- NOTE: Current version of implementation is just a simplified version of ALSTM. It is an LSTM with attention.

View File

@@ -0,0 +1,4 @@
numpy==1.21.0
pandas==1.1.2
scikit_learn==0.23.2
torch==1.7.0

View File

@@ -0,0 +1,98 @@
qlib_init:
provider_uri: "~/.qlib/qlib_data/cn_data"
region: cn
market: &market csi300
benchmark: &benchmark SH000300
data_handler_config: &data_handler_config
start_time: 2008-01-01
end_time: 2020-08-01
fit_start_time: 2008-01-01
fit_end_time: 2014-12-31
instruments: *market
infer_processors:
- class: FilterCol
kwargs:
fields_group: feature
col_list: ["RESI5", "WVMA5", "RSQR5", "KLEN", "RSQR10", "CORR5", "CORD5", "CORR10",
"ROC60", "RESI10", "VSTD5", "RSQR60", "CORR60", "WVMA60", "STD5",
"RSQR20", "CORD60", "CORD10", "CORR20", "KLOW"
]
- class: RobustZScoreNorm
kwargs:
fields_group: feature
clip_outlier: true
- class: Fillna
kwargs:
fields_group: feature
learn_processors:
- class: DropnaLabel
- class: CSRankNorm
kwargs:
fields_group: label
label: ["Ref($close, -2) / Ref($close, -1) - 1"]
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy
kwargs:
signal: <PRED>
topk: 50
n_drop: 5
backtest:
start_time: 2017-01-01
end_time: 2020-08-01
account: 100000000
benchmark: *benchmark
exchange_kwargs:
limit_threshold: 0.095
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: ALSTM
module_path: qlib.contrib.model.pytorch_alstm_ts
kwargs:
d_feat: 20
hidden_size: 64
num_layers: 2
dropout: 0.0
n_epochs: 200
lr: 1e-3
early_stop: 10
batch_size: 800
metric: loss
loss: mse
n_jobs: 20
GPU: 0
rnn_type: GRU
dataset:
class: TSDatasetH
module_path: qlib.data.dataset
kwargs:
handler:
class: Alpha158
module_path: qlib.contrib.data.handler
kwargs: *data_handler_config
segments:
train: [2008-01-01, 2014-12-31]
valid: [2015-01-01, 2016-12-31]
test: [2017-01-01, 2020-08-01]
step_len: 20
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs:
model: <MODEL>
dataset: <DATASET>
- class: SigAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
ana_long_short: False
ann_scaler: 252
- class: PortAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
config: *port_analysis_config

View File

@@ -0,0 +1,88 @@
qlib_init:
provider_uri: "~/.qlib/qlib_data/cn_data"
region: cn
market: &market csi300
benchmark: &benchmark SH000300
data_handler_config: &data_handler_config
start_time: 2008-01-01
end_time: 2020-08-01
fit_start_time: 2008-01-01
fit_end_time: 2014-12-31
instruments: *market
infer_processors:
- class: RobustZScoreNorm
kwargs:
fields_group: feature
clip_outlier: true
- class: Fillna
kwargs:
fields_group: feature
learn_processors:
- class: DropnaLabel
- class: CSRankNorm
kwargs:
fields_group: label
label: ["Ref($close, -2) / Ref($close, -1) - 1"]
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy
kwargs:
signal: <PRED>
topk: 50
n_drop: 5
backtest:
start_time: 2017-01-01
end_time: 2020-08-01
account: 100000000
benchmark: *benchmark
exchange_kwargs:
limit_threshold: 0.095
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: ALSTM
module_path: qlib.contrib.model.pytorch_alstm
kwargs:
d_feat: 6
hidden_size: 64
num_layers: 2
dropout: 0.0
n_epochs: 200
lr: 1e-3
early_stop: 20
batch_size: 800
metric: loss
loss: mse
GPU: 0
rnn_type: GRU
dataset:
class: DatasetH
module_path: qlib.data.dataset
kwargs:
handler:
class: Alpha360
module_path: qlib.contrib.data.handler
kwargs: *data_handler_config
segments:
train: [2008-01-01, 2014-12-31]
valid: [2015-01-01, 2016-12-31]
test: [2017-01-01, 2020-08-01]
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs:
model: <MODEL>
dataset: <DATASET>
- class: SigAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
ana_long_short: False
ann_scaler: 252
- class: PortAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
config: *port_analysis_config

View File

@@ -0,0 +1,3 @@
# CatBoost
* Code: [https://github.com/catboost/catboost](https://github.com/catboost/catboost)
* Paper: CatBoost: unbiased boosting with categorical features. [https://proceedings.neurips.cc/paper/2018/file/14491b756b3a51daac41c24863285549-Paper.pdf](https://proceedings.neurips.cc/paper/2018/file/14491b756b3a51daac41c24863285549-Paper.pdf).

View File

@@ -0,0 +1,3 @@
pandas==1.1.2
numpy==1.21.0
catboost==0.24.3

View File

@@ -0,0 +1,70 @@
qlib_init:
provider_uri: "~/.qlib/qlib_data/cn_data"
region: cn
market: &market csi300
benchmark: &benchmark SH000300
data_handler_config: &data_handler_config
start_time: 2008-01-01
end_time: 2020-08-01
fit_start_time: 2008-01-01
fit_end_time: 2014-12-31
instruments: *market
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy
kwargs:
signal: <PRED>
topk: 50
n_drop: 5
backtest:
start_time: 2017-01-01
end_time: 2020-08-01
account: 100000000
benchmark: *benchmark
exchange_kwargs:
limit_threshold: 0.095
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: CatBoostModel
module_path: qlib.contrib.model.catboost_model
kwargs:
loss: RMSE
learning_rate: 0.0421
subsample: 0.8789
max_depth: 6
num_leaves: 100
thread_count: 20
grow_policy: Lossguide
bootstrap_type: Poisson
dataset:
class: DatasetH
module_path: qlib.data.dataset
kwargs:
handler:
class: Alpha158
module_path: qlib.contrib.data.handler
kwargs: *data_handler_config
segments:
train: [2008-01-01, 2014-12-31]
valid: [2015-01-01, 2016-12-31]
test: [2017-01-01, 2020-08-01]
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs:
model: <MODEL>
dataset: <DATASET>
- class: SigAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
ana_long_short: False
ann_scaler: 252
- class: PortAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
config: *port_analysis_config

View File

@@ -0,0 +1,70 @@
qlib_init:
provider_uri: "~/.qlib/qlib_data/cn_data"
region: cn
market: &market csi500
benchmark: &benchmark SH000905
data_handler_config: &data_handler_config
start_time: 2008-01-01
end_time: 2020-08-01
fit_start_time: 2008-01-01
fit_end_time: 2014-12-31
instruments: *market
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy
kwargs:
signal: <PRED>
topk: 50
n_drop: 5
backtest:
start_time: 2017-01-01
end_time: 2020-08-01
account: 100000000
benchmark: *benchmark
exchange_kwargs:
limit_threshold: 0.095
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: CatBoostModel
module_path: qlib.contrib.model.catboost_model
kwargs:
loss: RMSE
learning_rate: 0.0421
subsample: 0.8789
max_depth: 6
num_leaves: 100
thread_count: 20
grow_policy: Lossguide
bootstrap_type: Poisson
dataset:
class: DatasetH
module_path: qlib.data.dataset
kwargs:
handler:
class: Alpha158
module_path: qlib.contrib.data.handler
kwargs: *data_handler_config
segments:
train: [2008-01-01, 2014-12-31]
valid: [2015-01-01, 2016-12-31]
test: [2017-01-01, 2020-08-01]
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs:
model: <MODEL>
dataset: <DATASET>
- class: SigAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
ana_long_short: False
ann_scaler: 252
- class: PortAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
config: *port_analysis_config

View File

@@ -0,0 +1,77 @@
qlib_init:
provider_uri: "~/.qlib/qlib_data/cn_data"
region: cn
market: &market csi300
benchmark: &benchmark SH000300
data_handler_config: &data_handler_config
start_time: 2008-01-01
end_time: 2020-08-01
fit_start_time: 2008-01-01
fit_end_time: 2014-12-31
instruments: *market
infer_processors: []
learn_processors:
- class: DropnaLabel
- class: CSRankNorm
kwargs:
fields_group: label
label: ["Ref($close, -2) / Ref($close, -1) - 1"]
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy
kwargs:
signal: <PRED>
topk: 50
n_drop: 5
backtest:
start_time: 2017-01-01
end_time: 2020-08-01
account: 100000000
benchmark: *benchmark
exchange_kwargs:
limit_threshold: 0.095
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: CatBoostModel
module_path: qlib.contrib.model.catboost_model
kwargs:
loss: RMSE
learning_rate: 0.0421
subsample: 0.8789
max_depth: 6
num_leaves: 100
thread_count: 20
grow_policy: Lossguide
bootstrap_type: Poisson
dataset:
class: DatasetH
module_path: qlib.data.dataset
kwargs:
handler:
class: Alpha360
module_path: qlib.contrib.data.handler
kwargs: *data_handler_config
segments:
train: [2008-01-01, 2014-12-31]
valid: [2015-01-01, 2016-12-31]
test: [2017-01-01, 2020-08-01]
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs:
model: <MODEL>
dataset: <DATASET>
- class: SigAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
ana_long_short: False
ann_scaler: 252
- class: PortAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
config: *port_analysis_config

Some files were not shown because too many files have changed in this diff Show More