Add real-time data dashboard with account, positions, keys, and closes.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -222,6 +222,7 @@ def _static_asset_v() -> str:
|
||||
base = os.path.dirname(os.path.abspath(__file__))
|
||||
rels = (
|
||||
"static/js/trade.js",
|
||||
"static/js/dashboard.js",
|
||||
"static/js/orientation.js",
|
||||
"static/css/records.css",
|
||||
"static/js/records.js",
|
||||
@@ -229,6 +230,7 @@ def _static_asset_v() -> str:
|
||||
"static/css/mobile.css",
|
||||
"static/css/responsive.css",
|
||||
"static/css/trade.css",
|
||||
"static/css/dashboard.css",
|
||||
"static/css/base.css",
|
||||
)
|
||||
mtimes = []
|
||||
@@ -1632,6 +1634,34 @@ def api_stats_refresh():
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
_dashboard_sync_tick = {"n": 0}
|
||||
|
||||
|
||||
@app.route("/dashboard")
|
||||
@login_required
|
||||
@require_nav("dashboard")
|
||||
def dashboard():
|
||||
return render_template("dashboard.html")
|
||||
|
||||
|
||||
@app.route("/api/dashboard/live")
|
||||
@login_required
|
||||
def api_dashboard_live():
|
||||
if not nav_enabled(get_setting, "dashboard"):
|
||||
return jsonify({"ok": False, "error": "数据看板已在系统设置中关闭"}), 403
|
||||
from dashboard_lib import build_dashboard_payload
|
||||
|
||||
_dashboard_sync_tick["n"] += 1
|
||||
sync_trades = _dashboard_sync_tick["n"] % 5 == 0
|
||||
payload = build_dashboard_payload(
|
||||
get_db=get_db,
|
||||
get_setting=get_setting,
|
||||
fetch_price=fetch_price,
|
||||
sync_ctp_trades=sync_trades,
|
||||
)
|
||||
return jsonify(payload)
|
||||
|
||||
|
||||
@app.route("/market")
|
||||
@login_required
|
||||
@require_nav("market")
|
||||
|
||||
Reference in New Issue
Block a user