Match immediate buys against a cash budget and price cap
This commit is contained in:
@@ -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)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user