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:
@@ -647,9 +647,11 @@ def reconcile_monitors_without_position(conn, mode: str, *, grace_sec: int = 120
|
||||
for p in positions:
|
||||
if int(p.get("lots") or 0) <= 0:
|
||||
continue
|
||||
sym = (p.get("symbol") or "").lower()
|
||||
sym = (p.get("symbol") or "").strip()
|
||||
direction = p.get("direction") or "long"
|
||||
position_keys.add((sym, direction))
|
||||
if sym:
|
||||
base = sym.lower().split(".")[0]
|
||||
position_keys.add((base, (direction or "long").strip().lower()))
|
||||
try:
|
||||
from modules.ctp.ctp_trading_state import trading_state
|
||||
|
||||
@@ -657,9 +659,11 @@ def reconcile_monitors_without_position(conn, mode: str, *, grace_sec: int = 120
|
||||
lots = int(p.get("lots") or 0)
|
||||
if lots <= 0:
|
||||
continue
|
||||
sym = (p.get("symbol") or "").lower()
|
||||
sym = (p.get("symbol") or "").strip()
|
||||
direction = p.get("direction") or "long"
|
||||
position_keys.add((sym, direction))
|
||||
if sym:
|
||||
base = sym.lower().split(".")[0]
|
||||
position_keys.add((base, (direction or "long").strip().lower()))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -709,6 +713,12 @@ def reconcile_monitors_without_position(conn, mode: str, *, grace_sec: int = 120
|
||||
break
|
||||
if matched:
|
||||
continue
|
||||
mid = mon.get("id")
|
||||
if conn.execute(
|
||||
"SELECT 1 FROM roll_groups WHERE order_monitor_id=? AND status='active' LIMIT 1",
|
||||
(mid,),
|
||||
).fetchone():
|
||||
continue
|
||||
try:
|
||||
cancel_monitor_exit_orders(conn, mon, mode=mode)
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user