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:
@@ -170,6 +170,7 @@ def validate_roll_geometry(
|
||||
limit_price: Optional[float] = None,
|
||||
breakthrough_price: Optional[float] = None,
|
||||
at_trigger: bool = False,
|
||||
off_session_pending: bool = False,
|
||||
) -> Optional[str]:
|
||||
"""几何校验。
|
||||
|
||||
@@ -206,6 +207,12 @@ def validate_roll_geometry(
|
||||
trigger = float(breakthrough_price or 0)
|
||||
if trigger <= 0:
|
||||
return "须填写突破价"
|
||||
if off_session_pending:
|
||||
if direction == "long" and not (sl < trigger):
|
||||
return "做多突破:休盘提交须满足 止损 < 突破价"
|
||||
if direction == "short" and not (trigger < sl):
|
||||
return "做空突破:休盘提交须满足 突破价 < 止损"
|
||||
return None
|
||||
if at_trigger:
|
||||
if direction == "long":
|
||||
if not (sl < trigger <= mark):
|
||||
@@ -269,12 +276,15 @@ def preview_roll(
|
||||
fib_lower: Optional[float] = None,
|
||||
legs_done: int = 0,
|
||||
at_trigger: bool = False,
|
||||
off_session_pending: bool = False,
|
||||
) -> Tuple[Optional[dict[str, Any]], Optional[str]]:
|
||||
direction = (direction or "long").strip().lower()
|
||||
if legs_done >= max_roll_legs(direction):
|
||||
return None, f"滚仓已达 {max_roll_legs(direction)} 次上限"
|
||||
mode = (add_mode or ADD_MODE_MARKET).strip().lower()
|
||||
mark = float(mark_price or add_price or 0)
|
||||
if mark <= 0 and mode == ADD_MODE_BREAKOUT and off_session_pending:
|
||||
mark = float(breakthrough_price or 0)
|
||||
if mark <= 0:
|
||||
return None, "需要有效参考价"
|
||||
sl = float(new_stop_loss)
|
||||
@@ -314,6 +324,7 @@ def preview_roll(
|
||||
limit_price=trigger_price if mode in FIB_MODES else None,
|
||||
breakthrough_price=trigger_price if mode == ADD_MODE_BREAKOUT else None,
|
||||
at_trigger=at_trigger,
|
||||
off_session_pending=off_session_pending and is_pending,
|
||||
)
|
||||
if geom_err:
|
||||
return None, geom_err
|
||||
|
||||
Reference in New Issue
Block a user