Files
crypto_monitor/lib/instance/instance_dashboard_register.py
T
dekun c7aae67881 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>
2026-07-17 12:09:29 +08:00

32 lines
917 B
Python

"""注册 GET /api/instance/dashboard(三所共用)."""
from __future__ import annotations
from typing import Any, Callable, Optional
from flask import Flask, jsonify
def register_instance_dashboard_routes(
app: Flask,
*,
login_required: Callable,
get_db: Callable,
fetch_options_positions: Optional[Callable[[], list[dict[str, Any]]]] = None,
hedge_enabled: bool = False,
) -> None:
from lib.instance.instance_dashboard_lib import build_instance_dashboard_payload
@app.route("/api/instance/dashboard")
@login_required
def api_instance_dashboard():
conn = get_db()
try:
payload = build_instance_dashboard_payload(
conn,
fetch_options_positions=fetch_options_positions,
hedge_enabled=bool(hedge_enabled),
)
return jsonify(payload)
finally:
conn.close()