Add one-expiry-per-day open rhythm gate (default on).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user