From 749373fbc42e7c214cb38393072a45b64c7a5b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E7=BA=AF=E5=87=80?= <1113655791@qq.com> Date: Wed, 30 Oct 2024 22:45:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index 4e0c14e..d61dd5f 100644 --- a/client.go +++ b/client.go @@ -234,12 +234,12 @@ func (this *Client) GetStockMinuteTradeAll(exchange protocol.Exchange, code stri resp := &protocol.StockMinuteTradeResp{} size := uint16(1800) for i := uint16(0); ; i += size { - r, err := this.GetStockMinuteTrade(exchange, code, i, i+size) + r, err := this.GetStockMinuteTrade(exchange, code, i, size) if err != nil { return nil, err } resp.Count += r.Count - resp.List = append(resp.List, r.List...) + resp.List = append(r.List, resp.List...) if r.Count < size { break @@ -269,7 +269,7 @@ func (this *Client) GetStockHistoryMinuteTradeAll(exchange protocol.Exchange, co resp := &protocol.StockMinuteTradeResp{} size := uint16(2000) for i := uint16(0); ; i += size { - r, err := this.GetStockMinuteTrade(exchange, code, i, i+size) + r, err := this.GetStockMinuteTrade(exchange, code, i, size) if err != nil { return nil, err } @@ -299,18 +299,25 @@ func (this *Client) GetStockKline(Type protocol.TypeKline, req *protocol.StockKl func (this *Client) GetStockKlineAll(Type protocol.TypeKline, exchange protocol.Exchange, code string) (*protocol.StockKlineResp, error) { resp := &protocol.StockKlineResp{} size := uint16(800) + var last *protocol.StockKline for i := uint16(0); ; i += size { r, err := this.GetStockKline(Type, &protocol.StockKlineReq{ Exchange: exchange, Code: code, Start: i, - Count: i + size, + Count: size, }) if err != nil { return nil, err } + if last != nil && len(r.List) > 0 { + last.Last = r.List[len(r.List)-1].Close + } + if len(r.List) > 0 { + last = r.List[0] + } resp.Count += r.Count - resp.List = append(resp.List, r.List...) + resp.List = append(r.List, resp.List...) if r.Count < size { break }