Query editor
with trades as (selectcast(date_trunc('minute', block_time) as timestamp) as minute,block_slot,tx_id,casewhen token_bought_mint_address = 'sc1dNAxRBj5CNWaGC26AR7PEW75R36Umzt1V8vuP8kZ'then cast(token_sold_amount as double) / cast(token_bought_amount as double)else cast(token_bought_amount as double) / cast(token_sold_amount as double)end as pricefrom dex_solana.tradeswhere (token_bought_mint_address = 'sc1dNAxRBj5CNWaGC26AR7PEW75R36Umzt1V8vuP8kZ'or token_sold_mint_address = 'sc1dNAxRBj5CNWaGC26AR7PEW75R36Umzt1V8vuP8kZ')and (token_bought_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'or token_sold_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')and token_bought_amount > 0and token_sold_amount > 0-- and project = 'meteora'-- and version = 1-- and version_name = 'amm'--and block_month >= date '2024-06-01'--and block_date <= date '2025-12-31'),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,