9.9 KiB
QuantumBotX Automatic Strategy Switching System
Overview
The Automatic Strategy Switching System is an intelligent trading system that automatically monitors multiple instruments and strategies, evaluates their performance in real-time, and switches to the best performing combination based on comprehensive performance metrics and market conditions.
Key Features
1. Market Condition Detection
- Trend vs Range Analysis: Uses ADX, moving averages, and price action to identify market conditions
- Volatility Regime Monitoring: Detects high, normal, and low volatility periods
- Session Awareness: Identifies active trading sessions for different instruments
- Instrument Classification: Automatically classifies instruments (Indices, Forex, Gold, Crypto)
2. Performance Scoring System
- Multi-Metric Evaluation: Scores strategy/instrument combinations across 5 key dimensions:
- Profitability (30% weight): Net profit, profit factor, win rate
- Risk Control (25% weight): Drawdown, risk/reward ratio
- Consistency (20% weight): Trade frequency, profit consistency
- Activity Level (15% weight): Number of trades generated
- Market Fit (10% weight): Strategy-to-instrument compatibility
- Risk-Adjusted Returns: Prioritizes consistent, low-risk performance over high-risk gains
- Recent Performance Focus: Emphasizes recent results for current market relevance
3. Automatic Switching Logic
- Intelligent Ranking: Continuously ranks all strategy/instrument combinations
- Threshold-Based Switching: Only switches when significant improvement is detected
- Cooldown Periods: Prevents excessive switching with configurable cooldown periods
- Historical Tracking: Maintains performance history and switch logs
4. Dashboard & Monitoring
- Real-Time Status: Current active strategy and instrument
- Performance Rankings: Live ranking of all combinations
- Switch History: Log of all strategy changes with reasons
- Market Conditions: Current state of all monitored instruments
- REST API: Full programmatic access to all system features
System Architecture
┌─────────────────────────────────────────────────────────────┐
│ Web Dashboard/API │
└─────────────────────┬───────────────────────────────────────┘
│
┌─────────────────────▼───────────────────────────────────────┐
│ Strategy Switcher Core Logic │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Market Condition Detector │ │
│ │ • Trend/Ranging detection │ │
│ │ • Volatility analysis │ │
│ │ • Session awareness │ │
│ └────────────────────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Performance Scorer │ │
│ │ • Multi-metric scoring │ │
│ │ • Risk-adjusted returns │ │
│ │ • Strategy ranking │ │
│ └────────────────────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Switching Logic │ │
│ │ • Automatic evaluation │ │
│ │ • Threshold-based switching │ │
│ │ • Cooldown management │ │
│ └────────────────────────────────────────────────────────┘ │
└─────────────────────┬───────────────────────────────────────┘
│
┌─────────────────────▼───────────────────────────────────────┐
│ Backtesting Engine │
│ • Enhanced backtesting with realistic conditions │
│ • ATR-based risk management │
│ • Spread cost modeling │
└─────────────────────┬───────────────────────────────────────┘
│
┌─────────────────────▼───────────────────────────────────────┐
│ Market Data Feeds │
│ • Historical data from CSV files │
│ • Live market data (future integration) │
└─────────────────────────────────────────────────────────────┘
Configuration
The system is highly configurable through strategy_switcher_config.json:
{
"switching_cooldown_hours": 24,
"performance_evaluation_period": 500,
"min_performance_score": 0.6,
"switch_threshold": 0.1,
"data_directory": "lab/backtest_data",
"monitored_instruments": ["US500", "EURUSD", "GBPUSD", "XAUUSD", "BTCUSD"],
"test_strategies": [
"INDEX_BREAKOUT_PRO",
"MA_CROSSOVER",
"RSI_CROSSOVER",
"TURTLE_BREAKOUT",
"QUANTUMBOTX_HYBRID"
]
}
Performance Metrics
The system evaluates strategy/instrument combinations using these key metrics:
-
Profitability Score
- Net profit analysis
- Profit factor calculation
- Win rate evaluation
- Average win/loss ratio
-
Risk Control Score
- Maximum drawdown assessment
- Risk/reward ratio
- Position sizing effectiveness
- Volatility-adjusted returns
-
Consistency Score
- Trade frequency analysis
- Profit consistency
- Win/loss distribution
- Performance stability
-
Activity Level Score
- Number of trades generated
- Signal quality
- Market engagement
-
Market Fit Score
- Strategy-to-instrument compatibility
- Market condition alignment
- Historical performance in similar conditions
Benefits
For Traders
- Hands-Free Trading: Automatic optimization without manual intervention
- Risk Management: Consistent low-risk, high-reward approach
- Market Adaptation: Automatically adapts to changing market conditions
- Performance Maximization: Always uses the best performing strategy
For Developers
- Modular Design: Easy to extend with new strategies and instruments
- Comprehensive API: Full programmatic control
- Real-Time Monitoring: Dashboard for performance tracking
- Configurable Parameters: Flexible system configuration
Test Results
In recent testing, the system successfully identified optimal combinations:
Top Performers:
- 🥇 INDEX_BREAKOUT_PRO/US500 (Score: 0.707)
- 🥈 MA_CROSSOVER/GBPUSD (Score: 0.698)
- 🥉 MA_CROSSOVER/EURUSD (Score: 0.696)
Key Insights:
- US500 with INDEX_BREAKOUT_PRO showed excellent risk-adjusted returns
- GBPUSD and EURUSD performed well with trend-following strategies
- Gold (XAUUSD) was challenging for most strategies in current conditions
- Crypto (BTCUSD) showed strong performance with momentum strategies
Future Enhancements
- Live Market Integration: Connect to real-time market data feeds
- Machine Learning: Implement ML models for predictive performance scoring
- Portfolio Management: Extend to multi-instrument portfolio optimization
- Custom Strategies: Allow user-defined strategy evaluation criteria
- Mobile Alerts: Push notifications for strategy switches and key events
- Advanced Risk Models: Incorporate Value-at-Risk and other advanced metrics
Integration Points
The system integrates seamlessly with existing QuantumBotX components:
- Strategy Library: Works with all existing strategies
- Backtesting Engine: Uses enhanced backtesting for performance evaluation
- Web Interface: Dashboard available through Flask web framework
- Trading Bots: Can automatically update bot configurations
- AI Mentor: Performance data feeds into trading mentor analytics
Conclusion
The Automatic Strategy Switching System represents a significant advancement in algorithmic trading, providing intelligent, automated strategy optimization that adapts to changing market conditions while maintaining strict risk controls. This system ensures traders are always using the most effective strategy for current market conditions without requiring constant manual oversight.