Wire manual close to actually flatten option then perp then sell coin.
UI 平仓 now calls /api/hedge-plan/<id>/close instead of end-only (不平仓). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -919,7 +919,7 @@ def register_hedge_plan_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
@app.route("/api/hedge-plan/<int:plan_id>/end", methods=["POST"])
|
||||
@lr
|
||||
def api_hedge_end_plan(plan_id: int):
|
||||
"""人工结束进行中计划:不自动平仓;未成交腿改为 cancelled."""
|
||||
"""仅结束计划记录(不平仓).有持仓请用 /close."""
|
||||
from lib.hedge_plan.hedge_plan_db import init_hedge_plan_tables
|
||||
from lib.hedge_plan.hedge_plan_orders_lib import execute_manual_end_plan
|
||||
|
||||
@@ -934,6 +934,29 @@ def register_hedge_plan_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
conn.close()
|
||||
return jsonify(out)
|
||||
|
||||
@app.route("/api/hedge-plan/<int:plan_id>/close", methods=["POST"])
|
||||
@lr
|
||||
def api_hedge_close_plan(plan_id: int):
|
||||
"""人工平仓:期权→永续→卖币,再结束计划."""
|
||||
from lib.hedge_plan.hedge_plan_db import init_hedge_plan_tables
|
||||
from lib.hedge_plan.hedge_plan_orders_lib import execute_manual_close_plan
|
||||
|
||||
conn = cfg["get_db"]()
|
||||
try:
|
||||
init_hedge_plan_tables(conn)
|
||||
out = execute_manual_close_plan(cfg, conn, plan_id)
|
||||
if not out.get("ok"):
|
||||
# 半平成功时也要落库(期权已平/永续失败标记)
|
||||
try:
|
||||
conn.commit()
|
||||
except Exception:
|
||||
pass
|
||||
return jsonify(out), 400
|
||||
conn.commit()
|
||||
finally:
|
||||
conn.close()
|
||||
return jsonify(out)
|
||||
|
||||
@app.route("/api/hedge-plan/<int:plan_id>/complete-leg", methods=["POST"])
|
||||
@lr
|
||||
def api_hedge_complete_leg(plan_id: int):
|
||||
|
||||
Reference in New Issue
Block a user