2022-03-07 05:44:43 +00:00
|
|
|
-- +up
|
|
|
|
CREATE TABLE `positions`
|
|
|
|
(
|
|
|
|
`gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
`strategy` VARCHAR(32) NOT NULL,
|
|
|
|
`strategy_instance_id` VARCHAR(64) NOT NULL,
|
|
|
|
|
2024-09-25 08:05:12 +00:00
|
|
|
`symbol` VARCHAR(32) NOT NULL,
|
2022-03-07 05:44:43 +00:00
|
|
|
`quote_currency` VARCHAR(10) NOT NULL,
|
2024-09-25 08:07:11 +00:00
|
|
|
`base_currency` VARCHAR(16) NOT NULL,
|
2022-03-07 05:44:43 +00:00
|
|
|
|
|
|
|
-- average_cost is the position average cost
|
|
|
|
`average_cost` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
|
|
|
`base` DECIMAL(16, 8) NOT NULL,
|
|
|
|
`quote` DECIMAL(16, 8) NOT NULL,
|
2022-03-10 11:00:02 +00:00
|
|
|
`profit` DECIMAL(16, 8) NULL,
|
2022-03-07 05:44:43 +00:00
|
|
|
|
2022-03-11 05:49:32 +00:00
|
|
|
-- trade related columns
|
|
|
|
`trade_id` BIGINT UNSIGNED NOT NULL, -- the trade id in the exchange
|
|
|
|
`side` VARCHAR(4) NOT NULL, -- side of the trade
|
2024-09-25 08:07:11 +00:00
|
|
|
`exchange` VARCHAR(20) NOT NULL, -- exchange of the trade
|
2022-03-11 05:49:32 +00:00
|
|
|
`traded_at` DATETIME(3) NOT NULL, -- millisecond timestamp
|
2022-03-07 05:44:43 +00:00
|
|
|
|
|
|
|
PRIMARY KEY (`gid`),
|
2022-03-11 05:49:32 +00:00
|
|
|
UNIQUE KEY `trade_id` (`trade_id`, `side`, `exchange`)
|
2022-03-07 05:44:43 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
-- +down
|
|
|
|
DROP TABLE IF EXISTS `positions`;
|