Files
ai-exchange/migrations/019_create_sweep_events.sql
T
2026-04-24 13:39:01 +08:00

23 lines
892 B
SQL

create table if not exists sweep_events (
id bigserial primary key,
instrument_id bigint not null references instruments(id),
timeframe text not null,
side_swept text not null,
pool_id bigint not null references liquidity_pools(id),
sweep_high numeric(20,10) not null,
sweep_low numeric(20,10) not null,
sweep_ts timestamptz not null,
close_back_inside boolean not null default false,
validation_level text not null default 'weak',
status text not null default 'active',
meta jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
unique (instrument_id, timeframe, pool_id, sweep_ts)
);
create index if not exists idx_sweep_events_instr_tf_ts_desc
on sweep_events (instrument_id, timeframe, sweep_ts desc);
create index if not exists idx_sweep_events_pool_ts_desc
on sweep_events (pool_id, sweep_ts desc);