From 06430ef801a33d79ab2c29399e9cb7056ad6a0f6 Mon Sep 17 00:00:00 2001 From: mianyang <784310601@qq.com> Date: Tue, 12 May 2026 22:55:00 +0800 Subject: [PATCH] sql --- mysql.txt | 309 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 309 insertions(+) create mode 100644 mysql.txt diff --git a/mysql.txt b/mysql.txt new file mode 100644 index 0000000..21b6495 --- /dev/null +++ b/mysql.txt @@ -0,0 +1,309 @@ +# macmini本地mysql配置 +DB_CONFIG = { + "host": os.getenv("MYSQL_HOST", "localhost"), + "port": int(os.getenv("MYSQL_PORT", "3306")), + "user": os.getenv("MYSQL_USER", "yangfan"), + "password": os.getenv("MYSQL_PASSWORD", "admin"), + "database": os.getenv("MYSQL_DATABASE", "level"), + "charset": os.getenv("MYSQL_CHARSET", "utf8mb4"), +} + +# macmini +-- auto-generated definition +create table limit_list_d +( + id bigint auto_increment + primary key, + trade_date date not null comment '交易日期', + ts_code varchar(20) not null comment '股票代码', + industry varchar(100) null comment '所属行业', + name varchar(50) null comment '股票名称', + close decimal(16, 4) null comment '收盘价', + pct_chg decimal(10, 4) null comment '涨跌幅', + amount decimal(24, 4) null comment '成交额', + limit_amount decimal(24, 4) null comment '板上成交金额', + float_mv decimal(24, 4) null comment '流通市值', + total_mv decimal(24, 4) null comment '总市值', + turnover_ratio decimal(10, 4) null comment '换手率', + fd_amount decimal(24, 4) null comment '封单金额', + first_time varchar(20) null comment '首次封板时间', + last_time varchar(20) null comment '最后封板时间', + open_times int null comment '打开次数', + up_stat varchar(50) null comment '涨停统计', + limit_times int null comment '连板数', + `limit` varchar(1) not null comment 'D跌停 U涨停 Z炸板', + constraint uniq_trade_code_limit + unique (trade_date, ts_code, `limit`) +); + +create index idx_limit + on limit_list_d (`limit`); + +create index idx_trade_date + on limit_list_d (trade_date); + +create index idx_ts_code + on limit_list_d (ts_code); + + +-- auto-generated definition +create table stock_basic +( + ts_code text null, + symbol text null, + name text null, + area text null, + industry text null, + fullname text null, + enname text null, + cnspell text null, + market text null, + exchange text null, + curr_type text null, + list_status text null, + list_date text null, + delist_date text null, + is_hs text null, + act_name text null, + act_ent_type text null +); + +-- auto-generated definition +create table stock_daily +( + id bigint auto_increment + primary key, + ts_code varchar(20) not null, + symbol varchar(10) not null, + trade_date date not null, + open decimal(16, 4) null, + high decimal(16, 4) null, + low decimal(16, 4) null, + close decimal(16, 4) null, + pre_close decimal(16, 4) null, + change_val decimal(16, 4) null, + pct_chg decimal(10, 4) null, + vol bigint null, + amount bigint null, + constraint uniq_code_date + unique (ts_code, trade_date) +); + +-- auto-generated definition +create table stock_limit_combined_data +( + id bigint auto_increment + primary key, + trade_date date not null comment '交易日期', + symbol varchar(10) not null comment '股票代码,以stock_daily为准', + ts_code varchar(20) not null comment 'TS股票代码,以stock_daily为准', + name varchar(50) not null comment '股票名称,以stock_daily关联基础表为准', + final_status tinyint not null comment '融合状态:1-涨停,2-炸板', + source_count int default 0 not null comment '命中的数据源数量', + source_flags varchar(50) null comment '命中的数据源:calc,tushare', + calc_status tinyint null comment '本地行情计算状态:1-涨停,2-炸板', + calc_limit_price decimal(16, 4) null comment '本地行情计算涨停价', + calc_high decimal(16, 4) null comment 'stock_daily最高价', + calc_close decimal(16, 4) null comment 'stock_daily收盘价', + calc_pre_close decimal(16, 4) null comment 'stock_daily前收盘价', + calc_vol bigint null comment 'stock_daily成交量', + market varchar(20) null comment '所属板块', + tushare_limit_type varchar(1) null comment 'Tushare-D跌停U涨停Z炸板', + tushare_industry varchar(100) null comment 'Tushare-所属行业', + tushare_name varchar(50) null comment 'Tushare-名称', + tushare_close decimal(16, 4) null comment 'Tushare-收盘价', + tushare_pct_chg decimal(10, 4) null comment 'Tushare-涨跌幅', + tushare_amount decimal(24, 4) null comment 'Tushare-成交额', + tushare_limit_amount decimal(24, 4) null comment 'Tushare-板上成交金额', + tushare_float_mv decimal(24, 4) null comment 'Tushare-流通市值', + tushare_total_mv decimal(24, 4) null comment 'Tushare-总市值', + tushare_turnover_ratio decimal(10, 4) null comment 'Tushare-换手率', + tushare_fd_amount decimal(24, 4) null comment 'Tushare-封单金额', + tushare_first_time varchar(20) null comment 'Tushare-首次封板时间', + tushare_last_time varchar(20) null comment 'Tushare-最后封板时间', + tushare_open_times int null comment 'Tushare-炸板/开板次数', + tushare_up_stat varchar(50) null comment 'Tushare-涨停统计', + tushare_limit_times int null comment 'Tushare-连板数', + constraint uniq_date_code + unique (trade_date, ts_code) +); + +create index idx_symbol + on stock_limit_combined_data (symbol); + +create index idx_trade_date + on stock_limit_combined_data (trade_date); + +create index idx_trade_date_status + on stock_limit_combined_data (trade_date, final_status); + +-- auto-generated definition +create table trade_calendar +( + cal_date date not null, + exchange varchar(10) not null, + is_open tinyint null, + pretrade_date date null, + primary key (cal_date, exchange) +) + charset = utf8mb4; + +#macbook pro +-- auto-generated definition +create table stock_basic +( + ts_code text null, + symbol text null, + name text null, + area text null, + industry text null, + fullname text null, + enname text null, + cnspell text null, + market text null, + exchange text null, + curr_type text null, + list_status text null, + list_date text null, + delist_date text null, + is_hs text null, + act_name text null, + act_ent_type text null +); + +-- auto-generated definition +create table stock_daily +( + id bigint auto_increment + primary key, + ts_code varchar(20) not null, + symbol varchar(10) not null, + trade_date date not null, + open decimal(16, 4) null, + high decimal(16, 4) null, + low decimal(16, 4) null, + close decimal(16, 4) null, + pre_close decimal(16, 4) null, + change_val decimal(16, 4) null, + pct_chg decimal(10, 4) null, + vol bigint null, + amount bigint null, + constraint uniq_code_date + unique (ts_code, trade_date) +) + charset = utf8mb4; + +-- auto-generated definition +create table stock_limit_combined_data +( + id bigint auto_increment + primary key, + trade_date date not null comment '交易日期', + symbol varchar(10) not null comment '股票代码,以stock_daily为准', + ts_code varchar(20) not null comment 'TS股票代码,以stock_daily为准', + name varchar(50) not null comment '股票名称,以stock_daily关联基础表为准', + final_status tinyint not null comment '融合状态:1-涨停,2-炸板', + source_count int default 0 not null comment '命中的数据源数量', + source_flags varchar(50) null comment '命中的数据源:calc,tushare', + calc_status tinyint null comment '本地行情计算状态:1-涨停,2-炸板', + calc_limit_price decimal(16, 4) null comment '本地行情计算涨停价', + calc_high decimal(16, 4) null comment 'stock_daily最高价', + calc_close decimal(16, 4) null comment 'stock_daily收盘价', + calc_pre_close decimal(16, 4) null comment 'stock_daily前收盘价', + calc_vol bigint null comment 'stock_daily成交量', + market varchar(20) null comment '所属板块', + tushare_limit_type varchar(1) null comment 'Tushare-D跌停U涨停Z炸板', + tushare_industry varchar(100) null comment 'Tushare-所属行业', + tushare_name varchar(50) null comment 'Tushare-名称', + tushare_close decimal(16, 4) null comment 'Tushare-收盘价', + tushare_pct_chg decimal(10, 4) null comment 'Tushare-涨跌幅', + tushare_amount decimal(24, 4) null comment 'Tushare-成交额', + tushare_limit_amount decimal(24, 4) null comment 'Tushare-板上成交金额', + tushare_float_mv decimal(24, 4) null comment 'Tushare-流通市值', + tushare_total_mv decimal(24, 4) null comment 'Tushare-总市值', + tushare_turnover_ratio decimal(10, 4) null comment 'Tushare-换手率', + tushare_fd_amount decimal(24, 4) null comment 'Tushare-封单金额', + tushare_first_time varchar(20) null comment 'Tushare-首次封板时间', + tushare_last_time varchar(20) null comment 'Tushare-最后封板时间', + tushare_open_times int null comment 'Tushare-炸板/开板次数', + tushare_up_stat varchar(50) null comment 'Tushare-涨停统计', + tushare_limit_times int null comment 'Tushare-连板数', + constraint uniq_date_code + unique (trade_date, ts_code) +); + +create index idx_symbol + on stock_limit_combined_data (symbol); + +create index idx_trade_date + on stock_limit_combined_data (trade_date); + +create index idx_trade_date_status + on stock_limit_combined_data (trade_date, final_status); + +-- auto-generated definition +create table trade_calendar +( + cal_date date not null, + exchange varchar(10) not null, + is_open tinyint null, + pretrade_date date null, + primary key (cal_date, exchange) +) + charset = utf8mb4; + +#阿里云 +-- auto-generated definition +create table stock_basic +( + ts_code text null, + symbol text null, + name text null, + area text null, + industry text null, + fullname text null, + enname text null, + cnspell text null, + market text null, + exchange text null, + curr_type text null, + list_status text null, + list_date text null, + delist_date text null, + is_hs text null, + act_name text null, + act_ent_type text null +); + +-- auto-generated definition +create table stock_daily +( + id bigint auto_increment + primary key, + ts_code varchar(20) not null, + symbol varchar(10) not null, + trade_date date not null, + open decimal(16, 4) null, + high decimal(16, 4) null, + low decimal(16, 4) null, + close decimal(16, 4) null, + pre_close decimal(16, 4) null, + change_val decimal(16, 4) null, + pct_chg decimal(10, 4) null, + vol bigint null, + amount bigint null, + constraint uniq_code_date + unique (ts_code, trade_date) +); + +-- auto-generated definition +create table trade_calendar +( + cal_date date not null, + exchange varchar(10) not null, + is_open tinyint null, + pretrade_date date null, + primary key (cal_date, exchange) +) + charset = utf8mb4; +