deving
This commit is contained in:
36
internal/logic/strategy/rule/price.go
Normal file
36
internal/logic/strategy/rule/price.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package rule
|
||||
|
||||
import (
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/quant/gostock/internal/impl"
|
||||
"git.apinb.com/quant/gostock/internal/logic/types"
|
||||
"git.apinb.com/quant/gostock/internal/models"
|
||||
)
|
||||
|
||||
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 {
|
||||
var daily models.StockDaily
|
||||
impl.DBService.Where("ts_code = ?", code).Order("trade_date desc").Limit(1).First(&daily)
|
||||
printer.Json(daily)
|
||||
|
||||
if daily.Close < MinPrice {
|
||||
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: "股价低于5元"}
|
||||
}
|
||||
|
||||
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Desc: "股价高于5元"}
|
||||
}
|
||||
Reference in New Issue
Block a user