A deep learning–powered crypto trading bot using a hybrid 3D CNN + GRU model to predict market signals (BUY, SELL, HOLD) and execute real-time trades via the Binance API.
-
🔍 Hybrid Deep Learning Model
Combines 3D Convolutional Neural Networks and GRU layers to analyze spatio-temporal patterns in market data -
🧾 Real-Time Trading
Executes live trades using the Binance API, based on the model’s predictions -
🛠️ Customizable Parameters
Easily tune training parameters likeepochs,batch size,learning rate, etc. -
💾 Model State Management
Saves and loads the best-performing model via PyTorch'sstate_dict -
💹 Backtesting Module
Run strategy simulations on historical data to evaluate performance -
🔗 Binance Integration
Fetches real-time market data (default: BTC/USDT) with easy support for other pairs -
📦 Modular Codebase
Designed for clarity and experimentation — each stage is separated and reusable
- 3D Convolutional Neural Networks (3D CNNs) are excellent at capturing spatio-temporal features — that is, patterns across both indicators (features) and time.
- GRU (Gated Recurrent Units) are powerful for sequence modeling, allowing the model to remember trends and time dependencies.
- The combination enables the system to recognize complex multi-dimensional market patterns and short-term trends — essential for high-frequency crypto trading.
This hybrid model aims to improve predictive performance over traditional 2D CNNs or LSTMs used alone.
The pipeline consists of five core Python scripts, each responsible for a key step in the trading workflow:
-
Data Preparation
Collects raw crypto data from Binance, computes technical indicators, assigns labels (BUY,SELL,HOLD), normalizes inputs, and applies oversampling to balance the dataset. -
Model Training
Defines and trains the hybrid deep learning model using a combination of 3D CNN and GRU layers. Includes the training loop, loss tracking, and model saving. -
Backtesting
Tests the trained model on historical data to estimate profitability and performance over a selected time period. Outputs include trade logs and profit metrics. -
Dynamic Optimizer
Connects data prep, training, and backtesting in one loop. Automatically adjusts parameters (e.g., learning rate, batch size) every N iterations to search for better results. -
Live Trading Bot
Uses the trained model to make predictions in real-time and places trades via the Binance API based on the current market conditions.
Install all required libraries with:
pip install requests websocket-client pandas numpy ta torch scikit-learn python-binance python-dotenv