Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Highfreq Backtest with the Model/Rule/RL Strategy #438

Merged
merged 223 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
223 commits
Select commit Hold shift + click to select a range
d3a1e03
add sample & base class
bxdd Mar 19, 2021
971d6a2
update strategy
bxdd Apr 21, 2021
8979d78
update report & account
bxdd Apr 21, 2021
39deb7d
update env & strategy, add workflow
bxdd Apr 22, 2021
b14efa1
update trade calendar & backtest workflow
bxdd Apr 23, 2021
af0053e
fix bug
bxdd Apr 24, 2021
8920c19
del outdate file
bxdd Apr 26, 2021
86a6f56
trade_account support multi bar report
bxdd Apr 28, 2021
49cdaf8
update port_ana_record
bxdd Apr 28, 2021
f404a03
black format
bxdd Apr 28, 2021
a109df3
fix bug in recorder
bxdd Apr 29, 2021
d297a49
fix bugs
bxdd Apr 30, 2021
e30df11
solve the conflict
bxdd Apr 30, 2021
ae33950
del old strategy
bxdd Apr 30, 2021
7540ecd
fix trade time bug
bxdd May 6, 2021
bc3eada
black format
bxdd May 6, 2021
f7d3096
update the internal bar strategy
bxdd May 6, 2021
621cb24
fix some comments and add docstring
bxdd May 11, 2021
07eaada
fix comments
bxdd May 12, 2021
c703dab
fix rule_strategy reset method
bxdd May 12, 2021
de2658a
fix rule_strategy bug
bxdd May 13, 2021
ea60e60
update rule_startegy & add README, notebook for multi-level trading
bxdd May 13, 2021
eaa719d
optimize rule_strategy performance
bxdd May 14, 2021
dda509d
Update record_temp.py
you-n-g May 19, 2021
26d75b7
Update sample.py
you-n-g May 19, 2021
0c6e505
fix comments
bxdd May 24, 2021
75fcb38
Merge branch 'qlib_highfreq_backtest' of github.com:bxdd/qlib into bx…
bxdd May 24, 2021
ee74489
solve the conflict
bxdd May 24, 2021
2ad61f1
rename var in backtest
bxdd May 27, 2021
4085b44
move backtest to core, fix calendar bugs, add some docstring
bxdd May 27, 2021
6a63654
Merge github.com:microsoft/qlib into bxdd-qlib_highfreq_backtest
bxdd May 27, 2021
c26bee1
Support loading for backtest
ultmaster May 28, 2021
029b63c
fix bugs & add highfreq backtest example
bxdd May 28, 2021
96e393b
del DEBUG log
bxdd May 28, 2021
bf3b757
fix bugs
bxdd May 28, 2021
60e082e
add infra interface & fix no KeyboardInterpret bug
bxdd May 31, 2021
d3dac06
Update simple playground
ultmaster Jun 1, 2021
cdc59a7
Merge branch 'nested_decision_exe' into rl-dummy
ultmaster Jun 1, 2021
bf16e1a
update Order with dataclass
bxdd Jun 1, 2021
a46d99a
black format
bxdd Jun 1, 2021
a183d8a
update workflow_by_code & update executor
bxdd Jun 1, 2021
04fff8c
solve conflict
bxdd Jun 1, 2021
449e3f4
Update init in backtest
ultmaster Jun 1, 2021
a8e96e5
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
ultmaster Jun 1, 2021
83535bf
Playground checkpoint
ultmaster Jun 1, 2021
4d48c96
fix CI
bxdd Jun 1, 2021
3200bb8
Update an initial version of RL
ultmaster Jun 2, 2021
d515efb
Finish RL dummy example
ultmaster Jun 2, 2021
cc8339a
Add a few comments
ultmaster Jun 2, 2021
2314405
Rename files
ultmaster Jun 2, 2021
f5ac623
Refactor for strategy
ultmaster Jun 2, 2021
bf02fc2
Add RL strategy demo
ultmaster Jun 2, 2021
8aee853
update Exchange
bxdd Jun 3, 2021
c43805e
Update end-to-end example and requirements
ultmaster Jun 4, 2021
1581ef1
Update impl for robustness
ultmaster Jun 4, 2021
46d253b
update Exchange.deal_order
bxdd Jun 4, 2021
a06fa2b
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
ultmaster Jun 4, 2021
76be5d5
Refine example
ultmaster Jun 7, 2021
f78e901
fix comments & add VAStrategy & add trade indicator
bxdd Jun 14, 2021
9e45528
update backtest time range
bxdd Jun 14, 2021
4ac6e6e
fix account bug & update indicator_analysis & fix some comments
bxdd Jun 21, 2021
56cf43d
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jun 22, 2021
7525854
Add shortcut in init
Jun 22, 2021
ab97e82
fix bug in Exchange
bxdd Jun 22, 2021
d226ac8
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jun 22, 2021
583fbbe
Resolve init conflict
Jun 22, 2021
1517a9e
add default executor config & update bug in indicator
bxdd Jun 24, 2021
b6564cd
support trade decision update
bxdd Jun 24, 2021
284d967
fix bug in resam feature
bxdd Jun 27, 2021
4f384d3
API enhancement
you-n-g Jun 25, 2021
b68294d
add InfPosition
you-n-g Jun 25, 2021
b41267f
successful run random order gen in day script
you-n-g Jun 25, 2021
9b91758
performance optimization for cal_sam_minute
you-n-g Jun 27, 2021
e78cdd4
return the detailed order indicator
you-n-g Jun 27, 2021
c907d8d
fix bugs of random strategy
you-n-g Jun 27, 2021
72c9593
adapting strategies to latest interfaces.
you-n-g Jun 28, 2021
27f0db6
black format & add comments & add randStrategy direction
you-n-g Jun 28, 2021
8e8bba1
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
ultmaster Jun 28, 2021
20d566c
Merge branch 'rl-dummy' of github.com:ultmaster/qlib into rl-dummy
ultmaster Jun 28, 2021
e1b6f31
add Handler Storage
bxdd Jun 28, 2021
90bbf2b
Fix account update bar_count bug
you-n-g Jun 30, 2021
9985bef
update HashingStockStorage
bxdd Jun 29, 2021
8d1b197
update handler_storage test
bxdd Jun 29, 2021
b242d6e
delMiniTimer in haandler storage test
bxdd Jun 29, 2021
bbf5d1b
add file order strategy
you-n-g Jun 30, 2021
24d5a31
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jun 30, 2021
a401f1e
improve the docstring
you-n-g Jun 30, 2021
2b4a493
Order patch
Jul 1, 2021
8b85b9e
optimize performance of resam data in rule_strategy & exchange
bxdd Jul 1, 2021
8dd5788
fix comments & update resam ts_last method
bxdd Jul 1, 2021
ef7fe8a
support parallel HF trading
you-n-g Jul 3, 2021
ecf2f24
fix comments
bxdd Jul 3, 2021
9b74a19
Merge pull request #493 from bxdd/optimize_resam_data
bxdd Jul 3, 2021
50c0e99
fix ffr and order amount
you-n-g Jul 4, 2021
7048bef
fix ffr and order amount
you-n-g Jul 4, 2021
e063d35
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jul 5, 2021
8264523
Support order dataframe
Jul 6, 2021
cb72857
fix annotation recursive error
you-n-g Jul 6, 2021
bdac9f4
supporting seperated buy and sell price
you-n-g Jul 6, 2021
e214557
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jul 6, 2021
354f7e6
Constrain TWAP trade step
Jul 6, 2021
03d6fac
fix TWAP strategy
you-n-g Jul 6, 2021
dd8231e
simplify the portfolio-based report
you-n-g Jul 6, 2021
6fd50a5
Supporting skip empty decisions
you-n-g Jul 6, 2021
4e41e9c
simplify the portfolio-based report
you-n-g Jul 6, 2021
e42aa67
Supporting skip empty decisions
you-n-g Jul 6, 2021
d6984a3
fill_placehorder
gandalf-in-web3 Jun 19, 2021
d1b8ed9
fix qrun
gandalf-in-web3 Jun 22, 2021
85c75a6
config_extend
Jun 22, 2021
cbe7c52
high_fre_yaml
wangwenxi-handsome Jun 23, 2021
bd6080b
yaml update
wangwenxi-handsome Jun 23, 2021
4488c3b
code optimization
wangwenxi-handsome Jun 23, 2021
8b28575
fill placehorder dict and list
wangwenxi-handsome Jun 24, 2021
267ee35
fix all example
wangwenxi-handsome Jun 28, 2021
93796bd
add exchange kwargs
wangwenxi-handsome Jun 29, 2021
8c743a4
use init_instance_by_config
wangwenxi-handsome Jul 4, 2021
1fb50d5
Merge branch 'main' into nested_decision_exe
you-n-g Jul 7, 2021
0c946cf
add supporting setting trade unit in exchange
you-n-g Jul 7, 2021
e8f5a1e
black format
you-n-g Jul 7, 2021
5c5379e
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jul 7, 2021
32ae6e4
fix calculating base_price
you-n-g Jul 8, 2021
eada864
align range limit
you-n-g Jul 8, 2021
17d8b8a
fix calculating base_price
you-n-g Jul 8, 2021
cbd52b7
align range limit
you-n-g Jul 8, 2021
80f5426
update docsting
you-n-g Jul 9, 2021
ece7b66
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jul 9, 2021
155019b
move the pa sign from last step to first
you-n-g Jul 9, 2021
45bde75
move the pa sign from last step to first
you-n-g Jul 9, 2021
c29e5b2
Fix circular import
Jul 12, 2021
4c4b30e
fix base price and volumn
wangwenxi-handsome Jul 13, 2021
9b38e62
Add more friendly index range by timing
you-n-g Jul 13, 2021
ca14e36
initial account by position
wangwenxi-handsome Jul 13, 2021
0646e53
fix spell error
wangwenxi-handsome Jul 13, 2021
7b9e338
add docs
wangwenxi-handsome Jul 13, 2021
831773a
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jul 14, 2021
571d27c
exchange support expression buy sell limit
you-n-g Jul 14, 2021
94b4567
refactor index_range to trade_range
you-n-g Jul 15, 2021
870f834
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jul 15, 2021
d907817
unify variable names
you-n-g Jul 15, 2021
aae4b02
*tuple
wangwenxi-handsome Jul 15, 2021
f295497
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
wangwenxi-handsome Jul 15, 2021
344f4f6
add data calendar API and refine order cal api
you-n-g Jul 16, 2021
5241b2f
Merge branch 'nested_decision_exe' of github.com:microsoft/qlib into …
you-n-g Jul 16, 2021
65b4434
add PandasQuote
wangwenxi-handsome Jul 16, 2021
110141d
add doc
wangwenxi-handsome Jul 16, 2021
567841e
get qlib data in exchange
wangwenxi-handsome Jul 16, 2021
6ad52e8
black and doc
wangwenxi-handsome Jul 16, 2021
2b8d4dc
callable
wangwenxi-handsome Jul 16, 2021
7738f39
filter zero base price
you-n-g Jul 17, 2021
5f50614
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jul 17, 2021
ed12c7f
add common_infra warning and fix time bug
you-n-g Jul 18, 2021
572181e
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jul 18, 2021
4a62e02
add get_data_cal_avail_range method
you-n-g Jul 18, 2021
25ff62f
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jul 18, 2021
92f2891
fix order factor setting issue
you-n-g Jul 19, 2021
62583ea
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jul 19, 2021
4e862f7
add print cash in verbose mode and code format
you-n-g Jul 20, 2021
9bf8c99
type checking update
Jul 20, 2021
83d4387
pandas_order_indicator
wangwenxi-handsome Jul 21, 2021
10c182e
add order_indicator doc
wangwenxi-handsome Jul 21, 2021
2c8a3de
high_performance_data_structure
wangwenxi-handsome Jul 22, 2021
bbba960
Merge branch 'nested_decision_exe' into nested_decision_exe
you-n-g Jul 23, 2021
d445f28
Merge branch 'main' into nested_decision_exe
you-n-g Jul 23, 2021
0ec6b87
fix little bug
wangwenxi-handsome Jul 23, 2021
301e047
Merge branch 'nested_decision_exe' of https://github.com/wangwenxi-ha…
wangwenxi-handsome Jul 23, 2021
9e6f4ec
Merge pull request #520 from wangwenxi-handsome/nested_decision_exe
you-n-g Jul 23, 2021
a8ea66b
black
wangwenxi-handsome Jul 23, 2021
9d732e9
Update Action
wangwenxi-handsome Jul 23, 2021
6dcbf51
update action
wangwenxi-handsome Jul 24, 2021
4ffb05a
Update Action
wangwenxi-handsome Jul 23, 2021
103d303
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
wangwenxi-handsome Jul 25, 2021
e88c45e
update position
wangwenxi-handsome Jul 25, 2021
bdebe12
support empty benchmark
you-n-g Jul 26, 2021
c202a4b
fix _get_base_vol_pri clip_time_range
wangwenxi-handsome Jul 26, 2021
4924717
fix black
wangwenxi-handsome Jul 26, 2021
fcca242
add cash settlement mechanism
you-n-g Jul 26, 2021
66971d5
fix indicator
wangwenxi-handsome Jul 27, 2021
ba1c575
doc and black for indicator
wangwenxi-handsome Jul 27, 2021
0d41ca2
fix data format bug & twap peeking strategy
you-n-g Jul 27, 2021
0b607da
Merge branch 'nested_decision_exe' of https://github.com/microsoft/ql…
Jul 27, 2021
e817413
Restore examples
Jul 27, 2021
c1992b1
Merge pull request #456 from ultmaster/rl-dummy
you-n-g Jul 27, 2021
ab3c4a2
new twap (more even)
you-n-g Jul 28, 2021
73f5cc0
add suspend check in twap
you-n-g Jul 29, 2021
5c2ddac
volume limit
wangwenxi-handsome Jul 31, 2021
0f2d85d
volume limit update
wangwenxi-handsome Aug 1, 2021
f5db0e1
fix vol limit bug
wangwenxi-handsome Aug 2, 2021
3ff1d91
add __init__
wangwenxi-handsome Aug 2, 2021
8e87950
Print volume limitation log
you-n-g Aug 4, 2021
74e1ee6
update position and negative cash
wangwenxi-handsome Aug 6, 2021
7c85880
add position test
wangwenxi-handsome Aug 8, 2021
05b9fb5
Fix bug when Account.benchmark_config is None
you-n-g Aug 9, 2021
735153a
Cash Update (#559)
wangwenxi-handsome Aug 12, 2021
309dfa3
Add a example to collecting all the decisions
you-n-g Aug 15, 2021
2da6a8c
fix Path re
wangwenxi-handsome Aug 31, 2021
f67b99a
update exchange
wangwenxi-handsome Aug 15, 2021
222c2fd
fix exchange bug
wangwenxi-handsome Aug 15, 2021
8eb7a1f
numpy_order_indicator
wangwenxi-handsome Aug 17, 2021
f7d7f1a
fix nanmean
wangwenxi-handsome Aug 17, 2021
16b9548
get_base_info
wangwenxi-handsome Aug 18, 2021
e134c35
fix index data bug
wangwenxi-handsome Aug 18, 2021
be0d9e6
update freq
wangwenxi-handsome Aug 18, 2021
f111e34
align interface
wangwenxi-handsome Aug 19, 2021
9c326fd
add import order
you-n-g Aug 20, 2021
13a9b7c
type error bug
you-n-g Aug 20, 2021
d9ad8ff
index_data
wangwenxi-handsome Aug 26, 2021
25f54dd
new high freq struc
wangwenxi-handsome Aug 26, 2021
7ee4a20
add lru
wangwenxi-handsome Aug 26, 2021
43a8f50
fix bug
wangwenxi-handsome Aug 27, 2021
d39c8de
draft design
you-n-g Aug 31, 2021
9a74471
Pass basic tests
you-n-g Aug 31, 2021
5f0ee6c
fix bugs
you-n-g Aug 31, 2021
5003e49
fix metric calculation error
you-n-g Sep 1, 2021
9446116
redundant references
wangwenxi-handsome Sep 1, 2021
4da3f3b
broadcast_to and get single data
wangwenxi-handsome Sep 1, 2021
9193805
close and reindex
wangwenxi-handsome Sep 1, 2021
f71b0c1
250s
wangwenxi-handsome Sep 1, 2021
88d2f92
fix sum index data bug
you-n-g Sep 2, 2021
6203e4c
Update the docs of Report
you-n-g Sep 13, 2021
163e3c6
replace multi processing with joblib (#477)
you-n-g Sep 13, 2021
3760a18
Merge nested main (#597)
wangwenxi-handsome Sep 30, 2021
4099050
Merge remote-tracking branch 'origin/main' into nested_decision_exe
you-n-g Sep 30, 2021
48a860c
fix backtest yaml
you-n-g Sep 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ jobs:
pip install --upgrade cython jupyter jupyter_contrib_nbextensions numpy scipy scikit-learn # installing without this line will cause errors on GitHub Actions, while instsalling locally won't
pip install -e .

- name: Test data downloads
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
$CONDA\\python.exe scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --interval 1d --region cn
else
$CONDA/bin/python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --interval 1d --region cn
fi
shell: bash

- name: Install test dependencies
run: |
pip install --upgrade pip
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
python -m pip install black
python -m black qlib -l 120 --check --diff
# Test Qlib installed with pip

- name: Install Qlib with pip
run: |
python -m pip install numpy==1.19.5
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dist/
.nvimrc
.vscode

qlib/VERSION.txt
qlib/data/_libs/expanding.cpp
qlib/data/_libs/rolling.cpp
examples/estimator/estimator_example/
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Recent released features
Features released before 2021 are not listed here.

<p align="center">
<img src="http://fintech.msra.cn/images_v060/logo/1.png" />
<img src="http://fintech.msra.cn/images_v070/logo/1.png" />
</p>


Expand Down Expand Up @@ -70,7 +70,7 @@ Your feedbacks about the features are very important.
# Framework of Qlib

<div style="align: center">
<img src="http://fintech.msra.cn/images_v060/framework.png?v=0.2" />
<img src="docs/_static/img/framework.svg" />
</div>


Expand Down Expand Up @@ -247,19 +247,19 @@ Qlib provides a tool named `qrun` to run the whole workflow automatically (inclu
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_v060/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_v060/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_v060/analysis/analysis_model_IC.png?v=0.1)
![Monthly IC](http://fintech.msra.cn/images_v060/analysis/analysis_model_monthly_IC.png?v=0.1)
![IC](http://fintech.msra.cn/images_v060/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_v060/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_v060/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)
Expand Down Expand Up @@ -389,7 +389,7 @@ Qlib data are stored in a compact format, which is efficient to be combined into
Join IM discussion groups:
|[Gitter](https://gitter.im/Microsoft/qlib)|
|----|
|![image](http://fintech.msra.cn/images_v060/qrcode/gitter_qr.png)|
|![image](http://fintech.msra.cn/images_v070/qrcode/gitter_qr.png)|

# Contributing

Expand Down
Binary file modified docs/_static/img/analysis/analysis_model_IC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/analysis/analysis_model_NDQ.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/analysis/analysis_model_auto_correlation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/analysis/analysis_model_long_short.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/analysis/analysis_model_monthly_IC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/analysis/report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/analysis/risk_analysis_annualized_return.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/analysis/risk_analysis_bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/analysis/risk_analysis_information_ratio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/analysis/risk_analysis_max_drawdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/analysis/risk_analysis_std.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/analysis/score_ic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/_static/img/framework.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/component/backtest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The simple example of the default strategy is as follows.

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)
report, positions = backtest(pred_score, topk=50, n_drop=0.5, limit_threshold=0.0095)

To know more about backtesting with a specific ``Strategy``, please refer to `Portfolio Strategy <strategy.html>`_.

Expand Down
120 changes: 120 additions & 0 deletions docs/component/highfreq.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
.. _highfreq:

============================================
Design of hierarchical order execution framework
============================================
.. currentmodule:: qlib

Introduction
===================

In order to support reinforcement learning algorithms for high-frequency trading, a corresponding framework is required. None of the publicly available high-frequency trading frameworks now consider multi-layer trading mechanisms, and the currently designed algorithms cannot directly use existing frameworks.
In addition to supporting the basic intraday multi-layer trading, the linkage with the day-ahead strategy is also a factor that affects the performance evaluation of the strategy. Different day strategies generate different order distributions and different patterns on different stocks. To verify that high-frequency trading strategies perform well on real trading orders, it is necessary to support day-frequency and high-frequency multi-level linkage trading. In addition to more accurate backtesting of high-frequency trading algorithms, if the distribution of day-frequency orders is considered when training a high-frequency trading model, the algorithm can also be optimized more for product-specific day-frequency orders.
Therefore, innovation in the high-frequency trading framework is necessary to solve the various problems mentioned above, for which we designed a hierarchical order execution framework that can link daily-frequency and intra-day trading at different granularities.

.. image:: ../_static/img/framework.svg

The design of the framework is shown in the figure above. At each layer consists of Trading Agent and Execution Env. The Trading Agent has its own data processing module (Information Extractor), forecasting module (Forecast Model) and decision generator (Decision Generator). The trading algorithm generates the corresponding 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. Here the frequency of trading algorithm, decision content and execution environment can be customized by users (e.g. intra-day 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 hierarchical order execution framework is user-defined in terms of hierarchy division and decision frequency, making it easy for users to explore the effects of combining different levels of trading algorithms and breaking down the barriers between different levels of trading algorithm optimization.
In addition to the innovation in the framework, the hierarchical order execution framework also takes into account various details of the real backtesting environment, minimizing the differences with the final real environment as much as possible. At the same time, the framework is designed to unify the interface between online and offline (e.g. data pre-processing level supports using the same set of code to process both offline and online data) to reduce the cost of strategy go-live as much as possible.

Prepare Data
===================
.. _data:: ../../examples/highfreq/README.md


Example
===========================

Here is an example of highfreq execution.

.. code-block:: python

import qlib
# init qlib
provider_uri_day = "~/.qlib/qlib_data/cn_data"
provider_uri_1min = "~/.qlib/qlib_data/cn_data_1min"
provider_uri_map = {"1min": provider_uri_1min, "day": provider_uri_day}
qlib.init(provider_uri=provider_uri_day, expression_cache=None, dataset_cache=None)

# data freq and backtest time
freq = "1min"
inst_list = D.list_instruments(D.instruments("all"), as_list=True)
start_time = "2020-01-01"
start_time = "2020-01-31"

When initializing qlib, if the default data is used, then both daily and minute frequency data need to be passed in.

.. code-block:: python

# random order strategy config
strategy_config = {
"class": "RandomOrderStrategy",
"module_path": "qlib.contrib.strategy.rule_strategy",
"kwargs": {
"trade_range": TradeRangeByTime("9:30", "15:00"),
"sample_ratio": 1.0,
"volume_ratio": 0.01,
"market": market,
},
}

.. code-block:: python
# backtest config
backtest_config = {
"start_time": start_time,
"end_time": end_time,
"account": 100000000,
"benchmark": None,
"exchange_kwargs": {
"freq": freq,
"limit_threshold": 0.095,
"deal_price": "close",
"open_cost": 0.0005,
"close_cost": 0.0015,
"min_cost": 5,
"codes": market,
},
"pos_type": "InfPosition", # Position with infinitive position
}

please refer to "../../qlib/backtest".

.. code-block:: python
# excutor config
executor_config = {
"class": "NestedExecutor",
"module_path": "qlib.backtest.executor",
"kwargs": {
"time_per_step": "day",
"inner_executor": {
"class": "SimulatorExecutor",
"module_path": "qlib.backtest.executor",
"kwargs": {
"time_per_step": freq,
"generate_portfolio_metrics": True,
"verbose": False,
# "verbose": True,
"indicator_config": {
"show_indicator": False,
},
},
},
"inner_strategy": {
"class": "TWAPStrategy",
"module_path": "qlib.contrib.strategy.rule_strategy",
},
"track_data": True,
"generate_portfolio_metrics": True,
"indicator_config": {
"show_indicator": True,
},
},
}

NestedExecutor represents not the innermost layer, the initialization parameters should contain inner_executor and inner_strategy. simulatorExecutor represents the current excutor is the innermost layer, the innermost strategy used here is the TWAP strategy, the framework currently also supports the VWAP strategy

.. code-block:: python
# backtest
portfolio_metrics_dict, indicator_dict = backtest(executor=executor_config, strategy=strategy_config, **backtest_config)

The metrics of backtest are included in the portfolio_metrics_dict and indicator_dict.
1 change: 0 additions & 1 deletion docs/component/recorder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ Here is a simple exampke of what is done in ``PortAnaRecord``, which users can r
"n_drop": 5,
}
BACKTEST_CONFIG = {
"verbose": False,
"limit_threshold": 0.095,
"account": 100000000,
"benchmark": BENCHMARK,
Expand Down
1 change: 0 additions & 1 deletion docs/component/strategy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ Usage & Example
"n_drop": 5,
}
BACKTEST_CONFIG = {
"verbose": False,
"limit_threshold": 0.095,
"account": 100000000,
"benchmark": BENCHMARK,
Expand Down
2 changes: 0 additions & 2 deletions docs/component/workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Below is a typical config file of ``qrun``.
topk: 50
n_drop: 5
backtest:
verbose: False
limit_threshold: 0.095
account: 100000000
benchmark: *benchmark
Expand Down Expand Up @@ -242,7 +241,6 @@ The following script is the configuration of `backtest` and the `strategy` used
topk: 50
n_drop: 5
backtest:
verbose: False
limit_threshold: 0.095
account: 100000000
benchmark: *benchmark
Expand Down
2 changes: 0 additions & 2 deletions docs/hidden/tuner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ With ``Qlib``, users can easily try their ideas to create better Quant investmen
Framework
===================

.. image:: ../_static/img/framework.png
.. image:: ../_static/img/framework.svg
:align: center


Expand Down
22 changes: 14 additions & 8 deletions examples/benchmarks/ALSTM/workflow_config_alstm_Alpha158.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,23 @@ data_handler_config: &data_handler_config
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy.strategy
module_path: qlib.contrib.strategy
kwargs:
model: <MODEL>
dataset: <DATASET>
topk: 50
n_drop: 5
backtest:
verbose: False
limit_threshold: 0.095
start_time: 2017-01-01
end_time: 2020-08-01
account: 100000000
benchmark: *benchmark
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
exchange_kwargs:
limit_threshold: 0.095
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: ALSTM
Expand Down Expand Up @@ -81,7 +85,9 @@ task:
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs: {}
kwargs:
model: <MODEL>
dataset: <DATASET>
- class: SigAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
Expand Down
22 changes: 14 additions & 8 deletions examples/benchmarks/ALSTM/workflow_config_alstm_Alpha360.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,23 @@ data_handler_config: &data_handler_config
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy.strategy
module_path: qlib.contrib.strategy
kwargs:
model: <MODEL>
dataset: <DATASET>
topk: 50
n_drop: 5
backtest:
verbose: False
limit_threshold: 0.095
start_time: 2017-01-01
end_time: 2020-08-01
account: 100000000
benchmark: *benchmark
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
exchange_kwargs:
limit_threshold: 0.095
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: ALSTM
Expand Down Expand Up @@ -71,7 +75,9 @@ task:
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs: {}
kwargs:
model: <MODEL>
dataset: <DATASET>
- class: SigAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ data_handler_config: &data_handler_config
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy.strategy
module_path: qlib.contrib.strategy
kwargs:
model: <MODEL>
dataset: <DATASET>
topk: 50
n_drop: 5
backtest:
verbose: False
limit_threshold: 0.095
start_time: 2017-01-01
end_time: 2020-08-01
account: 100000000
benchmark: *benchmark
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
exchange_kwargs:
limit_threshold: 0.095
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: CatBoostModel
Expand Down Expand Up @@ -53,7 +57,9 @@ task:
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs: {}
kwargs:
model: <MODEL>
dataset: <DATASET>
- class: SigAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
Expand Down
Loading