Add active hedge plan tab
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user