Files
Place-Order-Trading-Bot/CONFIGURATION_GUIDE.md
T

348 lines
7.9 KiB
Markdown
Raw Normal View History

2026-01-14 13:32:42 +01:00
# 📋 Trading Bot Configuration Guide
**Version:** 1.6 Adaptive Complete
**Last Updated:** 2026-01-14
**Status:** ✅ Centralized Configuration Active
---
## 🎯 Overview
All trading bot settings are now centralized in **Cell 6** of the Jupyter Notebook (`TRADING_CONFIG` dictionary). This eliminates scattered hardcoded values and provides a single source of truth for all configuration.
---
## 📍 Configuration Location
**File:** `TradingBot_V1.6_Adaptive_Complete_CORRECTED.ipynb`
**Cell:** Cell 6 (Code Cell after "CENTRALIZED TRADING CONFIGURATION" markdown)
---
## 🔧 Configuration Structure
### 1. **Lot Sizing & Position Management**
```python
'lot_sizing': {
'min_lot': 0.10, # Minimum lot size
'max_lot': 0.20, # Maximum lot size
'default_lot': 0.10, # Fallback lot size
'use_adaptive': True, # Use adaptive position sizing
}
```
**What it controls:**
- All volume calculations in `execute_trade_v2_adaptive()`
- Position sizing in `calculate_position_size()`
- Fallback values when calculations fail
**How to change:**
1. Edit values in Cell 6
2. Restart kernel
3. Run all cells
---
### 2. **Risk Management**
```python
'risk': {
'max_risk_per_trade': 0.02, # 2% max risk per trade
'max_positions': 1, # Maximum concurrent positions
'max_daily_loss': 0.05, # 5% max daily loss
}
```
**What it controls:**
- Maximum risk amount per trade
- How many positions can be open simultaneously
- Daily loss limits
**Recommended values:**
- Conservative: `max_risk_per_trade: 0.01` (1%)
- Moderate: `max_risk_per_trade: 0.02` (2%)
- Aggressive: `max_risk_per_trade: 0.03` (3%)
---
### 3. **Confidence Thresholds**
```python
'confidence': {
'base_threshold': 70, # Base confidence threshold (all sessions)
'ny_threshold': 70, # NY session threshold
'asian_threshold': 70, # Asian session threshold
'london_threshold': 70, # London session threshold
}
```
**What it controls:**
- Minimum confidence required to open trades
- Session-specific fine-tuning
- Signal quality filtering
**Current settings:**
- All sessions: 70% (relaxed for more trading opportunities)
- Previously NY was 97% (too strict, reduced trade volume)
---
### 4. **ATR & Stop Loss**
```python
'atr': {
'base_multiplier': 1.5, # Base ATR multiplier for SL/TP
'period': 14, # ATR calculation period
}
```
**What it controls:**
- Stop loss distance (price ± ATR * multiplier)
- Take profit distance (price ± ATR * multiplier * 2.5)
- Dynamic adjustment based on market regime
---
### 5. **News Filter**
```python
'news_filter': {
'enabled': True, # Enable/disable news filter
'minutes_before': 30, # Minutes before event to block
'minutes_after': 30, # Minutes after event to block
}
```
**What it controls:**
- Trading blocks around high-impact news events
- Protection from volatile news-driven price spikes
**Status:** ✅ Active and working (blocked NFP on 09.01.2026)
---
### 6. **Session Settings**
```python
'sessions': {
'asian_enabled': True,
'london_enabled': False, # Currently disabled
'ny_enabled': True,
'overlap_enabled': False, # Currently disabled
}
```
**What it controls:**
- Which trading sessions are active
- Asian: Best performance (93.09% avg confidence)
- NY: Good performance (92.49% avg confidence)
- London/Overlap: Disabled due to lower performance
---
### 7. **Trading Symbols**
```python
'symbols': {
'primary': 'XAUUSD', # Primary trading symbol (Gold)
'alternative': [], # Alternative symbols (if needed)
}
```
**What it controls:**
- Default trading symbol
- Can be extended for multi-symbol trading
---
## 🔄 How to Change Settings
### Step-by-Step Process:
1. **Open Jupyter Notebook**
```
jupyter notebook TradingBot_V1.6_Adaptive_Complete_CORRECTED.ipynb
```
2. **Locate Cell 6**
- Look for "CENTRALIZED TRADING CONFIGURATION" markdown
- Next cell contains `TRADING_CONFIG` dictionary
3. **Edit Values**
- Example: Change lot size
```python
'min_lot': 0.20, # Changed from 0.10
'max_lot': 0.30, # Changed from 0.20
```
4. **Restart Kernel**
- Menu: Kernel → Restart
- Or keyboard shortcut: `00` (press 0 twice)
5. **Run All Cells**
- Menu: Cell → Run All
- Or run cells sequentially
6. **Verify Changes**
- Check output: "Lot Sizing: 0.20 - 0.30 lots"
- Monitor next trade to confirm new lot size
---
## ⚠️ Important Notes
### DO NOT Edit These Cells Directly:
- **Cell 25:** `calculate_position_size()` - now reads from config
- **Cell 27:** `execute_trade_v2_adaptive()` - now reads from config
- **Cell 49:** `ADAPTIVE_COMPLETE_CONFIG` - deprecated, references config
### If You See Hardcoded Values:
These are **OUTDATED** and should be ignored:
- `volume = 0.10` → Now uses `TRADING_CONFIG['lot_sizing']['default_lot']`
- `max_risk = 0.01` → Now uses `TRADING_CONFIG['risk']['max_risk_per_trade']`
---
## 📊 Current Configuration Status
**As of 2026-01-14:**
| Setting | Value | Status |
|---------|-------|--------|
| Min Lot | 0.10 | ✅ Active |
| Max Lot | 0.20 | ✅ Active |
| Default Lot | 0.10 | ✅ Active |
| Max Risk | 2% | ✅ Active |
| Max Positions | 1 | ✅ Active |
| Confidence Threshold | 70% | ✅ Active |
| News Filter | Enabled | ✅ Active |
| Asian Session | Enabled | ✅ Active |
| NY Session | Enabled | ✅ Active |
---
## 🎯 Common Configuration Changes
### Increase Lot Size to 0.20:
```python
'lot_sizing': {
'min_lot': 0.20,
'max_lot': 0.30,
'default_lot': 0.20,
}
```
### More Conservative Risk (1%):
```python
'risk': {
'max_risk_per_trade': 0.01, # Changed from 0.02
}
```
### Stricter Confidence (95%+):
```python
'confidence': {
'base_threshold': 95, # Changed from 70
}
```
### Disable News Filter (NOT RECOMMENDED):
```python
'news_filter': {
'enabled': False, # Changed from True
}
```
---
## 📈 Performance Impact
### Current Settings (0.10 lot, 2% risk):
- **Daily Trades:** ~14.8 trades/day
- **Win Rate:** TBD (need P&L data)
- **Avg Confidence:** 92.90%
- **Sessions:** 67.6% Asian, 32.4% NY
### If Increased to 0.20 lot:
- Profit/Loss will **double**
- Risk will **double**
- Same number of trades
- Same win rate
---
## 🚨 Safety Warnings
### NEVER Change During Active Trading:
- Wait for all positions to close
- Changes take effect after kernel restart
- Old positions use old settings
### Test Before Live Trading:
- Change settings
- Restart kernel
- Run all cells
- Verify output
- Monitor first trade carefully
### Backup Before Major Changes:
```bash
git add -A
git commit -m "backup before config change"
```
---
## 🛠️ Helper Functions
### Get Configuration Value:
```python
get_config('lot_sizing', 'min_lot') # Returns: 0.10
get_config('risk') # Returns entire risk section
```
### Update Configuration (Runtime Only):
```python
update_config('lot_sizing', 'min_lot', 0.15)
# ✅ Updated: lot_sizing.min_lot = 0.15
# NOTE: Does not save to notebook, only runtime change
```
---
## 📞 Support & Documentation
**Related Files:**
- `PERFORMANCE_REPORT_JAN_2026.md` - Performance analysis
- `BOT_ANALYSIS_2026-01-10.md` - Trading gap analysis
- `NY_SESSION_FINETUNING.md` - Session optimization
**Scripts:**
- `centralize_config.py` - Created centralized config
- `update_cells_to_use_config.py` - Updated cells to use config
- `update_lot_size.py` - Old lot size updater (DEPRECATED)
---
## ✅ Verification Checklist
After changing configuration:
- [ ] Edited `TRADING_CONFIG` in Cell 6
- [ ] Restarted kernel
- [ ] Ran Cell 6 (config cell)
- [ ] Ran all other cells
- [ ] Verified output shows new settings
- [ ] Checked no error messages
- [ ] Monitored first trade with new settings
- [ ] Committed changes to Git
---
**Last Updated:** 2026-01-14
**Author:** Trading Bot V1.6 Adaptive Complete
**Status:** ✅ Production Ready
🎯 Generated with [Claude Code](https://claude.com/claude-code)