Serve SDK-compatible order book snapshots from resident depth

This commit is contained in:
2026-12-03 07:24:13 +08:00
parent 5d82be0091
commit b1fe4c2fd5
10 changed files with 328 additions and 15 deletions
+7
View File
@@ -14,6 +14,7 @@ mod validation;
mod volume;
use validation::identifier;
mod book;
mod book_snapshot;
mod cancellation;
mod command;
mod inventory;
@@ -80,6 +81,11 @@ impl Exchange {
db.execute_batch(include_str!("valuation_schema.sql"))?;
}
lots::migrate(&mut db)?;
let snapshot_ready: bool = db.query_row(
"SELECT EXISTS(SELECT 1 FROM sqlite_schema WHERE type='table' AND name='book_snapshot_times')", [], |r| r.get(0))?;
if !snapshot_ready {
db.execute_batch(include_str!("book_snapshot_schema.sql"))?;
}
let tx = expiry::transaction(&db, TransactionBehavior::Deferred)?;
let books = Books::recover(&tx)?;
tx.commit()?;
@@ -124,6 +130,7 @@ impl Exchange {
| "prices"
| "quote_history"
| "volume"
| "clob_book"
| "book"
| "open_orders"
| "positions"