Soheil_MKUntitled Query
Updated 2022-12-20
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 OP AS (
SELECT date_trunc('day', hour) as date,
avg(price) as OP_price,
lag(OP_price) ignore nulls over(order by date asc) as lag_OP_price,
((OP_price-lag_OP_price)/ lag_OP_price)*100 as OP_volatility
FROM optimism.core.fact_hourly_token_prices
WHERE token_address = '0x4200000000000000000000000000000000000042'
GROUP BY 1
),
eth_price as (
select
date_trunc('day', hour) as date,
avg(price) as eth_price,
lag(eth_price) ignore nulls over(order by date asc) as lag_eth_price,
((eth_price-lag_eth_price)/ lag_eth_price)*100 as ETH_volatility
from ethereum.core.fact_hourly_token_prices
where symbol = 'WETH'
and date >='2022-11-01'
group by date
order by date
),
main1 as (
select
op.date,
op.OP_price,
eth.eth_price,
op_volatility,
ETH_volatility
from op op
join eth_price eth
on op.date=eth.date
)
select *
Run a query to Download Data