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:
dekun
2026-07-29 19:18:12 +08:00
parent 55109e82d3
commit 0ee1d8be5d
16 changed files with 427 additions and 46 deletions
+20 -1
View File
@@ -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)