bbgo_origin/migrations/sqlite3/20220307132917_add_positions.sql

28 lines
942 B
MySQL
Raw Normal View History

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