Settle sub-cent orders and migrate historical book prices

This commit is contained in:
2026-12-03 07:07:25 +08:00
parent 064b301ebd
commit 20ce08adf9
32 changed files with 393 additions and 138 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ WITH selected_events AS (
WHERE at_ms BETWEEN :start AND :before_ms AND (at_ms,seq)<=(:before_ms,:before_execution)
), legs AS (
SELECT e.at_ms,e.execution,e.market,o.seq AS order_seq,o.account,o.outcome,o.side,e.kind,
CASE WHEN e.kind<>'transfer' AND o.seq=e.second_order THEN 100-e.price ELSE e.price END AS price,
CASE WHEN e.kind<>'transfer' AND o.seq=e.second_order THEN 10000-e.price ELSE e.price END AS price,
e.quantity,
CASE WHEN c.execution IS NULL THEN NULL WHEN c.taker_order IS NULL THEN 'auction'
WHEN c.taker_order=o.seq THEN 'taker' ELSE 'maker' END AS role
@@ -26,5 +26,5 @@ WITH selected_events AS (
AND (e.at_ms,e.execution,o.seq)<(:before_ms,:before_execution,:before_order)
)
SELECT at_ms,execution,order_seq,account,market,outcome,side,kind,price,quantity,role
FROM legs WHERE CASE WHEN :cash THEN price*quantity/10000.0 ELSE quantity/100.0 END >= :minimum
FROM legs WHERE CASE WHEN :cash THEN price*quantity/1000000.0 ELSE quantity/100.0 END >= :minimum
ORDER BY at_ms DESC,execution DESC,order_seq DESC LIMIT :limit