29 lines
1.5 KiB
SQL
29 lines
1.5 KiB
SQL
create table if not exists shadow_paper_observations (
|
|
id bigserial primary key,
|
|
instrument_id bigint not null references instruments(id) on delete cascade,
|
|
observation_date date not null,
|
|
timeframe varchar(16) not null default '1m',
|
|
session_code varchar(32) not null default 'ALL',
|
|
candidate_id bigint references trade_plan_candidates(id) on delete set null,
|
|
decision_packet_id bigint references decision_packets(id) on delete set null,
|
|
paper_ticket_id bigint references execution_tickets(id) on delete set null,
|
|
paper_execution_id bigint references trade_executions(id) on delete set null,
|
|
observation_status varchar(64) not null default 'observed',
|
|
system_recommendation varchar(64) not null default 'monitor',
|
|
operator_agreement varchar(32) not null default 'pending',
|
|
operator_note text not null default '',
|
|
created_by text not null default 'runtime_shadow_collector',
|
|
reason_codes jsonb not null default '[]'::jsonb,
|
|
payload jsonb not null default '{}'::jsonb,
|
|
observed_ts timestamptz not null default now(),
|
|
created_ts timestamptz not null default now(),
|
|
updated_ts timestamptz not null default now(),
|
|
unique (instrument_id, observation_date, timeframe, session_code)
|
|
);
|
|
|
|
create index if not exists idx_shadow_paper_observations_instrument_date_desc
|
|
on shadow_paper_observations (instrument_id, observation_date desc, id desc);
|
|
|
|
create index if not exists idx_shadow_paper_observations_status_date_desc
|
|
on shadow_paper_observations (instrument_id, observation_status, observation_date desc);
|