Query editor
/** NOT PRODUCTION READY**/with data as (select date_trunc('minute', block_time) as period,approx_percentile(case when token_bought_symbol ='EURe' then token_sold_amount/token_bought_amount else token_bought_amount / token_sold_amount end, 0.5) as price_50,approx_percentile(case when token_bought_symbol ='EURe' then token_sold_amount/token_bought_amount else token_bought_amount / token_sold_amount end, 0.05) as price_lower,approx_percentile(case when token_bought_symbol ='EURe' then token_sold_amount/token_bought_amount else token_bought_amount / token_sold_amount end, 0.95) as price_upper,count(*) as transactions,count(case when project = 'balance' then 1 else 0 end) as transactions_balancer,sum(case when token_bought_symbol ='EURe' then token_bought_amount else token_sold_amount end) as volume_eurofrom dex.tradeswhere blockchain = 'gnosis'and (token_bought_symbol = 'EURe'or token_sold_symbol = 'EURe')and (coalesce(token_bought_symbol, 'USD') like '%USD%'or coalesce(token_sold_symbol, 'USD') like '%USD%')and block_date >= current_date - interval '30' dayand block_date not between DATE'2023-08-22' and DATE'2023-09-13'and day_of_week(block_date) < 6 -- removing WE as there is no forexgroup by 1order by 1 desc)select period, price_50, price as chainlink_price, price_50/price-1.0000 as deviation_chainlink,abs(price_50/price-1.0000) as deviation_chainlink_abs, volume_eurofrom datainner join query_3086103 using (period)order by 1 desc