31ece2e99a
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34 lines
1.2 KiB
SQL
34 lines
1.2 KiB
SQL
create table if not exists trade_signals (
|
|
id bigserial primary key,
|
|
instrument_id bigint not null references instruments(id),
|
|
model_code text not null,
|
|
side text not null,
|
|
status text not null,
|
|
bias_snapshot_id bigint references bias_snapshots(id),
|
|
entry_type text not null,
|
|
entry_low numeric(20,10),
|
|
entry_high numeric(20,10),
|
|
stop_loss numeric(20,10),
|
|
tp1 numeric(20,10),
|
|
tp2 numeric(20,10),
|
|
rr_tp1 numeric(8,4),
|
|
rr_tp2 numeric(8,4),
|
|
session_code text,
|
|
created_ts timestamptz not null,
|
|
expires_ts timestamptz,
|
|
invalidations jsonb not null default '[]'::jsonb,
|
|
evidence jsonb not null default '{}'::jsonb,
|
|
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_trade_signals_instr_created_desc
|
|
on trade_signals (instrument_id, created_ts desc);
|
|
|
|
create index if not exists idx_trade_signals_instr_status_created_desc
|
|
on trade_signals (instrument_id, status, created_ts desc);
|
|
|
|
create index if not exists idx_trade_signals_instr_model_created_desc
|
|
on trade_signals (instrument_id, model_code, created_ts desc);
|