2017-09-07 23:04:47 -07:00
|
|
|
CREATE TABLE trades (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
trade_id integer NOT NULL,
|
2017-09-21 10:25:30 -07:00
|
|
|
product CHAR(7) NOT NULL,
|
2017-09-07 23:04:47 -07:00
|
|
|
price NUMERIC(1000, 8) NOT NULL,
|
|
|
|
size NUMERIC(1000, 8) NOT NULL,
|
|
|
|
buy BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
sell BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
timestamp TIMESTAMPTZ NOT NULL);
|
|
|
|
|
2017-09-10 13:06:53 -07:00
|
|
|
CREATE UNIQUE INDEX product_trade_id_index ON trades (
|
|
|
|
product,
|
|
|
|
trade_id);
|
2017-09-07 23:04:47 -07:00
|
|
|
|
|
|
|
CREATE INDEX timestamp_index ON trades (timestamp);
|
2017-09-22 07:24:42 -07:00
|
|
|
|
|
|
|
CREATE TABLE confirmations (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
product CHAR(7) NOT NULL,
|
2017-10-10 17:22:00 -07:00
|
|
|
type CHAR(1) NOT NULL,
|
|
|
|
last_id INTEGER NOT NULL DEFAULT 0);
|
2017-10-08 11:19:42 -07:00
|
|
|
|
|
|
|
CREATE TABLE aggregations (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
interval integer NOT NULL,
|
|
|
|
product CHAR(7) NOT NULL,
|
|
|
|
price NUMERIC(1000, 8) NOT NULL,
|
|
|
|
buy_volume NUMERIC(1000, 8) NOT NULL,
|
|
|
|
sell_volume NUMERIC(1000, 8) NOT NULL,
|
|
|
|
buy_transactions integer NOT NULL,
|
|
|
|
sell_transactions integer NOT NULL,
|
|
|
|
timestamp TIMESTAMPTZ NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE UNIQUE INDEX interval_product_time_index ON aggregations (
|
|
|
|
interval,
|
|
|
|
product,
|
|
|
|
timestamp);
|