Files
ai-exchange/migrations/027_create_market_states.sql
T
2026-05-06 18:33:13 +08:00

20 lines
787 B
SQL

create table if not exists market_states (
id bigserial primary key,
instrument_id bigint not null references instruments(id),
snapshot_ts timestamptz not null,
timeframe text not null,
session_code text,
data_freshness text,
candle_age_seconds numeric(18,4),
news_window_state jsonb not null default '{}'::jsonb,
opening_volatility_state jsonb not null default '{}'::jsonb,
account_state jsonb not null default '{}'::jsonb,
position_state 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_market_states_instr_snapshot_desc
on market_states (instrument_id, snapshot_ts desc);