mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
pkg/exchange: support GetFeeRates on bybit exchange
This commit is contained in:
parent
ace2c55a17
commit
0b03336fb0
|
@ -27,10 +27,10 @@ const (
|
|||
// https://bybit-exchange.github.io/docs/zh-TW/v5/rate-limit
|
||||
// sharedRateLimiter indicates that the API belongs to the public API.
|
||||
//
|
||||
// The default order limiter apply 3 requests per second and a 2 initial bucket
|
||||
// this includes QueryMarkets, QueryTicker, QueryAccountBalances
|
||||
// The default order limiter apply 5 requests per second and a 5 initial bucket
|
||||
// this includes QueryMarkets, QueryTicker, QueryAccountBalances, GetFeeRates
|
||||
var (
|
||||
sharedRateLimiter = rate.NewLimiter(rate.Every(time.Second/3), 2)
|
||||
sharedRateLimiter = rate.NewLimiter(rate.Every(time.Second/5), 5)
|
||||
tradeRateLimiter = rate.NewLimiter(rate.Every(time.Second/5), 5)
|
||||
orderRateLimiter = rate.NewLimiter(rate.Every(100*time.Millisecond), 10)
|
||||
closedOrderQueryLimiter = rate.NewLimiter(rate.Every(time.Second), 1)
|
||||
|
@ -490,6 +490,18 @@ func (e *Exchange) IsSupportedInterval(interval types.Interval) bool {
|
|||
return ok
|
||||
}
|
||||
|
||||
func (e *Exchange) GetFeeRates(ctx context.Context) (bybitapi.FeeRates, error) {
|
||||
if err := sharedRateLimiter.Wait(ctx); err != nil {
|
||||
return bybitapi.FeeRates{}, fmt.Errorf("query fee rate limiter wait error: %w", err)
|
||||
}
|
||||
feeRates, err := e.client.NewGetFeeRatesRequest().Do(ctx)
|
||||
if err != nil {
|
||||
return bybitapi.FeeRates{}, fmt.Errorf("failed to get fee rates, err: %w", err)
|
||||
}
|
||||
|
||||
return *feeRates, nil
|
||||
}
|
||||
|
||||
func (e *Exchange) NewStream() types.Stream {
|
||||
return NewStream(e.key, e.secret)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user