Add ATM open-offset toggle default off.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-25 12:42:20 +08:00
parent 79c074ec6c
commit fff285c1f9
12 changed files with 93 additions and 24 deletions
+8 -2
View File
@@ -52,9 +52,15 @@ def atm_open_offset(strike: float, mark_px: float) -> float:
def atm_allows_open(
strike: float, mark_px: float, *, max_offset: float
strike: float,
mark_px: float,
*,
max_offset: float,
enabled: bool = False,
) -> bool:
"""|strike mark| ≤ max_offset 才允许开仓。"""
"""开启限制时:|strike mark| ≤ max_offset 才允许开仓;关闭则始终允许"""
if not enabled:
return True
if mark_px <= 0 or max_offset < 0:
return False
return atm_open_offset(strike, mark_px) <= float(max_offset) + 1e-9