10 KiB
Trading System - Launch Modes Guide
Overview
The unified trading system now provides clean, modular launch modes optimized for scalping and multi-timeframe analysis.
Available Modes
1. Test Mode
python main_clean.py --mode test
- Tests enhanced data provider with multi-timeframe indicators
- Validates feature matrix creation (26 technical indicators)
- Checks data provider health and caching
- Use case: System validation and debugging
2. CNN Training Mode
python main_clean.py --mode cnn --symbol ETH/USDT
- Trains CNN models only
- Prepares multi-timeframe, multi-symbol feature matrices
- Supports timeframes: 1s, 1m, 5m, 1h, 4h
- Use case: Isolated CNN model development
3. RL Training Mode
python main_clean.py --mode rl --symbol ETH/USDT
- Trains RL agents only
- Focuses on 1s scalping data
- Optimized for short-term decision making
- Use case: Isolated RL agent development
4. Combined Training Mode
python main_clean.py --mode train --symbol ETH/USDT
- Trains both CNN and RL models sequentially
- First runs CNN training, then RL training
- Use case: Full model pipeline training
5. Live Trading Mode
python main_clean.py --mode trade --symbol ETH/USDT
- Runs live trading with 1s scalping focus
- Real-time data streaming integration
- Use case: Production trading execution
6. Web Dashboard Mode
python main_clean.py --mode web --demo --port 8050
- Enhanced scalping dashboard with 1s charts
- Real-time technical indicators visualization
- Scalping demo mode with realistic decisions
- Use case: System monitoring and visualization
Key Features
Enhanced Data Provider
- 26 Technical Indicators including:
- Trend: SMA, EMA, MACD, ADX, PSAR
- Momentum: RSI, Stochastic, Williams %R
- Volatility: Bollinger Bands, ATR, Keltner Channels
- Volume: OBV, MFI, VWAP, Volume profiles
- Custom composites for trend/momentum
Scalping Optimization
- Primary timeframe: 1s (falls back to 1m, 5m)
- High-frequency decision making
- Precise buy/sell marker positioning
- Small price movement detection
Memory Management
- 8GB total memory limit with per-model limits
- Automatic cleanup and GPU/CPU fallback
- Model registry with memory tracking
Multi-Timeframe Architecture
- Unified feature matrix: (n_timeframes, window_size, n_features)
- Common feature set across all timeframes
- Consistent shape validation
Quick Start Examples
Test the enhanced system:
python main_clean.py --mode test
# Expected output: Feature matrix (2, 20, 26) with 26 indicators
Start scalping dashboard:
python main_clean.py --mode web --demo
# Access: http://localhost:8050
# Shows 1s charts with scalping decisions
Prepare CNN training data:
python main_clean.py --mode cnn
# Prepares multi-symbol, multi-timeframe matrices
Setup RL training environment:
python main_clean.py --mode rl
# Focuses on 1s scalping data
Technical Improvements
Fixed Issues
✅ Feature matrix shape mismatch - Now uses common features across timeframes
✅ Buy/sell marker positioning - Properly aligned with chart timestamps
✅ Chart timeframe - Optimized for 1s scalping with fallbacks
✅ Unicode encoding errors - Removed problematic emoji characters
✅ Launch configuration - Clean, modular mode selection
New Capabilities
🚀 Enhanced indicators - 26 vs previous 17 features
🚀 Scalping focus - 1s timeframe with dense data points
🚀 Separate training - CNN and RL can be trained independently
🚀 Memory efficiency - 8GB limit with automatic management
🚀 Real-time charts - Enhanced dashboard with multiple indicators
Integration Notes
- CNN modules: Connect to
run_cnn_training()
function - RL modules: Connect to
run_rl_training()
function - Live trading: Integrate with
run_live_trading()
function - Custom indicators: Add to
_add_technical_indicators()
method
Performance Specifications
- Data throughput: 1s candles with 200+ data points
- Feature processing: 26 indicators in < 1 second
- Memory usage: Monitored and limited per model
- Chart updates: 2-second refresh for real-time display
- Decision latency: Optimized for scalping (< 100ms target)
🚀 VSCode Launch Configurations
1. Core Trading Modes
Live Trading (Demo)
"name": "Live Trading (Demo)"
"program": "main.py"
"args": ["--mode", "live", "--demo", "true", "--symbol", "ETH/USDT", "--timeframe", "1m"]
- Purpose: Safe demo trading with virtual funds
- Environment: Paper trading mode
- Risk: Zero (no real money)
Live Trading (Real)
"name": "Live Trading (Real)"
"program": "main.py"
"args": ["--mode", "live", "--demo", "false", "--symbol", "ETH/USDT", "--leverage", "50"]
- Purpose: Real trading with actual funds
- Environment: Live exchange API
- Risk: High (real money)
2. Training & Development Modes
Train Bot
"name": "Train Bot"
"program": "main.py"
"args": ["--mode", "train", "--episodes", "100"]
- Purpose: Standard RL agent training
- Duration: 100 episodes
- Output: Trained model files
Evaluate Bot
"name": "Evaluate Bot"
"program": "main.py"
"args": ["--mode", "eval", "--episodes", "10"]
- Purpose: Model performance evaluation
- Duration: 10 test episodes
- Output: Performance metrics
3. Neural Network Training
NN Training Pipeline
"name": "NN Training Pipeline"
"module": "NN.realtime_main"
"args": ["--mode", "train", "--model-type", "cnn", "--epochs", "10"]
- Purpose: Deep learning model training
- Framework: PyTorch
- Monitoring: Automatic TensorBoard integration
Quick CNN Test (Real Data + TensorBoard)
"name": "Quick CNN Test (Real Data + TensorBoard)"
"program": "test_cnn_only.py"
- Purpose: Fast CNN validation with real market data
- Duration: 2 epochs, 500 samples
- Output:
test_models/quick_cnn.pt
- Monitoring: TensorBoard metrics
4. 🔥 Realtime RL Training + Monitoring
Realtime RL Training + TensorBoard + Web UI
"name": "Realtime RL Training + TensorBoard + Web UI"
"program": "train_realtime_with_tensorboard.py"
"args": ["--episodes", "50", "--symbol", "ETH/USDT", "--web-port", "8051"]
- Purpose: Advanced RL training with comprehensive monitoring
- Features:
- Real-time TensorBoard metrics logging
- Live web dashboard at http://localhost:8051
- Episode rewards, balance tracking, win rates
- Trading performance metrics
- Agent learning progression
- Data: 100% real ETH/USDT market data from Binance
- Monitoring: Dual monitoring (TensorBoard + Web UI)
- Duration: 50 episodes with real-time feedback
5. Monitoring & Visualization
TensorBoard Monitor (All Runs)
"name": "TensorBoard Monitor (All Runs)"
"program": "run_tensorboard.py"
- Purpose: Monitor all training sessions
- Features: Auto-discovery of training logs
- Access: http://localhost:6006
Realtime Charts with NN Inference
"name": "Realtime Charts with NN Inference"
"program": "realtime.py"
- Purpose: Live trading charts with ML predictions
- Features: Real-time price updates + model inference
- Models: CNN + RL integration
6. Advanced Training Modes
TRAIN Realtime Charts with NN Inference
"name": "TRAIN Realtime Charts with NN Inference"
"program": "train_rl_with_realtime.py"
"args": ["--episodes", "100", "--max-position", "0.1"]
- Purpose: RL training with live chart integration
- Features: Visual training feedback
- Position limit: 10% portfolio allocation
📊 Monitoring URLs
Development
- TensorBoard: http://localhost:6006
- Web Dashboard: http://localhost:8051
- Training Status:
python monitor_training.py
Production
- Live Trading Dashboard: Integrated in trading interface
- Performance Metrics: Real-time P&L tracking
- Risk Management: Position size and drawdown monitoring
🎯 Quick Start Recommendations
For CNN Development
- Start: "Quick CNN Test (Real Data + TensorBoard)"
- Monitor: Open TensorBoard at http://localhost:6006
- Validate: Check
test_models/
for output files
For RL Development
- Start: "Realtime RL Training + TensorBoard + Web UI"
- Monitor: TensorBoard (http://localhost:6006) + Web UI (http://localhost:8051)
- Track: Episode rewards, balance progression, win rates
For Production Trading
- Test: "Live Trading (Demo)" first
- Validate: Confirm strategy performance
- Deploy: "Live Trading (Real)" with appropriate risk management
⚡ Performance Features
GPU Acceleration
- Automatic CUDA detection and utilization
- Mixed precision training support
- Memory optimization for large datasets
Real-time Data
- Direct Binance API integration
- Multi-timeframe data synchronization
- Live price feed with minimal latency
Professional Monitoring
- Industry-standard TensorBoard integration
- Custom web dashboards for trading metrics
- Real-time performance tracking
🛡️ Safety Features
Pre-launch Tasks
- Kill Stale Processes: Automatic cleanup before launch
- Port Management: Intelligent port allocation
- Resource Monitoring: Memory and GPU usage tracking
Real Market Data Policy
- ✅ No Synthetic Data: All training uses authentic exchange data
- ✅ Live API Integration: Direct connection to cryptocurrency exchanges
- ✅ Data Validation: Quality checks for completeness and consistency
- ✅ Multi-timeframe Sync: Aligned data across all time horizons
✅ Launch configuration - Clean, modular mode selection
✅ Professional monitoring - TensorBoard + custom dashboards
✅ Real market data - Authentic cryptocurrency price data
✅ Safety features - Risk management and validation
✅ GPU acceleration - Optimized for high-performance training