Add one-expiry-per-day open rhythm gate (default on).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-01 16:39:32 +08:00
parent 22c42a19a0
commit f1da2778ef
11 changed files with 166 additions and 2 deletions
+22
View File
@@ -295,7 +295,29 @@ class StrategySession:
logger.info("no expiry with hours>=%.1f", min_hours)
return None
used_expiries: set[str] = set()
one_exp_day = bool(s.one_expiry_per_day)
try:
from ..models.db import get_db
from .clock import used_expiry_ymds_for_day
db = get_db()
one_exp_day = _as_bool_setting(
db.get_setting("one_expiry_per_day", str(s.one_expiry_per_day)),
s.one_expiry_per_day,
)
if one_exp_day:
used_expiries = used_expiry_ymds_for_day(db)
except Exception:
logger.exception("one_expiry_per_day lookup failed; continue without skip")
for ymd in eligible:
if one_exp_day and ymd in used_expiries:
logger.info(
"skip expiry=%s: already used today (one_expiry_per_day)",
ymd,
)
continue
pair = select_option_pair(
contracts,
mark_px=underlying,