Count roll groups as one position slot and protect monitors during roll.

Include active roll groups in deduped position slots; normalize CTP position keys in reconcile; skip closing monitors tied to active roll groups.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-02 23:04:34 +08:00
parent 93bdce3568
commit ae28bc6273
2 changed files with 23 additions and 4 deletions
+9
View File
@@ -289,6 +289,15 @@ def active_position_slots_from_monitors(conn) -> set[tuple[str, str]]:
sym = (r["symbol"] or "").strip()
if sym:
keys.add(_position_slot_key(sym, r["direction"] or "long"))
for r in conn.execute(
"""SELECT m.symbol, m.direction
FROM roll_groups g
JOIN trade_order_monitors m ON m.id = g.order_monitor_id
WHERE g.status='active'"""
):
sym = (r["symbol"] or "").strip()
if sym:
keys.add(_position_slot_key(sym, r["direction"] or "long"))
except Exception:
pass
return keys