From 2e17db7faf9f29bbbf1df2d98f4cd49b120a1f16 Mon Sep 17 00:00:00 2001 From: injoyai <1113655791@qq.com> Date: Tue, 8 Jul 2025 10:45:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0GetStockAll=E5=92=8CGetETFAll?= =?UTF-8?q?,=E7=94=A8=E4=BA=8E=E5=AE=9E=E6=97=B6=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/client.go b/client.go index 249dae3..e9556ad 100644 --- a/client.go +++ b/client.go @@ -233,6 +233,40 @@ func (this *Client) GetCodeAll(exchange protocol.Exchange) (*protocol.CodeResp, return resp, nil } +// GetStockAll 获取所有股票代码 +func (this *Client) GetStockAll() ([]string, error) { + ls := []string(nil) + for _, ex := range []protocol.Exchange{protocol.ExchangeSH, protocol.ExchangeSZ} { + resp, err := this.GetCodeAll(ex) + if err != nil { + return nil, err + } + for _, v := range resp.List { + if protocol.IsStock(v.Code) { + ls = append(ls, v.Code) + } + } + } + return ls, nil +} + +// GetETFAll 获取所有ETF代码 +func (this *Client) GetETFAll() ([]string, error) { + ls := []string(nil) + for _, ex := range []protocol.Exchange{protocol.ExchangeSH, protocol.ExchangeSZ} { + resp, err := this.GetCodeAll(ex) + if err != nil { + return nil, err + } + for _, v := range resp.List { + if protocol.IsETF(v.Code) { + ls = append(ls, v.Code) + } + } + } + return ls, nil +} + // GetQuote 获取盘口五档报价 func (this *Client) GetQuote(codes ...string) (protocol.QuotesResp, error) { for i := range codes {