Query editor
with cpi(d, actual, cons) as (values(date '2021-01-13',1.4,1.3),(date '2021-02-10',1.4,1.5),(date '2021-03-10',1.7,1.7),(date '2021-04-13',2.6,2.5),(date '2021-05-12',4.2,3.6),(date '2021-06-10',5.0,4.7),(date '2021-07-13',5.4,4.9),(date '2021-08-11',5.4,5.3),(date '2021-09-14',5.3,5.3),(date '2021-10-13',5.4,5.3),(date '2021-11-10',6.2,5.8),(date '2021-12-10',6.8,6.8),(date '2022-01-12',7.0,7.0),(date '2022-02-10',7.5,7.3),(date '2022-03-10',7.9,7.9),(date '2022-04-12',8.5,8.4),(date '2022-05-11',8.3,8.1),(date '2022-06-10',8.6,8.3),(date '2022-07-13',9.1,8.8),(date '2022-08-10',8.5,8.7),(date '2022-09-13',8.3,8.1),(date '2022-10-13',8.2,8.1),(date '2022-11-10',7.7,8.0),(date '2022-12-13',7.1,7.3),(date '2023-01-12',6.5,6.5),(date '2023-02-14',6.4,6.2),(date '2023-03-14',6.0,6.0),(date '2023-04-12',5.0,5.2),(date '2023-05-10',4.9,5.0),(date '2023-06-13',4.0,4.1),(date '2023-07-12',3.0,3.1),(date '2023-08-10',3.2,3.3),(date '2023-09-13',3.7,3.6),(date '2023-10-12',3.7,3.6),(date '2023-11-14',3.2,3.3),(date '2023-12-12',3.1,3.1),(date '2024-01-11',3.4,3.2),(date '2024-02-13',3.1,2.9),(date '2024-03-12',3.2,3.1),(date '2024-04-10',3.5,3.4),(date '2024-05-15',3.4,3.4),(date '2024-06-12',3.3,3.4),(date '2024-07-11',3.0,3.1),(date '2024-08-14',2.9,3.0),(date '2024-09-11',2.5,2.6),(date '2024-10-10',2.4,2.3),(date '2024-11-13',2.6,2.6),(date '2024-12-11',2.7,2.7),(date '2025-01-15',2.9,2.9),(date '2025-02-12',3.0,2.9),(date '2025-03-12',2.8,2.9),(date '2025-04-10',2.4,2.6),(date '2025-05-13',2.3,2.4),(date '2025-06-11',2.4,2.5),(date '2025-07-15',2.7,2.7),(date '2025-08-12',2.7,2.8),(date '2025-09-11',2.9,2.9),(date '2025-10-24',3.0,3.1),(date '2025-12-18',2.7,3.1),(date '2026-01-13',2.7,2.7),(date '2026-02-13',2.4,2.5),(date '2026-03-11',2.4,2.4),(date '2026-04-10',3.3,3.3),(date '2026-05-12',3.8,3.7),(date '2026-06-10',4.2,4.2),(date '2026-07-14',3.5,3.8),(date '2026-08-12',3.4,3.4),(date '2026-09-11',3.4,3.4),(date '2026-10-14',3.7,3.6)),tx as (select ledger_close_date d, sum(transaction_count) txs from xrpl.ledger where ledger_close_date >= date '2020-12-01' and ledger_close_date < date '2026-11-10' group by 1),m as (select a.date d, ln(nullif(cast(t.txs as double),0)) l_tx, ln(nullif(cast(a.xrp_payment_volume_xrp as double),0)) l_pay, ln(nullif(cast(a.dex_traders_count_daily as double),0)) l_trd, ln(nullif(cast(a.dex_xrp_pair_volume_xrp as double),0)) l_dexfrom xrpl.aggregated_metrics_daily a join tx t on t.d = a.date where a.date >= date '2020-12-01'),z as (select d,l_tx - avg(l_tx) over w z_tx, l_pay - avg(l_pay) over w z_pay, l_trd - avg(l_trd) over w z_trd, l_dex - avg(l_dex) over w z_dexfrom m window w as (order by d rows between 28 preceding and 1 preceding)),px as (select date(timestamp) d, max(price) p from prices.hour where symbol='XRP' and blockchain='bnb' and contract_address=0x1d2f0da169ceb9fc7b3144628db156f3f6c60dbe and timestamp >= timestamp '2020-12-31' and hour(timestamp)=0 group by 1),r as (select d, lead(p) over (order by d)/p-1 ret from px),j as (select z.*, r.ret, c.actual, c.cons, c.d cd, lag(c.d) over (order by z.d) prev_cd from z join r on r.d=z.d left join cpi c on c.d=z.d where z.d >= date '2021-01-01'),lab as (select j.*, 'all_2021+' period from junion all select j.*, 'Nov2023+' from j where d >= date '2023-11-01'),g as (select period, '1 CPI day (all)' grp, z_tx, z_pay, z_trd, z_dex, ret from lab where cd is not nullunion all select period, case when actual>cons then '2 CPI hot' when actual<cons then '4 CPI cool' else '3 CPI in-line' end, z_tx, z_pay, z_trd, z_dex, ret from lab where cd is not nullunion all select period, '5 day after CPI', z_tx, z_pay, z_trd, z_dex, ret from lab where prev_cd is not null and cd is nullunion all select period, '6 non-CPI weekday', z_tx, z_pay, z_trd, z_dex, ret from lab where cd is null and day_of_week(d) between 1 and 5union all select period, '7 non-CPI day, XRP moved 5%+', z_tx, z_pay, z_trd, z_dex, ret from lab where cd is null and abs(ret)>=0.05union all select period, '8 CPI day, XRP moved 5%+', z_tx, z_pay, z_trd, z_dex, ret from lab where cd is not null and abs(ret)>=0.05union all select period, '9 CPI day, XRP moved <5%', z_tx, z_pay, z_trd, z_dex, ret from lab where cd is not null and abs(ret)<0.05)select period, grp, count(*) n,round(100*(exp(avg(z_tx))-1),1) tx_pct, round(avg(z_tx)/(stddev(z_tx)/sqrt(count(*))),2) tx_t,round(100*(exp(avg(z_pay))-1),1) pay_pct, round(avg(z_pay)/(stddev(z_pay)/sqrt(count(*))),2) pay_t,round(100*(exp(avg(z_trd))-1),1) trd_pct, round(avg(z_trd)/(stddev(z_trd)/sqrt(count(*))),2) trd_t,round(100*(exp(avg(z_dex))-1),1) dex_pct, round(avg(z_dex)/(stddev(z_dex)/sqrt(count(*))),2) dex_t,round(avg(z_tx),4) m_tx, round(stddev(z_tx),4) s_tx, round(avg(z_pay),4) m_pay, round(stddev(z_pay),4) s_pay, round(avg(z_trd),4) m_trd, round(stddev(z_trd),4) s_trd, round(avg(z_dex),4) m_dex, round(stddev(z_dex),4) s_dex,round(100*avg(abs(ret)),2) avg_abs_retfrom g group by 1,2 order by 1,2