fix: 突破加仓按 mark 触价触发,避免漏单

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-02 22:31:49 +08:00
parent 0b8f410fbe
commit 394793b9d2
3 changed files with 16 additions and 9 deletions
+7 -8
View File
@@ -176,21 +176,20 @@ def roll_breakout_trigger_crossed(
mark: float,
breakthrough_price: float,
) -> bool:
"""突破:多=向上穿越突破价;空=向下穿越突破价。"""
"""突破:多=mark 在突破价之上;空=mark 在突破价之下
提交时已校验 mark 在逆势侧(多低于突破价、空高于突破价),触价侧到达即成交。
不再要求单 tick 内穿越,避免 mark 已破位但 last_mark 也落在突破价另一侧时永久漏触发。
"""
try:
m = float(mark)
bp = float(breakthrough_price)
pm = float(prev_mark) if prev_mark is not None else None
except (TypeError, ValueError):
return False
direction = (direction or "long").strip().lower()
if direction == "long":
if pm is None:
return m > bp
return pm <= bp and m > bp
if pm is None:
return m < bp
return pm >= bp and m < bp
return m > bp
return m < bp
def roll_fib_invalidate(direction: str, mark: float, upper: float, lower: float) -> bool: