Skip to content
Using DQN/DDPG for stock trading
Python HTML Jupyter Notebook
Branch: master
Clone or download
YinchuanCU Delete main.ipynb
Incorrect operation caused wrong uploaded file
Latest commit a1e2c90 Feb 11, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
Data_Daily_Stock_Dow_Jones_30 updated Oct 19, 2018
Documents dow jones Oct 11, 2018
baselines add new baselines Oct 13, 2018
gym add two package Oct 13, 2018
.DS_Store added weight Oct 17, 2018
.gitignore updated data Oct 16, 2018
LICENSE Initial commit Sep 19, 2018 Update Nov 3, 2018
^DJI.csv update Oct 23, 2018 add draft Sep 28, 2018
ddpg.csv update Nov 26, 2018
history.csv add new result Nov 23, 2018
mean_variance_return.xlsx updated Oct 19, 2018
return_final_quarterly.xlsx update Nov 26, 2018

Practical Deep Reinforcement Learning Approach for Stock Trading


Python 3.6 envrionment

CMake, OpenMPI

Installation of system packages CMake, OpenMPI on Mac

brew install cmake openmpi

Activate your envrionment using using conda or Anaconda

source activate myenv

Install gym under this environment

pip install gym

Download Official Baseline Package

  • Clone the repo and cd into it:

    git clone
    cd baselines
  • Install tendorflow

    pip install Tensorflow

    should be sufficient. Refer to TensorFlow installation guide for more details.

  • Install baselines package

    pip install -e .

Testing the installation

All unit tests in baselines can be run using pytest runner:

pip install pytest

Replace files with files in this repository and change file address


Find your gym package under environment folder, in my computer it is under

  • Replece the file

with file from this repository

  • Add folder in this repository to gym\envs in your computer
DQN_Stock_Trading/gym/envs/zxstock of this repository 
  • Open
gym/envs/zxstock/ and gym/envs/zxstock/

change the address at line 9 and line 10 into where you want to save the image


  • Open your baselines folder cloned before, find
  • Replace it with
DQN_Stock_Trading/baselines/baselines/ in this reposotory

Training model and Testing

If you only want to train the model run this

python -m --alg=ddpg --env=ZXStock-v0 --network=mlp --num_timesteps=1e4

If you also want to see the testing result

python -m --alg=ddpg --env=ZXStock-v0 --network=mlp --num_timesteps=1e4 --play

Some Other Commands May Need:

Tensorflow Update

pip install --upgrade tensorflow==1.11.0
pip3 install opencv-python
pip3 install lockfile
pip3 install -U numpy
pip3 install mujoco-py==0.5.7
You can’t perform that action at this time.