hmxinternTrade Size segmentation
Updated 2024-05-15
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
with sizeLimit(id , size, name) as (
SELECT * FROM VALUES
(0, 200000, 'ETHUSD'),
(1, 200000, 'BTCUSD'),
(12, 80000, 'OPUSD'),
(19, 100000, 'DOGEUSD')
),
open as (
select
BLOCK_TIMESTAMP, DECODED_LOG['primaryAccount'] as account,
abs(DECODED_LOG['marketIndex']) as marketIndex,
abs(DECODED_LOG['increasedSize']) / 1e30 as trade_size
from blast.core.fact_decoded_event_logs
where CONTRACT_ADDRESS = lower('0x0a8D9c0A4a039dDe3Cb825fF4c2f063f8B54313A')
and EVENT_NAME in ('LogIncreasePosition')
),
stats as (
select date_trunc('day', block_timestamp) as time,
marketIndex, name, size, count(*) as trades
from open
join sizeLimit on open.marketIndex = sizeLimit.id
group by date_trunc('day', block_timestamp), marketIndex, name, size
),
onLimit as (
select date_trunc('day', block_timestamp) as time,
marketIndex, name, count(*) as trades
from (
select * from open
join sizeLimit on open.marketIndex = sizeLimit.id
where trade_size >= (sizeLimit.size * 0.8)
)
group by 1,2,3
)
select stats.time, stats.name, stats.trades, coalesce(onLimit.trades, 0) as tradesOnLimit,
QueryRunArchived: QueryRun has been archived