Files
ai-exchange/migrations/003_create_candles.sql
2026-04-24 13:39:01 +08:00

17 lines
588 B
SQL

create table if not exists candles (
id bigserial not null,
instrument_id bigint not null references instruments(id),
timeframe text not null,
ts_open timestamptz not null,
ts_close timestamptz not null,
open numeric(20,10) not null,
high numeric(20,10) not null,
low numeric(20,10) not null,
close numeric(20,10) not null,
volume numeric(28,10),
source text not null default 'api',
created_at timestamptz not null default now(),
primary key (id, ts_open),
unique (instrument_id, timeframe, ts_open)
) partition by range (ts_open);