Files
dekun 0ee1d8be5d 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>
2026-07-29 19:18:12 +08:00

63 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""兼容层:选约逻辑已迁至 strategy.selectionOKX 解析在 exchange.okx.parse。"""
from __future__ import annotations
from typing import Any
from ..exchange.expiry import expiry_ms_from_ymd
from ..exchange.okx.parse import (
parse_option_inst_id,
safe_float,
)
from ..exchange.types import OptionPair
from ..strategy.selection import (
hours_until_expiry,
list_eligible_expiry_ymds as _list_eligible,
next_session_expiry_ymd,
option_leverage,
pick_atm_strike,
select_option_pair as _select_pair,
normalize_contracts,
)
__all__ = [
"expiry_ms_from_ymd",
"hours_until_expiry",
"list_eligible_expiry_ymds",
"next_session_expiry_ymd",
"option_leverage",
"parse_option_inst_id",
"pick_atm_strike",
"safe_float",
"select_option_pair",
]
def select_option_pair(
instruments: list[dict[str, Any]],
*,
mark_px: float,
expiry_ymd: str | None = None,
min_hours: float | None = None,
now=None,
option_side: str | None = None,
) -> OptionPair | None:
contracts = normalize_contracts(instruments)
return _select_pair(
contracts,
mark_px=mark_px,
expiry_ymd=expiry_ymd,
min_hours=min_hours,
now=now,
option_side=option_side,
)
def list_eligible_expiry_ymds(
instruments: list[dict[str, Any]],
*,
min_hours: float,
now=None,
) -> list[str]:
return _list_eligible(normalize_contracts(instruments), min_hours=min_hours, now=now)