Skip to content

SrDevGui/Q-Learning-Stock-Trading-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Q-Learning Stock Trading Bot

This project demonstrates a simple Q-Learning algorithm applied to stock trading using Apple's historical price data. The agent learns to buy, sell, or hold shares to maximize profit over time.

What is Q-Learning?

Q-Learning is a reinforcement learning algorithm where an agent interacts with an environment, receives feedback, and learns the best actions to take. The agent updates its knowledge (Q-table) based on rewards received from its actions.

Below is a visual explanation of how Q-Learning works:

Q-Learning Process

  1. Input: The agent receives an input (state).
  2. Response: The agent makes a prediction or takes an action.
  3. Feedback: The environment provides feedback (reward or penalty).
  4. Learns: The agent updates its knowledge based on feedback.
  5. Reinforced Response: The agent improves its future responses.

How This Project Works

  • Loads historical stock data for Apple.
  • Sets up a trading environment with three actions: buy, sell, hold.
  • Trains a Q-Learning agent to maximize profit.
  • Tests the agent's performance on the data.

Usage

  1. Place your dataset as dataset.csv in the project folder.

  2. Run the script:

    python app.py
  3. The script will display candlestick charts and print the trading results.

Requirements

  • Python 3.x
  • pandas
  • numpy
  • plotly

Install dependencies with:

pip install pandas numpy plotly

Files

  • app.py: Main script with Q-Learning implementation.
  • dataset.csv: Historical stock data.
  • readme.md: Project documentation.

About

Demonstrates a simple Q-Learning algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages