mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
Manage简单兼容DefaultCodes
This commit is contained in:
6
codes.go
6
codes.go
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
20
manage.go
20
manage.go
@@ -22,16 +22,9 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
|
||||
cfg.WorkdayDir = "./data/database"
|
||||
}
|
||||
|
||||
//连接池
|
||||
p, err := NewPool(func() (*Client, error) {
|
||||
return DialHosts(cfg.Hosts, op...)
|
||||
}, cfg.Number)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//代码
|
||||
codesClient, err := DialHosts(cfg.Hosts, op...)
|
||||
DefaultCodes = &Codes{}
|
||||
codesClient, err := DialHostsRandom(cfg.Hosts, op...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -40,6 +33,15 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
DefaultCodes = codes
|
||||
|
||||
//连接池
|
||||
p, err := NewPool(func() (*Client, error) {
|
||||
return DialHosts(cfg.Hosts, op...)
|
||||
}, cfg.Number)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//工作日
|
||||
workdayClient, err := DialHosts(cfg.Hosts, op...)
|
||||
|
||||
Reference in New Issue
Block a user