Query editor
with buys as (select date_trunc('week', evt_block_time) as week,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('week', evt_block_time) as week,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.week,coalesce(buyers, 0) as buyers,coalesce(sellers, 0) as sellersfrom buys afull outer join sells b on a.week = b.week)selectweek,buyers,sellers,cast(buyers as double precision) / nullif(cast(sellers as double precision), 0) as buy_sell_ratio,((buyers + sellers) - lag(buyers + sellers) over (order by week)) / nullif(cast(lag(buyers + sellers) over (order by week) as double precision), 0) as percent_change_tradersfrom groupedorder by week desc