Skip to content

Latest commit

 

History

History
executable file
·
50 lines (38 loc) · 1.4 KB

Readme.md

File metadata and controls

executable file
·
50 lines (38 loc) · 1.4 KB

Stock Trading with Gym Environment

A custom OpenAI gym environment for simulating stock trades on historical price data.

Installation of Stable_Baselines

Prerequisites

Baselines requires python3 (>=3.5) with the development headers. You'll also need system packages CMake, OpenMPI and zlib. Those can be installed as follows

Mac OS X

Installation of system packages on Mac requires Homebrew. With Homebrew installed, run the follwing:

brew install cmake openmpi

Install using pip

Install the Stable Baselines package

Using pip from pypi:

pip install stable-baselines

Please read the documentation for more details and alternatives (from source, using docker).

Installation of mpl_finance

Install the mpl_finance package for plotting

Using pip from pypi:

pip install mpl_finance

How to run

Get historical data

To get historical stock price data from Alpha Vantage, run the following code:

python fetchdata.py

Run the algorithm

You can either render the result to a text file or visualize it

python main.py

Check the parameter of the render function for usage.

References

If you'd like to learn about creating custom OpenAI gym environments, check out the Medium article