RL-Stock  by wangshub

RL agent for stock trading

created 5 years ago
3,347 stars

Top 14.9% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides a deep reinforcement learning (DRL) framework for automated stock trading, targeting individuals interested in applying DRL to financial markets. It aims to develop trading agents that learn optimal buy, sell, and hold strategies to maximize profits, offering an alternative to traditional predictive models.

How It Works

The system models stock trading as a sequential decision-making problem within an OpenAI Gym-like environment. Agents observe normalized stock market data (open, high, low, close prices, volume, etc.) and output actions: buy, sell, or hold, along with a percentage. The reward function is designed to directly reflect current profit, with significant penalties for losses to encourage faster learning of profitable strategies. Policy gradient methods, specifically PPO, are employed for optimizing the agent's strategy due to the continuous nature of action outputs.

Quick Start & Requirements

  • Install dependencies: pip install -r requirements.txt
  • Obtain stock data using baostock: pip install baostock then run python get_stock_data.py
  • Requires Python 3.6+.
  • Official documentation and demo are not explicitly linked, but the README provides code snippets for environment setup and data acquisition.

Highlighted Details

  • Uses Proximal Policy Optimization (PPO) for strategy optimization.
  • Employs a custom reward function based on current profit, with a -100 penalty for losses.
  • Demonstrates results on single stocks (e.g., China Merchants Bank) and a portfolio of over 400 stocks.
  • Claims a 44.5% profit rate for a 1002-stock training set, with 46.5% breaking even.

Maintenance & Community

The project appears to be a personal endeavor with no explicit mention of maintainers, community channels (like Discord/Slack), or a roadmap. The author welcomes feedback and corrections.

Licensing & Compatibility

The repository does not specify a license. The absence of a license implies all rights are reserved, potentially restricting commercial use or integration into closed-source projects.

Limitations & Caveats

The project is presented as a "Just For Fun" experiment by a self-proclaimed novice. The data and methods are sourced from the internet, and the author cannot guarantee their effectiveness or accuracy. The environment is a modified version of an existing stock trading environment.

Health Check
Last commit

2 years ago

Responsiveness

1 week

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

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Travis Fischer Travis Fischer(Founder of Agentic), and
2 more.

ai-hedge-fund by virattt

1.2%
39k
AI-powered hedge fund proof-of-concept for educational use
created 8 months ago
updated 1 day ago
Feedback? Help us improve.