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
|
package tdx
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/injoyai/conv"
|
||||||
"github.com/injoyai/logs"
|
"github.com/injoyai/logs"
|
||||||
"github.com/injoyai/tdx/protocol"
|
"github.com/injoyai/tdx/protocol"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
@@ -108,14 +109,15 @@ func (this *Codes) GetName(code string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetStocks 获取股票代码,sh6xxx sz0xx sz30xx
|
// 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)
|
ls := []string(nil)
|
||||||
for _, m := range this.list {
|
for _, m := range this.list {
|
||||||
code := m.FullCode()
|
code := m.FullCode()
|
||||||
if protocol.IsStock(code) {
|
if protocol.IsStock(code) {
|
||||||
ls = append(ls, code)
|
ls = append(ls, code)
|
||||||
}
|
}
|
||||||
if len(limit) > 0 && len(ls) >= limit[0] {
|
if limit > 0 && len(ls) >= limit {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
manage.go
20
manage.go
@@ -22,16 +22,9 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
|
|||||||
cfg.WorkdayDir = "./data/database"
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,6 +33,15 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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...)
|
workdayClient, err := DialHosts(cfg.Hosts, op...)
|
||||||
|
|||||||
Reference in New Issue
Block a user