Add instance data dashboard (default off).

Read-only overview of live orders, key monitors, and strategy; show options/hedge only when present. Toggle via system settings nav prefs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 12:09:29 +08:00
parent f7ba7c2f7d
commit c7aae67881
20 changed files with 825 additions and 20 deletions
+37
View File
@@ -6858,6 +6858,15 @@ def stats_page():
return render_main_page("stats")
@app.route("/dashboard")
@login_required
def dashboard_page():
redir = redirect_to_embed_shell_if_enabled("dashboard")
if redir is not None:
return redir
return render_main_page("dashboard")
@app.route("/risk_policy")
@login_required
def risk_policy_page():
@@ -9003,6 +9012,34 @@ register_trade_records_api(
)
def _dashboard_fetch_options_positions():
if not OKX_OPTIONS_ENABLED:
return []
cfg = app.extensions.get("options_cfg")
if not isinstance(cfg, dict) or not cfg.get("enabled"):
return []
try:
from lib.options.options_hub_lib import build_options_hub_snapshot
snap = build_options_hub_snapshot(cfg)
except Exception:
return []
if not snap.get("ok"):
return []
return list(snap.get("positions") or [])
from lib.instance.instance_dashboard_register import register_instance_dashboard_routes
register_instance_dashboard_routes(
app,
login_required=login_required,
get_db=get_db,
fetch_options_positions=_dashboard_fetch_options_positions,
hedge_enabled=os.getenv("HEDGE_PLAN_ENABLED", "false").lower() in ("1", "true", "yes", "on"),
)
@app.route("/api/journals")
@login_required
def api_journals():