deving
This commit is contained in:
@@ -2,10 +2,10 @@ package rule
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
"git.apinb.com/quant/gostock/internal/impl"
|
||||
"git.apinb.com/quant/gostock/internal/logic/types"
|
||||
"git.apinb.com/quant/gostock/internal/models"
|
||||
)
|
||||
|
||||
@@ -13,31 +13,26 @@ var (
|
||||
MinRoe float64 = 0
|
||||
)
|
||||
|
||||
type Roe struct {
|
||||
Key string
|
||||
Name string
|
||||
}
|
||||
|
||||
func NewRoe() *Roe {
|
||||
return &Roe{
|
||||
Key: "Roe",
|
||||
Name: "年化净资产收益率",
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Roe) Run(code string) *types.RuleResult {
|
||||
func (r *RuleFactory) RunRoe(code string) {
|
||||
log.Println("RunRoe:", r.Model.Code)
|
||||
|
||||
var data models.StockFinaIndicator
|
||||
err := impl.DBService.Where("ts_code = ?", code).Order("period desc").Limit(1).First(&data).Error
|
||||
if err != nil {
|
||||
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: "最近无财报,无ROE值!"}
|
||||
r.Model.GtAmount = -1
|
||||
r.Model.AddDesc("最近无财报,无ROE值!")
|
||||
return
|
||||
}
|
||||
|
||||
data.Roe = utils.FloatRound(data.Roe, 2)
|
||||
|
||||
if data.Roe < MinRoe {
|
||||
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("ROE=%.2f 低于%.2f", data.Roe, MinRoe)}
|
||||
r.Model.GtAmount = -1
|
||||
r.Model.AddDesc(fmt.Sprintf("ROE=%.2f 低于%.2f", data.Roe, MinRoe))
|
||||
return
|
||||
}
|
||||
|
||||
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Desc: fmt.Sprintf("ROE=%.2f 高于%.2f", data.Roe, MinRoe)}
|
||||
r.Model.GtAmount = 1
|
||||
r.Model.AddDesc(fmt.Sprintf("ROE=%.2f 高于%.2f", data.Roe, MinRoe))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user