Files
gocryptotrader/exchanges/bitflyer/ratelimit.go
Ryan O'Hara-Reid f6a95da536 exchanges/request: abstract and consolidate rate limiting code to request package (#1477)
* 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>
2024-06-03 11:57:31 +10:00

29 lines
1.0 KiB
Go

package bitflyer
import (
"time"
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
)
// Exchange specific rate limit consts
const (
biflyerRateInterval = time.Minute * 5
bitflyerPrivateRequestRate = 500
bitflyerPrivateLowVolumeRequestRate = 100
bitflyerPrivateSendOrderRequestRate = 300
bitflyerPublicRequestRate = 500
)
// GetRateLimit returns the rate limit for the exchange
func GetRateLimit() request.RateLimitDefinitions {
return request.RateLimitDefinitions{
request.Auth: request.NewRateLimitWithWeight(biflyerRateInterval, bitflyerPrivateRequestRate, 1),
request.UnAuth: request.NewRateLimitWithWeight(biflyerRateInterval, bitflyerPublicRequestRate, 1),
// TODO: Below limits need to also take from auth rate limit. This
// can not yet be tested and verified so is left not done for now.
orders: request.NewRateLimitWithWeight(biflyerRateInterval, bitflyerPrivateSendOrderRequestRate, 1),
lowVolume: request.NewRateLimitWithWeight(time.Minute, bitflyerPrivateLowVolumeRequestRate, 1),
}
}