Add active hedge plan tab

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 07:04:51 +08:00
parent e280220951
commit 6e6cb7caac
3 changed files with 100 additions and 2 deletions
+22
View File
@@ -522,6 +522,28 @@ def register_hedge_plan_routes(app: Flask, cfg: dict[str, Any]) -> None:
conn.close()
return jsonify({"ok": True, "plans": merged})
@app.route("/api/hedge-plan/active")
@lr
def api_hedge_active():
from lib.hedge_plan.hedge_plan_db import (
attach_legs_to_plans,
init_hedge_plan_tables,
list_plans,
)
conn = cfg["get_db"]()
try:
init_hedge_plan_tables(conn)
rows = []
for status in ("opening", "active", "partial"):
rows.extend(list_plans(conn, status=status, limit=80))
rows.sort(key=lambda row: int(row.get("id") or 0), reverse=True)
plans = attach_legs_to_plans(conn, rows)
conn.commit()
finally:
conn.close()
return jsonify({"ok": True, "plans": plans})
@app.route("/api/hedge-plan/stats")
@lr
def api_hedge_stats():