1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-06-06 05:51:17 +08:00
Files
qlib/examples/rl
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
..
2022-12-06 20:49:56 +08:00
2023-01-03 00:17:18 +08:00

This folder contains a simple example of how to run Qlib RL. It contains:

.
├── experiment_config
│   ├── backtest       # Backtest config
│   └── training       # Training config
├── README.md          # Readme (the current file)
└── scripts            # Scripts for data pre-processing

Data preparation

Use AzCopy to download data:

azcopy copy https://qlibpublic.blob.core.windows.net/data/rl/qlib_rl_example_data ./ --recursive
mv qlib_rl_example_data data

The downloaded data will be placed at ./data. The original data are in data/csv. To create all data needed by the case, run:

bash scripts/data_pipeline.sh

After the execution finishes, the data/ directory should be like:

data
├── backtest_orders.csv
├── bin
├── csv
├── pickle
├── pickle_dataframe
└── training_order_split

Run training

Run:

python -m qlib.rl.contrib.train_onpolicy --config_path ./experiment_config/training/config.yml

After training, checkpoints will be stored under checkpoints/.

Run backtest

python -m qlib.rl.contrib.backtest --config_path ./experiment_config/backtest/config.yml

The backtest workflow will use the trained model in checkpoints/. The backtest summary can be found in outputs/.

Others

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 for RL without business loss is created.