2024-01-19 07:27:06 +00:00
|
|
|
-- !txn
|
2021-01-15 02:31:37 +00:00
|
|
|
-- +up
|
2020-11-03 07:28:30 +00:00
|
|
|
CREATE TABLE `orders`
|
|
|
|
(
|
|
|
|
`gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
`exchange` VARCHAR(24) NOT NULL DEFAULT '',
|
2020-11-05 03:00:51 +00:00
|
|
|
-- order_id is the order id returned from the exchange
|
|
|
|
`order_id` BIGINT UNSIGNED NOT NULL,
|
2022-03-11 05:32:40 +00:00
|
|
|
`client_order_id` VARCHAR(122) NOT NULL DEFAULT '',
|
2020-11-05 03:00:51 +00:00
|
|
|
`order_type` VARCHAR(16) NOT NULL,
|
2022-03-11 05:32:40 +00:00
|
|
|
`symbol` VARCHAR(20) NOT NULL,
|
2020-11-05 03:00:51 +00:00
|
|
|
`status` VARCHAR(12) NOT NULL,
|
2020-11-03 10:45:14 +00:00
|
|
|
`time_in_force` VARCHAR(4) NOT NULL,
|
2020-11-03 07:28:30 +00:00
|
|
|
`price` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
|
|
|
`stop_price` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
|
|
|
`quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
2020-11-05 03:00:51 +00:00
|
|
|
`executed_quantity` DECIMAL(16, 8) UNSIGNED NOT NULL DEFAULT 0.0,
|
2020-11-03 07:28:30 +00:00
|
|
|
`side` VARCHAR(4) NOT NULL DEFAULT '',
|
2020-11-03 10:45:14 +00:00
|
|
|
`is_working` BOOL NOT NULL DEFAULT FALSE,
|
2020-11-05 05:35:04 +00:00
|
|
|
`created_at` DATETIME(3) NOT NULL,
|
|
|
|
`updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
2020-11-03 07:28:30 +00:00
|
|
|
|
2022-03-11 05:32:40 +00:00
|
|
|
`is_margin` BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
`is_isolated` BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
|
|
|
|
PRIMARY KEY (`gid`)
|
2021-01-15 02:31:37 +00:00
|
|
|
);
|
2022-03-11 05:32:40 +00:00
|
|
|
CREATE INDEX orders_symbol ON orders (exchange, symbol);
|
|
|
|
CREATE UNIQUE INDEX orders_order_id ON orders (order_id, exchange);
|
|
|
|
|
2021-01-15 02:31:37 +00:00
|
|
|
-- +down
|
2022-03-11 05:32:40 +00:00
|
|
|
DROP INDEX orders_symbol ON orders;
|
|
|
|
DROP INDEX orders_order_id ON orders;
|
2020-11-03 07:28:30 +00:00
|
|
|
DROP TABLE `orders`;
|