gogo2/crypto/gogo2/_model.md
2025-03-12 00:56:32 +02:00

68 lines
2.2 KiB
Markdown

# 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:
1. **Price Prediction Model** - Forecasts future price movements and extrema points
2. **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:**
1. Input data passes through LSTM layers
2. Self-attention mechanism applied to LSTM outputs
3. Linear layers process the attended features
4. Output represents predicted prices for next 5 candles
**Outputs:**
- `predicted_prices`: Array of 5 future price predictions
- `predicted_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,