TradeBot is a reinforcement learning-powered trading assistant designed to help users make informed and optimized trading decisions. By leveraging sentiment analysis and market data, TradeBot dynamically adjusts buy and sell thresholds to maximize portfolio performance. This tool is ideal for traders seeking to integrate artificial intelligence into their strategies, offering insights based on real-time sentiment and price trends.
- Python for backend development and reinforcement learning implementation.
- Stable-Baselines3 PPO for reinforcement learning model training.
- Gymnasium for creating a custom trading environment.
- Pandas & NumPy for data handling and preprocessing.
- Sentiment Analysis Model: Hugging Face's
twitter-roberta-base-sentiment-latestfor analyzing sentiment scores from social media data.
- Data Collection:
- Scrape Reddit posts using
reddit_scrape.pyor Mastodon posts withmastodon_scraping.py. Specify the start/end dates and subreddit or hashtag.
- Scrape Reddit posts using
- Sentiment Analysis:
- Analyze collected posts with
sentiment_analysis.py, which uses a pre-trained sentiment model to generate sentiment scores.
- Analyze collected posts with
- Trading Strategy Implementation:
- The custom Gymnasium environment (
TradingEnv) simulates trading decisions based on sentiment scores and market data (e.g., closing prices).
- The custom Gymnasium environment (
- Reinforcement Learning:
- Train a Proximal Policy Optimization (PPO) model to optimize buy/sell thresholds dynamically.
- Backtesting Framework:
- Use
backtesting_with_sentiment.pyto evaluate the basic performance, generating metrics and transaction logs. - use
testingRL.pyto evaluate automatic trade bot, generating action steps and final value
- Use
- Prepare your dataset by running the scraping scripts (
reddit_scrape.pyormastodon_scraping.py) and analyzing them withsentiment_analysis.py. - Train the PPO model using market data in
TradingEnv. - Deploy the trained model to simulate trading or use it in real-world scenarios.
- Clone the repository and navigate to the project folder.
- Install required libraries:
> pip install -r requirements.txt- Use
reddit_scrape.pyand mastodon_scraping.py to collect post data from reddit and mastodon - Use
sentiment_analysis.pyto categorize the sentiment of each post content - Use
data_preprocessing.pyand necessary script to clean the data
- Train the model by tesla stock data using the
RLbot.pyfile, altering the timestep to train to your needs - Test the model by nvidia stock data using the
testingRL.pyfile
TradeBotRL is licensed under MIT License. All development is currently maintain by Hoang Quy Nguyen.