CREATE DATABASE `stockdb` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;

-- stockdb.hs300 definition

CREATE TABLE `hs300` (
  `up_date` varchar(100) NOT NULL DEFAULT '',
  `index_code` varchar(100) NOT NULL DEFAULT '000300',
  `index_name` varchar(100) NOT NULL DEFAULT '',
  `index_name_eng` varchar(100) NOT NULL DEFAULT '',
  `code_inner` varchar(100) NOT NULL DEFAULT '',
  `code_name` varchar(100) NOT NULL DEFAULT '',
  `code_name_eng` varchar(100) NOT NULL DEFAULT '',
  `exchange` varchar(100) NOT NULL DEFAULT '',
  `exchange_eng` varchar(100) NOT NULL DEFAULT '',
  `code` varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (`up_date`,`code_inner`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


-- stockdb.hs300_3years_yield_stats_2410 definition

CREATE TABLE `hs300_3years_yield_stats_2410` (
  `code` varchar(100) NOT NULL,
  `name` varchar(100) NOT NULL,
  `year_diff` int NOT NULL,
  `max_yield_rate` float NOT NULL,
  `max_yield_rate_start` datetime NOT NULL,
  `max_yield_rate_end` datetime NOT NULL,
  `min_yield_rate` float NOT NULL,
  `min_yield_rate_start` datetime NOT NULL,
  `min_yield_rate_end` datetime NOT NULL,
  `avg_yield_rate` float NOT NULL,
  `median_yield_rate` float NOT NULL,
  `win_rate` float NOT NULL,
  `annual_max_yield_rate` float NOT NULL,
  `annual_max_yield_rate_start` datetime NOT NULL,
  `annual_max_yield_rate_end` datetime NOT NULL,
  `annual_min_yield_rate` float NOT NULL,
  `annual_min_yield_rate_start` datetime NOT NULL,
  `annual_min_yield_rate_end` datetime NOT NULL,
  `annual_avg_yield_rate` float NOT NULL,
  `annual_median_yield_rate` float NOT NULL,
  `max_deficit_days` int NOT NULL,
  `max_deficit_start` datetime NOT NULL,
  `max_deficit_end` datetime NOT NULL,
  `annual_yield_variance` float NOT NULL,
  PRIMARY KEY (`code`,`year_diff`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;



-- stockdb.hs300_5years_yield_stats_2410 definition

CREATE TABLE `hs300_5years_yield_stats_2410` (
  `code` varchar(100) NOT NULL,
  `name` varchar(100) NOT NULL,
  `year_diff` int NOT NULL,
  `max_yield_rate` float NOT NULL,
  `max_yield_rate_start` datetime NOT NULL,
  `max_yield_rate_end` datetime NOT NULL,
  `min_yield_rate` float NOT NULL,
  `min_yield_rate_start` datetime NOT NULL,
  `min_yield_rate_end` datetime NOT NULL,
  `avg_yield_rate` float NOT NULL,
  `median_yield_rate` float NOT NULL,
  `win_rate` float NOT NULL,
  `annual_max_yield_rate` float NOT NULL,
  `annual_max_yield_rate_start` datetime NOT NULL,
  `annual_max_yield_rate_end` datetime NOT NULL,
  `annual_min_yield_rate` float NOT NULL,
  `annual_min_yield_rate_start` datetime NOT NULL,
  `annual_min_yield_rate_end` datetime NOT NULL,
  `annual_avg_yield_rate` float NOT NULL,
  `annual_median_yield_rate` float NOT NULL,
  `max_deficit_days` int NOT NULL,
  `max_deficit_start` datetime NOT NULL,
  `max_deficit_end` datetime NOT NULL,
  `annual_yield_variance` float NOT NULL,
  PRIMARY KEY (`code`,`year_diff`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


-- stockdb.hs300_qfq_his definition

CREATE TABLE `hs300_qfq_his` (
  `code` varchar(100) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `time_key` datetime NOT NULL,
  `open` float NOT NULL,
  `close` float NOT NULL,
  `high` float NOT NULL,
  `low` float NOT NULL,
  `pe_ratio` float DEFAULT NULL,
  `turnover_rate` float DEFAULT NULL,
  `volume` bigint DEFAULT NULL,
  `turnover` double DEFAULT NULL,
  `change_rate` float DEFAULT NULL,
  `last_close` float DEFAULT NULL,
  PRIMARY KEY (`code`,`time_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


-- stockdb.plat_list definition

CREATE TABLE `plat_list` (
  `up_date` date NOT NULL,
  `market` varchar(50) NOT NULL,
  `plat` varchar(50) NOT NULL DEFAULT 'INDUSTRY',
  `code` varchar(50) NOT NULL,
  `plate_id` varchar(50) NOT NULL,
  `plate_name` varchar(255) NOT NULL,
  PRIMARY KEY (`up_date`,`plat`,`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


-- stockdb.sp500 definition

CREATE TABLE `sp500` (
  `sp_no` int NOT NULL DEFAULT '0',
  `code_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '',
  `code_inner` varchar(100) NOT NULL DEFAULT '',
  `sector` varchar(100) NOT NULL DEFAULT '',
  `code` varchar(100) NOT NULL DEFAULT '',
  `up_date` varchar(100) NOT NULL DEFAULT '2024-10-02',
  PRIMARY KEY (`up_date`,`code_inner`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;



