Match immediate buys against a cash budget and price cap

This commit is contained in:
2026-12-03 04:27:01 +08:00
parent c27bb60fd2
commit 763b46f43e
11 changed files with 244 additions and 9 deletions
+6
View File
@@ -155,3 +155,9 @@ CREATE VIEW IF NOT EXISTS twap_result AS
FROM twap_markets t
LEFT JOIN twap_reports a ON a.stream=t.stream AND a.observed_at=t.start_at
LEFT JOIN twap_reports b ON b.stream=t.stream AND b.observed_at=t.end_at;
CREATE TABLE IF NOT EXISTS budget_buys (
order_seq INTEGER PRIMARY KEY REFERENCES orders,
amount_cents INTEGER NOT NULL CHECK(amount_cents>0),
spent_cents INTEGER NOT NULL CHECK(spent_cents BETWEEN 0 AND amount_cents)
);