All Projects → ShuaiW → Teach Machine To Trade

ShuaiW / Teach Machine To Trade

Programming Languages

python
139335 projects - #7 most used programming language

Teach Machine to Trade

This repo has code for the post: Teach Machine to Trade

Dependencies

Python 2.7. To install all the libraries, run pip install -r requirements.txt

Table of content

  • agent.py: a Deep Q learning agent
  • envs.py: a simple 3-stock trading environment
  • model.py: a multi-layer perceptron as the function approximator
  • utils.py: some utility functions
  • run.py: train/test logic
  • requirement.txt: all dependencies
  • data/: 3 csv files with IBM, MSFT, and QCOM stock prices from Jan 3rd, 2000 to Dec 27, 2017 (5629 days). The data was retrieved using Alpha Vantage API

How to run

To train a Deep Q agent, run python run.py --mode train. There are other parameters and I encourage you look at the run.py script. After training, a trained model as well as the portfolio value history at episode end would be saved to disk.

To test the model performance, run python run.py --mode test --weights <trained_model>, where <trained_model> points to the local model weights file. Test data portfolio value history at episode end would be saved to disk.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].