This commit is contained in:
yanweidong
2026-01-31 18:22:58 +08:00
parent b4310c22cd
commit 32cbe88964
12 changed files with 104 additions and 155 deletions

View File

@@ -2,9 +2,9 @@ package rule
import (
"fmt"
"log"
"git.apinb.com/quant/gostock/internal/impl"
"git.apinb.com/quant/gostock/internal/logic/types"
"git.apinb.com/quant/gostock/internal/models"
)
@@ -13,19 +13,8 @@ var (
MinPrice = 5.0
)
type Price struct {
Key string
Name string
}
func NewPrice() *Price {
return &Price{
Key: "Price",
Name: "股价",
}
}
func (r *Price) Run(code string) *types.RuleResult {
func (r *RuleFactory) RunPrice(code string) {
log.Println("RunPrice:", r.Model.Code, "Args:", LastDay, MinPrice)
var data []models.StockDaily
impl.DBService.Where("ts_code = ?", code).Order("trade_date desc").Limit(LastDay).Find(&data)
@@ -39,8 +28,10 @@ func (r *Price) Run(code string) *types.RuleResult {
}
if !check {
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("最近%d天, 有价格低于%.2f", LastDay, MinPrice)}
r.Model.GtAmount = -1
r.Model.AddDesc(fmt.Sprintf("最近%d天, 有价格低于%.2f", LastDay, MinPrice))
return
}
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Desc: fmt.Sprintf("最近%d天, 价格均高于%.2f", LastDay, MinPrice)}
r.Model.GtAmount = 1
}