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
Permalink
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
README.md Update README.md Nov 3, 2018
^DJI.csv update Oct 23, 2018
__init__.py add draft Sep 28, 2018
calculate_return.ipynb
ddpg.csv update Nov 26, 2018
history.csv add new result Nov 23, 2018
mean_variance_return.xlsx updated Oct 19, 2018
result.png
return_final_quarterly.xlsx update Nov 26, 2018

README.md

Practical Deep Reinforcement Learning Approach for Stock Trading

Prerequisites

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 https://github.com/openai/baselines.git
    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
pytest

Replace files with files in this repository and change file address

gym

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

/Users/xiongzhuoran/anaconda3/envs/venv/lib/python3.6/site-packages/gym/
  • Replece the file
gym\envs\__init__.py

with file from this repository

DQN_Stock_Trading/gym/envs/__init__.py 
  • Add folder in this repository to gym\envs in your computer
DQN_Stock_Trading/gym/envs/zxstock of this repository 
  • Open
gym/envs/zxstock/zxstock_env.py and gym/envs/zxstock/zxstock_testenv.py

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

Baseline

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

Training model and Testing

If you only want to train the model run this

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

If you also want to see the testing result

python -m baselines.run --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.