diff --git a/rdagent/app/cli.py b/rdagent/app/cli.py index 07937172..d8ccf55b 100644 --- a/rdagent/app/cli.py +++ b/rdagent/app/cli.py @@ -6,7 +6,9 @@ This will - autoamtically load dotenv """ +import os import sys +from pathlib import Path from dotenv import load_dotenv @@ -108,7 +110,35 @@ 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"), + 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. + """ + import subprocess + import threading + import time + + # Start 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") + 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.start() + time.sleep(2) # Kurze Verzögerung damit Dashboard starten kann + + # Fin Quant starten fin_quant(path=path, step_n=step_n, loop_n=loop_n, all_duration=all_duration, checkout=checkout) diff --git a/start_trading.sh b/start_trading.sh new file mode 100755 index 00000000..7e07676d --- /dev/null +++ b/start_trading.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Start EURUSD Trading mit automatischem Dashboard +# Verwendung: ./start_trading.sh + +set -e + +echo "============================================================" +echo " Predix EURUSD Trading - Start mit Dashboard" +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, 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 "" +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 + +# RD-Agent fin_quant starten +echo "🔄 Starte EURUSD Trading-Agent..." +echo "" +dotenv run -- rdagent fin_quant + +# Cleanup wenn fertig +cleanup