mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +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>
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package deribit
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
|
|
)
|
|
|
|
const (
|
|
// Request rates per interval
|
|
minMatchingBurst = 100
|
|
nonMatchingRate = 20
|
|
portfoliMarginRate = 1
|
|
// Weightings
|
|
matchingWeight = 5
|
|
standardWeight = 1
|
|
// Rate limit keys
|
|
nonMatchingEPL request.EndpointLimit = iota
|
|
matchingEPL
|
|
portfolioMarginEPL
|
|
privatePortfolioMarginEPL
|
|
)
|
|
|
|
// GetRateLimits returns the rate limit for the exchange
|
|
func GetRateLimits() request.RateLimitDefinitions {
|
|
return request.RateLimitDefinitions{
|
|
nonMatchingEPL: request.GetRateLimiterWithWeight(request.NewRateLimit(time.Second, nonMatchingRate), standardWeight),
|
|
matchingEPL: request.GetRateLimiterWithWeight(request.NewRateLimit(time.Second, minMatchingBurst), matchingWeight),
|
|
portfolioMarginEPL: request.GetRateLimiterWithWeight(request.NewRateLimit(5*time.Second, portfoliMarginRate), standardWeight),
|
|
privatePortfolioMarginEPL: request.GetRateLimiterWithWeight(request.NewRateLimit(5*time.Second, portfoliMarginRate), standardWeight),
|
|
}
|
|
}
|