2020-12-31 09:07:12 +00:00
|
|
|
-- +up
|
2021-01-15 02:31:37 +00:00
|
|
|
CREATE TABLE `trades`
|
|
|
|
(
|
|
|
|
`gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
2020-10-05 09:51:01 +00:00
|
|
|
|
2021-01-15 02:31:37 +00:00
|
|
|
`id` BIGINT UNSIGNED,
|
2022-03-11 05:25:51 +00:00
|
|
|
`order_id` BIGINT UNSIGNED NOT NULL,
|
2021-01-15 02:31:37 +00:00
|
|
|
`exchange` VARCHAR(24) NOT NULL DEFAULT '',
|
2022-03-11 05:32:40 +00:00
|
|
|
`symbol` VARCHAR(20) NOT NULL,
|
2021-01-15 02:31:37 +00:00
|
|
|
`price` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
|
|
|
`quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
|
|
|
`quote_quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
|
|
|
`fee` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
2022-04-19 04:19:14 +00:00
|
|
|
`fee_currency` VARCHAR(10) NOT NULL,
|
2021-01-15 02:31:37 +00:00
|
|
|
`is_buyer` BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
`is_maker` BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
`side` VARCHAR(4) NOT NULL DEFAULT '',
|
|
|
|
`traded_at` DATETIME(3) NOT NULL,
|
2020-10-05 09:51:01 +00:00
|
|
|
|
2022-03-11 05:32:40 +00:00
|
|
|
`is_margin` BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
`is_isolated` BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
|
2022-03-11 05:34:35 +00:00
|
|
|
`strategy` VARCHAR(32) NULL,
|
|
|
|
`pnl` DECIMAL NULL,
|
|
|
|
|
2021-01-15 02:31:37 +00:00
|
|
|
PRIMARY KEY (`gid`),
|
2022-03-11 05:32:40 +00:00
|
|
|
UNIQUE KEY `id` (`exchange`, `symbol`, `side`, `id`)
|
2021-01-15 02:31:37 +00:00
|
|
|
);
|
2021-02-05 06:15:28 +00:00
|
|
|
|
2022-03-11 05:32:40 +00:00
|
|
|
CREATE INDEX trades_symbol ON trades (exchange, symbol);
|
|
|
|
CREATE INDEX trades_symbol_fee_currency ON trades (exchange, symbol, fee_currency, traded_at);
|
|
|
|
CREATE INDEX trades_traded_at_symbol ON trades (exchange, traded_at, symbol);
|
|
|
|
|
|
|
|
|
2021-01-15 02:31:37 +00:00
|
|
|
-- +down
|
2021-02-05 06:15:28 +00:00
|
|
|
DROP TABLE IF EXISTS `trades`;
|
2022-03-11 05:32:40 +00:00
|
|
|
|
|
|
|
DROP INDEX trades_symbol ON trades;
|
|
|
|
DROP INDEX trades_symbol_fee_currency ON trades;
|
|
|
|
DROP INDEX trades_traded_at_symbol ON trades;
|
|
|
|
|