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

Push master configuration #5

Merged
merged 10 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions examples/benchmarks/MASTER/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ paper: [MASTER: Market-Guided Stock Transformer for Stock Price Forecasting](htt

codes: [https://github.com/SJTU-Quant/MASTER](https://github.com/SJTU-Quant/MASTER)

## config
We recommend you to use conda to config the environment and run the codes:
> Note that you should install `torch` and by your self.
```
bash config.sh
```

## run
You can directly use the bash script to run the codes (you can set the `universe` and `only_backtest` flag in `run.sh`), this `main.py` will test the model with 3 random seeds:
```
conda activate MASTER
bash run.sh
```
<!-- or you can just directly use `qrun` tp run the codes (note that you should modify your `qlib`, since we add or modify some files in `qlib/contrib/data/dataset.py`, `qlib/data/dataset/__init__.py`, `qlib/data/dataset/processor.py` and `qlib/contrib/model/pytorch_master.py`):
Expand Down
19 changes: 19 additions & 0 deletions examples/benchmarks/MASTER/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# create a new conda environment named `MASTER`
conda create -n MASTER python=3.8
eval "$(conda shell.bash hook)"
conda activate MASTER

# install `qlib`
pip install pyqlib
pip install -r requirements.txt

# the following codes copy the `*.so` files in the installed `qlib` package to our customizable `qlib`
path=$(which conda)
parent_path=$(dirname $path)
parent_path=$(dirname $parent_path)
lib_path="$parent_path/envs/MASTER/lib/python3.8/site-packages/qlib/data/_libs"
echo $lib_path
find $lib_path -type f -name "*.so" -exec cp {} "../../../qlib/data/_libs" \;

# we directly use our customizable `qlib`
pip uninstall pyqlib
2 changes: 1 addition & 1 deletion examples/benchmarks/MASTER/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ def parse_args():
pp.pprint(all_metrics)

for k in all_metrics.keys():
print(f"{k}: {np.mean(all_metrics[k])} +- {np.std(all_metrics[k])}")
print(f"{k}: {np.mean(all_metrics[k])} +- {np.std(all_metrics[k])}")
1 change: 1 addition & 0 deletions examples/benchmarks/MASTER/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chardet
5 changes: 4 additions & 1 deletion examples/benchmarks/MASTER/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ if [ ! -d "./backtest" ]; then
mkdir ./backtest
fi

# set the config
# set the market, you can choose `csi300` or `csi500`
universe=csi300

# set the flag: whether only backtest.
# If choose 'true', we will directly use the trained model and do backtesting; If choose 'false', the script will first train then backtest.
only_backtest=false

sed -i "s/csi.../$universe/g" workflow_config_master_Alpha158.yaml
Expand Down
Loading