CREATE TABLE IF NOT EXISTS taker_buy_sell_volume (
  source TEXT NOT NULL,
  symbol TEXT NOT NULL,
  period TEXT NOT NULL,

  timestamp BIGINT NOT NULL,

  buy_sell_ratio NUMERIC(36, 18),
  buy_volume NUMERIC(36, 18),
  sell_volume NUMERIC(36, 18),

  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),

  PRIMARY KEY (source, symbol, period, timestamp)
);

CREATE INDEX IF NOT EXISTS idx_taker_buy_sell_symbol_period_time
ON taker_buy_sell_volume(symbol, period, timestamp DESC);

SELECT create_hypertable('taker_buy_sell_volume', 'timestamp',
  chunk_time_interval => 604800000,
  if_not_exists => TRUE,
  migrate_data => TRUE);
