Files
siloqy/prod/clickhouse/violet/04_position_state.sql
Codex 99e529c32a VIOLET V1a: dolphin_violet DDL set + statement-wise applier (applied + verified)
14 tables consolidated from the LIVE post-ALTER dolphin_pink schema
(maras_tp + provenance folded into base CREATEs — a fresh DB never replays
ALTER chains) + violet_feed_divergence (scan-vs-venue divergence metric,
session_id + plane seqs + mono_ns). apply_violet_ddl.py posts ONE statement
per HTTP request (multi-statement posts fail — proven on pink 08), is
idempotent (all IF NOT EXISTS, double-apply tested live), and verifies the
expected table set. Applied to live CH: verify all 14 present.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 15:40:05 +02:00

31 lines
1.0 KiB
SQL

-- dolphin_violet DDL — consolidated from the LIVE dolphin_pink schema
-- (post-ALTER: includes maras_tp + provenance columns). Generated 2026-06-12.
-- Apply via apply_violet_ddl.py (one statement per HTTP POST).
CREATE TABLE IF NOT EXISTS dolphin_violet.position_state
(
`ts` DateTime64(6, 'UTC'),
`trade_id` String,
`asset` LowCardinality(String),
`direction` Int8,
`entry_price` Float64,
`quantity` Float64,
`notional` Float64,
`leverage` Float32,
`bucket_id` Int32 DEFAULT -1,
`entry_bar` Int32 DEFAULT 0,
`status` LowCardinality(String),
`exit_reason` LowCardinality(String) DEFAULT '',
`pnl` Float64 DEFAULT 0,
`bars_held` UInt16 DEFAULT 0,
`market_state_bundle_json` String DEFAULT '',
`tp_base_pct` Float32 DEFAULT 0,
`tp_effective_pct` Float32 DEFAULT 0,
`our_leverage` Float32 DEFAULT 0
)
ENGINE = ReplacingMergeTree(ts)
PARTITION BY toYYYYMM(ts)
ORDER BY (trade_id, ts)
TTL toDateTime(ts) + toIntervalDay(180)
SETTINGS index_granularity = 8192;