Expose aggregated binary order book depth per outcome

This commit is contained in:
2026-12-03 03:53:29 +08:00
parent 47d49cb8c9
commit 646cf193bb
6 changed files with 100 additions and 14 deletions
+8
View File
@@ -73,3 +73,11 @@ CREATE VIEW IF NOT EXISTS outcome_trade_prices AS
SELECT fill,market,outcome,at_ms,price_micros,quantity FROM trade_prices
UNION ALL SELECT seq,market,'YES',at_ms,yes_price*10000,quantity FROM paired_fills
UNION ALL SELECT seq,market,'NO',at_ms,(100-yes_price)*10000,quantity FROM paired_fills;
-- Each live binary order contributes once to each outcome's depth.
CREATE VIEW IF NOT EXISTS visible_orders AS
SELECT market,outcome,side,price,remaining FROM orders WHERE status='live'
UNION ALL
SELECT market,CASE outcome WHEN 'YES' THEN 'NO' ELSE 'YES' END,
CASE side WHEN 'buy' THEN 'sell' ELSE 'buy' END,100-price,remaining
FROM orders WHERE status='live';