/*
 Navicat Premium Dump SQL

 Source Server         : 192.168.0.222
 Source Server Type    : MySQL
 Source Server Version : 80031 (8.0.31)
 Source Host           : 192.168.0.222:3306
 Source Schema         : ry_refactor0120

 Target Server Type    : MySQL
 Target Server Version : 80031 (8.0.31)
 File Encoding         : 65001

 Date: 24/01/2026 11:00:05
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for t_stock_daily_trade
-- ----------------------------
DROP TABLE IF EXISTS `t_stock_daily_trade`;
CREATE TABLE `t_stock_daily_trade`  (
  `stock_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '证券代码（关联t_stock_basic，通过应用层校验一致性）',
  `trade_date` date NOT NULL COMMENT '交易日期',
  `open_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '开盘价（单位：元）',
  `close_price` decimal(10, 2) NOT NULL COMMENT '收盘价（单位：元）',
  `high_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '最高价（单位：元）',
  `low_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '最低价（单位：元）',
  `price_change_rate` decimal(6, 4) NULL DEFAULT NULL COMMENT '当日涨跌幅（百分比）',
  `volume` bigint NULL DEFAULT NULL COMMENT '成交量（单位：股）',
  `turnover` decimal(20, 2) NULL DEFAULT NULL COMMENT '成交额（单位：万元）',
  `free_circulation_cap` decimal(20, 2) NULL DEFAULT NULL COMMENT '自由流通市值（单位：万元）',
  `is_limit_up` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否涨停（1=是，0=否）',
  `is_limit_down` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否跌停（1=是，0=否）',
  `momentum_10d` decimal(20, 4) NULL DEFAULT NULL COMMENT '10日动量（涨跌幅）',
  `momentum_20d` decimal(20, 4) NULL DEFAULT NULL COMMENT '20日动量（涨跌幅）',
  `momentum_60d` decimal(20, 4) NULL DEFAULT NULL COMMENT '60日动量（涨跌幅）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据创建时间',
  PRIMARY KEY (`stock_code`, `trade_date`) USING BTREE,
  INDEX `idx_t_stock_daily_trade_date`(`trade_date` ASC) USING BTREE,
  INDEX `idx_t_stock_daily_trade_code`(`stock_code` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'A股个股每日交易数据-按月分区' ROW_FORMAT = Dynamic PARTITION BY RANGE (to_days(`trade_date`))
PARTITIONS 16
(PARTITION `p202412` VALUES LESS THAN (739617) ENGINE = InnoDB COMMENT = '2024年12月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202501` VALUES LESS THAN (739648) ENGINE = InnoDB COMMENT = '2025年1月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202502` VALUES LESS THAN (739676) ENGINE = InnoDB COMMENT = '2025年2月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202503` VALUES LESS THAN (739707) ENGINE = InnoDB COMMENT = '2025年3月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202504` VALUES LESS THAN (739737) ENGINE = InnoDB COMMENT = '2025年4月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202505` VALUES LESS THAN (739768) ENGINE = InnoDB COMMENT = '2025年5月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202506` VALUES LESS THAN (739798) ENGINE = InnoDB COMMENT = '2025年6月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202507` VALUES LESS THAN (739829) ENGINE = InnoDB COMMENT = '2025年7月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202508` VALUES LESS THAN (739860) ENGINE = InnoDB COMMENT = '2025年8月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202509` VALUES LESS THAN (739890) ENGINE = InnoDB COMMENT = '2025年9月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202510` VALUES LESS THAN (739921) ENGINE = InnoDB COMMENT = '2025年10月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202511` VALUES LESS THAN (739951) ENGINE = InnoDB COMMENT = '2025年11月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202512` VALUES LESS THAN (739982) ENGINE = InnoDB COMMENT = '2025年12月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202601` VALUES LESS THAN (740013) ENGINE = InnoDB COMMENT = '2026年1月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202602` VALUES LESS THAN (740041) ENGINE = InnoDB COMMENT = '2026年2月数据' MAX_ROWS = 0 MIN_ROWS = 0 ,
PARTITION `p202603` VALUES LESS THAN (740072) ENGINE = InnoDB COMMENT = '2026年3月数据' MAX_ROWS = 0 MIN_ROWS = 0 )
;

SET FOREIGN_KEY_CHECKS = 1;
