Keep unflat legs on 当前持仓 after plan end.
Closed plans with open legs stay visible and closable so residual positions are not orphaned from the UI. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1464,7 +1464,12 @@ def execute_manual_close_plan(cfg: dict[str, Any], conn: Any, plan_id: int) -> d
|
||||
if not plan:
|
||||
return {"ok": False, "msg": "计划不存在"}
|
||||
st = str(plan.get("status") or "")
|
||||
if st not in ("opening", "active", "partial", "watching"):
|
||||
legs0 = get_plan_legs(conn, int(plan_id))
|
||||
has_open_leg = any(str(x.get("status") or "").lower() == "open" for x in legs0)
|
||||
# 进行中可平;已结束但腿仍 open(人工结束未平仓残留)也可补平
|
||||
if st not in ("opening", "active", "partial", "watching") and not (
|
||||
st == "closed" and has_open_leg
|
||||
):
|
||||
return {"ok": False, "msg": f"当前状态 {st or '—'} 不可平仓"}
|
||||
|
||||
# 盯盘无持仓:直接结束
|
||||
|
||||
Reference in New Issue
Block a user