Isolate CTP in worker process and improve strategy roll UX.

Split vn.py into qihuo-ctp worker with IPC client bridge, keep CTP connected during breaks with cached account fallback, speed up strategy page loads, and allow off-session breakout roll submissions.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-01 12:35:47 +08:00
parent 08d55411aa
commit 9cd81a3ea7
17 changed files with 2214 additions and 227 deletions
+40 -6
View File
@@ -60,13 +60,47 @@ MONITOR_ORDER_COLUMNS = (
TRADE_RESULTS = ("止损", "止盈", "移动止盈", "保本止盈", "手动平仓")
_MONITOR_COLUMNS_READY = False
_MONITOR_COLUMNS_LOCK = threading.Lock()
def ensure_monitor_order_columns(conn) -> None:
for sql in MONITOR_ORDER_COLUMNS:
try:
conn.execute(sql)
except Exception:
pass
def _monitor_columns_exist(conn) -> bool:
try:
rows = conn.execute("PRAGMA table_info(trade_order_monitors)").fetchall()
cols = set()
for r in rows:
if isinstance(r, dict):
cols.add(r.get("name") or "")
else:
cols.add(r[1])
return "open_fee" in cols
except Exception:
return False
def ensure_monitor_order_columns(conn, *, migrate: bool = False) -> None:
"""列齐全后不再 ALTER,避免 worker 每次请求锁 SQLite。"""
global _MONITOR_COLUMNS_READY
if _MONITOR_COLUMNS_READY:
return
with _MONITOR_COLUMNS_LOCK:
if _MONITOR_COLUMNS_READY:
return
if _monitor_columns_exist(conn):
_MONITOR_COLUMNS_READY = True
return
if not migrate:
return
for sql in MONITOR_ORDER_COLUMNS:
try:
conn.execute(sql)
conn.commit()
except Exception:
try:
conn.rollback()
except Exception:
pass
_MONITOR_COLUMNS_READY = True
def _tick_size(ths_code: str) -> float: