Query editor
with buys as (select date_trunc('day', evt_block_time) as date,cast(sum(ethAmount) as double) / 1e18 as eth_volume_buy,count(distinct trader) as buyersfrom friendtech_base.FriendtechSharesV1_evt_Trade ftwhere isBuy = true and shareAmount > cast(0 as uint256)group by 1),sells as (select date_trunc('day', evt_block_time) as date,- cast(sum(ethAmount) as double) / 1e18 as eth_volume_sell,count(distinct trader) as sellersfrom friendtech_base.FriendtechSharesV1_evt_Trade ftwhere isBuy = false and shareAmount > cast(0 as uint256)group by 1),prices as (select date_trunc('day', minute) as date,avg(price) as pricefrom prices.usd pwhere symbol = 'ETH'group by 1),grouped as (select a.date,eth_volume_buy,eth_volume_buy * c.price as eth_volume_buy_usd,eth_volume_sell,eth_volume_sell * c.price as eth_volume_sell_usd,buyers,sellersfrom buys aleft join sells b on a.date = b.dateleft join prices c on a.date = c.date)select *,((buyers + sellers) - lag(buyers + sellers) over (order by date)) / cast(lag(buyers + sellers) over (order by date) as double precision) as percent_change_traders,cast(buyers as double precision) / nullif(cast(sellers as double precision), 0) as buy_sell_ratio,sum(eth_volume_buy) over (order by date) as cumu_eth_volume_bought,sum(eth_volume_sell) over (order by date) as cumu_eth_volume_sold,sum(eth_volume_buy_usd) over (order by date) as cumu_eth_volume_bought_usd,sum(eth_volume_sell_usd) over (order by date) as cumu_eth_volume_sold_usd,sum(eth_volume_sell + eth_volume_buy) over (order by date) as cumu_eth_volume,((eth_volume_buy + eth_volume_sell) - lag(eth_volume_buy + eth_volume_sell) over (order by date)) / lag(eth_volume_buy + eth_volume_sell) over (order by date) as daily_pct_change_eth_volume,sum(eth_volume_sell_usd + eth_volume_buy_usd) over (order by date) as cumu_eth_volume_usd,((eth_volume_buy_usd + eth_volume_sell_usd) - lag(eth_volume_buy_usd + eth_volume_sell_usd) over (order by date)) / lag(eth_volume_buy_usd + eth_volume_sell_usd) over (order by date) as daily_pct_change_eth_volume_usd,sum(buyers) over (order by date) as cumu_buyers,sum(sellers) over (order by date) as cumu_sellers,eth_volume_buy + eth_volume_sell as eth_differential,eth_volume_buy_usd + eth_volume_sell_usd as usd_differentialfrom groupedorder by 1 desc