Files
Place-Order-Trading-Bot/DASHBOARD_WINDOWS_SERVER.md
cbazzaandClaude 596718e30b feat: Trading Bot V1.8 - Aggressive Mode + Infrastructure
## Major Features
- Session Filter: NY-only trading (13:00-21:00 UTC)
- SQLite Database: Structured trade logging
- Telegram Bot: Real-time notifications (@Xausd_digger_bot)
- Streamlit Dashboard: Visual monitoring & analytics
- JSON Import: Historical data migration

## Infrastructure
- trading_database.py: SQLite trade storage
- telegram_notifier.py: Telegram integration
- infrastructure_patch.py: Combined DB + Telegram
- trading_dashboard.py: Real-time web dashboard
- import_json_to_db.py: JSON to SQLite migration

## Session Filter (V1.8 Aggressive Mode)
- session_filter_patch.py: Whitelist-based filter
- Blocks: Asian, London, Overlap sessions
- Active: NY session only (best performance: 47.6% WR)
- Base confidence: 60%

## Documentation
- V1.8_AGGRESSIVE_MODE_AKTIVIERT.md
- FIX_DUPLICATE_SCHEDULER.md
- DASHBOARD_WINDOWS_SERVER.md
- SQLITE_TELEGRAM_SETUP.md
- PROJECT_CLEANUP.md

## Cleanup
- Archived old V1.1-V1.7 versions
- Removed obsolete analysis scripts (replaced by dashboard)
- Added .gitignore for secrets and temp files

## Breaking Changes
- Requires telegram_config.json (use template)
- Requires Python packages: streamlit, plotly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 21:14:01 +01:00

12 KiB

📊 Streamlit Dashboard - Windows Server Deployment

Übersicht

Diese Anleitung zeigt dir wie du das Trading Dashboard auf einem Windows Server (oder Windows VPS) zum Laufen bringst.

🚀 Installation auf Windows Server

SCHRITT 1: Python & Dependencies prüfen

1. Öffne PowerShell als Administrator

# Prüfe Python Version
python --version
# Sollte Python 3.8+ zeigen

# Falls Python nicht gefunden wird:
# Installiere von: https://www.python.org/downloads/

2. Navigiere zum Trading Bot Ordner

# Beispiel (passe Pfad an):
cd C:\TradingBot\placeorder

3. Installiere Streamlit & Dependencies

pip install streamlit plotly pandas

Falls pip nicht funktioniert:

python -m pip install streamlit plotly pandas

SCHRITT 2: Dashboard-Datei kopieren

Option A: Via RDP (Remote Desktop)

  1. Verbinde per RDP zu deinem Windows Server
  2. Öffne Browser auf dem Server
  3. Lade trading_dashboard.py herunter (z.B. via GitHub, Email, Cloud)
  4. Kopiere nach: C:\TradingBot\placeorder\

Option B: Via SCP (von Mac aus)

# Auf deinem Mac (Terminal)
scp "/Users/sebastianfrohlich/Library/Mobile Documents/com~apple~CloudDocs/Jupyter Notebooks/FinancialTrading/PlaceOrder/placeorder/trading_dashboard.py" user@windows-server-ip:C:/TradingBot/placeorder/

Hinweis: Benötigt OpenSSH Server auf Windows. Siehe unten für Aktivierung.

Option C: Manuell erstellen

  1. Auf Windows Server: Öffne Notepad++, VSCode oder Editor
  2. Erstelle neue Datei: trading_dashboard.py
  3. Copy-Paste den Code aus der Datei
  4. Speichere in: C:\TradingBot\placeorder\

SCHRITT 3: Dashboard starten

Option A: PowerShell (zum Testen)

cd C:\TradingBot\placeorder
streamlit run trading_dashboard.py --server.port 8501 --server.address 0.0.0.0

Das Dashboard startet und sollte automatisch den Browser öffnen!

Option B: CMD (Command Prompt)

cd C:\TradingBot\placeorder
streamlit run trading_dashboard.py --server.port 8501 --server.address 0.0.0.0

SCHRITT 4: Firewall-Regel erstellen

Windows Firewall für Port 8501 öffnen:

Via GUI:

  1. Windows-Taste → "Windows Defender Firewall"
  2. "Erweiterte Einstellungen"
  3. "Eingehende Regeln" → "Neue Regel..."
  4. "Port" auswählen → Weiter
  5. "TCP" → "Bestimmte lokale Ports": 8501 → Weiter
  6. "Verbindung zulassen" → Weiter
  7. Alle Profile aktivieren → Weiter
  8. Name: "Streamlit Dashboard" → Fertig

Via PowerShell (als Administrator):

New-NetFirewallRule -DisplayName "Streamlit Dashboard" -Direction Inbound -LocalPort 8501 -Protocol TCP -Action Allow

SCHRITT 5: Dashboard im Browser öffnen

Lokal auf dem Server:

http://localhost:8501

Von anderem Computer:

http://WINDOWS-SERVER-IP:8501

Beispiel:

http://192.168.1.100:8501

🔄 Dashboard permanent laufen lassen

Option 1: Als Windows Service (EMPFOHLEN)

Mit NSSM (Non-Sucking Service Manager):

1. NSSM herunterladen:

https://nssm.cc/download

2. NSSM installieren:

# NSSM entpacken nach C:\nssm
# PowerShell als Administrator öffnen
cd C:\nssm\win64

# Service erstellen
.\nssm.exe install TradingDashboard

3. Im NSSM GUI konfigurieren:

  • Application Tab:

    • Path: C:\Python310\Scripts\streamlit.exe (passe Python-Pfad an)
    • Startup directory: C:\TradingBot\placeorder
    • Arguments: run trading_dashboard.py --server.port 8501 --server.address 0.0.0.0
  • Details Tab:

    • Display name: Trading Dashboard
    • Description: Streamlit Dashboard for Trading Bot V1.8
  • Log on Tab:

    • Wähle Account (z.B. dein User-Account)
  • I/O Tab:

    • Output (stdout): C:\TradingBot\placeorder\dashboard_stdout.log
    • Error (stderr): C:\TradingBot\placeorder\dashboard_stderr.log

4. Service starten:

# Service starten
.\nssm.exe start TradingDashboard

# Service Status prüfen
.\nssm.exe status TradingDashboard

# Service stoppen
.\nssm.exe stop TradingDashboard

# Service entfernen (falls nötig)
.\nssm.exe remove TradingDashboard

Oder via Windows Services:

  1. Windows-Taste → "services.msc"
  2. Finde "Trading Dashboard"
  3. Rechtsklick → "Starten"

Option 2: Batch-Datei + Task Scheduler

1. Erstelle Batch-Datei:

Erstelle start_dashboard.bat:

@echo off
echo Starting Trading Dashboard...
cd /d C:\TradingBot\placeorder
streamlit run trading_dashboard.py --server.port 8501 --server.address 0.0.0.0
pause

2. Task Scheduler konfigurieren:

  1. Windows-Taste → "Task Scheduler"
  2. "Create Basic Task..."
  3. Name: "Trading Dashboard"
  4. Trigger: "When the computer starts"
  5. Action: "Start a program"
  6. Program: C:\TradingBot\placeorder\start_dashboard.bat
  7. Finish

Task manuell starten:

  • Task Scheduler → Rechtsklick auf Task → "Run"

Option 3: PowerShell Background Job (temporär)

# Starte als Background Job
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd C:\TradingBot\placeorder; streamlit run trading_dashboard.py --server.port 8501 --server.address 0.0.0.0"

# Prüfe laufende Prozesse
Get-Process | Where-Object {$_.ProcessName -like "*streamlit*"}

# Stoppe Dashboard
Stop-Process -Name streamlit -Force

🔒 Sicherheit & Zugriff

Option 1: SSH Tunnel (von Mac aus)

Falls OpenSSH Server auf Windows aktiviert:

# Auf Mac
ssh -L 8501:localhost:8501 user@windows-server-ip

# Dann Browser öffnen
http://localhost:8501

OpenSSH Server auf Windows aktivieren:

# PowerShell als Administrator
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

# SSH Service starten
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'

# Firewall-Regel (falls nötig)
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

Option 2: IIS Reverse Proxy (für HTTPS)

Falls du IIS verwendest, kannst du einen Reverse Proxy einrichten:

  1. Installiere "Application Request Routing" (ARR)
  2. Installiere "URL Rewrite"
  3. Konfiguriere Reverse Proxy von Port 80/443 → 8501

Option 3: VPN-Only Access

Öffne Port 8501 nur im VPN-Netzwerk, nicht öffentlich.

📱 Zugriff von außen (Internet)

Router Port Forwarding (falls Home Server)

  1. Router-Verwaltung öffnen

  2. Port Forwarding Regel erstellen:

    • External Port: 8501
    • Internal IP: Windows Server IP (z.B. 192.168.1.100)
    • Internal Port: 8501
    • Protocol: TCP
  3. Zugriff via:

    http://DEINE-ÖFFENTLICHE-IP:8501
    

Cloud VPS (z.B. Azure, AWS)

Firewall/Security Group konfigurieren:

  • Erlaube eingehenden Traffic auf Port 8501 (TCP)
  • Von deiner IP oder 0.0.0.0/0 (öffentlich, vorsichtig!)

🛠️ Troubleshooting

Dashboard startet nicht

1. Prüfe Python/Streamlit Installation:

python --version
streamlit --version

2. Prüfe ob Port belegt:

netstat -ano | findstr :8501

Falls Port belegt, finde Prozess:

# Nutze die PID aus netstat output
tasklist | findstr <PID>

# Prozess killen
taskkill /PID <PID> /F

3. Prüfe Logs:

Falls als Service läuft, schaue in:

C:\TradingBot\placeorder\dashboard_stdout.log
C:\TradingBot\placeorder\dashboard_stderr.log

Dashboard nicht erreichbar von außen

1. Firewall prüfen:

Get-NetFirewallRule | Where-Object {$_.LocalPort -eq 8501}

2. Prüfe ob Streamlit auf richtiger IP hört:

netstat -ano | findstr :8501

Sollte zeigen: 0.0.0.0:8501 (nicht 127.0.0.1:8501)

Falls falsch, starte mit --server.address 0.0.0.0:

streamlit run trading_dashboard.py --server.port 8501 --server.address 0.0.0.0

Database Error

# Prüfe ob trading_bot.db existiert
dir trading_bot.db

# Falls nicht:
# 1. Starte zuerst den Trading Bot (Jupyter Notebook)
# 2. Der erstellt automatisch die Datenbank

📊 PowerShell Helper Scripts

start_dashboard.ps1

# Trading Dashboard Starter Script
Write-Host "Starting Trading Dashboard..." -ForegroundColor Green

$path = "C:\TradingBot\placeorder"
Set-Location $path

# Check if database exists
if (!(Test-Path "trading_bot.db")) {
    Write-Host "WARNING: trading_bot.db not found!" -ForegroundColor Yellow
    Write-Host "Make sure the Trading Bot is running first." -ForegroundColor Yellow
}

# Start Streamlit
Write-Host "Dashboard starting on http://localhost:8501" -ForegroundColor Cyan
streamlit run trading_dashboard.py --server.port 8501 --server.address 0.0.0.0

stop_dashboard.ps1

# Stop Trading Dashboard
Write-Host "Stopping Trading Dashboard..." -ForegroundColor Yellow

Get-Process | Where-Object {$_.ProcessName -like "*streamlit*"} | Stop-Process -Force

Write-Host "Dashboard stopped!" -ForegroundColor Green

check_dashboard.ps1

# Check Dashboard Status
Write-Host "Checking Trading Dashboard Status..." -ForegroundColor Cyan

$process = Get-Process | Where-Object {$_.ProcessName -like "*streamlit*"}

if ($process) {
    Write-Host "Dashboard is RUNNING" -ForegroundColor Green
    Write-Host "Process ID: $($process.Id)" -ForegroundColor White
    Write-Host "URL: http://localhost:8501" -ForegroundColor Cyan
} else {
    Write-Host "Dashboard is NOT running" -ForegroundColor Red
}

# Check if port is listening
$port = Get-NetTCPConnection -LocalPort 8501 -ErrorAction SilentlyContinue

if ($port) {
    Write-Host "Port 8501 is LISTENING" -ForegroundColor Green
} else {
    Write-Host "Port 8501 is NOT listening" -ForegroundColor Yellow
}

Installation Checklist

  • Python 3.8+ installiert
  • Streamlit installiert (pip install streamlit plotly pandas)
  • trading_dashboard.py im richtigen Ordner
  • Windows Firewall Port 8501 geöffnet
  • Dashboard gestartet (manuell oder als Service)
  • Im Browser erreichbar (http://localhost:8501)
  • Von außen erreichbar (http://SERVER-IP:8501)
  • Als Windows Service konfiguriert (optional, empfohlen)
  • Auto-Start beim Boot konfiguriert (optional)

🎯 Empfohlenes Setup für Windows Server

Beste Praxis:

  1. Dashboard als Windows Service (mit NSSM)

    • Auto-Start beim Boot
    • Läuft auch ohne User-Login
  2. Firewall konfiguriert

    • Port 8501 nur von vertrauenswürdigen IPs
  3. Logs aktiviert

    • stdout/stderr Logs für Debugging
  4. Auto-Refresh im Dashboard (30s)

🎉 Quick Start Commands

# Dashboard starten (manuell)
cd C:\TradingBot\placeorder
streamlit run trading_dashboard.py --server.port 8501 --server.address 0.0.0.0

# Dashboard Status prüfen
Get-Process | Where-Object {$_.ProcessName -like "*streamlit*"}

# Dashboard stoppen
Stop-Process -Name streamlit -Force

# Service starten (falls als Service installiert)
Start-Service TradingDashboard

# Service stoppen
Stop-Service TradingDashboard

📝 Zugriff URLs

Lokal auf Server:

http://localhost:8501

Vom Netzwerk:

http://WINDOWS-SERVER-IP:8501

Von außen (Internet):

http://ÖFFENTLICHE-IP:8501

Via SSH Tunnel:

# Auf Mac
ssh -L 8501:localhost:8501 user@windows-server-ip

# Browser öffnen
http://localhost:8501

💡 Pro-Tipps

  1. Dedicated User Account: Erstelle einen separaten Windows User nur für den Trading Bot
  2. Scheduled Restart: Task Scheduler für täglichen Neustart (z.B. 3:00 nachts)
  3. Backup: Sichere trading_bot.db regelmäßig
  4. Monitoring: Nutze Windows Performance Monitor für Ressourcen-Überwachung
  5. Updates: Halte Streamlit aktuell: pip install --upgrade streamlit

🚨 Wichtige Sicherheitshinweise

⚠️ NIEMALS Port 8501 öffentlich ohne Authentifizierung öffnen!

Empfohlene Absicherung:

  • VPN-Only Access
  • SSH Tunnel
  • IIS Reverse Proxy mit Basic Auth
  • IP Whitelist in Firewall

Du bist jetzt bereit das Dashboard auf Windows Server zu deployen! 🎉