dannyamahDaily Trading by Type
    Updated 2024-08-06
    -- forked from Ario / Vertex - Weekly trading volume and traders by type @ https://flipsidecrypto.xyz/Ario/q/40k0T5YHzYGU/vertex---weekly-trading-volume-and-traders-by-type

    with main as (
    SELECT
    'Spot' as Type,
    block_timestamp,
    TRADER,
    tx_hash,
    AMOUNT_USD
    from arbitrum.vertex.ez_spot_trades
    where IS_TAKER = 'TRUE'

    union all

    SELECT
    'Perp' as Type,
    block_timestamp,
    TRADER,
    tx_hash,
    AMOUNT_USD
    from arbitrum.vertex.ez_perp_trades
    where IS_TAKER = 'TRUE'
    )
    select
    date_trunc(week, block_timestamp) as date,
    count(DISTINCT case when Type = 'Spot' then TRADER end) as "Spot Trader",
    count(DISTINCT case when Type = 'Perp' then TRADER end) as "Perp Trader",
    "Spot Trader" + "Perp Trader" as "Total # Traders",
    count(DISTINCT case when Type = 'Spot' then tx_hash end) as "Spot Trade",
    count(DISTINCT case when Type = 'Perp' then tx_hash end) as "Perp Trade",
    "Spot Trade" + "Perp Trade" as "Total # Trades",
    sum(case when Type = 'Spot' then zeroifnull(AMOUNT_USD) end) as "Spot Volume",
    sum(case when Type = 'Perp' then zeroifnull(AMOUNT_USD) end) as "Perp Volume",
    sum(zeroifnull(AMOUNT_USD)) as "Total Trading Volume"
    from main
    group by 1
    Last run: 3 months ago
    DATE
    Spot Trader
    Perp Trader
    Total # Traders
    Spot Trade
    Perp Trade
    Total # Trades
    Spot Volume
    Perp Volume
    Total Trading Volume
    1
    2024-02-05 00:00:00.000237660897405850219079529097795.3904541467805573.23311996903368.62355
    2
    2024-11-25 00:00:00.00014767281914777219869616113923.3028562653429112.894191669543036.197047
    3
    2024-09-30 00:00:00.0007649056625946475906924221915.9247809775010835.677397799232751.602178
    4
    2023-08-14 00:00:00.000307775108230106948995894489064.4618552720320404.04341814809468.505265
    5
    2024-07-22 00:00:00.000120127613965023101411516473663598.27733591858373328.483421932036926.76076
    6
    2023-06-05 00:00:00.0001042313356071024163139092324.2349004191386663.87915230478988.11405
    7
    2023-10-30 00:00:00.000348132716754131151871931859149884.6415741406127824.60361465277709.24518
    8
    2024-01-15 00:00:00.000262687949340740727479252109132.5007171416690925.431151668800057.93187
    9
    2023-05-15 00:00:00.00037621158711271443257054165957.2161037151966019.066142206131976.282246
    10
    2024-06-17 00:00:00.0001296928214800118191661968785188.95738342243307093.115782312092282.07316
    11
    2023-09-11 00:00:00.00016362478721635156731954411280.6649896600133097.761901654544378.426891
    12
    2023-07-10 00:00:00.00025073298222175783800036951078.9526181473352929.519709510304008.472327
    13
    2024-07-29 00:00:00.00013911841323531195621487366715947.03153851675555441.593291742271388.62483
    14
    2023-06-12 00:00:00.00073214287537931146827929892.7120232167605908.904026195535801.616049
    15
    2024-10-28 00:00:00.0008345253519014254615525030397.0517154477574974.978997502605372.030712
    16
    2024-10-14 00:00:00.0009141650720494904695320994170.3671713553206555.708206574200726.075377
    17
    2023-06-19 00:00:00.00016137653712432963420656810002.1112573272429458.322019329239460.433277
    18
    2024-07-15 00:00:00.000233139616296403192932569674797381.0653541551905386.083021626702767.14838
    19
    2023-04-10 00:00:00.0003412616080187267109051.8403471652685278.519185572794330.35953273
    20
    2024-04-29 00:00:00.000154570724406979041197372744536.41760212078431118.082972151175654.50058
    92
    9KB
    6s