fix schema

This commit is contained in:
2026-05-01 17:47:58 +08:00
parent 5673e5c6ca
commit 4f4781aad3
5 changed files with 33 additions and 33 deletions

View File

@@ -2,8 +2,8 @@ package schema
import "strconv"
// DatasetStockDaily 股票日线数据(两仓库结构一致)。
type DatasetStockDaily struct {
// DatasetDaily 股票日线数据(两仓库结构一致)。
type DatasetDaily struct {
ID uint `gorm:"primarykey;autoIncrement" json:"id"`
TsCode string `gorm:"type:varchar(20);not null;index:idx_ts_code;uniqueIndex:un_code_date;comment:股票代码" json:"ts_code"`
TradeDate int `gorm:"index:idx_trade_date;uniqueIndex:un_code_date;comment:交易日期" json:"trade_date"`
@@ -19,12 +19,12 @@ type DatasetStockDaily struct {
Amount float64 `gorm:"type:decimal(20,2);comment:成交额(千元)" json:"amount"`
}
func (DatasetStockDaily) TableName() string {
return "dataset_stock_daily"
func (DatasetDaily) TableName() string {
return "dataset_daily"
}
// Key 业务主键ts_code + 交易日。
func (d *DatasetStockDaily) Key() string {
func (d *DatasetDaily) Key() string {
if d.TsCode == "" && d.TradeDate == 0 {
return ""
}
@@ -32,17 +32,17 @@ func (d *DatasetStockDaily) Key() string {
}
// IsRising 是否收涨(昨收有效且收盘高于昨收)。
func (d *DatasetStockDaily) IsRising() bool {
func (d *DatasetDaily) IsRising() bool {
return d.PreClose > 0 && d.Close > d.PreClose
}
// IsFalling 是否收跌。
func (d *DatasetStockDaily) IsFalling() bool {
func (d *DatasetDaily) IsFalling() bool {
return d.PreClose > 0 && d.Close < d.PreClose
}
// PctChangeFromPre 由昨收计算的涨跌幅(%);昨收无效时返回 0。
func (d *DatasetStockDaily) PctChangeFromPre() float64 {
func (d *DatasetDaily) PctChangeFromPre() float64 {
if d.PreClose <= 0 {
return 0
}
@@ -50,7 +50,7 @@ func (d *DatasetStockDaily) PctChangeFromPre() float64 {
}
// AmplitudePct 振幅(相对昨收,%(最高-最低)/昨收*100。
func (d *DatasetStockDaily) AmplitudePct() float64 {
func (d *DatasetDaily) AmplitudePct() float64 {
if d.PreClose <= 0 {
return 0
}