bachiethbad4
    Updated 2022-11-24
    with table_1 as (select date_trunc('day', block_timestamp) as day,
    count(distinct(origin_from_address)) as selling_eth_wallet,
    sum(amount_in_usd) as eth_selling_vol,
    sum(eth_selling_vol) over (order by day) as cumu_eth_selling_vol
    from ethereum.core.ez_dex_swaps
    where block_timestamp >= current_date - 60
    and symbol_in in ('WETH', 'ETH')
    group by 1),

    table_2 as (select date_trunc('day', block_timestamp) as day,
    count(distinct(origin_from_address)) as buying_eth_wallet,
    sum(amount_out_usd) as eth_buying_vol,
    sum(eth_buying_vol) over (order by day) as cumu_eth_buying_vol
    from ethereum.core.ez_dex_swaps
    where block_timestamp >= current_date - 60
    and symbol_out in ('WETH', 'ETH')
    group by 1),

    table_3 as (select date_trunc('day', block_timestamp) as day,
    count(distinct(origin_from_address)) as wallet_count
    from ethereum.core.ez_dex_swaps
    where block_timestamp >= current_date - 60
    and (symbol_in in ('WETH', 'ETH')
    or symbol_out in ('WETH', 'ETH'))
    group by 1)

    select a.day,
    eth_selling_vol,
    eth_selling_vol*-1,
    eth_buying_vol,
    avg(eth_buying_vol) over (order by a.day rows between 4 preceding and current row) as "5-Day Moving Average",
    avg(eth_buying_vol) over (order by a.day rows between 9 preceding and current row) as "10-Day Moving Average",
    avg(eth_buying_vol) over (order by a.day rows between 49 preceding and current row) as "50-Day Moving Average",
    avg(eth_buying_vol) over (order by a.day rows between 199 preceding and current row) as "200-Day Moving Average",
    eth_buying_vol - eth_selling_vol as net_volume,
    cumu_eth_selling_vol,
    Run a query to Download Data