From b611a42bd9d68537249bf2679b51ef22edb75e84 Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 3 May 2022 12:11:02 +0800 Subject: [PATCH] kucoin: fix kucoin rate limit --- pkg/exchange/kucoin/exchange.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/exchange/kucoin/exchange.go b/pkg/exchange/kucoin/exchange.go index 0310affab..c6451e9bd 100644 --- a/pkg/exchange/kucoin/exchange.go +++ b/pkg/exchange/kucoin/exchange.go @@ -17,7 +17,7 @@ import ( "github.com/c9s/bbgo/pkg/types" ) -var marketDataLimiter = rate.NewLimiter(rate.Every(1*time.Second), 1) +var marketDataLimiter = rate.NewLimiter(rate.Every(5*time.Second), 1) var queryTradeLimiter = rate.NewLimiter(rate.Every(5*time.Second), 1) var queryOrderLimiter = rate.NewLimiter(rate.Every(5*time.Second), 1) @@ -160,7 +160,9 @@ func (e *Exchange) IsSupportedInterval(interval types.Interval) bool { } func (e *Exchange) QueryKLines(ctx context.Context, symbol string, interval types.Interval, options types.KLineQueryOptions) ([]types.KLine, error) { - _ = marketDataLimiter.Wait(ctx) + if err := marketDataLimiter.Wait(ctx); err != nil { + return nil, err + } req := e.client.MarketDataService.NewGetKLinesRequest() req.Symbol(toLocalSymbol(symbol))