fix: OKX 持仓张数优先读 info.pos,滚仓后同步 order_amount
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user