Files
ai-exchange/migrations/006_create_swings.sql
2026-04-24 13:39:01 +08:00

24 lines
820 B
SQL

create table if not exists swings (
id bigserial primary key,
instrument_id bigint not null references instruments(id),
timeframe text not null,
kind text not null,
strength text not null,
price numeric(20,10) not null,
ts timestamptz not null,
left_bars integer not null,
right_bars integer not null,
confirmed boolean not null default true,
meta jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now()
);
create index if not exists idx_swings_instr_tf_ts_desc
on swings (instrument_id, timeframe, ts desc);
create index if not exists idx_swings_instr_tf_kind_ts_desc
on swings (instrument_id, timeframe, kind, ts desc);
create index if not exists idx_swings_instr_tf_strength_ts_desc
on swings (instrument_id, timeframe, strength, ts desc);