The project detailed in the notebook is focused on developing a Deep Reinforcement Learning (DRL) model for trading strategies. Here's a technical breakdown of the workflow:
-
Data Import and Preparation:
- The project begins by downloading financial data (OHLCV) from Yahoo Finance into a pandas DataFrame. This includes time-series stock data that will be processed and analyzed.
-
Feature Engineering:
- The
ta(technical analysis) library is employed to create relevant technical indicators and features that describe market conditions. - Feature correlations are analyzed, and highly correlated features are removed to enhance model performance by reducing redundancy.
- The
-
Train/Test Data Split:
- Data is split into training and testing sets using a sequential split, preserving the temporal structure necessary for accurate financial modeling.
-
Custom Gym Environment for Trading:
- A reinforcement learning environment is created using
gym. It includes:- Action Space: Defines the possible actions (buy, sell, hold).
- Observation Space: Contains the input data used by the agent for decision-making.
- Reward Function: Defines the feedback mechanism based on actions taken by the agent, linked to profit/loss or market performance.
- A reinforcement learning environment is created using
-
Hyperparameter Optimization:
- Bayesian optimization is used to fine-tune the reinforcement learning model's hyperparameters to maximize trading performance.
-
DRL Model Implementation:
- A Deep Reinforcement Learning algorithm is implemented using the
stable_baselines3library, and the model is trained in the custom environment.
- A Deep Reinforcement Learning algorithm is implemented using the
-
Evaluation and Visualization:
- After training, the agent’s performance is evaluated, and results are visualized to track trading strategies over time, including profits, losses, and bankruptcies.
The project uses a combination of Python libraries such as pandas, numpy, matplotlib, ta, yfinance, and stable_baselines3 to implement and train a trading agent in a reinforcement learning framework.