bbgo_origin/migrations/sqlite3/20220304153309_add_profit_table.sql

69 lines
2.1 KiB
MySQL
Raw Permalink Normal View History

2022-03-04 07:58:59 +00:00
-- +up
CREATE TABLE `profits`
(
2022-03-04 11:24:40 +00:00
`gid` INTEGER PRIMARY KEY AUTOINCREMENT,
2022-03-04 07:58:59 +00:00
2022-03-04 11:24:40 +00:00
`strategy` VARCHAR(32) NOT NULL,
`strategy_instance_id` VARCHAR(64) NOT NULL,
`symbol` VARCHAR(8) NOT NULL,
2022-03-04 07:58:59 +00:00
-- average_cost is the position average cost
2022-03-04 11:24:40 +00:00
`average_cost` DECIMAL(16, 8) NOT NULL,
2022-03-04 07:58:59 +00:00
-- profit is the pnl (profit and loss)
2022-03-04 11:24:40 +00:00
`profit` DECIMAL(16, 8) NOT NULL,
2022-03-04 08:40:01 +00:00
-- net_profit is the pnl (profit and loss)
2022-03-04 11:24:40 +00:00
`net_profit` DECIMAL(16, 8) NOT NULL,
2022-03-04 08:40:01 +00:00
-- profit_margin is the pnl (profit and loss)
2022-03-04 11:24:40 +00:00
`profit_margin` DECIMAL(16, 8) NOT NULL,
2022-03-04 08:40:01 +00:00
-- net_profit_margin is the pnl (profit and loss)
2022-03-04 11:24:40 +00:00
`net_profit_margin` DECIMAL(16, 8) NOT NULL,
2022-03-04 08:40:01 +00:00
2022-03-04 11:24:40 +00:00
`quote_currency` VARCHAR(10) NOT NULL,
2022-03-04 08:40:01 +00:00
2022-03-04 11:24:40 +00:00
`base_currency` VARCHAR(10) NOT NULL,
2022-03-04 08:40:01 +00:00
-- -------------------------------------------------------
-- embedded trade data --
-- -------------------------------------------------------
2022-03-04 11:24:40 +00:00
`exchange` VARCHAR(24) NOT NULL DEFAULT '',
2022-03-04 08:40:01 +00:00
2022-03-04 11:24:40 +00:00
`is_futures` BOOLEAN NOT NULL DEFAULT FALSE,
2022-03-04 08:40:01 +00:00
2022-03-04 11:24:40 +00:00
`is_margin` BOOLEAN NOT NULL DEFAULT FALSE,
2022-03-04 08:40:01 +00:00
2022-03-04 11:24:40 +00:00
`is_isolated` BOOLEAN NOT NULL DEFAULT FALSE,
2022-03-04 08:40:01 +00:00
2022-03-04 11:24:40 +00:00
`trade_id` BIGINT NOT NULL,
2022-03-04 08:40:01 +00:00
-- side is the side of the trade that makes profit
2022-03-04 11:24:40 +00:00
`side` VARCHAR(4) NOT NULL DEFAULT '',
`is_buyer` BOOLEAN NOT NULL DEFAULT FALSE,
`is_maker` BOOLEAN NOT NULL DEFAULT FALSE,
2022-03-04 07:58:59 +00:00
-- price is the price of the trade that makes profit
2022-03-04 11:24:40 +00:00
`price` DECIMAL(16, 8) NOT NULL,
2022-03-04 07:58:59 +00:00
-- quantity is the quantity of the trade that makes profit
2022-03-04 11:24:40 +00:00
`quantity` DECIMAL(16, 8) NOT NULL,
2022-03-04 07:58:59 +00:00
2022-03-04 08:40:01 +00:00
-- trade_amount is the quote quantity of the trade that makes profit
2022-03-04 11:24:40 +00:00
`quote_quantity` DECIMAL(16, 8) NOT NULL,
2022-03-04 07:58:59 +00:00
2022-03-04 11:24:40 +00:00
`traded_at` DATETIME(3) NOT NULL,
2022-03-04 07:58:59 +00:00
2022-03-04 08:40:01 +00:00
-- fee
2022-03-04 11:24:40 +00:00
`fee_in_usd` DECIMAL(16, 8),
`fee` DECIMAL(16, 8) NOT NULL,
`fee_currency` VARCHAR(10) NOT NULL
2022-03-04 07:58:59 +00:00
);
-- +down
DROP TABLE IF EXISTS `profits`;