Manage简单兼容DefaultCodes

This commit is contained in:
injoyai
2025-03-18 14:48:02 +08:00
parent 51d8d06fbd
commit b221dbc3e2
2 changed files with 15 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
package tdx
import (
"github.com/injoyai/conv"
"github.com/injoyai/logs"
"github.com/injoyai/tdx/protocol"
"github.com/robfig/cron/v3"
@@ -108,14 +109,15 @@ func (this *Codes) GetName(code string) string {
}
// GetStocks 获取股票代码,sh6xxx sz0xx sz30xx
func (this *Codes) GetStocks(limit ...int) []string {
func (this *Codes) GetStocks(limits ...int) []string {
limit := conv.DefaultInt(-1, limits...)
ls := []string(nil)
for _, m := range this.list {
code := m.FullCode()
if protocol.IsStock(code) {
ls = append(ls, code)
}
if len(limit) > 0 && len(ls) >= limit[0] {
if limit > 0 && len(ls) >= limit {
break
}
}