95 lines
2.1 KiB
Go
95 lines
2.1 KiB
Go
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()
|
|
|
|
for _, code := range strategy.GetStocks() {
|
|
strategy.InitCacheByCode(code)
|
|
model := models.NewStratModel("selector", code)
|
|
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 {
|
|
stratRule.RunAi(code)
|
|
}
|
|
}
|
|
|
|
model.Save()
|
|
}
|
|
}
|
|
|
|
func ai() {
|
|
log.Println("Hello Cli!")
|
|
config.New(ServiceKey)
|
|
impl.NewImpl()
|
|
|
|
code := "601899.SH"
|
|
model := models.NewStratModel("selector", code)
|
|
stratRule := rule.NewRule(model)
|
|
stratRule.RunAi(code)
|
|
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
}
|