Files
gostock/internal/logic/strategy/rule/roe.go
yanweidong d89d7967b8 deving
2026-02-01 14:57:20 +08:00

41 lines
841 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"
"log"
"git.apinb.com/bsm-sdk/core/utils"
"git.apinb.com/quant/gostock/internal/impl"
"git.apinb.com/quant/gostock/internal/models"
)
var (
MinRoe float64 = 0
)
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 {
r.Model.GtRoe = -1
r.Model.ValRoe = -1
r.Model.AddDesc("最近无财报无ROE值")
return
}
data.Roe = utils.FloatRound(data.Roe, 2)
r.Model.ValRoe = data.Roe
if data.Roe < MinRoe {
r.Model.GtRoe = -1
r.Model.AddDesc(fmt.Sprintf("ROE=%.2f 低于%.2f", data.Roe, MinRoe))
return
}
r.Model.GtRoe = 1
r.Model.AddDesc(fmt.Sprintf("ROE=%.2f 高于%.2f", data.Roe, MinRoe))
return
}