Skip used/residual expiries so ATM monitors the next day.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-02 10:31:07 +08:00
parent 05520f82bd
commit 9427d9c429
3 changed files with 132 additions and 23 deletions
+14
View File
@@ -59,6 +59,20 @@ def used_expiry_ymds_for_day(db: Any, now: datetime | None = None) -> set[str]:
return out
def pending_residual_expiry_ymds(db: Any) -> set[str]:
"""待到期结算的残留期权到期日(YYMMDD);监控/下一组开仓应跳过这些档。"""
rows = db.fetchall(
"""SELECT DISTINCT expiry_ymd FROM residual_options
WHERE status='pending' AND expiry_ymd IS NOT NULL AND TRIM(expiry_ymd) != ''"""
)
out: set[str] = set()
for r in rows or []:
y = str(r["expiry_ymd"] or "").strip()
if y:
out.add(y)
return out
def expiry_blocked_by_one_per_day(
expiry_ymd: str | None,
used: set[str],