Gate opens when ATM-spot offset exceeds configurable max (default 3).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-25 12:32:36 +08:00
parent a4bcc3ab0d
commit ee0ec57f89
12 changed files with 93 additions and 13 deletions
+14
View File
@@ -46,6 +46,20 @@ def pick_atm_strike(strikes: list[float], mark_px: float) -> float | None:
return min(strikes, key=lambda s: (abs(s - mark_px), s))
def atm_open_offset(strike: float, mark_px: float) -> float:
"""开仓用:ATM 行权价相对标的的绝对点差。"""
return abs(float(strike) - float(mark_px))
def atm_allows_open(
strike: float, mark_px: float, *, max_offset: float
) -> bool:
"""|strike mark| ≤ max_offset 才允许开仓。"""
if mark_px <= 0 or max_offset < 0:
return False
return atm_open_offset(strike, mark_px) <= float(max_offset) + 1e-9
def option_leverage(underlying_px: float, premium_ask: float) -> float | None:
if underlying_px <= 0 or premium_ask is None or premium_ask <= 0:
return None