mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
adjust rate limiter
This commit is contained in:
parent
e869e04092
commit
26c128b3ab
|
@ -17,7 +17,7 @@ func (e ExchangeBatchProcessor) BatchQueryClosedOrders(ctx context.Context, symb
|
|||
errC = make(chan error, 1)
|
||||
|
||||
go func() {
|
||||
limiter := rate.NewLimiter(rate.Every(time.Minute), 45)
|
||||
limiter := rate.NewLimiter(rate.Every(5*time.Second), 2) // from binance (original 1200, use 1000 for safety)
|
||||
|
||||
defer close(c)
|
||||
defer close(errC)
|
||||
|
@ -67,7 +67,7 @@ func (e ExchangeBatchProcessor) BatchQueryKLines(ctx context.Context, symbol str
|
|||
errC = make(chan error, 1)
|
||||
|
||||
go func() {
|
||||
limiter := rate.NewLimiter(rate.Every(time.Minute), 45)
|
||||
limiter := rate.NewLimiter(rate.Every(5*time.Second), 2) // from binance (original 1200, use 1000 for safety)
|
||||
|
||||
defer close(c)
|
||||
defer close(errC)
|
||||
|
@ -123,11 +123,16 @@ func (e ExchangeBatchProcessor) BatchQueryTrades(ctx context.Context, symbol str
|
|||
var lastTradeID = options.LastTradeID
|
||||
|
||||
go func() {
|
||||
limiter := rate.NewLimiter(rate.Every(5*time.Second), 2) // from binance (original 1200, use 1000 for safety)
|
||||
|
||||
defer close(c)
|
||||
defer close(errC)
|
||||
|
||||
for {
|
||||
time.Sleep(5 * time.Second)
|
||||
if err := limiter.Wait(ctx); err != nil {
|
||||
logrus.WithError(err).Error("rate limit error")
|
||||
}
|
||||
|
||||
logrus.Infof("querying %s trades from %s, limit=%d", symbol, startTime, options.Limit)
|
||||
|
||||
trades, err := e.QueryTrades(ctx, symbol, &TradeQueryOptions{
|
||||
|
|
Loading…
Reference in New Issue
Block a user