From fa232bfa15578e46d5de0d030bc4dc974ea98ee0 Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Tue, 16 Jun 2026 13:29:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(turnover):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8D=A2=E6=89=8B=E7=8E=87=E8=AE=A1=E7=AE=97=EF=BC=8CFloatShar?= =?UTF-8?q?es=20=E5=8D=95=E4=BD=8D=E6=98=AF=E4=B8=87=E8=82=A1=E9=9C=80?= =?UTF-8?q?=E9=99=A4=E4=BB=A5=2010000?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client_unified.go | 8 ++++---- client_unified_test.go | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client_unified.go b/client_unified.go index 0945eb4..9e6389b 100644 --- a/client_unified.go +++ b/client_unified.go @@ -1004,7 +1004,7 @@ func (client *Client) loadFloatSharesMap(qc *Client, keys []stockKey) map[stockK func applyTurnoverToSecurityQuotes(items []proto.SecurityQuote, shares map[stockKey]float64) { for i := range items { if floatShares := shares[stockKey{Market: items[i].Market, Code: items[i].Code}]; floatShares > 0 { - items[i].Turnover = round2(float64(items[i].Vol) * 10000 / floatShares) + items[i].Turnover = round2(float64(items[i].Vol) / floatShares) } } } @@ -1012,7 +1012,7 @@ func applyTurnoverToSecurityQuotes(items []proto.SecurityQuote, shares map[stock func applyTurnoverToQuoteList(items []proto.QuoteListItem, shares map[stockKey]float64) { for i := range items { if floatShares := shares[stockKey{Market: items[i].Market, Code: items[i].Code}]; floatShares > 0 { - items[i].Turnover = round2(float64(items[i].Vol) * 10000 / floatShares) + items[i].Turnover = round2(float64(items[i].Vol) / floatShares) } } } @@ -1022,7 +1022,7 @@ func applyTurnoverToBars(items []proto.SecurityBar, floatShares float64) { return } for i := range items { - items[i].Turnover = round2(items[i].Vol * 100 / floatShares) + items[i].Turnover = round2(items[i].Vol * 100 / (floatShares * 10000)) } } @@ -1030,7 +1030,7 @@ func applyTurnoverToVolumeProfile(reply *proto.GetVolumeProfileReply, floatShare if reply == nil || floatShares <= 0 { return } - reply.Turnover = round2(float64(reply.Vol) * 10000 / floatShares) + reply.Turnover = round2(float64(reply.Vol) / floatShares) } func round2(v float64) float64 { diff --git a/client_unified_test.go b/client_unified_test.go index ad9ba11..bb96ad9 100644 --- a/client_unified_test.go +++ b/client_unified_test.go @@ -77,42 +77,42 @@ func TestNewMACExUsesMacExAddressAsPrimary(t *testing.T) { func TestApplyTurnoverHelpers(t *testing.T) { shares := map[stockKey]float64{ - {Market: types.MarketSZ.Uint8(), Code: "000001"}: 1000000, + {Market: types.MarketSZ.Uint8(), Code: "000001"}: 100000, } quotes := []proto.SecurityQuote{{ Market: types.MarketSZ.Uint8(), Code: "000001", - Vol: 12345, + Vol: 100000, }} applyTurnoverToSecurityQuotes(quotes, shares) - if quotes[0].Turnover != 123.45 { + if quotes[0].Turnover != 1.0 { t.Fatalf("unexpected security quote turnover: %.2f", quotes[0].Turnover) } quoteList := []proto.QuoteListItem{{ Market: types.MarketSZ.Uint8(), Code: "000001", - Vol: 23456, + Vol: 150000, }} applyTurnoverToQuoteList(quoteList, shares) - if quoteList[0].Turnover != 234.56 { + if quoteList[0].Turnover != 1.5 { t.Fatalf("unexpected quote list turnover: %.2f", quoteList[0].Turnover) } - bars := []proto.SecurityBar{{Vol: 12345}} - applyTurnoverToBars(bars, 1000000) - if bars[0].Turnover != 1.23 { + bars := []proto.SecurityBar{{Vol: 2000000}} + applyTurnoverToBars(bars, 2000) + if bars[0].Turnover != 10.0 { t.Fatalf("unexpected bar turnover: %.2f", bars[0].Turnover) } reply := &proto.GetVolumeProfileReply{ Market: types.MarketSZ.Uint8(), Code: "000001", - Vol: 34567, + Vol: 200000, } - applyTurnoverToVolumeProfile(reply, 1000000) - if reply.Turnover != 345.67 { + applyTurnoverToVolumeProfile(reply, 100000) + if reply.Turnover != 2.0 { t.Fatalf("unexpected volume profile turnover: %.2f", reply.Turnover) } } From 3c000a7084c90d4c9e3ce5de48dc7c897fa943bc Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Sat, 20 Jun 2026 21:51:16 +0800 Subject: [PATCH 2/2] fix(StockKLine930): replace FullTransaction with single-page Transaction(start=0,count=1) to avoid looping all pages --- client_unified.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client_unified.go b/client_unified.go index eb508d8..0ebcb2a 100644 --- a/client_unified.go +++ b/client_unified.go @@ -157,7 +157,7 @@ func (client *Client) StockKLine930(category uint16, market uint8, code string, // 当前数据是不是当前交易日 data := proto.SecurityBar{} if cast.ToUint32(v.DateTime.Format("20060102")) == info.Date { - if trans, err := client.StockFullTransaction(market, code); err == nil { + if trans, err := client.StockTransaction(market, code, 0, 1); err == nil { data.Open = trans[0].Price data.High = trans[0].Price data.Low = trans[0].Price @@ -172,7 +172,7 @@ func (client *Client) StockKLine930(category uint16, market uint8, code string, list = append(list, data) } } else { - if trans, err := client.StockHistoryFullTransaction(cast.ToUint32(v.DateTime.Format("20060102")), market, code); err == nil { + if trans, err := client.StockHistoryTransaction(cast.ToUint32(v.DateTime.Format("20060102")), market, code, 0, 1); err == nil { // if len(trans) > 0 && trans[0].Time.Format(time.TimeOnly) < "09:30:00" { data.Open = trans[0].Price data.High = trans[0].Price