Compare commits

..

6 Commits

Author SHA1 Message Date
钱纯净
81c45e76d0 修复Codes,更新数据的时候,少了交易所的条件 2025-03-05 22:54:23 +08:00
钱纯净
a8c248bf9d 修复Codes,更新数据的时候,少了交易所的条件 2025-03-05 22:50:45 +08:00
钱纯净
3e57f54978 增加全局变量ExchangeEstablish(上海交易所成立时间) 2025-03-03 22:35:43 +08:00
钱纯净
50c997f26f 细节优化 2025-03-03 19:35:56 +08:00
injoyai
0740ff7ca0 优化RangeDesc 2025-02-28 10:38:24 +08:00
injoyai
81f2ffcbea 优化RangeDesc 2025-02-28 10:36:13 +08:00
4 changed files with 21 additions and 13 deletions

View File

@@ -145,7 +145,7 @@ func (this *Codes) Code(byDatabase bool) ([]*CodeModel, error) {
}
}
for _, v := range update {
if _, err := session.Where("Code=?", v.Code).Cols("Name").Update(v); err != nil {
if _, err := session.Where("Exchange=? and Code=? ", v.Exchange, v.Code).Cols("Name").Update(v); err != nil {
return err
}
}

View File

@@ -15,8 +15,11 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
if len(cfg.Hosts) == 0 {
cfg.Hosts = Hosts
}
if cfg.Dir == "" {
cfg.Dir = "./data/"
if cfg.CodesDir == "" {
cfg.CodesDir = "./data/database"
}
if cfg.WorkdayDir == "" {
cfg.WorkdayDir = "./data/database"
}
//连接池
@@ -33,18 +36,18 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
return nil, err
}
codesClient.Wait.SetTimeout(time.Second * 5)
codes, err := NewCodes(codesClient, filepath.Join(cfg.Dir, "database/codes.db"))
codes, err := NewCodes(codesClient, filepath.Join(cfg.CodesDir, "codes.db"))
if err != nil {
return nil, err
}
///工作日
//工作日
workdayClient, err := DialHosts(cfg.Hosts, op...)
if err != nil {
return nil, err
}
workdayClient.Wait.SetTimeout(time.Second * 5)
workday, err := NewWorkday(workdayClient, filepath.Join(cfg.Dir, "database/codes.db"))
workday, err := NewWorkday(workdayClient, filepath.Join(cfg.WorkdayDir, "workday.db"))
if err != nil {
return nil, err
}
@@ -76,7 +79,8 @@ func (this *Manage) AddWorkdayTask(spec string, f func(m *Manage)) {
}
type ManageConfig struct {
Hosts []string //服务端IP
Number int //客户端数量
Dir string //数据位置
Hosts []string //服务端IP
Number int //客户端数量
CodesDir string //代码数据位置
WorkdayDir string //工作日数据库位置
}

View File

@@ -1,5 +1,7 @@
package protocol
import "time"
const (
TypeConnect = 0x000D //建立连接
TypeHeart = 0x0004 //心跳
@@ -12,6 +14,11 @@ const (
TypeKline = 0x052D //K线图
)
var (
// ExchangeEstablish 交易所成立时间
ExchangeEstablish = time.Date(1990, 12, 19, 0, 0, 0, 0, time.Local)
)
/*
从其他地方复制
const (

View File

@@ -113,10 +113,7 @@ func (this *Workday) TodayIs() bool {
// 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
}
for ; t.After(time.Date(1990, 12, 18, 0, 0, 0, 0, time.Local)); t = t.Add(-time.Hour * 24) {
if this.Is(t) {
if !f(t) {
return