SHA256
98 lines
5.4 KiB
Go
98 lines
5.4 KiB
Go
// Package model 定义了A股数据相关的数据模型
|
|
//
|
|
// 数据源:
|
|
// - stock_daily 表: 个股每日行情数据(开盘、收盘、最高、最低、成交量、成交额、涨跌幅等)
|
|
// - stock_info 表: 个股基本信息(代码、名称、上市日期)
|
|
// - index_daily 表: 指数每日行情数据
|
|
package model
|
|
|
|
// StockDaily 个股每日行情记录
|
|
type StockDaily struct {
|
|
ID int `gorm:"primaryKey" json:"id"`
|
|
Code string `gorm:"column:code;type:varchar(10)" json:"code"` // 股票代码,如 "600498"
|
|
Date string `gorm:"column:date;type:date" json:"date"` // 交易日期
|
|
Open float64 `gorm:"column:open" json:"open"` // 开盘价
|
|
Close float64 `gorm:"column:close" json:"close"` // 收盘价
|
|
High float64 `gorm:"column:high" json:"high"` // 最高价
|
|
Low float64 `gorm:"column:low" json:"low"` // 最低价
|
|
Volume float64 `gorm:"column:volume" json:"volume"` // 成交量(股)
|
|
Turnover float64 `gorm:"column:turnover" json:"turnover"` // 成交额(元)
|
|
Amplitude float64 `gorm:"column:amplitude" json:"amplitude"` // 振幅(%)
|
|
PctChange float64 `gorm:"column:pct_change" json:"pct_change"` // 涨跌幅(%)
|
|
Change float64 `gorm:"column:change" json:"change"` // 涨跌额
|
|
TurnoverRate float64 `gorm:"column:turnover_rate" json:"turnover_rate"` // 换手率(%)
|
|
}
|
|
|
|
func (StockDaily) TableName() string {
|
|
return "stock_daily"
|
|
}
|
|
|
|
// StockInfo 个股基本信息
|
|
type StockInfo struct {
|
|
Code string `gorm:"primaryKey;column:code;type:varchar(10)" json:"code"` // 股票代码
|
|
Name string `gorm:"column:name;type:varchar(50)" json:"name"` // 股票名称
|
|
IpoDate string `gorm:"column:ipo_date;type:date" json:"ipo_date"` // 上市日期
|
|
}
|
|
|
|
func (StockInfo) TableName() string {
|
|
return "stock_info"
|
|
}
|
|
|
|
// StockRank 涨停/跌停/百日新高排行
|
|
type StockRank struct {
|
|
Code string `json:"code"` // 股票代码
|
|
Name string `json:"name"` // 股票名称
|
|
PctChange float64 `json:"pct_change"` // 涨跌幅(%)
|
|
Close float64 `json:"close"` // 收盘价
|
|
}
|
|
|
|
// DailySummary 每日市场统计汇总
|
|
type DailySummary struct {
|
|
Date string `gorm:"column:date" json:"date"` // 交易日期
|
|
TotalStocks int `gorm:"column:total_stocks" json:"total_stocks"` // 当日交易股票总数
|
|
UpCount int `gorm:"column:up_count" json:"up_count"` // 上涨数量
|
|
DownCount int `gorm:"column:down_count" json:"down_count"` // 下跌数量
|
|
FlatCount int `gorm:"column:flat_count" json:"flat_count"` // 平盘数量
|
|
TotalTurnover float64 `gorm:"column:total_turnover" json:"total_turnover"` // 总成交额
|
|
AvgPctChange float64 `gorm:"column:avg_pct_change" json:"avg_pct_change"` // 平均涨跌幅(%)
|
|
LimitUp10 int `gorm:"column:limit_up_10" json:"limit_up_10"` // 主板涨停数量(涨幅>=9.5%)
|
|
LimitDown10 int `gorm:"column:limit_down_10" json:"limit_down_10"` // 主板跌停数量(跌幅<=-9.5%)
|
|
LimitUp20 int `gorm:"column:limit_up_20" json:"limit_up_20"` // 创业板/科创板涨停数量(涨幅>=19.5%)
|
|
LimitDown20 int `gorm:"column:limit_down_20" json:"limit_down_20"` // 创业板/科创板跌停数量(跌幅<=-19.5%)
|
|
ConsecutiveLimitCount int `gorm:"column:consecutive_limit_count" json:"consecutive_limit_count"` // 连板股票数量(当日涨停且前一日也涨停)
|
|
}
|
|
|
|
// DashboardSummary 市场概览数据
|
|
type DashboardSummary struct {
|
|
TotalStocks int64 `json:"total_stocks"` // 当日交易股票总数
|
|
UpCount int64 `json:"up_count"` // 上涨数量
|
|
DownCount int64 `json:"down_count"` // 下跌数量
|
|
FlatCount int64 `json:"flat_count"` // 平盘数量
|
|
TotalTurnover float64 `json:"total_turnover"` // 总成交额
|
|
AvgPctChange float64 `json:"avg_pct_change"` // 平均涨跌幅(%)
|
|
LimitUpList []StockRank `json:"limit_up_list"` // 涨停股票列表
|
|
LimitDownList []StockRank `json:"limit_down_list"` // 跌停股票列表
|
|
High100List []StockRank `json:"high_100_list"` // 百日新高股票列表
|
|
}
|
|
|
|
// ConsecutiveLimit 连板统计
|
|
type ConsecutiveLimit struct {
|
|
Code string `json:"code"` // 股票代码
|
|
Name string `json:"name"` // 股票名称
|
|
Streak int `json:"streak"` // 连板天数(连续涨停天数)
|
|
Close float64 `json:"close"` // 收盘价
|
|
PctChange float64 `json:"pct_change"` // 当日涨跌幅(%)
|
|
}
|
|
|
|
// IndexKline K线数据(通用结构,同时用于指数和个股)
|
|
type IndexKline struct {
|
|
Date string `json:"date"` // 交易日期
|
|
Open float64 `json:"open"` // 开盘价
|
|
Close float64 `json:"close"` // 收盘价
|
|
High float64 `json:"high"` // 最高价
|
|
Low float64 `json:"low"` // 最低价
|
|
Volume float64 `json:"volume"` // 成交量
|
|
Amount float64 `json:"amount"` // 成交额
|
|
PctChange float64 `json:"pct_change"` // 涨跌幅(%)
|
|
}
|