mirror of
https://github.com/chrisnov-it/quantumbotx.git
synced 2026-07-27 18:57:47 +00:00
Implement automatic holiday detection and conditional visibility for Ramadan mode. Ramadan navigation link now only appears when Ramadan is active. Enhanced dashboard with holiday-specific widgets that appear automatically. Updated documentation for holiday integration features.
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
# Holiday Integration System
|
||||
|
||||
## Overview
|
||||
|
||||
The QuantumBotX platform includes an automatic holiday detection system that seamlessly activates culturally-appropriate trading modes for both Christian and Muslim traders. This system automatically adjusts trading parameters, UI themes, and risk management settings based on calendar dates.
|
||||
|
||||
## Features
|
||||
|
||||
### Automatic Activation
|
||||
- **Christmas Mode**: Automatically activates from December 20th through January 6th
|
||||
- **Ramadan Mode**: Automatically activates during the Islamic holy month of Ramadan
|
||||
- **New Year Mode**: Automatically activates around New Year's Day
|
||||
- **Eid al-Fitr Mode**: Automatically activates during the Eid al-Fitr celebration
|
||||
|
||||
### Dynamic UI Visibility
|
||||
- **Conditional Navigation**: Holiday-specific pages (like Ramadan) only appear in navigation when active
|
||||
- **Dashboard Widgets**: Holiday-specific widgets appear automatically on the main dashboard
|
||||
- **Thematic Elements**: Visual themes and effects activate based on the current holiday
|
||||
|
||||
### Ramadan Trading Mode
|
||||
|
||||
When Ramadan is detected, the system automatically applies:
|
||||
|
||||
1. **Trading Pauses**:
|
||||
- Sahur: 03:30-05:00 WIB
|
||||
- Iftar: 18:00-19:30 WIB
|
||||
- Tarawih: 20:00-21:30 WIB
|
||||
|
||||
2. **Risk Adjustments**:
|
||||
- 20% risk reduction during fasting hours
|
||||
- Reduced position sizing
|
||||
- Conservative trade execution
|
||||
|
||||
3. **UI Enhancements**:
|
||||
- Islamic green and gold color scheme
|
||||
- Crescent moon decorations
|
||||
- Iftar countdown timer
|
||||
- Patience reminders
|
||||
|
||||
4. **Special Features**:
|
||||
- Zakat calculator
|
||||
- Charity tracker
|
||||
- Optimal trading hours guidance
|
||||
- Patience-focused trading advice
|
||||
|
||||
### Christmas Trading Mode
|
||||
|
||||
When Christmas is detected, the system automatically applies:
|
||||
|
||||
1. **Trading Pauses**:
|
||||
- December 24th (Christmas Eve)
|
||||
- December 25th (Christmas Day)
|
||||
- December 26th (Boxing Day)
|
||||
- December 31st (New Year's Eve)
|
||||
- January 1st (New Year's Day)
|
||||
|
||||
2. **Risk Adjustments**:
|
||||
- 50% risk reduction during the holiday period
|
||||
- 30% reduction in lot sizes
|
||||
- Maximum of 3 trades per day
|
||||
|
||||
3. **UI Enhancements**:
|
||||
- Christmas red and green color scheme
|
||||
- Snow effect animation
|
||||
- Christmas countdown timer
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Backend Components
|
||||
|
||||
1. **Holiday Manager** (`core/seasonal/holiday_manager.py`):
|
||||
- Detects active holidays based on current date
|
||||
- Provides holiday-specific configurations
|
||||
- Calculates prayer times for Ramadan
|
||||
- Manages trading adjustments
|
||||
|
||||
2. **API Endpoints**:
|
||||
- `/api/holiday/status` - Get current holiday status
|
||||
- `/api/holiday/pause-status` - Check if trading is paused
|
||||
- `/api/ramadan/features` - Get Ramadan-specific features
|
||||
|
||||
### Frontend Integration
|
||||
|
||||
1. **Base Template** (`templates/base.html`):
|
||||
- Global holiday detection script
|
||||
- Dynamic CSS theme application
|
||||
- Holiday banner display
|
||||
- Conditional navigation visibility
|
||||
|
||||
2. **Dashboard** (`templates/index.html`):
|
||||
- Holiday-specific widgets
|
||||
- Iftar countdown timer (Ramadan)
|
||||
- Christmas countdown timer
|
||||
- Risk adjustment indicators
|
||||
- Patience reminders (Ramadan)
|
||||
|
||||
3. **Holiday Pages**:
|
||||
- Dedicated Ramadan page (only visible when active)
|
||||
- Informational content about automatic activation
|
||||
|
||||
## Benefits
|
||||
|
||||
1. **Cultural Sensitivity**: Automatically respects religious observances
|
||||
2. **Risk Management**: Reduces trading activity during distracted periods
|
||||
3. **User Experience**: Seamless integration without manual configuration
|
||||
4. **Inclusivity**: Supports both Christian and Muslim trading traditions
|
||||
5. **Automation**: No user intervention required for activation
|
||||
6. **Clean Interface**: Holiday-specific navigation only appears when relevant
|
||||
|
||||
## Technical Notes
|
||||
|
||||
- Holiday dates are estimated for Ramadan due to the lunar calendar
|
||||
- Production implementations should use proper Islamic calendar libraries
|
||||
- UI themes are applied dynamically through CSS variables
|
||||
- Trading pauses are checked in real-time during bot execution
|
||||
- Navigation elements are conditionally displayed based on holiday status
|
||||
@@ -0,0 +1,226 @@
|
||||
# Ramadan Trading Mode Documentation
|
||||
|
||||
## Overview
|
||||
|
||||
The Ramadan Trading Mode is a culturally-sensitive feature designed specifically for Muslim traders during the holy month of Ramadan. This feature automatically activates based on the Islamic calendar and provides trading adjustments that respect the spiritual practices of fasting, prayer times, and charitable giving.
|
||||
|
||||
## Features
|
||||
|
||||
### 1. Automatic Activation
|
||||
- Automatically activates when the Islamic month of Ramadan begins
|
||||
- Deactivates after Eid al-Fitr celebrations
|
||||
- Uses estimated Islamic calendar dates (can be enhanced with proper Hijri calendar library)
|
||||
|
||||
### 2. Prayer Time Trading Pauses
|
||||
The system automatically pauses trading during the following prayer times to respect spiritual practices:
|
||||
|
||||
#### Sahur Pause (03:30 - 05:00 WIB)
|
||||
- Time for pre-dawn meal before fasting begins
|
||||
- Spiritual preparation time
|
||||
- Trading bots will pause execution during this period
|
||||
|
||||
#### Iftar Pause (18:00 - 19:30 WIB)
|
||||
- Time for breaking the daily fast
|
||||
- Family and community time
|
||||
- Trading bots will pause execution during this period
|
||||
|
||||
#### Tarawih Pause (20:00 - 21:30 WIB)
|
||||
- Special nightly prayers during Ramadan
|
||||
- Spiritual devotion time
|
||||
- Trading bots will pause execution during this period
|
||||
|
||||
### 3. Risk Management Adjustments
|
||||
- **Reduced Risk Mode**: 20% risk reduction during fasting hours
|
||||
- **Patience Mode**: Emphasis on quality over quantity in trading decisions
|
||||
- **Optimal Trading Hours**: Recommended trading times (22:00 - 03:00 WIB) when traders are most alert
|
||||
|
||||
### 4. Spiritual and Cultural Features
|
||||
- **Iftar Countdown**: Real-time countdown to Iftar time
|
||||
- **Zakat Calculator**: Information and reminders about trading zakat obligations
|
||||
- **Charity Tracker**: Track charitable donations throughout Ramadan
|
||||
- **Patience Reminders**: Inspirational messages connecting trading principles with Islamic values
|
||||
- **Ramadan Greetings**: Culturally appropriate greetings in Bahasa Indonesia
|
||||
|
||||
### 5. UI/UX Enhancements
|
||||
- **Islamic Color Theme**: Green and gold color scheme
|
||||
- **Crescent Moon Decorations**: Visual elements appropriate for Ramadan
|
||||
- **Islamic Patterns**: Background patterns inspired by Islamic art
|
||||
- **Ramadan Decorations**: Special UI elements for the holy month
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### Ramadan Status
|
||||
- **Endpoint**: `GET /api/ramadan/status`
|
||||
- **Description**: Get current Ramadan trading mode status
|
||||
- **Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"is_ramadan": true,
|
||||
"holiday_name": "Ramadan Trading Mode",
|
||||
"start_date": "2024-03-11",
|
||||
"end_date": "2024-04-09",
|
||||
"trading_adjustments": {
|
||||
"sahur_pause": [3, 30, 5, 0],
|
||||
"iftar_pause": [18, 0, 19, 30],
|
||||
"tarawih_pause": [20, 0, 21, 30],
|
||||
"risk_reduction": 0.8,
|
||||
"optimal_hours": [[22, 0], [3, 0]],
|
||||
"patience_mode": true,
|
||||
"halal_focus": true
|
||||
},
|
||||
"ui_theme": {
|
||||
"primary_color": "#006600",
|
||||
"secondary_color": "#ffd700",
|
||||
"accent_color": "#ffffff",
|
||||
"background_gradient": "linear-gradient(135deg, #006600 0%, #ffd700 100%)",
|
||||
"crescent_moon": true,
|
||||
"islamic_patterns": true
|
||||
},
|
||||
"greeting": "🌙 Ramadan Mubarak! Semoga trading dan ibadah berkah"
|
||||
}
|
||||
```
|
||||
|
||||
### Ramadan Features
|
||||
- **Endpoint**: `GET /api/ramadan/features`
|
||||
- **Description**: Get Ramadan-specific features data
|
||||
- **Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"is_ramadan": true,
|
||||
"features": {
|
||||
"iftar_countdown": {
|
||||
"hours": 5,
|
||||
"minutes": 30,
|
||||
"next_prayer": "Iftar"
|
||||
},
|
||||
"zakat_info": {
|
||||
"nissab_gold": 85,
|
||||
"nissab_silver": 595,
|
||||
"zakat_percentage": 2.5,
|
||||
"reminder": "Zakat perdagangan: 2.5% dari profit trading selama 1 tahun hijriah"
|
||||
},
|
||||
"charity_tracker": {
|
||||
"total_donated": 0.0,
|
||||
"monthly_target": 100.0,
|
||||
"progress_percentage": 0,
|
||||
"suggested_amount": 10.0
|
||||
},
|
||||
"patience_reminder": "🧠 Sabar dalam trading seperti puasa - hasil terbaik datang dengan kesabaran",
|
||||
"optimal_trading_hours": [[22, 0], [3, 0]]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Pause Status
|
||||
- **Endpoint**: `GET /api/ramadan/pause-status`
|
||||
- **Description**: Check if trading is currently paused due to Ramadan prayer times
|
||||
- **Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"is_paused": true,
|
||||
"pause_reason": "Iftar time - breaking fast and family time",
|
||||
"message": "Iftar time - breaking fast and family time"
|
||||
}
|
||||
```
|
||||
|
||||
## Integration with Trading Bots
|
||||
|
||||
### Bot Controller Integration
|
||||
The trading bot controller checks for Ramadan pause status before executing trades:
|
||||
|
||||
```python
|
||||
from core.seasonal.holiday_manager import holiday_manager
|
||||
|
||||
def should_pause_trading():
|
||||
"""Check if trading should be paused due to Ramadan prayer times"""
|
||||
return holiday_manager.is_trading_paused()
|
||||
```
|
||||
|
||||
### Risk Adjustment
|
||||
Bots automatically adjust their risk parameters during Ramadan:
|
||||
|
||||
```python
|
||||
from core.seasonal.holiday_manager import holiday_manager
|
||||
|
||||
def get_risk_multiplier():
|
||||
"""Get risk reduction multiplier for current holiday"""
|
||||
return holiday_manager.get_risk_multiplier()
|
||||
```
|
||||
|
||||
## Dashboard Features
|
||||
|
||||
### Ramadan Dashboard Page
|
||||
Access the Ramadan dashboard through the "Ramadan Mode" link in the sidebar.
|
||||
|
||||
#### Key Components:
|
||||
1. **Status Display**: Shows current Ramadan period and greeting
|
||||
2. **Iftar Countdown**: Real-time countdown to Iftar time
|
||||
3. **Trading Adjustments**: Displays prayer time pauses and risk adjustments
|
||||
4. **Zakat Calculator**: Information about trading zakat obligations
|
||||
5. **Patience Reminders**: Inspirational messages connecting trading with Islamic values
|
||||
|
||||
## Configuration
|
||||
|
||||
### Holiday Manager
|
||||
The Ramadan configuration is managed in `core/seasonal/holiday_manager.py`:
|
||||
|
||||
```python
|
||||
def _get_ramadan_config(self) -> HolidayConfig:
|
||||
return HolidayConfig(
|
||||
name="Ramadan Trading Mode",
|
||||
start_date=ramadan_start,
|
||||
end_date=ramadan_end,
|
||||
trading_adjustments={
|
||||
'sahur_pause': (3, 30, 5, 0), # 03:30-05:00 WIB
|
||||
'iftar_pause': (18, 0, 19, 30), # 18:00-19:30 WIB
|
||||
'tarawih_pause': (20, 0, 21, 30), # 20:00-21:30 WIB
|
||||
'risk_reduction': 0.8, # 20% risk reduction during fasting
|
||||
'optimal_hours': [(22, 0), (3, 0)], # 22:00-03:00 WIB
|
||||
'patience_mode': True,
|
||||
'halal_focus': True
|
||||
},
|
||||
ui_theme={
|
||||
'primary_color': '#006600', # Islamic green
|
||||
'secondary_color': '#ffd700', # Gold
|
||||
'accent_color': '#ffffff', # White
|
||||
'background_gradient': 'linear-gradient(135deg, #006600 0%, #ffd700 100%)',
|
||||
'crescent_moon': True,
|
||||
'islamic_patterns': True
|
||||
},
|
||||
greetings=[
|
||||
"🌙 Ramadan Mubarak! Semoga trading dan ibadah berkah",
|
||||
"🕌 Puasa mengajarkan sabar - apply dalam trading juga!",
|
||||
# ... more greetings
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### For Developers
|
||||
1. **Respect Prayer Times**: Always check pause status before executing trades
|
||||
2. **Cultural Sensitivity**: Use appropriate language and imagery
|
||||
3. **Risk Management**: Implement reduced risk during fasting hours
|
||||
4. **User Experience**: Provide clear information about Ramadan adjustments
|
||||
|
||||
### For Traders
|
||||
1. **Plan Ahead**: Schedule trades outside of prayer time pauses
|
||||
2. **Risk Awareness**: Understand that risk is reduced during Ramadan
|
||||
3. **Spiritual Connection**: Use patience reminders to connect trading with spiritual values
|
||||
4. **Charitable Giving**: Track and consider charitable donations from trading profits
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
### Planned Features
|
||||
1. **Proper Hijri Calendar Integration**: Use accurate Islamic calendar library
|
||||
2. **Customizable Prayer Times**: Allow users to set their local prayer times
|
||||
3. **Community Features**: Ramadan trading challenges and community goals
|
||||
4. **Advanced Zakat Calculator**: Detailed zakat calculations based on actual trading profits
|
||||
5. **Multi-Language Support**: Additional languages for international Muslim traders
|
||||
|
||||
## Conclusion
|
||||
|
||||
The Ramadan Trading Mode provides a respectful and culturally-aware trading experience for Muslim traders during the holy month of Ramadan. By automatically adjusting trading behavior to align with spiritual practices, this feature helps traders maintain their religious observances while continuing to engage in trading activities.
|
||||
@@ -0,0 +1,145 @@
|
||||
# QuantumBotX Automatic Strategy Switching Guide
|
||||
|
||||
## Overview
|
||||
|
||||
The Automatic Strategy Switching system is an advanced feature of QuantumBotX that automatically evaluates and switches between different strategy/instrument combinations based on their performance and current market conditions. This ensures your trading bots are always using the most profitable and suitable strategies for the current market environment.
|
||||
|
||||
## How It Works
|
||||
|
||||
### 1. Performance Evaluation
|
||||
The system continuously evaluates all configured strategy/instrument combinations using:
|
||||
- **Profitability Score**: Based on net profit, win rate, and profit factor
|
||||
- **Risk Control Score**: Based on maximum drawdown and risk/reward ratio
|
||||
- **Consistency Score**: Based on trade frequency and profit consistency
|
||||
- **Activity Level Score**: Based on the number of trades generated
|
||||
- **Market Fit Score**: Based on strategy compatibility with instrument type and market conditions
|
||||
|
||||
### 2. Market Condition Detection
|
||||
The system analyzes each instrument to determine:
|
||||
- **Market Condition**: Trending vs. ranging markets
|
||||
- **Volatility Regime**: High vs. low volatility periods
|
||||
- **Session Status**: Active trading sessions
|
||||
|
||||
### 3. Automatic Switching
|
||||
Based on the composite performance scores and market conditions, the system:
|
||||
- Switches to the highest-performing strategy/instrument combination
|
||||
- Respects cooldown periods to prevent excessive switching
|
||||
- Maintains a history of all switches for review
|
||||
|
||||
## Dashboard Features
|
||||
|
||||
### Strategy Switcher Dashboard
|
||||
Access the dashboard through the "Strategy Switcher" link in the sidebar.
|
||||
|
||||
#### Current Status
|
||||
- **Active Strategy**: The currently active strategy
|
||||
- **Active Symbol**: The currently active trading instrument
|
||||
- **Last Switch**: Timestamp of the last strategy switch
|
||||
- **Cooldown Status**: Indicates if switching is currently in cooldown
|
||||
|
||||
#### Strategy Performance Rankings
|
||||
Shows all strategy/instrument combinations ranked by their composite performance scores:
|
||||
- **Rank**: Position in the rankings
|
||||
- **Strategy/Symbol**: The strategy and instrument combination
|
||||
- **Composite Score**: Overall performance score (0-1)
|
||||
- **Profitability**: Profitability component score
|
||||
- **Risk Control**: Risk management component score
|
||||
- **Market Fit**: Compatibility with market conditions
|
||||
|
||||
#### Recent Strategy Switches
|
||||
Displays a history of recent strategy switches with details:
|
||||
- **Action**: Type of switch (Initial setup or strategy switch)
|
||||
- **From/To**: Previous and new strategy/instrument combinations
|
||||
- **Reason**: Reason for the switch
|
||||
- **Score**: Performance score of the new combination
|
||||
- **Improvement**: Performance improvement from the switch
|
||||
|
||||
#### Monitored Instruments & Strategies
|
||||
Lists all instruments and strategies being monitored by the system.
|
||||
|
||||
## Trading Bot Integration
|
||||
|
||||
### Enabling Strategy Switching
|
||||
When creating or editing a trading bot, you can enable automatic strategy switching:
|
||||
|
||||
1. Navigate to the Trading Bots page
|
||||
2. Click "Create Bot" or edit an existing bot
|
||||
3. Check the "Aktifkan Automatic Strategy Switching" checkbox
|
||||
4. Save the bot configuration
|
||||
|
||||
When enabled, the bot will automatically switch to the best-performing strategy/instrument combination as determined by the strategy switcher system.
|
||||
|
||||
## API Endpoints
|
||||
|
||||
The strategy switching system provides REST API endpoints for integration:
|
||||
|
||||
### Status Endpoints
|
||||
- `GET /api/strategy-switcher/status` - Get current strategy switcher status
|
||||
- `GET /api/strategy-switcher/recent-switches` - Get recent strategy switches
|
||||
|
||||
### Evaluation Endpoints
|
||||
- `POST /api/strategy-switcher/evaluate` - Manually trigger strategy evaluation
|
||||
- `POST /api/strategy-switcher/manual-trigger` - Manually trigger strategy evaluation and switch
|
||||
|
||||
### Data Endpoints
|
||||
- `GET /api/strategy-switcher/rankings` - Get current strategy performance rankings
|
||||
- `GET /api/strategy-switcher/market-conditions` - Get current market conditions
|
||||
- `GET /api/strategy-switcher/configuration` - Get strategy switcher configuration
|
||||
|
||||
### Configuration Endpoints
|
||||
- `GET /api/strategy-switcher/configuration` - Get current configuration
|
||||
- `PUT /api/strategy-switcher/configuration` - Update configuration
|
||||
|
||||
## Configuration
|
||||
|
||||
### Monitored Instruments
|
||||
The system monitors a configurable list of instruments including:
|
||||
- Indices (US500, US30, DE30, etc.)
|
||||
- Forex pairs (EURUSD, GBPUSD, etc.)
|
||||
- Gold (XAUUSD)
|
||||
- Cryptocurrencies (BTCUSD, etc.)
|
||||
|
||||
### Test Strategies
|
||||
The system evaluates a configurable list of strategies:
|
||||
- INDEX_BREAKOUT_PRO
|
||||
- MA_CROSSOVER
|
||||
- RSI_CROSSOVER
|
||||
- TURTLE_BREAKOUT
|
||||
- QUANTUMBOTX_HYBRID
|
||||
|
||||
### Settings
|
||||
- **Switching Cooldown**: 24 hours (minimum time between switches)
|
||||
- **Performance Evaluation Period**: 500 bars
|
||||
- **Minimum Performance Score**: 0.6 (minimum score to consider switching)
|
||||
- **Switch Threshold**: 0.1 (minimum score improvement to trigger switch)
|
||||
|
||||
## Best Practices
|
||||
|
||||
### For Optimal Performance
|
||||
1. **Diversify Instruments**: Monitor a variety of instruments to find the best opportunities
|
||||
2. **Regular Evaluation**: The system automatically evaluates performance, but you can manually trigger evaluations
|
||||
3. **Review Switches**: Regularly review the switch history to understand system behavior
|
||||
4. **Adjust Settings**: Fine-tune configuration parameters based on your trading preferences
|
||||
|
||||
### Monitoring Recommendations
|
||||
1. **Check Dashboard Regularly**: Review the strategy switcher dashboard for insights
|
||||
2. **Review Notifications**: Pay attention to strategy switch notifications
|
||||
3. **Analyze Performance**: Compare manual vs. automatic strategy selection performance
|
||||
4. **Adjust Parameters**: Modify strategy parameters based on market conditions
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
1. **No Switches Occurring**: Check if all monitored instruments have data files
|
||||
2. **Poor Performance**: Review strategy parameters and market conditions
|
||||
3. **Frequent Switching**: Increase the switching cooldown period or switch threshold
|
||||
|
||||
### Data Requirements
|
||||
The system requires historical data files in the `lab/backtest_data` directory:
|
||||
- Format: CSV files with time, open, high, low, close, volume columns
|
||||
- Naming: `{SYMBOL}_H1_data.csv` (e.g., EURUSD_H1_data.csv)
|
||||
- Content: Sufficient historical data for backtesting (minimum 500 bars)
|
||||
|
||||
## Conclusion
|
||||
|
||||
The Automatic Strategy Switching system provides a powerful way to optimize your trading performance by automatically selecting the best strategy/instrument combinations based on real-time performance analysis and market conditions. By enabling this feature on your trading bots, you can ensure they're always using the most profitable approaches without manual intervention.
|
||||
@@ -0,0 +1,185 @@
|
||||
# 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`:
|
||||
|
||||
```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:
|
||||
|
||||
1. **Profitability Score**
|
||||
- Net profit analysis
|
||||
- Profit factor calculation
|
||||
- Win rate evaluation
|
||||
- Average win/loss ratio
|
||||
|
||||
2. **Risk Control Score**
|
||||
- Maximum drawdown assessment
|
||||
- Risk/reward ratio
|
||||
- Position sizing effectiveness
|
||||
- Volatility-adjusted returns
|
||||
|
||||
3. **Consistency Score**
|
||||
- Trade frequency analysis
|
||||
- Profit consistency
|
||||
- Win/loss distribution
|
||||
- Performance stability
|
||||
|
||||
4. **Activity Level Score**
|
||||
- Number of trades generated
|
||||
- Signal quality
|
||||
- Market engagement
|
||||
|
||||
5. **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:**
|
||||
1. 🥇 INDEX_BREAKOUT_PRO/US500 (Score: 0.707)
|
||||
2. 🥈 MA_CROSSOVER/GBPUSD (Score: 0.698)
|
||||
3. 🥉 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
|
||||
|
||||
1. **Live Market Integration**: Connect to real-time market data feeds
|
||||
2. **Machine Learning**: Implement ML models for predictive performance scoring
|
||||
3. **Portfolio Management**: Extend to multi-instrument portfolio optimization
|
||||
4. **Custom Strategies**: Allow user-defined strategy evaluation criteria
|
||||
5. **Mobile Alerts**: Push notifications for strategy switches and key events
|
||||
6. **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.
|
||||
Reference in New Issue
Block a user