78fd046fb6
Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
1.4 KiB
Python
61 lines
1.4 KiB
Python
"""兼容层:选约逻辑已迁至 strategy.selection;OKX 解析在 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,
|
||
) -> OptionPair | None:
|
||
contracts = normalize_contracts(instruments)
|
||
return _select_pair(
|
||
contracts,
|
||
mark_px=mark_px,
|
||
expiry_ymd=expiry_ymd,
|
||
min_hours=min_hours,
|
||
now=now,
|
||
)
|
||
|
||
|
||
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)
|