docs: add README.md with current project state

Covers architecture, setup, configuration, active protections,
database state, key files, troubleshooting.

Reflects post-code-review state:
- All modules fixed and reviewed
- DB cleaned (626 historical imports, 0 live trades)
- bot_settings table migrated
- Accurate session/confidence/drawdown config values

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-12 12:22:25 +02:00
co-authored by Claude Sonnet 4.6
parent c959a26dc0
commit 5f11d9693c
+211
View File
@@ -0,0 +1,211 @@
# Place-Order Trading Bot
Automatisierter Forex/Gold-Trading-Bot für MetaTrader 5. Handelt XAUUSD (Gold) mit Multi-Timeframe-Analyse, adaptivem Rhythmus und mehrschichtigem Risikoschutz.
**Version:** V1.9 (Notebook V1.6 Adaptive Complete)
**Symbol:** XAUUSD
**Broker:** Vantage International (Demo-Account konfiguriert)
---
## Architektur
```
Jupyter Notebook (Hauptlogik)
├── Signal-Analyse extended_top_down_v2_adaptive()
├── Trade-Ausführung execute_trade_v2_adaptive()
├── Session-Filter session_filter_patch.py
├── Ranging-Filter multi_timeframe_regime_filter.py
└── Scheduler APScheduler (minütlich)
Standalone-Module
├── position_monitor.py Exit-Erkennung via MT5 History
├── drawdown_protection.py Verlust-Limits mit DB-Persistenz
├── advanced_position_management.py Trailing Stop + Partial TP
├── equity_curve_trading.py Lot-Reduktion bei Equity < MA
├── loss_protection_manager.py Konsekutive Verluste + Circuit Breaker
└── enhanced_signal_scoring.py Multi-Faktor Signal-Bewertung
Infrastruktur
├── trading_database.py SQLite-Wrapper (trading_bot.db)
├── infrastructure_patch.py DB + Telegram Orchestrierung
└── telegram_notifier.py Mobile Benachrichtigungen
Interfaces
├── trading_bot_gui.py Tkinter Desktop-App
└── trading_dashboard.py Streamlit Web-Dashboard
```
---
## Voraussetzungen
- Python 3.10+
- MetaTrader 5 (installiert und eingeloggt)
- Windows (MT5 läuft nur auf Windows/Wine)
```bash
pip install -r requirements.txt
```
Telegram optional — ohne Config laufen alle Notifications still.
---
## Bot starten
### Option 1 — Jupyter Notebook (empfohlen)
```bash
.\venv\Scripts\activate
jupyter notebook TradingBot_V1.6_Adaptive_Complete_CORRECTED.ipynb
```
Alle Cells sequenziell ausführen (Kernel → Run All).
### Option 2 — Desktop-GUI
```bash
python trading_bot_gui.py
```
### Option 3 — Nur Dashboard (Read-Only)
```bash
streamlit run trading_dashboard.py
```
---
## Konfiguration
### Trading-Parameter (Notebook Cell 6)
```python
TRADING_CONFIG = {
'lot_sizing': {'min_lot': 0.10, 'max_lot': 0.20, 'default_lot': 0.10},
'risk': {'max_risk_per_trade': 0.02, 'max_positions': 1},
'confidence': {'base_threshold': 95},
'atr': {'base_multiplier': 1.5, 'period': 14},
}
```
### Session-Filter (`session_filter_patch.py`)
```python
SESSION_WHITELIST_CONFIG = {
'enabled_sessions': {
'asian': True, # 97.8% historische WR
'ny': True, # 4356% WR (mit Confidence-Filter)
'london': False, # deaktiviert
'overlap': True,
},
'base_confidence': 95, # Minimum Confidence für alle Sessions
'max_risk_per_trade': 0.02,
}
```
### Drawdown-Schutz
Limits werden in `drawdown_protection.py` konfiguriert und in der DB persistiert (überleben Restarts):
| Limit | Default |
|-------|---------|
| Tagesverlust | $100 |
| Wochenverlust | $300 |
| Monatsverlust | $800 |
| Consecutive Losses | 5 |
| Cooldown | 24h |
### Telegram
Credentials in `telegram_config.json` (nicht in Git):
```json
{"bot_token": "...", "chat_id": "..."}
```
Alternativ: Umgebungsvariablen `TELEGRAM_BOT_TOKEN` und `TELEGRAM_CHAT_ID`.
---
## Aktive Schutzschichten
| # | Schutz | Beschreibung |
|---|--------|-------------|
| 1 | **Ranging-Filter** | Blockiert Trades wenn ADX < 25 auf H1/H4/D1 |
| 2 | **Session-Filter** | Nur erlaubte Sessions (Asian, NY, Overlap) |
| 3 | **Confidence-Filter** | Session-spezifische Mindest-Confidence |
| 4 | **Drawdown-Protection** | Tages-/Wochen-/Monatsverlust-Limits |
| 5 | **Equity-Curve-Filter** | Lot-Reduktion wenn Equity unter MA |
| 6 | **Loss-Protection** | Consecutive Losses + Circuit Breaker |
| 7 | **News-Filter** | Blockiert 30 min vor/nach High-Impact-Events |
| 8 | **Position-Monitor** | Automatisches Exit-Logging via MT5 History |
---
## Datenbank
SQLite: `trading_bot.db` (nicht in Git)
| Tabelle | Inhalt |
|---------|--------|
| `trades` | Alle Trades (status: open / closed / historical) |
| `bot_status` | Heartbeat-Log (start/stop Einträge) |
| `bot_settings` | Persistenter State (z.B. Drawdown-Pause) |
| `performance_summary` | Aggregierte Tagesstatistiken |
**Aktueller DB-Zustand:** 0 Live-Trades, 626 historische Imports (status=`historical`).
Nützliche Skripte:
```bash
python check_system_status.py # Übersicht + Consecutive Losses
python performance_analysis.py # Vollständige Performance-Auswertung
python cleanup_stale_positions.py # Stale open Positionen bereinigen
python reset_consecutive_losses.py # Notfall-Reset (nach manuellem Review)
```
---
## Wichtige Dateien
| Datei | Zweck |
|-------|-------|
| `TradingBot_V1.6_Adaptive_Complete_CORRECTED.ipynb` | Hauptnotebook |
| `session_filter_patch.py` | Session-Whitelist + Trading-Check-Factory |
| `trading_database.py` | Datenbankzugriff |
| `drawdown_protection.py` | Verlustschutz (mit DB-Persistenz) |
| `position_monitor.py` | Automatische Exit-Erkennung |
| `advanced_position_management.py` | Trailing Stop, Partial TP |
| `telegram_notifier.py` | Benachrichtigungen |
| `infrastructure_patch.py` | DB + Telegram Orchestrierung |
---
## Entwicklung
### Nicht in Git (`.gitignore`)
- `telegram_config.json` — Credentials
- `trading_bot.db` — Laufzeit-Datenbank
- `trade_performance_*.json` — Trade-Daten
- `*.pkl` — ML-Modelle
- `*_backup_*.ipynb` — Notebook-Backups
- `venv/` — Virtuelle Umgebung
### Workflow
```bash
git pull
.\venv\Scripts\activate
# ... Änderungen ...
git add <dateien>
git commit -m "fix: kurze Beschreibung"
git push
```
### System-Check
```bash
python check_system_status.py
```
---
## Troubleshooting
| Problem | Lösung |
|---------|--------|
| Trading pausiert | `check_system_status.py` → Drawdown-Grund prüfen |
| Kein Trade trotz Signal | Session-Filter aktiv? Confidence hoch genug? ADX > 25? |
| Position nicht in DB | `position_monitor` im Scheduler eingetragen? |
| Dashboard leer | `trade_filter = "Historical Only"` zeigt Import-Daten |
| MT5 nicht verbunden | MT5 starten → in GUI "Connect" klicken |
| `bot_settings` Fehler | `python -c "from trading_database import TradingDatabase; TradingDatabase()"` |