47 lines
927 B
Go
47 lines
927 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 (
|
|
LastDay = 20
|
|
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 {
|
|
|
|
var data []models.StockDaily
|
|
impl.DBService.Where("ts_code = ?", code).Order("trade_date desc").Limit(LastDay).Find(&data)
|
|
|
|
check := true
|
|
for _, row := range data {
|
|
if row.Close < MinPrice {
|
|
check = false
|
|
break
|
|
}
|
|
}
|
|
|
|
if !check {
|
|
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("最近%d天, 有价格低于%.2f", LastDay, MinPrice)}
|
|
}
|
|
|
|
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Desc: fmt.Sprintf("最近%d天, 价格均高于%.2f", LastDay, MinPrice)}
|
|
}
|