Query editor
WITH trades AS (SELECT -- buyblock_date,block_time,token_bought_amount AS amt,amount_usd AS usd,amount_usd/token_bought_amount AS priceFROM dex.tradesWHERE token_bought_address = 0xCA5b0AE1d104030a9B8F879523508EFd86c14483AND amount_usd IS NOT NULLUNION ALLSELECT --sellblock_date,block_time,token_sold_amount AS amt,amount_usd AS usd,amount_usd/token_sold_amount AS priceFROM dex.tradesWHERE token_sold_address = 0xCA5b0AE1d104030a9B8F879523508EFd86c14483AND amount_usd IS NOT NULL)selectblock_date,sum(amt) as total_amount,sum(usd) as usd_volume,sum(usd)*0.3/100 as fees_generated,sum(usd)/sum(amt) as avg_pricefrom tradesgroup by block_dateorder by block_date desc