Add fixed-direction switch for perp/option open side.
When enabled, lock perp long→buy Put or short→buy Call with ITM/ATM only; off keeps ATM/ask rules. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -88,7 +88,26 @@ def _open_bias(
|
||||
call: Quote | None,
|
||||
put: Quote | None,
|
||||
) -> str:
|
||||
"""与开仓 decide 一致:先按 ATM 相对现价,贴平时再卖一比价。"""
|
||||
"""与开仓 decide 一致;固定方向开启时显示 fixed_*。"""
|
||||
try:
|
||||
from ..config import get_settings
|
||||
from ..models.db import get_db
|
||||
|
||||
s = get_settings()
|
||||
db = get_db()
|
||||
raw = db.get_setting(
|
||||
"fixed_direction_enabled", str(s.fixed_direction_enabled)
|
||||
)
|
||||
on = str(raw or "").strip().lower() in ("1", "true", "yes", "on")
|
||||
if on:
|
||||
side = str(
|
||||
db.get_setting("fixed_perp_side", s.fixed_perp_side)
|
||||
or s.fixed_perp_side
|
||||
or "long"
|
||||
).strip().lower()
|
||||
return "fixed_long_put" if side == "long" else "fixed_short_call"
|
||||
except Exception:
|
||||
pass
|
||||
mark = None
|
||||
if index_px is not None and index_px > 0:
|
||||
mark = float(index_px)
|
||||
|
||||
Reference in New Issue
Block a user