Files
monisuo/sql/patch_coin_kline.sql
2026-04-06 16:34:02 +08:00

29 lines
1.4 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =============================================
-- K线模拟功能 — 数据库补丁
-- =============================================
-- 1. 新建 coin_kline 表K线蜡烛数据
CREATE TABLE IF NOT EXISTS `coin_kline` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`coin_code` varchar(20) NOT NULL COMMENT '币种代码',
`interval` varchar(5) NOT NULL COMMENT '周期: 15m/1h/4h/1d/1M',
`open_time` bigint(20) NOT NULL COMMENT '开盘时间戳(ms)',
`open_price` decimal(20,8) NOT NULL,
`high_price` decimal(20,8) NOT NULL,
`low_price` decimal(20,8) NOT NULL,
`close_price` decimal(20,8) NOT NULL,
`volume` decimal(20,4) DEFAULT 0 COMMENT '模拟成交量',
`close_time` bigint(20) NOT NULL COMMENT '收盘时间戳(ms)',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_coin_interval_open` (`coin_code`, `interval`, `open_time`),
KEY `idx_coin_interval_close` (`coin_code`, `interval`, `close_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='K线蜡烛数据';
-- 2. coin 表新增K线配置字段
ALTER TABLE `coin`
ADD COLUMN `trade_start_time` varchar(5) DEFAULT '09:00' COMMENT '交易开始时间 HH:mm',
ADD COLUMN `trade_end_time` varchar(5) DEFAULT '23:00' COMMENT '交易结束时间 HH:mm',
ADD COLUMN `max_change_percent` decimal(5,2) DEFAULT 5.00 COMMENT '每日最大涨跌幅(%)',
ADD COLUMN `simulation_enabled` tinyint(1) DEFAULT 0 COMMENT '1=启用K线模拟';