34 lines
1.4 KiB
SQL
34 lines
1.4 KiB
SQL
create table if not exists trade_plan_candidates (
|
|
id bigserial primary key,
|
|
instrument_id bigint not null references instruments(id),
|
|
trading_plan_id bigint not null references trading_plans(id),
|
|
model_code text not null,
|
|
status text not null,
|
|
side text,
|
|
setup_timeframe text not null,
|
|
trigger_timeframe text not null,
|
|
created_ts timestamptz not null,
|
|
expires_ts timestamptz,
|
|
confirmation_state jsonb not null default '{}'::jsonb,
|
|
missing_confirmations jsonb not null default '[]'::jsonb,
|
|
evidence jsonb not null default '{}'::jsonb,
|
|
entry jsonb not null default '{}'::jsonb,
|
|
invalidations jsonb not null default '[]'::jsonb,
|
|
narrative text not null,
|
|
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_plan_candidates_instr_created_desc
|
|
on trade_plan_candidates (instrument_id, created_ts desc);
|
|
|
|
create index if not exists idx_trade_plan_candidates_plan_created_desc
|
|
on trade_plan_candidates (trading_plan_id, created_ts desc);
|
|
|
|
create index if not exists idx_trade_plan_candidates_instr_status_created_desc
|
|
on trade_plan_candidates (instrument_id, status, created_ts desc);
|
|
|
|
create index if not exists idx_trade_plan_candidates_instr_model_created_desc
|
|
on trade_plan_candidates (instrument_id, model_code, created_ts desc);
|