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
+35
View File
@@ -66,3 +66,38 @@ def decide(
put_ask=pa,
)
return None
def decide_fixed(
call_ask: float | None,
put_ask: float | None,
*,
perp_side: str,
) -> Signal | None:
"""
固定方向:
- 永续多 → 买 Put
- 永续空 → 买 Call
"""
if call_ask is None or put_ask is None:
return None
side = (perp_side or "").strip().lower()
ca = float(call_ask)
pa = float(put_ask)
if side == "long":
return Signal(
bias="fixed_long_put",
option_side="put",
perp_side="long",
call_ask=ca,
put_ask=pa,
)
if side == "short":
return Signal(
bias="fixed_short_call",
option_side="call",
perp_side="short",
call_ask=ca,
put_ask=pa,
)
return None