Files
gostock/internal/logic/strategy/rule/roe.go
yanweidong d178a1b353 deving
2026-01-29 00:35:41 +08:00

44 lines
1.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package rule
import (
"fmt"
"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"
)
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 {
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值"}
}
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)}
}
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Roe: data.Roe, Desc: fmt.Sprintf("ROE=%.2f 高于%.2f", data.Roe, MinRoe)}
}