Files
gostock/internal/logic/strategy/rule/roe.go

44 lines
1.0 KiB
Go
Raw Normal View History

2026-01-27 20:35:05 +08:00
package rule
import (
"fmt"
2026-01-29 00:35:41 +08:00
"git.apinb.com/bsm-sdk/core/utils"
2026-01-27 20:35:05 +08:00
"git.apinb.com/quant/gostock/internal/impl"
"git.apinb.com/quant/gostock/internal/logic/types"
"git.apinb.com/quant/gostock/internal/models"
)
var (
2026-01-28 23:09:16 +08:00
MinRoe float64 = 0
2026-01-27 20:35:05 +08:00
)
type Roe struct {
Key string
Name string
}
func NewRoe() *Roe {
return &Roe{
Key: "Roe",
Name: "年化净资产收益率",
}
}
func (r *Roe) Run(code string) *types.RuleResult {
2026-01-28 23:09:16 +08:00
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值"}
2026-01-27 20:35:05 +08:00
}
2026-01-29 00:35:41 +08:00
data.Roe = utils.FloatRound(data.Roe, 2)
2026-01-28 23:09:16 +08:00
if data.Roe < MinRoe {
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("ROE=%.2f 低于%.2f", data.Roe, MinRoe)}
2026-01-27 20:35:05 +08:00
}
2026-01-29 00:35:41 +08:00
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Roe: data.Roe, Desc: fmt.Sprintf("ROE=%.2f 高于%.2f", data.Roe, MinRoe)}
2026-01-27 20:35:05 +08:00
}