mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
用60Minute来替代Hour,保留Hour作为60Minute的别名
This commit is contained in:
20
client.go
20
client.go
@@ -637,18 +637,32 @@ func (this *Client) GetKline30MinuteUntil(code string, f func(k *protocol.Kline)
|
|||||||
return this.GetKlineUntil(protocol.TypeKline30Minute, code, f)
|
return this.GetKlineUntil(protocol.TypeKline30Minute, code, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetKline60Minute 获取60分钟k线数据
|
||||||
|
func (this *Client) GetKline60Minute(code string, start, count uint16) (*protocol.KlineResp, error) {
|
||||||
|
return this.GetKline(protocol.TypeKline60Minute, code, start, count)
|
||||||
|
}
|
||||||
|
|
||||||
// GetKlineHour 获取小时k线数据
|
// GetKlineHour 获取小时k线数据
|
||||||
func (this *Client) GetKlineHour(code string, start, count uint16) (*protocol.KlineResp, error) {
|
func (this *Client) GetKlineHour(code string, start, count uint16) (*protocol.KlineResp, error) {
|
||||||
return this.GetKline(protocol.TypeKlineHour, code, start, count)
|
return this.GetKline(protocol.TypeKline60Minute, code, start, count)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetKline60MinuteAll 获取60分钟k线全部数据
|
||||||
|
func (this *Client) GetKline60MinuteAll(code string) (*protocol.KlineResp, error) {
|
||||||
|
return this.GetKlineAll(protocol.TypeKline60Minute, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetKlineHourAll 获取小时k线全部数据
|
// GetKlineHourAll 获取小时k线全部数据
|
||||||
func (this *Client) GetKlineHourAll(code string) (*protocol.KlineResp, error) {
|
func (this *Client) GetKlineHourAll(code string) (*protocol.KlineResp, error) {
|
||||||
return this.GetKlineAll(protocol.TypeKlineHour, code)
|
return this.GetKlineAll(protocol.TypeKline60Minute, code)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Client) GetKline60MinuteUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error) {
|
||||||
|
return this.GetKlineUntil(protocol.TypeKline60Minute, code, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Client) GetKlineHourUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error) {
|
func (this *Client) GetKlineHourUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error) {
|
||||||
return this.GetKlineUntil(protocol.TypeKlineHour, code, f)
|
return this.GetKlineUntil(protocol.TypeKline60Minute, code, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetKlineDay 获取日k线数据
|
// GetKlineDay 获取日k线数据
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ func (kline) Decode(bs []byte, c KlineCache) (*KlineResp, error) {
|
|||||||
k.Volume = int64(getVolume(Uint32(bs[:4])))
|
k.Volume = int64(getVolume(Uint32(bs[:4])))
|
||||||
bs = bs[4:]
|
bs = bs[4:]
|
||||||
switch c.Type {
|
switch c.Type {
|
||||||
case TypeKlineMinute, TypeKline5Minute, TypeKlineMinute2, TypeKline15Minute, TypeKline30Minute, TypeKlineHour, TypeKlineDay2:
|
case TypeKlineMinute, TypeKline5Minute, TypeKlineMinute2, TypeKline15Minute, TypeKline30Minute, TypeKline60Minute, TypeKlineDay2:
|
||||||
k.Volume /= 100
|
k.Volume /= 100
|
||||||
}
|
}
|
||||||
k.Amount = Price(getVolume(Uint32(bs[:4])) * 1000) //从元转为厘,并去除多余的小数
|
k.Amount = Price(getVolume(Uint32(bs[:4])) * 1000) //从元转为厘,并去除多余的小数
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ const (
|
|||||||
TypeKline5Minute uint8 = 0 // 5分钟K 线
|
TypeKline5Minute uint8 = 0 // 5分钟K 线
|
||||||
TypeKline15Minute uint8 = 1 // 15分钟K 线
|
TypeKline15Minute uint8 = 1 // 15分钟K 线
|
||||||
TypeKline30Minute uint8 = 2 // 30分钟K 线
|
TypeKline30Minute uint8 = 2 // 30分钟K 线
|
||||||
|
TypeKline60Minute uint8 = 3 // 60分钟K 线
|
||||||
TypeKlineHour uint8 = 3 // 1小时K 线
|
TypeKlineHour uint8 = 3 // 1小时K 线
|
||||||
TypeKlineDay2 uint8 = 4 // 日K 线, 发现和Day的区别是这个要除以100,其他未知
|
TypeKlineDay2 uint8 = 4 // 日K 线, 发现和Day的区别是这个要除以100,其他未知
|
||||||
TypeKlineWeek uint8 = 5 // 周K 线
|
TypeKlineWeek uint8 = 5 // 周K 线
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ func GetHourMinute(bs [2]byte) string {
|
|||||||
|
|
||||||
func GetTime(bs [4]byte, Type uint8) time.Time {
|
func GetTime(bs [4]byte, Type uint8) time.Time {
|
||||||
switch Type {
|
switch Type {
|
||||||
case TypeKlineMinute, TypeKlineMinute2, TypeKline5Minute, TypeKline15Minute, TypeKline30Minute, TypeKlineHour:
|
case TypeKlineMinute, TypeKlineMinute2, TypeKline5Minute, TypeKline15Minute, TypeKline30Minute, TypeKline60Minute:
|
||||||
|
|
||||||
yearMonthDay := Uint16(bs[:2])
|
yearMonthDay := Uint16(bs[:2])
|
||||||
hourMinute := Uint16(bs[2:4])
|
hourMinute := Uint16(bs[2:4])
|
||||||
|
|||||||
Reference in New Issue
Block a user