-- VIOLET V1: scan-vs-venue price divergence metric (the FET 0.2176-vs-0.1878
-- detector). One row per (scan, asset-with-fresh-venue-mid). session_id is a
-- boot-time UUID — mono_ns is meaningless across restarts without it.
-- Apply via apply_violet_ddl.py (one statement per HTTP POST).

CREATE TABLE IF NOT EXISTS dolphin_violet.violet_feed_divergence
(
    `ts`             DateTime64(3, 'UTC'),
    `session_id`     String,
    `asset`          LowCardinality(String),
    `scan_price`     Float64,
    `venue_mid`      Float64,
    `divergence_bps` Float64,
    `scan_seq`       UInt64,
    `venue_seq`      UInt64,
    `mono_ns`        UInt64
)
ENGINE = MergeTree
ORDER BY (asset, ts)
TTL toDate(ts) + toIntervalDay(180);
