优化sql
This commit is contained in:
@@ -96,6 +96,7 @@ GET /api/v1/download/limit-board/second-board-profit-csv?tradeStartDate=2026-04-
|
||||
| `market` | `string` | `市场` | 市场信息 |
|
||||
| `industry` | `string` | `行业` | 所属行业 |
|
||||
| `open_pct_chg` | `number \| null` | `T日开盘涨跌幅%` | T 日开盘价相对 T-1 收盘价的涨跌幅百分比 |
|
||||
| `next_open_pct_chg` | `number \| null` | `T+1日开盘涨跌幅%` | T+1 日开盘价相对 T 日收盘价的涨跌幅百分比 |
|
||||
| `next_open_profitable` | `string` | `T+1开盘是否盈利` | T+1 开盘收益大于 0 时为 `是`,否则为 `否`;无次日数据时为 `无次日数据` |
|
||||
| `next_close_profitable` | `string` | `T+1收盘是否盈利` | T+1 收盘收益大于 0 时为 `是`,否则为 `否`;无次日数据时为 `无次日数据` |
|
||||
| `next_intraday_profitable` | `string` | `T+1盘中是否可盈利` | T+1 最高收益大于 0 时为 `是`,否则为 `否`;无次日数据时为 `无次日数据` |
|
||||
@@ -133,6 +134,7 @@ GET /api/v1/download/limit-board/second-board-profit-csv?tradeStartDate=2026-04-
|
||||
"market": "主板",
|
||||
"industry": "软件开发",
|
||||
"open_pct_chg": 1.36,
|
||||
"next_open_pct_chg": 2.38,
|
||||
"next_open_profitable": "是",
|
||||
"next_close_profitable": "否",
|
||||
"next_intraday_profitable": "是",
|
||||
@@ -165,6 +167,7 @@ CSV 字段顺序:
|
||||
| `市场` | 市场信息 |
|
||||
| `行业` | 所属行业 |
|
||||
| `T日开盘涨跌幅%` | T 日开盘价相对 T-1 收盘价的涨跌幅百分比 |
|
||||
| `T+1日开盘涨跌幅%` | T+1 日开盘价相对 T 日收盘价的涨跌幅百分比 |
|
||||
| `T+1开盘是否盈利` | T+1 开盘收益大于 0 时为 `是`,否则为 `否`;无次日数据时为 `无次日数据` |
|
||||
| `T+1收盘是否盈利` | T+1 收盘收益大于 0 时为 `是`,否则为 `否`;无次日数据时为 `无次日数据` |
|
||||
| `T+1盘中是否可盈利` | T+1 最高收益大于 0 时为 `是`,否则为 `否`;无次日数据时为 `无次日数据` |
|
||||
|
||||
@@ -87,6 +87,7 @@ type secondProfitListItem struct {
|
||||
Market string `json:"market"`
|
||||
Industry string `json:"industry"`
|
||||
OpenPctChg *float64 `json:"open_pct_chg"`
|
||||
NextOpenPctChg *float64 `json:"next_open_pct_chg"`
|
||||
NextOpenProfitable string `json:"next_open_profitable"`
|
||||
NextCloseProfitable string `json:"next_close_profitable"`
|
||||
NextIntradayProfitable string `json:"next_intraday_profitable"`
|
||||
@@ -398,7 +399,7 @@ ORDER BY c.trade_date ASC, l.ts_code ASC`
|
||||
func secondProfitCSVHeaders() []string {
|
||||
return []string{
|
||||
"交易日", "股票代码", "股票简称", "市场", "行业",
|
||||
"T日开盘涨跌幅%",
|
||||
"T日开盘涨跌幅%", "T+1日开盘涨跌幅%",
|
||||
"T+1开盘是否盈利", "T+1收盘是否盈利", "T+1盘中是否可盈利",
|
||||
"T+1最高盈利%", "T+1最低盈利%", "开板次数", "换手率%",
|
||||
"首次涨停时间", "封单额", "成交额",
|
||||
@@ -413,6 +414,7 @@ func secondProfitCSVRecord(row secondProfitCSVRow) []string {
|
||||
row.Market,
|
||||
row.Industry,
|
||||
secondProfitFormatNullFloat(row.OpenPctChg),
|
||||
secondProfitFormatNullFloat(row.NextOpenReturnPct),
|
||||
row.NextOpenProfitable,
|
||||
row.NextCloseProfitable,
|
||||
row.NextIntradayProfitable,
|
||||
@@ -434,6 +436,7 @@ func secondProfitBuildItem(row secondProfitCSVRow) secondProfitListItem {
|
||||
Market: row.Market,
|
||||
Industry: row.Industry,
|
||||
OpenPctChg: secondProfitNullFloatPtr(row.OpenPctChg),
|
||||
NextOpenPctChg: secondProfitNullFloatPtr(row.NextOpenReturnPct),
|
||||
NextOpenProfitable: row.NextOpenProfitable,
|
||||
NextCloseProfitable: row.NextCloseProfitable,
|
||||
NextIntradayProfitable: row.NextIntradayProfitable,
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user