Query editor
with updates as (select timestamp, price, lead(price, 1) over (order by timestamp desc) as one_hour, lead(price, 2) over (order by timestamp desc) as two_hour, lead(price, 12) over (order by timestamp desc) as twelve_hour, lead(price, 24) over (order by timestamp desc) as twenty_four_hour, lead(price, 48) over (order by timestamp desc) as fourty_eight_hour, price - lead(price, 2) over (order by timestamp desc) as price_changefrom prices.hourwhere blockchain = 'ethereum'and symbol = 'WBTC'and source = 'coinpaprika'),ranges as (select *, (price_change / one_hour) * 100 as one_change, (price_change / two_hour) * 100 as two_change, (price_change / twelve_hour) * 100 as twelve_change, (price_change / twenty_four_hour) * 100 as twenty_four_change, (price_change / fourty_eight_hour) * 100 as fourty_eight_changefrom updates)-- select * from ranges-- where timestamp >= cast('2020-01-01' as timestamp)select avg(twenty_four_change) - 3 * stddev_pop(twenty_four_change) as three_sigma, 3 * stddev_pop(twenty_four_change) as std_dev, avg(twenty_four_change) as average, min(twenty_four_change) as max_drawdownfrom rangeswhere twenty_four_change < 0