Files
eth_hedge_sim/backend/app/market/instruments.py
T
2026-07-25 08:43:09 +08:00

61 lines
1.4 KiB
Python
Raw 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.okx.parse import (
expiry_ms_from_ymd,
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)