50 lines
2.3 KiB
Go
50 lines
2.3 KiB
Go
|
|
package schema
|
|||
|
|
|
|||
|
|
import "strconv"
|
|||
|
|
|
|||
|
|
// StockIndicator 每日基本面指标(采用 dataset/stock 的 decimal 定义,与采集端迁移一致)。
|
|||
|
|
type StockIndicator struct {
|
|||
|
|
ID uint `gorm:"primarykey;autoIncrement"`
|
|||
|
|
TsCode string `gorm:"type:varchar(20);not null;index:si_ts_code;uniqueIndex:un_si_code_date;comment:股票代码" json:"ts_code"`
|
|||
|
|
TradeDate int `gorm:"index:si_trade_date;uniqueIndex:un_si_code_date;comment:交易日期" json:"trade_date"`
|
|||
|
|
Close float64 `gorm:"type:decimal(20,4);comment:当日收盘价"`
|
|||
|
|
TurnoverRate float64 `gorm:"type:decimal(20,4);comment:换手率(%)"`
|
|||
|
|
TurnoverRateF float64 `gorm:"type:decimal(20,4);comment:换手率(自由流通股)"`
|
|||
|
|
VolumeRatio float64 `gorm:"type:decimal(20,4);comment:量比"`
|
|||
|
|
Pe float64 `gorm:"type:decimal(20,4);comment:市盈率(总市值/净利润)"`
|
|||
|
|
PeTtm float64 `gorm:"type:decimal(20,4);comment:市盈率(TTM)"`
|
|||
|
|
Pb float64 `gorm:"type:decimal(20,4);comment:市净率"`
|
|||
|
|
Ps float64 `gorm:"type:decimal(20,4);comment:市销率"`
|
|||
|
|
PsTtm float64 `gorm:"type:decimal(20,4);comment:市销率(TTM)"`
|
|||
|
|
DvRatio float64 `gorm:"type:decimal(20,4);comment:股息率(%)"`
|
|||
|
|
DvTtm float64 `gorm:"type:decimal(20,4);comment:股息率(TTM)(%)"`
|
|||
|
|
TotalShare float64 `gorm:"type:decimal(20,4);comment:总股本(万股)"`
|
|||
|
|
FloatShare float64 `gorm:"type:decimal(20,4);comment:流通股本(万股)"`
|
|||
|
|
FreeShare float64 `gorm:"type:decimal(20,4);comment:自由流通股本(万)"`
|
|||
|
|
TotalMv float64 `gorm:"type:decimal(20,4);comment:总市值(万元)"`
|
|||
|
|
CircMv float64 `gorm:"type:decimal(20,4);comment:流通市值(万元)"`
|
|||
|
|
Roe float64 `gorm:"type:decimal(20,4);comment:ROE(%) 净利润/股本"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (StockIndicator) TableName() string {
|
|||
|
|
return "stock_indicator"
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Key 业务主键:ts_code + 交易日。
|
|||
|
|
func (s *StockIndicator) Key() string {
|
|||
|
|
if s.TsCode == "" && s.TradeDate == 0 {
|
|||
|
|
return ""
|
|||
|
|
}
|
|||
|
|
return s.TsCode + "#" + strconv.Itoa(s.TradeDate)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// HasTotalMV 总市值是否已填充(大于 0)。
|
|||
|
|
func (s *StockIndicator) HasTotalMV() bool {
|
|||
|
|
return s.TotalMv > 0
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// HasCircMV 流通市值是否已填充。
|
|||
|
|
func (s *StockIndicator) HasCircMV() bool {
|
|||
|
|
return s.CircMv > 0
|
|||
|
|
}
|