Query editor
-- forensics: boring-base doctrine backtest-- Hourly median trade price per token (dex_solana.trades), Solana CAs from-- dune.czr.dataset_mcsniper_dd, top 150 by mcap_usd.-- Doctrine translated to SQL, with honest simplifications:-- peak_px = max hourly median px in the first 24h from first observed hour (t0)-- low_px = min hourly median px after the peak hour, up to t0+72h-- retraced = low_px <= 0.50 * peak_px (>= 50 pct retrace)-- survived = low_px >= 0.02 * peak_px (did not go to ~zero)-- bounced = max px after the low, up to t0+72h, >= 1.3 * low_px-- (bounce off the low is the higher-low proxy; a true higher-low-- sequence check needs swing detection and is NOT implemented)-- BASE = retraced AND survived AND bounced; else NO-BASE with reason-- fwd_px_7d = first hourly px at or after t0+7d (NULL = no trades by then;-- tokens with t0 after 2026-07-26 lack a full 7-day window)-- class_px = last hourly px at or before t0+72h; fwd_ret_pct = fwd vs class.WITH cas AS (SELECT caFROM (SELECT ca, MAX(TRY_CAST(mcap_usd AS double)) AS mcapFROM dune.czr.dataset_mcsniper_ddWHERE chain = 'solana'GROUP BY ca)ORDER BY mcap DESC NULLS LASTLIMIT 150),trades_px AS (SELECT c.ca, t.block_time,t.amount_usd / NULLIF(t.token_bought_amount, 0) AS pxFROM dex_solana.trades tJOIN cas c ON t.token_bought_mint_address = c.caWHERE t.block_time >= TIMESTAMP '2026-07-01 00:00'AND t.block_time < TIMESTAMP '2026-08-02 00:00'AND t.amount_usd > 0 AND t.token_bought_amount > 0UNION ALLSELECT c.ca, t.block_time,t.amount_usd / NULLIF(t.token_sold_amount, 0) AS pxFROM dex_solana.trades tJOIN cas c ON t.token_sold_mint_address = c.caWHERE t.block_time >= TIMESTAMP '2026-07-01 00:00'AND t.block_time < TIMESTAMP '2026-08-02 00:00'AND t.amount_usd > 0 AND t.token_sold_amount > 0),hourly AS (SELECT ca, DATE_TRUNC('hour', block_time) AS hr,APPROX_PERCENTILE(px, 0.5) AS pxFROM trades_pxGROUP BY ca, DATE_TRUNC('hour', block_time)),tok AS (SELECT ca, MIN(hr) AS t0 FROM hourly GROUP BY ca),feat AS (SELECT h.ca, h.hr, h.px, k.t0FROM hourly h JOIN tok k ON h.ca = k.ca),peak AS (SELECT ca, MAX(px) AS peak_px, MAX_BY(hr, px) AS peak_hrFROM featWHERE hr <= t0 + INTERVAL '24' HOUR