deving
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"git.apinb.com/quant/gostock/internal/impl"
|
||||
"git.apinb.com/quant/gostock/internal/logic/strategy"
|
||||
"git.apinb.com/quant/gostock/internal/logic/strategy/rule"
|
||||
"git.apinb.com/quant/gostock/internal/logic/types"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -18,8 +19,16 @@ func main() {
|
||||
log.Println("Hello Cli!")
|
||||
config.New(ServiceKey)
|
||||
impl.NewImpl()
|
||||
data := strategy.GetData("000012.SZ")
|
||||
result := rule.NewIdustry().Run(data.Basic.Industry)
|
||||
|
||||
basic := strategy.GetBasic("000012.SZ")
|
||||
|
||||
result := []*types.RuleResult{
|
||||
rule.NewUpDate().Run(basic.ListDate),
|
||||
rule.NewST().Run(basic.Name),
|
||||
rule.NewIdustry().Run(basic.Industry),
|
||||
rule.NewPrice().Run(basic.TsCode),
|
||||
}
|
||||
|
||||
printer.Json(result)
|
||||
|
||||
log.Println("Done!")
|
||||
|
||||
@@ -12,7 +12,7 @@ type StockData struct {
|
||||
FinaIndicator []models.StockFinaIndicator
|
||||
}
|
||||
|
||||
func GetData(code string) *StockData {
|
||||
func GetFullData(code string) *StockData {
|
||||
var data StockData
|
||||
impl.DBService.Where("ts_code = ?", code).First(&data.Basic)
|
||||
impl.DBService.Where("ts_code = ?", code).Order("trade_date desc").Find(&data.Daily)
|
||||
@@ -25,3 +25,9 @@ func GetIndustry() (industry []string) {
|
||||
impl.DBService.Model(&models.StockBasic{}).Group("industry").Pluck("industry", &industry)
|
||||
return
|
||||
}
|
||||
|
||||
func GetBasic(code string) *models.StockBasic {
|
||||
var data StockData
|
||||
impl.DBService.Where("ts_code = ?", code).First(&data.Basic)
|
||||
return &data.Basic
|
||||
}
|
||||
|
||||
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