Files
gostock/internal/logic/strategy/rule/amount.go
yanweidong 9b7f6ed2cf deving
2026-01-27 17:21:26 +08:00

47 lines
1023 B
Go

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 (
LastAmountDay = 20
MinAmount float64 = 100000 // 万元为单位
)
type Amount struct {
Key string
Name string
}
func NewAmount() *Amount {
return &Amount{
Key: "Amount",
Name: "成交额",
}
}
func (r *Amount) Run(code string) *types.RuleResult {
var data []models.StockDaily
impl.DBService.Where("ts_code = ?", code).Order("trade_date desc").Limit(LastAmountDay).Find(&data)
check := true
for _, row := range data {
if row.Amount < MinPrice {
check = false
break
}
}
if !check {
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("最近%d天, 有成交额低于%.2f万元", LastAmountDay, MinAmount)}
}
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Desc: fmt.Sprintf("最近%d天, 成交额均高于%.2f万元", LastAmountDay, MinAmount)}
}