trading-bot  by pskrunner14

Stock trading bot using deep Q-learning

created 7 years ago
1,102 stars

Top 35.3% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides a stock trading bot implemented using Deep Q-Learning, suitable for individuals interested in learning about reinforcement learning applications in finance. It offers a simplified, educational approach to building an RL trading agent, demonstrating core concepts and allowing for experimentation with different DQN variants.

How It Works

The bot operates as a model-free reinforcement learning agent. At each step, it observes the stock's recent price history (represented as normalized differences) as its state. Based on this state, it chooses an action: buy, sell, or hold. After executing the action, it receives a reward (change in portfolio value) and updates its internal Q-network parameters using techniques like Vanilla DQN and Double DQN to learn an optimal trading policy through trial and error.

Quick Start & Requirements

  • Install dependencies: pip3 install -r requirements.txt
  • Train agent: python3 train.py data/GOOG.csv data/GOOG_2018.csv --strategy t-dqn
  • Evaluate agent: python3 eval.py data/GOOG_2019.csv --model-name model_GOOG_50 --debug
  • Requires Python 3 and historical stock data (e.g., from Yahoo! Finance). Training is recommended on CPU.

Highlighted Details

  • Implements Vanilla DQN and Double DQN.
  • Trained on GOOG data (2010-17), achieving $1141.45 profit on 2019 test data.
  • State representation uses an n-day window of price differences, normalized via sigmoid.
  • Agent can only trade one stock at a time per decision.

Maintenance & Community

No specific community channels, roadmap, or notable contributors are mentioned in the README.

Licensing & Compatibility

The README does not explicitly state a license. Compatibility for commercial use or closed-source linking is not specified.

Limitations & Caveats

The agent's decision-making is limited to trading a single stock at a time, simplifying the complex problem of portfolio redistribution. The project is presented for learning purposes, and performance may vary significantly with different stocks or market conditions.

Health Check
Last commit

1 year ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
43 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.