Resolve up-down markets from exact same-stream TWAP observations

This commit is contained in:
2026-12-03 04:19:49 +08:00
parent 8aa33385fb
commit 67426ae617
11 changed files with 294 additions and 21 deletions
+3 -2
View File
@@ -19,8 +19,9 @@ pub(crate) fn outcomes(market: &str, yes: &str, no: &str) -> Value {
pub(crate) fn market_assets(db: &Connection, market: &str) -> Result<Value> {
identifier(market)?;
let (yes, no, phase): (String, String, String) = db.query_row(
"SELECT COALESCE(s.yes_label,'YES'),COALESCE(s.no_label,'NO'),m.phase
FROM markets m LEFT JOIN sports_markets s ON s.market=m.id WHERE m.id=?1",
"SELECT COALESCE(s.yes_label,CASE WHEN t.market IS NULL THEN 'YES' ELSE 'Up' END),
COALESCE(s.no_label,CASE WHEN t.market IS NULL THEN 'NO' ELSE 'Down' END),m.phase
FROM markets m LEFT JOIN sports_markets s ON s.market=m.id LEFT JOIN twap_markets t ON t.market=m.id WHERE m.id=?1",
[market],
|r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)),
)?;