mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
* initial consolidation of rate limiting code to request package to reduce bespoke code implementation * continued * finish abstraction * lint * exchanges: fix tests * linter: fix * poloniex: fix auth rate limit not being set * ratelimiter: convert from token to weight * glorious: nits addressed with fire * linter: rip * change func name set -> get * fix test * derbit: impl --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
43 lines
1.5 KiB
Go
43 lines
1.5 KiB
Go
package huobi
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
|
|
)
|
|
|
|
const (
|
|
// Huobi rate limits per API Key
|
|
huobiSpotRateInterval = time.Second * 1
|
|
huobiSpotRequestRate = 7
|
|
|
|
huobiFuturesRateInterval = time.Second * 3
|
|
huobiFuturesAuthRequestRate = 30
|
|
// Non market-request public interface rate
|
|
huobiFuturesUnAuthRequestRate = 60
|
|
huobiFuturesTransferRateInterval = time.Second * 3
|
|
huobiFuturesTransferReqRate = 10
|
|
|
|
huobiSwapRateInterval = time.Second * 3
|
|
huobiSwapAuthRequestRate = 30
|
|
huobiSwapUnauthRequestRate = 60
|
|
|
|
huobiFuturesAuth request.EndpointLimit = iota
|
|
huobiFuturesUnAuth
|
|
huobiFuturesTransfer
|
|
huobiSwapAuth
|
|
huobiSwapUnAuth
|
|
)
|
|
|
|
// GetRateLimit returns the rate limit for the exchange
|
|
func GetRateLimit() request.RateLimitDefinitions {
|
|
return request.RateLimitDefinitions{
|
|
request.Unset: request.NewRateLimitWithWeight(huobiSpotRateInterval, huobiSpotRequestRate, 1),
|
|
huobiFuturesAuth: request.NewRateLimitWithWeight(huobiFuturesRateInterval, huobiFuturesAuthRequestRate, 1),
|
|
huobiFuturesUnAuth: request.NewRateLimitWithWeight(huobiFuturesRateInterval, huobiFuturesUnAuthRequestRate, 1),
|
|
huobiSwapAuth: request.NewRateLimitWithWeight(huobiSwapRateInterval, huobiSwapAuthRequestRate, 1),
|
|
huobiSwapUnAuth: request.NewRateLimitWithWeight(huobiSwapRateInterval, huobiSwapUnauthRequestRate, 1),
|
|
huobiFuturesTransfer: request.NewRateLimitWithWeight(huobiFuturesTransferRateInterval, huobiFuturesTransferReqRate, 1),
|
|
}
|
|
}
|