Add ATM open-offset toggle default off.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user