all changes done over the last 2 weeks
This commit is contained in:
+430
@@ -0,0 +1,430 @@
|
||||
# 🖥️ Trading Bot GUI - Desktop Application
|
||||
|
||||
## Überblick
|
||||
|
||||
Eine professionelle **Tkinter Desktop-Anwendung** für den Trading Bot V1.9.
|
||||
|
||||
### Features
|
||||
|
||||
✅ **MT5 Connection Management**
|
||||
- One-Click MT5 Verbindung
|
||||
- Live Account Status
|
||||
- Balance Anzeige
|
||||
|
||||
✅ **Bot Controls**
|
||||
- Start/Stop Bot mit einem Klick
|
||||
- Live Bot Status
|
||||
- Session Filter Konfiguration
|
||||
|
||||
✅ **Real-time Monitoring**
|
||||
- Current Session Display
|
||||
- Adaptive Interval Anzeige
|
||||
- Position Count
|
||||
- Daily P/L
|
||||
|
||||
✅ **Drawdown Protection Status**
|
||||
- Live Loss Limits
|
||||
- Consecutive Loss Counter
|
||||
- Trading Status (Allowed/Paused)
|
||||
|
||||
✅ **Manual Controls**
|
||||
- Status Check
|
||||
- Position Check
|
||||
- Close All Positions (mit Confirmation)
|
||||
|
||||
✅ **Activity Log**
|
||||
- Live Event-Log
|
||||
- Color-coded Messages
|
||||
- Scrollable History
|
||||
|
||||
---
|
||||
|
||||
## Installation
|
||||
|
||||
### Voraussetzungen
|
||||
|
||||
```bash
|
||||
pip install tkinter # (meist bereits mit Python installiert)
|
||||
pip install MetaTrader5
|
||||
pip install pandas
|
||||
pip install pandas-ta
|
||||
pip install apscheduler
|
||||
pip install pytz
|
||||
```
|
||||
|
||||
### Projekt-Struktur
|
||||
|
||||
```
|
||||
placeorder/
|
||||
├── trading_bot_gui.py # 🖥️ Tkinter GUI (NEU!)
|
||||
├── adaptive_rhythm_manager.py # Adaptive Intervals (NEU!)
|
||||
├── execute_trade.py # Trade Execution (NEU!)
|
||||
│
|
||||
├── infrastructure_patch.py # Infrastructure
|
||||
├── trading_database.py # Database
|
||||
├── telegram_notifier.py # Telegram
|
||||
├── position_monitor.py # Position Monitor
|
||||
├── session_filter_patch.py # Session Filter
|
||||
├── drawdown_protection.py # Drawdown Protection
|
||||
│
|
||||
└── trading_bot.db # SQLite Database
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Starten der GUI
|
||||
|
||||
### Option 1: Direkt starten
|
||||
|
||||
```bash
|
||||
python trading_bot_gui.py
|
||||
```
|
||||
|
||||
### Option 2: Als ausführbare Datei (Windows)
|
||||
|
||||
```bash
|
||||
# Mit PyInstaller:
|
||||
pip install pyinstaller
|
||||
|
||||
pyinstaller --onefile --windowed \
|
||||
--name "TradingBot" \
|
||||
--icon=icon.ico \
|
||||
trading_bot_gui.py
|
||||
```
|
||||
|
||||
Dann findest du `TradingBot.exe` im `dist/` Ordner.
|
||||
|
||||
---
|
||||
|
||||
## 📖 Bedienungsanleitung
|
||||
|
||||
### 1️⃣ MT5 Verbindung herstellen
|
||||
|
||||
1. Klicke auf **"Connect to MT5"**
|
||||
2. Warte bis Status **"✅ Connected"** angezeigt wird
|
||||
3. Account-Info wird angezeigt
|
||||
|
||||
### 2️⃣ Bot starten
|
||||
|
||||
1. Stelle sicher MT5 ist verbunden
|
||||
2. Klicke auf **"▶️ Start Bot"**
|
||||
3. Bot Status ändert sich zu **"✅ Bot Running"**
|
||||
4. Trading beginnt automatisch
|
||||
|
||||
### 3️⃣ Session Filter anpassen
|
||||
|
||||
**Während der Laufzeit änderbar!**
|
||||
|
||||
- ☑️ **Asian**: An/Aus
|
||||
- ☑️ **London**: An/Aus
|
||||
- ☑️ **Overlap**: An/Aus
|
||||
- ☑️ **NY**: An/Aus
|
||||
|
||||
**Confidence Threshold:**
|
||||
- Slider: 50% - 90%
|
||||
- Empfohlen: 70% (aktuell)
|
||||
|
||||
### 4️⃣ Status überwachen
|
||||
|
||||
**Trading Status Panel zeigt:**
|
||||
- 📊 Current Session (Asian/London/NY/Overlap)
|
||||
- ⏱️ Adaptive Interval (5/15/30 min)
|
||||
- 📈 Open Positions (0/1)
|
||||
- 💰 Daily P/L
|
||||
|
||||
**Drawdown Protection Panel:**
|
||||
- ✅/🛑 Trading Status
|
||||
- Daily Loss: $X / $100
|
||||
- Consecutive Losses: X / 5
|
||||
|
||||
### 5️⃣ Manuelle Kontrollen
|
||||
|
||||
**Check Status:**
|
||||
- Aktualisiert alle Anzeigen
|
||||
- Prüft Drawdown Protection
|
||||
- Zeigt aktuelle Metriken
|
||||
|
||||
**Check Positions:**
|
||||
- Zeigt alle offenen Positionen im Log
|
||||
- Ticket, Typ, P/L
|
||||
|
||||
**Close All Positions:**
|
||||
- ⚠️ Schließt ALLE Positionen!
|
||||
- Confirmation-Dialog
|
||||
- Nur für Notfälle!
|
||||
|
||||
### 6️⃣ Activity Log
|
||||
|
||||
**Alle Events werden geloggt:**
|
||||
- ✅ Success Messages (grün)
|
||||
- ℹ️ Info Messages
|
||||
- ⚠️ Warnings
|
||||
- ❌ Errors (rot)
|
||||
|
||||
**Clear Log:**
|
||||
- Klick auf "🗑️ Clear Log" um Log zu leeren
|
||||
|
||||
### 7️⃣ Bot stoppen
|
||||
|
||||
1. Klicke auf **"⏹️ Stop Bot"**
|
||||
2. Scheduler wird gestoppt
|
||||
3. Offene Positionen bleiben **bestehen**!
|
||||
4. Bot Status ändert sich zu **"⏸️ Bot Stopped"**
|
||||
|
||||
---
|
||||
|
||||
## ⚙️ Konfiguration
|
||||
|
||||
### Session Filter (Live änderbar!)
|
||||
|
||||
```python
|
||||
# Im GUI einfach Checkboxen an/abwählen
|
||||
✅ Asian = True/False
|
||||
✅ London = True/False
|
||||
✅ Overlap = True/False
|
||||
✅ NY = True/False
|
||||
```
|
||||
|
||||
### Confidence Threshold
|
||||
|
||||
```python
|
||||
# Slider: 50 - 90
|
||||
Empfohlen: 70
|
||||
```
|
||||
|
||||
### Drawdown Protection
|
||||
|
||||
**Limits sind hardcoded in `drawdown_protection.py`:**
|
||||
|
||||
```python
|
||||
max_daily_loss = 100 # $100/Tag
|
||||
max_weekly_loss = 300 # $300/Woche
|
||||
max_monthly_loss = 800 # $800/Monat
|
||||
max_consecutive_losses = 5 # 5 Verluste in Folge
|
||||
cooldown_hours = 24 # 24h Pause
|
||||
```
|
||||
|
||||
**Zum Ändern:**
|
||||
- Öffne `drawdown_protection.py`
|
||||
- Passe `create_protected_trading_check()` an (Zeile 294-302)
|
||||
|
||||
---
|
||||
|
||||
## 🎨 GUI Layout
|
||||
|
||||
```
|
||||
┌────────────────────────────────────────────────────────────────┐
|
||||
│ 🤖 Trading Bot V1.9 - Control Center │
|
||||
├─────────────────────┬──────────────────────────────────────────┤
|
||||
│ 📡 MT5 Connection │ 📈 Trading Status │
|
||||
│ ✅ Connected │ Session: NY │
|
||||
│ Account: 10800246 │ Interval: 15 min │
|
||||
│ Balance: $7166.38 │ Positions: 0/1 │
|
||||
│ │ Daily P/L: $0.00 │
|
||||
├─────────────────────┼──────────────────────────────────────────┤
|
||||
│ 🤖 Bot Controls │ 📋 Activity Log │
|
||||
│ ✅ Bot Running │ [00:15:23] INFO: Bot started │
|
||||
│ [▶️ Start] │ [00:15:45] INFO: Connected to MT5 │
|
||||
│ [⏹️ Stop] │ [00:16:12] INFO: Position opened │
|
||||
│ │ ... │
|
||||
├─────────────────────┤ [🗑️ Clear Log] │
|
||||
│ 📊 Session Filter │ │
|
||||
│ ☑ Asian │ │
|
||||
│ ☐ London │ │
|
||||
│ ☐ Overlap │ │
|
||||
│ ☑ NY │ │
|
||||
│ Confidence: 70% │ │
|
||||
│ [═══════70═══] │ │
|
||||
├─────────────────────┤ │
|
||||
│ 🛡️ Drawdown Protect │ │
|
||||
│ ✅ Trading Allowed │ │
|
||||
│ Daily: $0/$100 │ │
|
||||
│ Consecutive: 0/5 │ │
|
||||
├─────────────────────┤ │
|
||||
│ 🎮 Manual Controls │ │
|
||||
│ [📊 Check Status] │ │
|
||||
│ [🔄 Check Pos] │ │
|
||||
│ [❌ Close All] │ │
|
||||
└─────────────────────┴──────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛡️ Sicherheitshinweise
|
||||
|
||||
### ⚠️ WICHTIG:
|
||||
|
||||
1. **Close All Positions** nur in Notfällen!
|
||||
- Confirmation-Dialog wird angezeigt
|
||||
- Schließt wirklich ALLE Positionen
|
||||
|
||||
2. **Bot Stop** beendet nur den Scheduler
|
||||
- Offene Positionen bleiben bestehen
|
||||
- Position Monitor läuft weiter bis GUI geschlossen wird
|
||||
|
||||
3. **Session Filter Änderungen** wirken sofort
|
||||
- Bot übernimmt neue Config im nächsten Interval
|
||||
- Keine Bestätigung nötig
|
||||
|
||||
4. **Drawdown Protection** arbeitet automatisch
|
||||
- Pausiert Trading bei Limit-Überschreitung
|
||||
- Telegram Notification wird gesendet
|
||||
- Auto-Resume nach Cooldown
|
||||
|
||||
---
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
### Problem: "MT5 initialization failed"
|
||||
|
||||
**Lösung:**
|
||||
- MetaTrader 5 muss laufen
|
||||
- Algo-Trading muss aktiviert sein (Tools → Options → Expert Advisors)
|
||||
|
||||
### Problem: "Bot starting error: execute_trade_v2_adaptive not found"
|
||||
|
||||
**Lösung:**
|
||||
- `execute_trade.py` ist ein Placeholder
|
||||
- Du musst die komplette Trade-Logik aus dem Notebook extrahieren
|
||||
- Siehe Abschnitt "Vollständige Integration" unten
|
||||
|
||||
### Problem: GUI friert ein
|
||||
|
||||
**Lösung:**
|
||||
- Alle langen Operationen laufen in Threads
|
||||
- Wenn GUI einfriert: Force-Close und neu starten
|
||||
- Check Log für Fehler
|
||||
|
||||
### Problem: Drawdown Status nicht sichtbar
|
||||
|
||||
**Lösung:**
|
||||
- Bot muss gestartet sein
|
||||
- Klick auf "Check Status" um zu aktualisieren
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Vollständige Integration (TODO)
|
||||
|
||||
**Die GUI ist aktuell ein Framework!**
|
||||
|
||||
Um voll funktionsfähig zu sein, musst du noch folgendes tun:
|
||||
|
||||
### 1. Trade Execution Module vervollständigen
|
||||
|
||||
Extrahiere aus Notebook:
|
||||
- `extended_top_down_v2_adaptive()`
|
||||
- `check_existing_positions()`
|
||||
- `market_order()`
|
||||
- `check_risk_limits()`
|
||||
- Alle Helper Functions
|
||||
|
||||
### 2. Market Analysis Module erstellen
|
||||
|
||||
```python
|
||||
# market_analysis.py
|
||||
def detect_market_regime(df, lookback=50):
|
||||
# ... aus Notebook
|
||||
|
||||
def get_enhanced_trend(timeframe, lookback, symbol):
|
||||
# ... aus Notebook
|
||||
```
|
||||
|
||||
### 3. Imports anpassen
|
||||
|
||||
In `trading_bot_gui.py`:
|
||||
|
||||
```python
|
||||
from execute_trade import (
|
||||
execute_trade_v2_adaptive,
|
||||
check_existing_positions,
|
||||
close_existing_positions
|
||||
)
|
||||
from market_analysis import (
|
||||
extended_top_down_v2_adaptive,
|
||||
detect_market_regime
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 💡 Vorteile der GUI
|
||||
|
||||
### vs. Jupyter Notebook:
|
||||
|
||||
✅ **Benutzerfreundlichkeit**
|
||||
- Keine Code-Kenntnisse nötig zum Bedienen
|
||||
- Buttons statt Code ausführen
|
||||
- Live Status-Anzeige
|
||||
|
||||
✅ **Stabilität**
|
||||
- Keine Kernel-Crashes
|
||||
- Thread-safe Operations
|
||||
- Exception Handling
|
||||
|
||||
✅ **Deployment**
|
||||
- Als .exe für Windows
|
||||
- Keine Jupyter Installation nötig
|
||||
- Standalone-App
|
||||
|
||||
### vs. Web Dashboard:
|
||||
|
||||
✅ **Kontrolle**
|
||||
- Start/Stop Bot direkt
|
||||
- Session Config ändern
|
||||
- Direkte MT5-Verbindung
|
||||
|
||||
✅ **Lokal**
|
||||
- Keine Server nötig
|
||||
- Läuft auf Windows-PC
|
||||
- Kein Port-Forwarding
|
||||
|
||||
### Kombination empfohlen:
|
||||
|
||||
```
|
||||
Desktop PC:
|
||||
└── trading_bot_gui.py # Kontrolle + Monitoring
|
||||
|
||||
VPS:
|
||||
└── trading_bot_service.py # 24/7 Trading
|
||||
└── trading_dashboard.py # Web Monitoring
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📈 Nächste Schritte
|
||||
|
||||
1. **Trade Execution vervollständigen**
|
||||
- Module aus Notebook extrahieren
|
||||
- Alle Dependencies auflösen
|
||||
|
||||
2. **Testing**
|
||||
- GUI auf Demo-Account testen
|
||||
- Alle Buttons durchklicken
|
||||
- Error-Handling prüfen
|
||||
|
||||
3. **Deployment**
|
||||
- PyInstaller .exe erstellen
|
||||
- Icon hinzufügen
|
||||
- Installer erstellen (NSIS)
|
||||
|
||||
4. **Enhancement**
|
||||
- Live Charts integrieren (matplotlib)
|
||||
- Trade History Tabelle
|
||||
- Performance Metrics
|
||||
|
||||
---
|
||||
|
||||
## 📞 Support
|
||||
|
||||
Bei Problemen:
|
||||
1. Check Activity Log für Errors
|
||||
2. Check `trading_bot.db` (SQLite Browser)
|
||||
3. Check Telegram Bot Messages
|
||||
|
||||
---
|
||||
|
||||
**Status:** 🟡 Framework Ready - Trade Execution TODO
|
||||
|
||||
**Version:** V1.9 GUI
|
||||
|
||||
**Last Updated:** 2025-12-06
|
||||
Reference in New Issue
Block a user