Query editor
WITH raw AS (SELECT'No' AS outcome,http_get('https://clob.polymarket.com/prices-history?market=20490903838795271872508839925457310042688796049257211138642443340719901864083&interval=max',ARRAY['Content-Type: application/json']) AS raw_jsonUNION ALLSELECT'Yes' AS outcome,http_get('https://clob.polymarket.com/prices-history?market=57338714801830110409291906331043415122319095430948035858069240523339447935973&interval=max',ARRAY['Content-Type: application/json']) AS raw_json),filtered AS (SELECTr.outcome,date_trunc('day', CAST(from_unixtime(CAST(json_extract_scalar(item, '$.t') AS bigint)) AS timestamp)) AS ts,CAST(json_extract_scalar(item, '$.p') AS double) AS priceFROM raw rCROSS JOIN UNNEST(CAST(json_extract(r.raw_json, '$.history') AS array(json))) AS t(item)),next_ AS (SELECTts,avg(CASE WHEN outcome = 'Yes' THEN f.price END) AS yes_p,avg(CASE WHEN outcome = 'No' THEN f.price END) AS no_p,avg(p.price) as BTC_priceFROM filtered fleft join prices.usd p on p.minute = f.ts and p.symbol = 'BTC' and p.blockchain IS NULLGROUP BY ts)SELECTdate_trunc('day', ts) AS day,yes_p * 100 as yes_price,no_p * 100 as no_price,BTC_priceFROM next_ORDER BY 1 desc