Gate one-open-per-expiry by historical expiry_ymd across days.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-03 07:35:44 +08:00
parent 5c334a4d89
commit a10ecf7409
10 changed files with 49 additions and 44 deletions
+3 -3
View File
@@ -72,13 +72,13 @@ def _as_bool_setting(raw: str | None, default: bool) -> bool:
def _skip_expiry_ymds_for_next() -> set[str]:
"""
空仓选约/监控应跳过的到期日:
- 当日已开过one_expiry_per_day
- 历史上已开过该到期one_expiry_per_day,跨日
- 仍有待结算残留期权的到期档(该档已「完成」开平,盯下一档)
"""
skip: set[str] = set()
try:
from ..models.db import get_db
from .clock import pending_residual_expiry_ymds, used_expiry_ymds_for_day
from .clock import pending_residual_expiry_ymds, used_expiry_ymds
s = get_settings()
db = get_db()
@@ -87,7 +87,7 @@ def _skip_expiry_ymds_for_next() -> set[str]:
s.one_expiry_per_day,
)
if one_exp_day:
skip |= used_expiry_ymds_for_day(db)
skip |= used_expiry_ymds(db)
skip |= pending_residual_expiry_ymds(db)
except Exception:
logger.exception("skip-expiry lookup failed; continue without skip")