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

23 lines
886 B
SQL

create table if not exists dealing_ranges (
id bigserial primary key,
instrument_id bigint not null references instruments(id),
timeframe text not null,
high numeric(20,10) not null,
low numeric(20,10) not null,
equilibrium numeric(20,10) not null,
high_swing_id bigint references swings(id),
low_swing_id bigint references swings(id),
state text not null default 'valid',
ts_start timestamptz not null,
ts_end timestamptz,
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_dealing_ranges_instr_tf_start_desc
on dealing_ranges (instrument_id, timeframe, ts_start desc);
create index if not exists idx_dealing_ranges_instr_tf_state_start_desc
on dealing_ranges (instrument_id, timeframe, state, ts_start desc);