2.2 KiB
2.2 KiB
Neural Network Architecture Analysis for Trading Bot
Overview
This document provides a comprehensive analysis of the neural network architecture used in our trading bot system. The system consists of two main neural network components:
- Price Prediction Model - Forecasts future price movements and extrema points
- DQN (Deep Q-Network) - Makes trading decisions based on state representations
1. Price Prediction Model
Architecture
PricePredictionModel(nn.Module)
├── Input Layer: [batch_size, seq_len, 2] (price, volume)
├── LSTM Layers: 2 stacked layers with hidden_size=128
├── Attention Mechanism: Self-attention with linear projections
├── Linear Layer 1: hidden_size → hidden_size
├── ReLU Activation
├── Linear Layer 2: hidden_size → output_size (5 future prices)
└── Output: [batch_size, output_size]
Data Flow
Inputs:
price_history
: Sequence of historical prices [batch_size, seq_len]volume_history
: Sequence of historical volumes [batch_size, seq_len]
Preprocessing:
- Normalization using MinMaxScaler (0-1 range)
- Reshaping to [batch_size, seq_len, 2] (price and volume features)
Forward Pass:
- Input data passes through LSTM layers
- Self-attention mechanism applied to LSTM outputs
- Linear layers process the attended features
- Output represents predicted prices for next 5 candles
Outputs:
predicted_prices
: Array of 5 future price predictionspredicted_extrema
: Binary indicators for potential price extrema points
2. DQN (Deep Q-Network)
Architecture
DQN(nn.Module)
├── Input Layer: [batch_size, state_size]
├── Linear Layer 1: state_size → hidden_size (384)
├── ReLU Activation
├── LSTM Layers: 2 stacked layers with hidden_size=384
├── Multi-Head Attention: 4 attention heads
├── Linear Layer 2: hidden_size → hidden_size
├── ReLU Activation
├── Linear Layer 3: hidden_size → action_size (4)
└── Output: [batch_size, action_size] (Q-values for each action)
Data Flow
Inputs:
state
: Current market state representation [batch_size, state_size]- Price features (normalized prices, returns, volatility)
- Technical indicators (RSI, MACD, Stochastic,