add mock order.
This commit is contained in:
94
cmd/selector/main.go
Normal file
94
cmd/selector/main.go
Normal file
@@ -0,0 +1,94 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"git.apinb.com/quant/gostock/internal/config"
|
||||
"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"
|
||||
"git.apinb.com/quant/gostock/internal/models"
|
||||
"github.com/gocarina/gocsv"
|
||||
)
|
||||
|
||||
var (
|
||||
ServiceKey = "gostock"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Println("Hello Cli!")
|
||||
config.New(ServiceKey)
|
||||
impl.NewImpl()
|
||||
|
||||
ymd := models.GetYmd()
|
||||
for _, code := range strategy.GetStocks() {
|
||||
strategy.InitCacheByCode(code)
|
||||
model := models.NewStratModel("selector", code, ymd)
|
||||
stratRule := rule.NewRule(model)
|
||||
{
|
||||
stratRule.RunUpDate(strategy.Cache[code].Basic.ListDate)
|
||||
stratRule.RunST(strategy.Cache[code].Basic.Name)
|
||||
stratRule.RunIndustry(strategy.Cache[code].Basic.Industry)
|
||||
stratRule.RunPrice(code)
|
||||
stratRule.RunAmount(code)
|
||||
stratRule.RunRoe(code)
|
||||
stratRule.RunRsi(code)
|
||||
|
||||
// 过滤无需AI分析
|
||||
if model.StScore > 0 && model.IndustryScore > 0 && model.GtPrice > 0 && model.GtAmount > 0 && model.GtRoe > 0 && model.ScoreRsi > 0 {
|
||||
model.AiScore = 0 // 待分析
|
||||
} else {
|
||||
model.AiScore = -2
|
||||
model.AddDesc("无需AI分析")
|
||||
}
|
||||
}
|
||||
model.Save()
|
||||
}
|
||||
|
||||
strategy.BootAiStart("selector", models.GetYmd())
|
||||
}
|
||||
|
||||
func ai() {
|
||||
log.Println("Hello Cli!")
|
||||
config.New(ServiceKey)
|
||||
impl.NewImpl()
|
||||
|
||||
}
|
||||
|
||||
func main3() {
|
||||
log.Println("Hello Cli!")
|
||||
config.New(ServiceKey)
|
||||
impl.NewImpl()
|
||||
|
||||
data_ok := []*types.ResultData{}
|
||||
data_not := []*types.ResultData{}
|
||||
for _, code := range strategy.GetStocks() {
|
||||
basic := strategy.GetBasic(code)
|
||||
if ok, data := strategy.MustFilter(basic); ok {
|
||||
data_ok = append(data_ok, data)
|
||||
} else {
|
||||
data_not = append(data_not, data)
|
||||
}
|
||||
}
|
||||
|
||||
WriteResults(data_ok, "ok")
|
||||
WriteResults(data_not, "not")
|
||||
|
||||
log.Println("Done!")
|
||||
}
|
||||
|
||||
func WriteResults(data []*types.ResultData, tag string) {
|
||||
rf, err := os.OpenFile("./result/stocks_"+tag+".csv", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer rf.Close()
|
||||
|
||||
err = gocsv.MarshalFile(&data, rf) // Use this to save the CSV back to the file
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user