mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a63c2ff2e | ||
|
|
71035fb210 | ||
|
|
f479d99c99 | ||
|
|
ddb36b5aa7 | ||
|
|
ddc4b801bf | ||
|
|
e22d2776e7 | ||
|
|
f46b97e1e1 |
@@ -38,6 +38,11 @@ func Dial(addr string, op ...client.Option) (cli *Client, err error) {
|
||||
return DialWith(tcp.NewDial(addr), op...)
|
||||
}
|
||||
|
||||
// DialDefault 默认连接方式
|
||||
func DialDefault(op ...client.Option) (cli *Client, err error) {
|
||||
return DialWith(NewHostDial(Hosts), op...)
|
||||
}
|
||||
|
||||
// DialHosts 与服务器建立连接,多个服务器轮询,开启重试生效
|
||||
func DialHosts(hosts []string, op ...client.Option) (cli *Client, err error) {
|
||||
return DialWith(NewHostDial(hosts), op...)
|
||||
|
||||
@@ -9,6 +9,9 @@ import (
|
||||
|
||||
func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
|
||||
//初始化配置
|
||||
if cfg == nil {
|
||||
cfg = &ManageConfig{}
|
||||
}
|
||||
if len(cfg.Hosts) == 0 {
|
||||
cfg.Hosts = Hosts
|
||||
}
|
||||
@@ -48,6 +51,7 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
|
||||
|
||||
return &Manage{
|
||||
Pool: p,
|
||||
Config: cfg,
|
||||
Codes: codes,
|
||||
Workday: workday,
|
||||
Cron: cron.New(cron.WithSeconds()),
|
||||
@@ -56,6 +60,7 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
|
||||
|
||||
type Manage struct {
|
||||
*Pool
|
||||
Config *ManageConfig
|
||||
Codes *Codes
|
||||
Workday *Workday
|
||||
Cron *cron.Cron
|
||||
|
||||
19
workday.go
19
workday.go
@@ -59,7 +59,7 @@ type Workday struct {
|
||||
|
||||
// Update 更新
|
||||
func (this *Workday) Update() error {
|
||||
//获取平安银行的日K线,用作历史是否节假日的判断依据
|
||||
//获取沪市指数的日K线,用作历史是否节假日的判断依据
|
||||
//判断日K线是否拉取过
|
||||
|
||||
//获取全部工作日
|
||||
@@ -77,7 +77,7 @@ func (this *Workday) Update() error {
|
||||
|
||||
now := time.Now()
|
||||
if lastWorkday == nil || lastWorkday.Unix < IntegerDay(now).Unix() {
|
||||
resp, err := this.Client.GetKlineDayAll("sz000001")
|
||||
resp, err := this.Client.GetKlineDayAll("sh000001")
|
||||
if err != nil {
|
||||
logs.Err(err)
|
||||
return err
|
||||
@@ -110,6 +110,21 @@ func (this *Workday) TodayIs() bool {
|
||||
return this.Is(time.Now())
|
||||
}
|
||||
|
||||
// RangeDesc 倒序遍历工作日,从今天-1990年12月19日(上海交易所成立时间)
|
||||
func (this *Workday) RangeDesc(f func(t time.Time) bool) {
|
||||
t := IntegerDay(time.Now())
|
||||
for ; t.Before(time.Date(1990, 12, 1, 0, 0, 0, 0, time.Local)); t = t.Add(-time.Hour * 24) {
|
||||
if t.Weekday() == time.Saturday || t.Weekday() == time.Sunday {
|
||||
continue
|
||||
}
|
||||
if this.Is(t) {
|
||||
if !f(t) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WorkdayModel 工作日
|
||||
type WorkdayModel struct {
|
||||
ID int64 `json:"id"` //主键
|
||||
|
||||
Reference in New Issue
Block a user