Clear resting sports orders once at scheduled kickoff

This commit is contained in:
2026-12-03 06:46:20 +08:00
parent 53b36cce82
commit 7b26767a97
10 changed files with 226 additions and 1 deletions
+2
View File
@@ -14,6 +14,7 @@ pub(crate) fn transaction(
"SELECT EXISTS(SELECT 1 FROM order_deadlines WHERE pending=1 AND expiration<=unixepoch()+60)
OR EXISTS(SELECT 1 FROM twap_markets WHERE pending_close=1 AND end_at<=unixepoch())
OR EXISTS(SELECT 1 FROM order_heartbeats WHERE deadline_ms<=CAST(unixepoch('subsec')*1000 AS INTEGER))
OR EXISTS(SELECT 1 FROM sports_kickoffs WHERE cleared_at_ms IS NULL AND due_ms<=CAST(unixepoch('subsec')*1000 AS INTEGER))
OR EXISTS(SELECT 1 FROM quote_pending)",
[], |row| row.get(0),
)?;
@@ -46,6 +47,7 @@ pub(crate) fn transaction(
for market in markets {
crate::market::close_market(&write, &market)?;
}
crate::kickoff::clear_due(&write)?;
crate::heartbeat::expire(&write)?;
crate::quotes::flush(&write)?;
write.commit()?;