feat: Beautiful CLI dashboard + corrected start command

New features:

1. CLI Dashboard (rdagent/log/ui/predix_dashboard.py)
   - Beautiful terminal UI with Rich library
   - Live progress bar for Loop/Step
   - Live Macro Data (EURUSD, DXY, Volatility)
   - Session info with recommendation
   - Statistics (Win-Rate, PnL, Success/Fail)
   - Recent factors list
   - Auto-refresh every 5 seconds

   Start: rdagent fin_quant --cli-dashboard

2. CLI extension (rdagent/app/cli.py)
   --with-dashboard/-d: Web Dashboard
   --cli-dashboard/-c: CLI Dashboard
   Both combinable: rdagent fin_quant -d -c

3. Start scripts updated:
   - start_trading.sh: Interactive with dashboard selection
   - start_loop.sh: Endless loop with auto-restart

   Corrected start command for endless loop:
   cd ~/Predix && conda activate rdagent && ./start_loop.sh

4. Dashboard URLs:
   - Web: http://localhost:5000/dashboard.html
   - CLI: rdagent fin_quant -c

All modules tested and integrated!
This commit is contained in:
TPTBusiness
2026-03-30 21:22:09 +02:00
parent 34416041c1
commit c2932cb069
3 changed files with 127 additions and 28 deletions
+29 -9
View File
@@ -21,6 +21,7 @@ from importlib.resources import path as rpath
from typing import Optional
import typer
from rich.console import Console
from typing_extensions import Annotated
from rdagent.app.data_science.loop import main as data_science
@@ -110,33 +111,52 @@ def fin_quant_cli(
loop_n: Optional[int] = None,
all_duration: Optional[str] = None,
checkout: CheckoutOption = True,
with_dashboard: bool = typer.Option(False, "--with-dashboard/-d", help="Start dashboard automatically"),
with_dashboard: bool = typer.Option(False, "--with-dashboard/-d", help="Start web dashboard automatically"),
with_cli_dashboard: bool = typer.Option(False, "--cli-dashboard/-c", help="Show beautiful CLI dashboard"),
dashboard_port: int = typer.Option(5000, "--dashboard-port", help="Dashboard port"),
):
"""
Start EURUSD quantitative trading loop.
Use --with-dashboard to automatically start the web dashboard.
Options:
--with-dashboard/-d: Start web dashboard at http://localhost:5000
--cli-dashboard/-c: Show beautiful terminal UI with live stats
Examples:
rdagent fin_quant
rdagent fin_quant -d # Web dashboard
rdagent fin_quant -c # CLI dashboard
rdagent fin_quant -d -c # Both dashboards
"""
import subprocess
import threading
import time
# Start Dashboard wenn gewünscht
# Start Web Dashboard wenn gewünscht
if with_dashboard:
def start_dashboard():
print(f"\n🚀 Starting Dashboard on http://localhost:{dashboard_port}...")
print(f" Open: http://localhost:{dashboard_port}/dashboard.html\n")
def start_web_dashboard():
console = Console()
console.print(f"\n[bold green]🚀 Starting Web Dashboard on http://localhost:{dashboard_port}...[/bold green]")
console.print(f" [cyan]Open: http://localhost:{dashboard_port}/dashboard.html[/cyan]\n")
subprocess.run(
["python", "web/dashboard_api.py"],
cwd=str(Path(__file__).parent.parent.parent),
env={**os.environ, "FLASK_ENV": "development"}
)
# Dashboard im Hintergrund starten
dashboard_thread = threading.Thread(target=start_dashboard, daemon=True)
dashboard_thread = threading.Thread(target=start_web_dashboard, daemon=True)
dashboard_thread.start()
time.sleep(2) # Kurze Verzögerung damit Dashboard starten kann
time.sleep(2)
# Start CLI Dashboard wenn gewünscht
if with_cli_dashboard:
def start_cli_dash():
from rdagent.log.ui.predix_dashboard import run_dashboard
run_dashboard(log_path="fin_quant.log", refresh_interval=3)
cli_thread = threading.Thread(target=start_cli_dash, daemon=True)
cli_thread.start()
time.sleep(1)
# Fin Quant starten
fin_quant(path=path, step_n=step_n, loop_n=loop_n, all_duration=all_duration, checkout=checkout)
Executable
+57
View File
@@ -0,0 +1,57 @@
#!/bin/bash
# Start EURUSD Trading in Endlosschleife mit Auto-Restart
# Verwendung: ./start_loop.sh
set -e
LOG_FILE=~/Predix/fin_quant.log
echo "============================================================"
echo " Predix EURUSD Trading - Endlosschleife mit Auto-Restart"
echo "============================================================"
echo ""
echo "Log-Datei: $LOG_FILE"
echo ""
echo "Dashboard Optionen:"
echo " Web: rdagent fin_quant --with-dashboard"
echo " CLI: rdagent fin_quant --cli-dashboard"
echo ""
echo "Stoppen mit: Ctrl+C"
echo "============================================================"
echo ""
# Conda Environment aktivieren
if [ -f ~/miniconda3/etc/profile.d/conda.sh ]; then
source ~/miniconda3/etc/profile.d/conda.sh
conda activate rdagent
echo "✓ Conda Environment 'rdagent' aktiviert"
else
echo "⚠️ Conda nicht gefunden..."
fi
echo ""
echo "Starte Endlosschleife..."
echo ""
cd /home/nico/Predix
while true; do
echo "=== START: $(date) ===" >> $LOG_FILE
echo ""
echo "╔════════════════════════════════════════════════════════╗"
echo "║ 🚀 START: $(date +"%Y-%m-%d %H:%M:%S")"
echo "╚════════════════════════════════════════════════════════╝"
echo ""
dotenv run -- rdagent fin_quant 2>&1 | tee -a $LOG_FILE
echo ""
echo "╔════════════════════════════════════════════════════════╗"
echo "║ ⏸️ RESTART: $(date +"%Y-%m-%d %H:%M:%S")"
echo "╚════════════════════════════════════════════════════════╝"
echo "=== RESTART: $(date) ===" >> $LOG_FILE
echo ""
echo "Warte 5 Sekunden vor Neustart..."
echo ""
sleep 5
done
+41 -19
View File
@@ -18,29 +18,49 @@ else
echo "⚠️ Conda nicht gefunden, versuche mit system Python..."
fi
# Dashboard API im Hintergrund starten
echo ""
echo "🚀 Starte Dashboard API..."
cd /home/nico/Predix
nohup python web/dashboard_api.py > /tmp/dashboard.log 2>&1 &
DASHBOARD_PID=$!
echo "✓ Dashboard API gestartet (PID: $DASHBOARD_PID)"
echo "Verwendung:"
echo " Option 1: Web Dashboard (empfohlen)"
echo " rdagent fin_quant --with-dashboard"
echo ""
echo "📊 Dashboard URL: http://localhost:5000/dashboard.html"
echo " Dashboard Log: /tmp/dashboard.log"
echo " Option 2: CLI Dashboard (Terminal UI)"
echo " rdagent fin_quant --cli-dashboard"
echo ""
echo " Option 3: Beide Dashboards"
echo " rdagent fin_quant -d -c"
echo ""
echo " Option 4: Endlosschleife mit Auto-Restart"
echo " ./start_loop.sh"
echo ""
echo "============================================================"
# Cleanup Funktion
cleanup() {
# Dashboard API im Hintergrund starten (optional)
read -p "Dashboard im Hintergrund starten? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo "⏹️ Stoppe Dashboard (PID: $DASHBOARD_PID)..."
kill $DASHBOARD_PID 2>/dev/null || true
echo "✓ Gestoppt"
exit 0
}
# Trap für Ctrl+C
trap cleanup SIGINT SIGTERM
echo "🚀 Starte Dashboard API..."
cd /home/nico/Predix
nohup python web/dashboard_api.py > /tmp/dashboard.log 2>&1 &
DASHBOARD_PID=$!
echo "✓ Dashboard API gestartet (PID: $DASHBOARD_PID)"
echo ""
echo "📊 Dashboard URL: http://localhost:5000/dashboard.html"
echo " Dashboard Log: /tmp/dashboard.log"
echo ""
# Cleanup Funktion
cleanup() {
echo ""
echo "⏹️ Stoppe Dashboard (PID: $DASHBOARD_PID)..."
kill $DASHBOARD_PID 2>/dev/null || true
echo "✓ Gestoppt"
exit 0
}
# Trap für Ctrl+C
trap cleanup SIGINT SIGTERM
fi
# RD-Agent fin_quant starten
echo "🔄 Starte EURUSD Trading-Agent..."
@@ -48,4 +68,6 @@ echo ""
dotenv run -- rdagent fin_quant
# Cleanup wenn fertig
cleanup
if [[ $REPLY =~ ^[Yy]$ ]]; then
cleanup
fi