Skip to content

An automated trading strategy that uses Deep Q-Learning for strategy refinement and adaptive decision-making in dynamic market conditions.

License

Notifications You must be signed in to change notification settings

ycz425/tradebot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DQN Trading Bot

⚠️ This project is undergoing transition from a sentiment-based trading bot to a DQN-based trading bot. This README has not been updated yet to reflect this change.

Table of Contents

Features

  • Alpaca Integration: Uses the Alpaca API to place buy/sell orders and manage positions.
  • Sentiment Analysis: Leverages the FinBERT model (a pre-trained BERT model) to predict the sentiment of financial news headlines.
  • Backtesting: Includes the ability to backtest the strategy with historical data using Yahoo Finance.
  • Risk Management: Implements stop-loss and take-profit mechanisms for automated trade execution.

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/sentiment-trading-bot.git
cd sentiment-trading-bot
  1. Install the required packages:
pip install -r requirements.txt
  1. Set up environment variables: Create a .env file in the root directory and add your Alpaca API credentials:
API_KEY=your_alpaca_api_key
API_SECRET=your_alpaca_api_secret
BASE_URL=https://paper-api.alpaca.markets

Usage

  1. Run the trading bot:
python bot.py
  1. Backtest the strategy: The backtesting is already included in the bot.py script. It uses Yahoo Finance data to backtest the strategy from January 1, 2020, to January 1, 2025.

Files

  • bot.py: Contains the main trading bot implementation.
  • sentiment.py: Contains the sentiment analysis function using the FinBERT model.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

An automated trading strategy that uses Deep Q-Learning for strategy refinement and adaptive decision-making in dynamic market conditions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages