Query editor
with trades as (selectcast(date_trunc('minute', block_time) as timestamp) as minute,block_slot,tx_id,-- USDC per old META (amounts here are already decimals-adjusted)casewhen token_bought_mint_address = 'omfgRBnxHsNJh6YeGbGAmWenNkenzsXyBXm3WDhmeta'then cast(token_sold_amount as double) / cast(token_bought_amount as double) -- buy: paid USDC, got METAelse cast(token_bought_amount as double) / cast(token_sold_amount as double) -- sell: paid META, got USDCend as pricefrom dex_solana.tradeswhere (token_bought_mint_address = 'omfgRBnxHsNJh6YeGbGAmWenNkenzsXyBXm3WDhmeta'or token_sold_mint_address = 'omfgRBnxHsNJh6YeGbGAmWenNkenzsXyBXm3WDhmeta')and (token_bought_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'or token_sold_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')and token_bought_amount > 0and token_sold_amount > 0and block_month >= date '2023-11-01'and block_date <= date '2026-01-06'),candles as (selectminute,min_by(price, row(block_slot, tx_id)) as open,max(price) as high,min(price) as low,max_by(price, row(block_slot, tx_id)) as closefrom tradesgroup by 1),bounds as (selectmin(minute) as first_minute,max(minute) as last_minutefrom candles),minutes as (select cast(d as timestamp) + u.n * interval '1' minute as minutefrom bounds bcross join unnest(sequence(cast(b.first_minute as date), cast(b.last_minute as date), interval '1' day)) as t(d)cross join unnest(sequence(0, 1439)) as u(n)where cast(d as timestamp) + u.n * interval '1' minutebetween b.first_minute and b.last_minute),filled as (selectm.minute,c.open,c.high,c.low,c.close,last_value(c.close) ignore nulls over (order by m.minute