mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
protocol.HistoryTradeResp替换成protocol.TradeResp
This commit is contained in:
12
client.go
12
client.go
@@ -360,14 +360,14 @@ func (this *Client) GetMinuteTradeAll(code string) (*protocol.TradeResp, error)
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Client) GetHistoryTrade(date, code string, start, count uint16) (*protocol.HistoryTradeResp, error) {
|
func (this *Client) GetHistoryTrade(date, code string, start, count uint16) (*protocol.TradeResp, error) {
|
||||||
return this.GetHistoryMinuteTrade(date, code, start, count)
|
return this.GetHistoryMinuteTrade(date, code, start, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHistoryMinuteTrade 获取历史分时交易
|
// GetHistoryMinuteTrade 获取历史分时交易
|
||||||
// 只能获取昨天及之前的数据,服务器最多返回2000条,count-start<=2000,如果日期输入错误,则返回0
|
// 只能获取昨天及之前的数据,服务器最多返回2000条,count-start<=2000,如果日期输入错误,则返回0
|
||||||
// 历史数据sz000001在20241116只能查到21111112,13年差几天,3141天,或者其他规则
|
// 历史数据sz000001在20241116只能查到21111112,13年差几天,3141天,或者其他规则
|
||||||
func (this *Client) GetHistoryMinuteTrade(date, code string, start, count uint16) (*protocol.HistoryTradeResp, error) {
|
func (this *Client) GetHistoryMinuteTrade(date, code string, start, count uint16) (*protocol.TradeResp, error) {
|
||||||
code = protocol.AddPrefix(code)
|
code = protocol.AddPrefix(code)
|
||||||
f, err := protocol.MHistoryTrade.Frame(date, code, start, count)
|
f, err := protocol.MHistoryTrade.Frame(date, code, start, count)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -380,17 +380,17 @@ func (this *Client) GetHistoryMinuteTrade(date, code string, start, count uint16
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return result.(*protocol.HistoryTradeResp), nil
|
return result.(*protocol.TradeResp), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Client) GetHistoryTradeAll(date, code string) (*protocol.HistoryTradeResp, error) {
|
func (this *Client) GetHistoryTradeAll(date, code string) (*protocol.TradeResp, error) {
|
||||||
return this.GetHistoryMinuteTradeAll(date, code)
|
return this.GetHistoryMinuteTradeAll(date, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHistoryMinuteTradeAll 获取历史分时全部交易,通过多次请求来拼接,只能获取昨天及之前的数据
|
// GetHistoryMinuteTradeAll 获取历史分时全部交易,通过多次请求来拼接,只能获取昨天及之前的数据
|
||||||
// 历史数据sz000001在20241116只能查到21111112,13年差几天,3141天,或者其他规则
|
// 历史数据sz000001在20241116只能查到21111112,13年差几天,3141天,或者其他规则
|
||||||
func (this *Client) GetHistoryMinuteTradeAll(date, code string) (*protocol.HistoryTradeResp, error) {
|
func (this *Client) GetHistoryMinuteTradeAll(date, code string) (*protocol.TradeResp, error) {
|
||||||
resp := &protocol.HistoryTradeResp{}
|
resp := &protocol.TradeResp{}
|
||||||
size := uint16(2000)
|
size := uint16(2000)
|
||||||
for start := uint16(0); ; start += size {
|
for start := uint16(0); ; start += size {
|
||||||
r, err := this.GetHistoryMinuteTrade(date, code, start, size)
|
r, err := this.GetHistoryMinuteTrade(date, code, start, size)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func (this *PullTrade) PullYear(ctx context.Context, m *tdx.Manage, year int, co
|
|||||||
|
|
||||||
date := t.Format("20060102")
|
date := t.Format("20060102")
|
||||||
|
|
||||||
var resp *protocol.HistoryTradeResp
|
var resp *protocol.TradeResp
|
||||||
err = m.Do(func(c *tdx.Client) error {
|
err = m.Do(func(c *tdx.Client) error {
|
||||||
resp, err = c.GetHistoryTradeAll(date, code)
|
resp, err = c.GetHistoryTradeAll(date, code)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -6,11 +6,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HistoryTradeResp 历史分时交易比实时少了单量
|
// HistoryTradeResp 兼容之前的版本
|
||||||
type HistoryTradeResp struct {
|
type HistoryTradeResp = TradeResp
|
||||||
Count uint16
|
|
||||||
List Trades
|
|
||||||
}
|
|
||||||
|
|
||||||
type historyTrade struct{}
|
type historyTrade struct{}
|
||||||
|
|
||||||
@@ -31,7 +28,7 @@ func (historyTrade) Frame(date, code string, start, count uint16) (*Frame, error
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (historyTrade) Decode(bs []byte, c TradeCache) (*HistoryTradeResp, error) {
|
func (historyTrade) Decode(bs []byte, c TradeCache) (*TradeResp, error) {
|
||||||
if len(bs) < 2 {
|
if len(bs) < 2 {
|
||||||
return nil, errors.New("数据长度不足")
|
return nil, errors.New("数据长度不足")
|
||||||
}
|
}
|
||||||
@@ -41,7 +38,7 @@ func (historyTrade) Decode(bs []byte, c TradeCache) (*HistoryTradeResp, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := &HistoryTradeResp{
|
resp := &TradeResp{
|
||||||
Count: Uint16(bs[:2]),
|
Count: Uint16(bs[:2]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user