修复分时K线,时间不对的问题

This commit is contained in:
injoyai
2024-11-11 08:56:13 +08:00
parent 5ff96b9d4a
commit 420a83dbc2
3 changed files with 31 additions and 5 deletions

View File

@@ -0,0 +1,20 @@
package main
import (
"github.com/injoyai/logs"
"github.com/injoyai/tdx"
"github.com/injoyai/tdx/example/common"
)
func main() {
common.Test(func(c *tdx.Client) {
resp, err := c.GetKlineMinute("sz000001", 0, 800)
logs.PanicErr(err)
for _, v := range resp.List {
logs.Debug(v)
}
logs.Debug("总数:", resp.Count)
})
}

View File

@@ -6,8 +6,14 @@ import (
)
func Test(f func(c *tdx.Client)) {
c, err := tdx.Dial("124.71.187.122:7709", tdx.WithDebug())
logs.PanicErr(err)
f(c)
<-c.Done()
for _, v := range tdx.Hosts {
c, err := tdx.Dial(v, tdx.WithDebug())
if err != nil {
logs.PrintErr(err)
continue
}
f(c)
<-c.Done()
break
}
}

View File

@@ -101,7 +101,7 @@ func GetTime(bs [4]byte, Type uint8) time.Time {
case TypeKlineDay2, TypeKlineMinute, TypeKlineMinute2:
yearMonthDay := Uint16(bs[:2])
hourMinute := Uint16(bs[:2])
hourMinute := Uint16(bs[2:4])
year := int(yearMonthDay>>11 + 2004)
month := yearMonthDay % 2048 / 100
day := int((yearMonthDay % 2048) % 100)