Query editor
with trades as (selectcast(date_trunc('minute', block_time) as timestamp) as minute,block_slot,tx_id,casewhen token_bought_mint_address = 'So11111111111111111111111111111111111111112'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 = 'So11111111111111111111111111111111111111112'or token_sold_mint_address = 'So11111111111111111111111111111111111111112')and (token_bought_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'or token_sold_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')and token_bought_amount > 0and token_sold_amount > 0and version_name = 'whirlpool_v2'and 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