This project implements a Bitcoin trading agent using Deep Q-Learning (DQN) enhanced with synthetic data containing rare events such as crashes, spikes, and volatility segments.
data.py: Download and preprocess real and synthetic Bitcoin data.environment.py: Trading environment definition.agent.py: DQN agent implementation using PyTorch.train.py: Training the agent with and without synthetic data.evaluate.py: Agent evaluation.visualize.py: Visualization of training results.main.py: Main script running the complete training and evaluation pipeline.
-
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # Linux/macOS .venv\Scripts\activate # Windows
-
Install the required packages:
pip install -r requirements.txt
-
Run the main script:
python main.py
-Uses the yfinance library to fetch historical Bitcoin data.
-Synthetic data is generated simulating prolonged crashes, flash crashes, and volatile periods.
-The model is trained with Deep Q-Learning via PyTorch.
-Provides visualization of agent performance during training.
-Suitable for experimentation with reinforcement learning on financial data.