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

23 lines
885 B
SQL

create table if not exists fvg_zones (
id bigserial primary key,
instrument_id bigint not null references instruments(id),
timeframe text not null,
direction text not null,
upper numeric(20,10) not null,
lower numeric(20,10) not null,
start_ts timestamptz not null,
end_ts timestamptz not null,
fill_pct numeric(8,4) not null default 0,
status text not null default 'open',
related_displacement_id bigint references displacement_events(id),
meta jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create index if not exists idx_fvg_zones_instr_tf_start_desc
on fvg_zones (instrument_id, timeframe, start_ts desc);
create index if not exists idx_fvg_zones_instr_tf_status_start_desc
on fvg_zones (instrument_id, timeframe, status, start_ts desc);