CREATE TABLE IF NOT EXISTS robo_rebalance_signal
(
    rrs_id          BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    rrs_date        DATETIME        NOT NULL COMMENT '信号日期',
    rrs_type        TINYINT         NOT NULL COMMENT '信号类型',
    rrs_risk        TINYINT         NOT NULL COMMENT '风险等级',
    rrs_p_type      VARCHAR(255)             DEFAULT NULL COMMENT '投组类型',
    rrs_p_weight    JSON                     DEFAULT NULL COMMENT '投组信息',
    rrs_effective   TINYINT         NOT NULL DEFAULT 0 COMMENT '是否生效',
    rrs_create_time DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    rrs_update_time DATETIME                 DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (rrs_id),
    INDEX (rrs_date),
    INDEX (rrs_type),
    INDEX (rrs_risk)
) ENGINE = InnoDB
  AUTO_INCREMENT = 0
  DEFAULT CHARSET = utf8mb4 COMMENT '再平衡信号表';



CREATE TABLE IF NOT EXISTS robo_weight_drift
(
    rwd_id          BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    rwd_date        DATETIME        NOT NULL COMMENT '日期',
    rwd_risk        TINYINT         NOT NULL COMMENT '风险等级',
    rwd_weight      DOUBLE          NOT NULL COMMENT '高风险资产权重',
    rwd_drift       DOUBLE          NOT NULL COMMENT '资产权重漂移计算值',
    rwd_create_time DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    rwd_update_time DATETIME                 DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (rwd_id),
    UNIQUE INDEX (rwd_date, rwd_risk),
    INDEX (rwd_risk)
) ENGINE = InnoDB
  AUTO_INCREMENT = 0
  DEFAULT CHARSET = utf8mb4 COMMENT '高风险资产权重漂移表';

