Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/charlesyuan02/reinforcement-learning-stock-trader

A reinforcement learning stock trader for the S&P 500.
https://github.com/charlesyuan02/reinforcement-learning-stock-trader

deep-reinforcement-learning openai-gym reinforcement-learning stock-trading yahoo-finance

Last synced: 5 days ago
JSON representation

A reinforcement learning stock trader for the S&P 500.

Awesome Lists containing this project

README

        

# reinforcement-learning-stock-trader

## Prerequisites
All code was written in Python 3.10. Please see requirements.txt for dependencies.
```
gym==0.26.2
gym-anytrading==1.3.2
pandas-datareader==0.10.0
scipy==1.10.1
stable_baselines3==1.8.0
tensorflow>=2.11.0
tqdm==4.65.0
yfinance==0.2.12
```

## Description of Files
### data_extractor.py
This file contains all the code used to extract the list of stocks on the S&P 500 and their respective financial data. It also contains a dataloader function for loading the correct data in the training scripts. See doc strings for details.

### single_feature_model.py and multi_feature_model.py
This is where the deep Q-learning models are defined, along with the trade and batch_train methods used in the training scripts. The single feature model only takes in the closing price as a feature, while the multi-feature model takes in as many features as is defined in the training script. Modifications were made accordingly to the multi-feature model methods.

### train_single_feature.py and train_multi_feature.py
This is where the training for the model actually happens. Note that for the multi-feature model's training, we defined the function to allow for multiple stocks to be used, as a further improvement on the single-feature training.

## Description of Files - Post-Interim Report
### custom_environment.py and custom_environment_multistock.py
Implementations of training environments with continuous action spaces. Both follow the format that OpenAI Gym uses, and are compatible with the off-the-shelf models A2C and PPO obtained from stable baselines.

### train_single_stock.py and train_multi_stock.py
The training and evaluation code for A2C and PPO, leveraging our custom environments. One is used for training on one stock at at time, while the other is used for a portfolio of multiple stocks.

## License
This project is licensed under the MIT License - see the LICENSE file for details.