We provide the original implementation for "Cost-Sensitive Portfolio Selection via Deep Reinforcement Learning (IEEE TKDE 2020)".
The paper is available [here].
Note that this library is several versions ahead of the article. The main difference is the decision making module, where we develop a new leverage operation that contributes a lot.
Python 2.7
Tensorflow>=1.4.0
Tflearn>=0.3.2
pympler>=0.5
cvxopt>=1.1.9
seaborn>=0.8.1
pandas>=0.20.3
The attached dataset is the S&P500, whose description can be found in the paper.
Please download the dataset [here], and put the dataset file (databse) in the main directory.
There are three steps (Please use this code after downloading the dataset):
- go into train_package/1 file, and modify the net_config.json file for parameter setting (one can also construct train_package/2)
- vim the main.py file, and set a specific GPU device
- python main.py --mode=train --process=1
(logging information: view train_package/1/programlog)
python main.py --mode=backtest --algo=1
(--algo could be either the name of traditional method or the index of training folder)
The trained weights of the network are saved at train_package/1 named as netfile (including 3 files)
python main.py --mode=plot --algos=crp,olmar,1 --labels=crp,olmar,ours
(--algos could be the name of the tdagent algorithms or the index of nnagent)
(--labels is the name of related algorithm that will be shown in the legend)
python main.py --mode=table --algos=1,olmar,ons --labels=nntrader,olmar,ons
This project is constructed based on the open source project:
- [PGPortfolio toolbox(https://github.com/ZhengyaoJiang/PGPortfolio)]
It would not have been finished without using the codes from the following open source projects:
There is always risk of loss in trading. All trading strategies are used at your own risk.
If you use this code, please cite:
@article{zhang2020cost,
title={Cost-sensitive portfolio selection via deep reinforcement learning},
author={Zhang, Yifan and Zhao, Peilin and Li, Bin and Wu, Qingyao and Huang, Junzhou and Tan, Mingkui},
journal={IEEE Transactions on Knowledge and Data Engineering},
year={2020},
publisher={IEEE}
}