/*
 Navicat Premium Dump SQL

 Source Server         : mysql本地
 Source Server Type    : MySQL
 Source Server Version : 80404 (8.4.4)
 Source Host           : localhost:3306
 Source Schema         : agricultural_stock

 Target Server Type    : MySQL
 Target Server Version : 80404 (8.4.4)
 File Encoding         : 65001

 Date: 04/06/2025 20:19:54
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for industry_analysis
-- ----------------------------
DROP TABLE IF EXISTS `industry_analysis`;
CREATE TABLE `industry_analysis`  (
  `industry` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `stock_count` bigint NOT NULL,
  `avg_change_percent` double NULL DEFAULT NULL,
  `total_market_cap` double NULL DEFAULT NULL,
  `total_volume` double NULL DEFAULT NULL,
  `analysis_date` date NOT NULL
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for market_analysis
-- ----------------------------
DROP TABLE IF EXISTS `market_analysis`;
CREATE TABLE `market_analysis`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `analysis_date` date NOT NULL COMMENT '分析日期',
  `up_count` int NULL DEFAULT NULL COMMENT '上涨股票数',
  `down_count` int NULL DEFAULT NULL COMMENT '下跌股票数',
  `flat_count` int NULL DEFAULT NULL COMMENT '平盘股票数',
  `total_count` int NULL DEFAULT NULL COMMENT '总股票数',
  `total_market_cap` decimal(15, 2) NULL DEFAULT NULL COMMENT '总市值',
  `total_volume` bigint NULL DEFAULT NULL COMMENT '总成交量',
  `total_turnover` decimal(15, 2) NULL DEFAULT NULL COMMENT '总成交额',
  `avg_change_percent` decimal(5, 2) NULL DEFAULT NULL COMMENT '平均涨跌幅',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_analysis_date`(`analysis_date` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '市场分析表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for market_trends
-- ----------------------------
DROP TABLE IF EXISTS `market_trends`;
CREATE TABLE `market_trends`  (
  `trade_date` timestamp NULL DEFAULT NULL,
  `avg_price` double NULL DEFAULT NULL,
  `avg_change_percent` double NULL DEFAULT NULL,
  `total_volume` double NULL DEFAULT NULL,
  `total_turnover` double NULL DEFAULT NULL,
  `stock_count` bigint NOT NULL
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for stock_data
-- ----------------------------
DROP TABLE IF EXISTS `stock_data`;
CREATE TABLE `stock_data`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `stock_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '股票代码',
  `stock_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '股票名称',
  `open_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '开盘价',
  `close_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '收盘价',
  `high_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '最高价',
  `low_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '最低价',
  `volume` bigint NULL DEFAULT NULL COMMENT '成交量',
  `turnover` decimal(15, 2) NULL DEFAULT NULL COMMENT '成交额',
  `change_percent` decimal(5, 2) NULL DEFAULT NULL COMMENT '涨跌幅(%)',
  `change_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '涨跌额',
  `total_shares` bigint NULL DEFAULT NULL COMMENT '总股本',
  `float_shares` bigint NULL DEFAULT NULL COMMENT '流通股本',
  `market_cap` decimal(15, 2) NULL DEFAULT NULL COMMENT '总市值',
  `float_market_cap` decimal(15, 2) NULL DEFAULT NULL COMMENT '流通市值',
  `pe_ratio` decimal(8, 2) NULL DEFAULT NULL COMMENT '市盈率',
  `pb_ratio` decimal(8, 2) NULL DEFAULT NULL COMMENT '市净率',
  `trade_date` datetime NOT NULL COMMENT '交易日期',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint NULL DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_stock_code`(`stock_code` ASC) USING BTREE,
  INDEX `idx_trade_date`(`trade_date` ASC) USING BTREE,
  INDEX `idx_stock_trade`(`stock_code` ASC, `trade_date` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 26 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '股票数据表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for stock_prediction
-- ----------------------------
DROP TABLE IF EXISTS `stock_prediction`;
CREATE TABLE `stock_prediction`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `stock_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '股票代码',
  `stock_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '股票名称',
  `predict_date` date NOT NULL COMMENT '预测日期',
  `predict_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '预测价格',
  `confidence` decimal(5, 2) NULL DEFAULT NULL COMMENT '置信度',
  `model_version` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模型版本',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_prediction_stock`(`stock_code` ASC) USING BTREE,
  INDEX `idx_prediction_date`(`predict_date` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '股票预测数据表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for stock_technical_indicators
-- ----------------------------
DROP TABLE IF EXISTS `stock_technical_indicators`;
CREATE TABLE `stock_technical_indicators`  (
  `stock_code` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `stock_name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `trade_date` timestamp NULL DEFAULT NULL,
  `close_price` double NULL DEFAULT NULL,
  `ma5` double NULL DEFAULT NULL,
  `ma10` double NULL DEFAULT NULL,
  `ma20` double NULL DEFAULT NULL,
  `ma30` double NULL DEFAULT NULL,
  `rsi` double NULL DEFAULT NULL,
  `macd_dif` double NULL DEFAULT NULL,
  `macd_dea` double NULL DEFAULT NULL,
  `bb_upper` double NULL DEFAULT NULL,
  `bb_middle` double NULL DEFAULT NULL,
  `bb_lower` double NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;
