This commit is contained in:
2026-01-15 12:52:12 +08:00
parent db1d5397c0
commit 2249667d8b
4 changed files with 130 additions and 69 deletions

View File

@@ -1,51 +1,37 @@
package models
import (
"time"
"gorm.io/gorm"
"git.apinb.com/bsm-sdk/core/database"
)
// LastIndicator 股票日线数据模型
type LastIndicator struct {
ID uint `gorm:"primarykey;autoIncrement"`
TsCode string `gorm:"type:varchar(20);not null;comment:TS股票代码;index:idx_ts_code"`
TradeDate time.Time `gorm:"type:date;not null;comment:交易日期;index:idx_trade_date;index:idx_ts_trade,priority:2"`
Close float64 `gorm:"type:decimal(10,4);comment:当日收盘价"`
TurnoverRate float64 `gorm:"type:decimal(10,6);comment:换手率(%)"`
TurnoverRateF float64 `gorm:"type:decimal(10,6);comment:换手率(自由流通股)"`
VolumeRatio float64 `gorm:"type:decimal(10,4);comment:量比"`
Pe *float64 `gorm:"type:decimal(10,4);comment:市盈率(总市值/净利润)"`
PeTtm *float64 `gorm:"type:decimal(10,4);comment:市盈率(TTM)"`
Pb float64 `gorm:"type:decimal(10,4);comment:市净率"`
Ps float64 `gorm:"type:decimal(10,4);comment:市销率"`
PsTtm float64 `gorm:"type:decimal(10,4);comment:市销率(TTM)"`
DvRatio float64 `gorm:"type:decimal(10,6);comment:股息率(%)"`
DvTtm float64 `gorm:"type:decimal(10,6);comment:股息率(TTM)(%)"`
TotalShare float64 `gorm:"type:decimal(15,2);comment:总股本(万股)"`
FloatShare float64 `gorm:"type:decimal(15,2);comment:流通股本(万股)"`
FreeShare float64 `gorm:"type:decimal(15,2);comment:自由流通股本(万)"`
TotalMv float64 `gorm:"type:decimal(15,2);comment:总市值(万元)"`
CircMv float64 `gorm:"type:decimal(15,2);comment:流通市值(万元)"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
ID uint `gorm:"primarykey;autoIncrement"`
TsCode string `gorm:"type:varchar(20);not null;comment:TS股票代码;index:idx_ts_code"`
TradeDate string `gorm:"type:date;not null;comment:交易日期;index:idx_trade_date;index:idx_ts_trade,priority:2"`
Close float64 `gorm:"type:decimal(10,4);comment:当日收盘价"`
TurnoverRate float64 `gorm:"type:decimal(10,6);comment:换手率(%)"`
TurnoverRateF float64 `gorm:"type:decimal(10,6);comment:换手率(自由流通股)"`
VolumeRatio float64 `gorm:"type:decimal(10,4);comment:量比"`
Pe float64 `gorm:"type:decimal(10,4);comment:市盈率(总市值/净利润)"`
PeTtm float64 `gorm:"type:decimal(10,4);comment:市盈率(TTM)"`
Pb float64 `gorm:"type:decimal(10,4);comment:市净率"`
Ps float64 `gorm:"type:decimal(10,4);comment:市销率"`
PsTtm float64 `gorm:"type:decimal(10,4);comment:市销率(TTM)"`
DvRatio float64 `gorm:"type:decimal(10,6);comment:股息率(%)"`
DvTtm float64 `gorm:"type:decimal(10,6);comment:股息率(TTM)(%)"`
TotalShare float64 `gorm:"type:decimal(15,2);comment:总股本(万股)"`
FloatShare float64 `gorm:"type:decimal(15,2);comment:流通股本(万股)"`
FreeShare float64 `gorm:"type:decimal(15,2);comment:自由流通股本(万)"`
TotalMv float64 `gorm:"type:decimal(15,2);comment:总市值(万元)"`
CircMv float64 `gorm:"type:decimal(15,2);comment:流通市值(万元)"`
}
func init() {
database.AppendMigrate(&LastIndicator{})
}
// TableName 设置表名
func (LastIndicator) TableName() string {
return "last_indicator"
return "last_indicator"
}
// 索引定义也可以在migration中创建
func (LastIndicator) Indexes() []string {
return []gorm.Index{
&gorm.IndexModel{
Name: "idx_ts_code_trade_date",
Fields: []string{"ts_code", "trade_date"},
},
}
}