mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
修复分时K线,时间不对的问题
This commit is contained in:
20
example/GetKlineMinute/main.go
Normal file
20
example/GetKlineMinute/main.go
Normal 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)
|
||||
})
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user