Query editor
WITH daily AS (SELECT block_date AS d,SUM(CAST(input_count AS DOUBLE)) AS inputs_consumed,SUM(CAST(output_count AS DOUBLE)) AS outputs_created,SUM(output_value) AS btc_moved,COUNT(*) AS tx_countFROM bitcoin.transactionsWHERE block_date >= CURRENT_DATE - INTERVAL '45' DAYAND is_coinbase = falseGROUP BY 1),ratio AS (SELECT d, tx_count, btc_moved,inputs_consumed / NULLIF(tx_count,0) AS inputs_per_tx,btc_moved / NULLIF(tx_count,0) AS btc_per_txFROM daily)SELECT d,ROUND(inputs_per_tx - AVG(inputs_per_tx) OVER (ORDER BY d ROWS BETWEEN 30 PRECEDING AND 1 PRECEDING), 5)AS net_consolidation_signal,ROUND(btc_per_tx - AVG(btc_per_tx) OVER (ORDER BY d ROWS BETWEEN 30 PRECEDING AND 1 PRECEDING), 5)AS net_size_signal,ROUND(inputs_per_tx,4) AS inputs_per_tx,ROUND(btc_per_tx,6) AS btc_per_tx,tx_countFROM ratio ORDER BY d DESC;