This commit is contained in:
yanweidong
2026-01-30 21:02:02 +08:00
parent 03bcce8007
commit e38e584535
7 changed files with 5510 additions and 5513 deletions

View File

@@ -15,7 +15,7 @@ var (
ServiceKey = "gostock" ServiceKey = "gostock"
) )
func main() { func main2() {
log.Println("Hello Cli!") log.Println("Hello Cli!")
config.New(ServiceKey) config.New(ServiceKey)
impl.NewImpl() impl.NewImpl()
@@ -23,7 +23,7 @@ func main() {
strategy.GenMarkData("601899.SH") strategy.GenMarkData("601899.SH")
} }
func main2() { func main() {
log.Println("Hello Cli!") log.Println("Hello Cli!")
config.New(ServiceKey) config.New(ServiceKey)
impl.NewImpl() impl.NewImpl()

View File

@@ -57,31 +57,28 @@ func MustFilter(basic *models.StockBasic) (bool, *types.ResultData) {
data.Desc = re.Desc data.Desc = re.Desc
return false, data return false, data
} else { } else {
data.ROE = re.Roe
descripts = append(descripts, re.Desc) descripts = append(descripts, re.Desc)
} }
if re := rule.NewRsi(GetArgs(basic.TsCode)).Run(basic.TsCode); re.Score <= 0 { // if re := rule.NewRsi(GetArgs(basic.TsCode)).Run(basic.TsCode); re.Score <= 0 {
data.Desc = re.Desc // data.Desc = re.Desc
return false, data // return false, data
} else { // } else {
data.RSI = re.Rsi // data.RSI = re.Rsi
descripts = append(descripts, re.Desc) // descripts = append(descripts, re.Desc)
} // }
data.Desc = strings.Join(descripts, "#") data.Desc = strings.Join(descripts, "#")
data.Pass = "OK" data.Pass = "OK"
return true, data return true, data
} }
func ClacFilter(basic *models.StockBasic) (bool, *types.ResultData) { func ClacFilter(allow []*types.ResultData) []*types.ResultData {
var descripts []string for idx, item := range allow {
data := &types.ResultData{ re := rule.NewRsi(GetArgs(item.Code)).Run(item.Code)
Code: basic.TsCode, allow[idx].Score = re.Score
Name: basic.Name, allow[idx].RSI = re.Result.(float64)
ROE: 0,
RSI: 0,
Desc: "",
Pass: "NOT",
} }
return allow
} }

View File

@@ -39,5 +39,5 @@ func (r *Roe) Run(code string) *types.RuleResult {
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("ROE=%.2f 低于%.2f", data.Roe, MinRoe)} return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("ROE=%.2f 低于%.2f", data.Roe, MinRoe)}
} }
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Roe: data.Roe, Desc: fmt.Sprintf("ROE=%.2f 高于%.2f", data.Roe, MinRoe)} return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Desc: fmt.Sprintf("ROE=%.2f 高于%.2f", data.Roe, MinRoe)}
} }

View File

@@ -76,10 +76,10 @@ func (r *Rsi) Run(code string) *types.RuleResult {
// 跌破RSI下轨 // 跌破RSI下轨
if lastRsiInt > r.Args.RsiOversold { if lastRsiInt > r.Args.RsiOversold {
if CheckLowest(close, lastRsiInt, 14) { if CheckLowest(close, lastRsiInt, 14) {
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Rsi: lastRsi, Desc: fmt.Sprintf("RSI=%d 跌破下轨,14日最低", lastRsiInt)} return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Result: lastRsi, Desc: fmt.Sprintf("RSI=%d 跌破下轨,14日最低", lastRsiInt)}
} }
if CheckLowest(close, lastRsiInt, 20) { if CheckLowest(close, lastRsiInt, 20) {
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Rsi: lastRsi, Desc: fmt.Sprintf("RSI=%d 跌破下轨,20日最低", lastRsiInt)} return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Result: lastRsi, Desc: fmt.Sprintf("RSI=%d 跌破下轨,20日最低", lastRsiInt)}
} }
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("RSI=%d 高于%d", lastRsiInt, r.Args.RsiOversold)} return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("RSI=%d 高于%d", lastRsiInt, r.Args.RsiOversold)}
} }
@@ -88,5 +88,5 @@ func (r *Rsi) Run(code string) *types.RuleResult {
if lastRsiInt < prveRsiInt { if lastRsiInt < prveRsiInt {
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("Rsi=%d prveRsi=%d,跌破下轨,持续下跌", lastRsiInt, prveRsiInt)} return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("Rsi=%d prveRsi=%d,跌破下轨,持续下跌", lastRsiInt, prveRsiInt)}
} }
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Rsi: lastRsi, Desc: fmt.Sprintf("RSI=%d prveRsi=%d,跌破下轨后呈上涨趋势", lastRsiInt, prveRsiInt)} return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Result: lastRsi, Desc: fmt.Sprintf("RSI=%d prveRsi=%d,跌破下轨后呈上涨趋势", lastRsiInt, prveRsiInt)}
} }

View File

@@ -4,8 +4,7 @@ type RuleResult struct {
Key string Key string
Name string Name string
Score int Score int
Roe float64 Result any
Rsi float64
Desc string Desc string
} }
@@ -15,5 +14,6 @@ type ResultData struct { // Our example struct, you can use "-" to ignore a fiel
ROE float64 `csv:"roe"` ROE float64 `csv:"roe"`
RSI float64 `csv:"rsi"` RSI float64 `csv:"rsi"`
Desc string `csv:"desc"` Desc string `csv:"desc"`
Score int
Pass string `csv:"pass"` Pass string `csv:"pass"`
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff