fix: OKX 持仓张数优先读 info.pos,滚仓后同步 order_amount

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-02 22:40:41 +08:00
parent 394793b9d2
commit be7896cc25
4 changed files with 51 additions and 22 deletions
+10 -2
View File
@@ -418,9 +418,17 @@ def _execute_pending_roll_leg(
"UPDATE roll_groups SET leg_count=?, current_stop_loss=?, updated_at=? WHERE id=?",
(filled + 1, sl, _now(cfg), gid),
)
live_qty = qty + float(amount)
try:
pos2 = cfg["get_position"](ex_sym, direction) or {}
q2 = float(pos2.get("contracts") or 0)
if q2 > 0:
live_qty = q2
except Exception:
pass
conn.execute(
"UPDATE order_monitors SET stop_loss=? WHERE id=? AND status='active'",
(sl, mon["id"]),
"UPDATE order_monitors SET stop_loss=?, order_amount=? WHERE id=? AND status='active'",
(sl, float(live_qty), mon["id"]),
)
notify = cfg.get("send_wechat")