Quickstart¶
Install q4l
Please refer to GitHub repo for installation instructions.
Getting example data
Download the example data from this link(OneDrive) or this link(Baidu). And put it under examples/benchmark/data
cd examples/benchmark/data
tar -xzvf market_data.tar.gz
You may also refer to q4l/config/q4l_builtin/job/machine/local.yaml
and check data_root
if you want it to be put in another place.
Running LSTM example
Since we use mongodb to track experiment results, you need to start mongodb first. Let’s suppose that you run a MongoDB server on localhost:27017, since this url is the default config in q4l. Then you can run the following command to start an experiment.
cd examples/benchmark
python src/main.py experiment/model=lstm
Experiment results are stored in the mlruns directory and you can use mlflow ui to view them. Mlflow is the experiment tracking system that is deeply integrated into q4l. By default we use local file system to track changes, and you can also specify mlflow tracking server url if you have deployed services.
Running more models
So far provides no more feature than qlib. Now let’s try another model in q4l:
python src/main.py experiment/model=patchtst
This will run a PatchTST model, with only 1 config change.
Running more experiments
Suppose you want to run multiple models, you can do this with one command:
python src/main.py -m experiment/model=lstm,patchtst,fedformer,mixer
This command will run 4 experiments with models being LSTM/PatchTST/FEDFormer/Mixer respectively.
Changing dataset
You may also want to change the dataset to run experiments. This can also be achived via command-line changes. For example, if you want to change region and pool, just run:
python src/main.py ++experiment.data.region=us ++experiment.data.pool=sp500
This will change the dataset to US stock market with SP500 stocks. If you want to change your alpha factors, just run:
python src/main.py +experiment/data/loader/alpha@experiment.data.loader.alpha.alpha101=alpha101 \
++experiment.data.sampler.x_group=[alpha101]
This will change the alpha factors to Alpha101, and change the x_group (i.e. the feature group) to alpha101.
Under the hood there are some other config changes, but they are handled by config groups in q4l.
There are a lot more components in q4l that can be tweaked, providing you with a lot of flexibility. Feel free to explore them in the following docs!