This commit is contained in:
yanweidong
2026-01-27 17:21:26 +08:00
parent 86abc3a80f
commit 9b7f6ed2cf
3 changed files with 64 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ func main() {
rule.NewST().Run(basic.Name),
rule.NewIdustry().Run(basic.Industry),
rule.NewPrice().Run(basic.TsCode),
rule.NewAmount().Run(basic.TsCode),
}
printer.Json(result)

View File

@@ -0,0 +1,46 @@
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)}
}

View File

@@ -1,13 +1,15 @@
package rule
import (
"git.apinb.com/bsm-sdk/core/printer"
"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
)
@@ -24,13 +26,21 @@ func NewPrice() *Price {
}
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元"}
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
}
}
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Desc: "股价高于5元"}
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)}
}