Compare commits

...

5 Commits

3 changed files with 24 additions and 5 deletions

View File

@@ -181,6 +181,11 @@ func (this *Client) handlerDealMessage(c *client.Client, msg ios.Acker) {
}
// SetTimeout 设置超时时间
func (this *Client) SetTimeout(t time.Duration) {
this.Wait.SetTimeout(t)
}
// SendFrame 发送数据,并等待响应
func (this *Client) SendFrame(f *protocol.Frame, cache ...any) (any, error) {
f.MsgID = atomic.AddUint32(&this.msgID, 1)
@@ -457,7 +462,12 @@ func (this *Client) GetHistoryTradeBefore(code string, w *Workday, before time.T
start := time.Date(resp.List[0].Time.Year(), resp.List[0].Time.Month(), 1, 0, 0, 0, 0, resp.List[0].Time.Location())
var res *protocol.TradeResp
w.Range(start, before, func(t time.Time) bool {
res, err = this.GetHistoryTradeDay(start.Format("20060102"), code)
for i := 0; i < 3; i++ {
res, err = this.GetHistoryTradeDay(t.Format("20060102"), code)
if err == nil {
break
}
}
if err != nil {
return false
}

View File

@@ -4,6 +4,14 @@ import (
"github.com/injoyai/tdx"
)
func GetBjCodes() ([]*tdx.BjCode, error) {
return tdx.GetBjCodes()
func GetBjCodes() ([]string, error) {
cs, err := tdx.GetBjCodes()
if err != nil {
return nil, err
}
ls := []string(nil)
for _, v := range cs {
ls = append(ls, "bj"+v.Code)
}
return ls, nil
}

View File

@@ -183,6 +183,7 @@ func (this Trades) Kline(t time.Time, last Price) *Kline {
// kline1 生成一分钟k线,一天
func (this Trades) klinesForDay(date time.Time) Klines {
_929 := 569 //9:29 的分钟,为了兼容性强,把9:25算9:29
_930 := 570 //9:30 的分钟
_1130 := 690 //11:30 的分钟
_1300 := 780 //13:00 的分钟
@@ -190,7 +191,7 @@ func (this Trades) klinesForDay(date time.Time) Klines {
keys := []int(nil)
//早上
m := map[int]Trades{}
for i := 1; i <= 120; i++ {
for i := 0; i <= 120; i++ {
keys = append(keys, _930+i)
m[_930+i] = []*Trade{}
}
@@ -210,7 +211,7 @@ func (this Trades) klinesForDay(date time.Time) Klines {
//分组,按
for _, v := range this {
ms := minutes(v.Time)
t := conv.Select(ms <= _930, _930, ms)
t := conv.Select(ms < _929, _929, ms)
t++
t = conv.Select(t > _1130 && t <= _1300, _1130, t)
t = conv.Select(t > _1500, _1500, t)