31ece2e99a
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
984 B
SQL
30 lines
984 B
SQL
create table if not exists trade_executions (
|
|
id bigserial primary key,
|
|
signal_id bigint not null references trade_signals(id),
|
|
venue_order_id text,
|
|
execution_mode text not null,
|
|
side text not null,
|
|
entry_price numeric(20,10),
|
|
stop_loss numeric(20,10),
|
|
take_profit_1 numeric(20,10),
|
|
take_profit_2 numeric(20,10),
|
|
size numeric(28,10),
|
|
risk_pct numeric(8,4),
|
|
status text not null,
|
|
opened_ts timestamptz,
|
|
closed_ts timestamptz,
|
|
pnl numeric(28,10),
|
|
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_executions_signal_id
|
|
on trade_executions (signal_id);
|
|
|
|
create index if not exists idx_trade_executions_status_created_desc
|
|
on trade_executions (status, created_at desc);
|
|
|
|
create index if not exists idx_trade_executions_mode_created_desc
|
|
on trade_executions (execution_mode, created_at desc);
|