Files
gostock/internal/logic/strategy/rule/roe.go
yanweidong 303acaccb2 deving
2026-01-28 23:09:16 +08:00

41 lines
934 B
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/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值"}
}
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, Desc: fmt.Sprintf("ROE=%.2f 高于%.2f", data.Roe, MinRoe)}
}