CREATE TABLE IF NOT EXISTS robo_mpt_portfolios
(
    rmp_id          BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    rmp_date        DATETIME        NOT NULL COMMENT '日期',
    rmp_risk        TINYINT         NOT NULL COMMENT '风险等级',
    rmp_type        VARCHAR(255)    NOT NULL COMMENT '投组类型',
    rmp_rolve       TINYINT         NOT NULL COMMENT '求解方式',
    rmp_portfolio   JSON                     DEFAULT NULL COMMENT '投组权重',
    rmp_cvar        DOUBLE                   DEFAULT NULL COMMENT '投组cvar',
    rmp_create_time DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    rmp_update_time DATETIME                 DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (rmp_id),
    UNIQUE INDEX (rmp_date, rmp_risk, rmp_type),
    INDEX (rmp_risk),
    INDEX (rmp_type)
) ENGINE = InnoDB
  AUTO_INCREMENT = 0
  DEFAULT CHARSET = utf8mb4 COMMENT '最优投组表';


CREATE TABLE IF NOT EXISTS robo_hold_portfolios
(
    rhp_id          BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    rhp_date        DATETIME        NOT NULL COMMENT '日期',
    rhp_risk        TINYINT         NOT NULL COMMENT '风险等级',
    rhp_rrs_id      BIGINT UNSIGNED          DEFAULT NULL COMMENT '调仓信号id',
    rhp_rebalance   TINYINT         NOT NULL DEFAULT 0 COMMENT '是否调仓',
    rhp_portfolios  JSON            NOT NULL COMMENT '投组信息',
    rhp_nav         DOUBLE(12, 4)          NOT NULL COMMENT '资产值',
    rhp_create_time DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    rhp_update_time DATETIME                 DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (rhp_id),
    UNIQUE INDEX (rhp_date, rhp_risk),
    INDEX (rhp_risk)
) ENGINE = InnoDB
  AUTO_INCREMENT = 0
  DEFAULT CHARSET = utf8mb4 COMMENT '持仓投组表';