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

21 lines
798 B
SQL

create table if not exists displacement_events (
id bigserial primary key,
instrument_id bigint not null references instruments(id),
timeframe text not null,
direction text not null,
start_ts timestamptz not null,
end_ts timestamptz not null,
strength_score numeric(8,4),
body_ratio numeric(8,4),
has_fvg boolean not null default false,
is_valid boolean not null default true,
meta jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now()
);
create index if not exists idx_displacement_events_instr_tf_end_desc
on displacement_events (instrument_id, timeframe, end_ts desc);
create index if not exists idx_displacement_events_instr_tf_dir_end_desc
on displacement_events (instrument_id, timeframe, direction, end_ts desc);