mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-16 07:26:47 +00:00
* BTSE: bump API version to 3.2 * BTSE: added AccountFee endpoint * BTSE: ratelimit, modified GetFee() to use GetFeeInformation, CreateWalletAddress support * BTSE: gofmt * BTSE: renamed ratelimits to ratelimit * BTSE: comments on exported methods, reworked const * BTSE: remove verbose * BTSE: increased test coverage * BTSE: removed futures test * BTSE: comments, correct types, moon * Add support for futures ticker/orderbook, pass data from OHLCV to append because data is important :D * BTSE: update futures test pair * BTSE: updated creatorder test to use negative numbers * BTSE: updated test wording * BTSE: no BTSEx anymore * BTSE: use GetEnabledPairs * BTSE: updated order structu * BTSE: goimport test package * BTSE: added orderIntToType method * BTSE: added extra params to Trade/OpenOrders, kline format method added * BTSE: CreateOrder and IndexOrderPeg updates * removed binary * BTSE: type fixes for orderid, comments * BTSE: remove float tos tring conversion correct casing * BTSE: updated return types * BTSE: return slice * BTSE: update type to string, fixed comment on Price(), removed verbose flag * BTSE: use FormatExchangeCurrency() * BTSE: status -> string * BTSE: added withinLimit method to confirm order is within valid limits * BTSE: gofmt * BTSE: updated comment * BTSE: comment update * BTSE: init map for cancelallexcahgneorders * BTSE: updated json structs for trade history, reworked withinlimits and ordersizelimits to use sync.map * BTSE: test other currencies to confirm matching values for incerement * BTSE: comment, changed type * BTSE: added ordersizelimits seed data to test * BTSE: fpair -> fPair naming & kline sort update * BTSE: removed format call & asset param from withinLimits * BTSE: range over pairs for active orders * BTSE: verbose removal pass * BTSE: ticker batching support * BTSE: remove old pair formatter
43 lines
891 B
Go
43 lines
891 B
Go
package btse
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
|
|
"golang.org/x/time/rate"
|
|
)
|
|
|
|
const (
|
|
btseRateInterval = time.Second
|
|
btseQueryLimit = 15
|
|
btseOrdersLimit = 75
|
|
|
|
queryFunc request.EndpointLimit = iota
|
|
orderFunc
|
|
)
|
|
|
|
// RateLimit implements the request.Limiter interface
|
|
type RateLimit struct {
|
|
Query *rate.Limiter
|
|
Orders *rate.Limiter
|
|
}
|
|
|
|
// Limit executes rate limiting functionality for exchange
|
|
func (r *RateLimit) Limit(f request.EndpointLimit) error {
|
|
switch f {
|
|
case orderFunc:
|
|
time.Sleep(r.Orders.Reserve().Delay())
|
|
default:
|
|
time.Sleep(r.Query.Reserve().Delay())
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetRateLimit returns the rate limit for the exchange
|
|
func SetRateLimit() *RateLimit {
|
|
return &RateLimit{
|
|
Orders: request.NewRateLimit(btseRateInterval, btseOrdersLimit),
|
|
Query: request.NewRateLimit(btseRateInterval, btseQueryLimit),
|
|
}
|
|
}
|