fix indicator bug
This commit is contained in:
@@ -29,7 +29,7 @@ func GetStockIndicator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fields := strings.Split("ts_code,trade_date,close,turnover_rate,turnover_rate_f,volume_ratio,pe,pe_ttm,pb,ps,ps_ttm,dv_ratio,dv_ttm,total_share,float_share,free_share,total_mv,circ_mv", ",")
|
fields := strings.Split("ts_code,trade_date,close,turnover_rate,turnover_rate_f,volume_ratio,pe,pe_ttm,pb,ps,ps_ttm,dv_ratio,dv_ttm,total_share,float_share,free_share,total_mv,circ_mv", ",")
|
||||||
reply, err := TushareClient.Daily(params, fields)
|
reply, err := TushareClient.DailyBasic(params, fields)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("ERROR", "GetStockIndicator", err)
|
log.Println("ERROR", "GetStockIndicator", err)
|
||||||
return
|
return
|
||||||
@@ -42,25 +42,24 @@ func GetStockIndicator() {
|
|||||||
impl.DBService.Create(&models.StockIndicator{
|
impl.DBService.Create(&models.StockIndicator{
|
||||||
TsCode: item[0].(string),
|
TsCode: item[0].(string),
|
||||||
TradeDate: item[1].(string),
|
TradeDate: item[1].(string),
|
||||||
Close: item[2].(float64),
|
Close: Any2Float(item[2]),
|
||||||
TurnoverRate: item[3].(float64),
|
TurnoverRate: Any2Float(item[3]),
|
||||||
TurnoverRateF: item[4].(float64),
|
TurnoverRateF: Any2Float(item[4]),
|
||||||
VolumeRatio: item[5].(float64),
|
VolumeRatio: Any2Float(item[5]),
|
||||||
Pe: item[6].(float64),
|
Pe: Any2Float(item[6]),
|
||||||
PeTtm: item[7].(float64),
|
PeTtm: Any2Float(item[7]),
|
||||||
Pb: item[8].(float64),
|
Pb: Any2Float(item[8]),
|
||||||
Ps: item[9].(float64),
|
Ps: Any2Float(item[9]),
|
||||||
PsTtm: item[10].(float64),
|
PsTtm: Any2Float(item[10]),
|
||||||
DvRatio: item[11].(float64),
|
DvRatio: Any2Float(item[11]),
|
||||||
DvTtm: item[12].(float64),
|
DvTtm: Any2Float(item[12]),
|
||||||
TotalShare: item[13].(float64),
|
TotalShare: Any2Float(item[13]),
|
||||||
FloatShare: item[14].(float64),
|
FloatShare: Any2Float(item[14]),
|
||||||
FreeShare: item[15].(float64),
|
FreeShare: Any2Float(item[15]),
|
||||||
TotalMv: item[16].(float64),
|
TotalMv: Any2Float(item[16]),
|
||||||
CircMv: item[17].(float64),
|
CircMv: Any2Float(item[17]),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,3 +30,10 @@ func Anys2Strings(any []any) []string {
|
|||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Any2Float(in any) float64 {
|
||||||
|
if in == nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return in.(float64)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"git.apinb.com/bsm-sdk/core/database"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StockFinaIndicator 财务指标模型
|
// StockFinaIndicator 财务指标模型
|
||||||
type StockFinaIndicator struct {
|
type StockFinaIndicator struct {
|
||||||
ID uint `gorm:"primarykey;autoIncrement"`
|
gorm.Model
|
||||||
TsCode string `gorm:"type:varchar(20);not null;index:idx_ts_code;comment:TS代码"`
|
TsCode string `gorm:"type:varchar(20);not null;index:idx_ts_code;comment:TS代码"`
|
||||||
AnnDate string `gorm:"type:date;not null;index:idx_ann_date;comment:公告日期"`
|
AnnDate string `gorm:"type:date;not null;index:idx_ann_date;comment:公告日期"`
|
||||||
EndDate string `gorm:"type:date;not null;index:idx_end_date;comment:报告期"`
|
EndDate string `gorm:"type:date;not null;index:idx_end_date;comment:报告期"`
|
||||||
@@ -201,9 +200,10 @@ type StockFinaIndicator struct {
|
|||||||
|
|
||||||
// 其他
|
// 其他
|
||||||
UpdateFlag string `gorm:"type:varchar(1);comment:更新标识"`
|
UpdateFlag string `gorm:"type:varchar(1);comment:更新标识"`
|
||||||
CreatedAt time.Time
|
}
|
||||||
UpdatedAt time.Time
|
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
func init() {
|
||||||
|
database.AppendMigrate(&StockFinaIndicator{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName 设置表名
|
// TableName 设置表名
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
// StockIndicator 股票日线数据模型
|
// StockIndicator 股票日线数据模型
|
||||||
type StockIndicator struct {
|
type StockIndicator struct {
|
||||||
ID uint `gorm:"primarykey;autoIncrement"`
|
ID uint `gorm:"primarykey;autoIncrement"`
|
||||||
TsCode string `gorm:"type:varchar(20);not null;comment:TS股票代码;index:idx_ts_code;uniqueIndex:un_code_date;"`
|
TsCode string `gorm:"type:varchar(20);not null;index:idx_ts_code;uniqueIndex:un_code_date;comment:股票代码" json:"ts_code"`
|
||||||
TradeDate string `gorm:"type:date;not null;comment:交易日期;index:idx_trade_date;uniqueIndex:un_code_date;"`
|
TradeDate string `gorm:"type:date;not null;index:idx_trade_date;uniqueIndex:un_code_date;comment:交易日期" json:"trade_date"`
|
||||||
Close float64 `gorm:"type:decimal(10,4);comment:当日收盘价"`
|
Close float64 `gorm:"type:decimal(10,4);comment:当日收盘价"`
|
||||||
TurnoverRate float64 `gorm:"type:decimal(10,6);comment:换手率(%)"`
|
TurnoverRate float64 `gorm:"type:decimal(10,6);comment:换手率(%)"`
|
||||||
TurnoverRateF float64 `gorm:"type:decimal(10,6);comment:换手率(自由流通股)"`
|
TurnoverRateF float64 `gorm:"type:decimal(10,6);comment:换手率(自由流通股)"`
|
||||||
|
|||||||
Reference in New Issue
Block a user