Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions exchanges/binance/binance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2721,31 +2721,37 @@ func TestUpdateOrderExecutionLimits(t *testing.T) {
require.NoError(t, e.UpdateOrderExecutionLimits(t.Context(), a), "UpdateOrderExecutionLimits must not error")
pairs, err := e.CurrencyPairs.GetPairs(a, false)
require.NoError(t, err, "GetPairs must not error")
l, err := e.GetOrderExecutionLimits(a, pairs[0])
require.NoError(t, err, "GetOrderExecutionLimits must not error")
assert.Positive(t, l.MinPrice, "MinPrice should be positive")
assert.Positive(t, l.MaxPrice, "MaxPrice should be positive")
assert.Positive(t, l.PriceStepIncrementSize, "PriceStepIncrementSize should be positive")
assert.Positive(t, l.MinimumBaseAmount, "MinimumBaseAmount should be positive")
assert.Positive(t, l.MaximumBaseAmount, "MaximumBaseAmount should be positive")
assert.Positive(t, l.AmountStepIncrementSize, "AmountStepIncrementSize should be positive")
assert.Positive(t, l.MarketMaxQty, "MarketMaxQty should be positive")
assert.Positive(t, l.MaxTotalOrders, "MaxTotalOrders should be positive")
switch a {
case asset.Spot, asset.Margin:
assert.Positive(t, l.MaxIcebergParts, "MaxIcebergParts should be positive")
case asset.USDTMarginedFutures:
assert.Positive(t, l.MinNotional, "MinNotional should be positive")
fallthrough
case asset.CoinMarginedFutures:
assert.Positive(t, l.MultiplierUp, "MultiplierUp should be positive")
assert.Positive(t, l.MultiplierDown, "MultiplierDown should be positive")
assert.Positive(t, l.MarketMinQty, "MarketMinQty should be positive")
assert.Positive(t, l.MarketStepIncrementSize, "MarketStepIncrementSize should be positive")
assert.Positive(t, l.MaxAlgoOrders, "MaxAlgoOrders should be positive")
for _, p := range pairs {
l, err := e.GetOrderExecutionLimits(a, p)
require.NoError(t, err, "GetOrderExecutionLimits must not error")
assert.Positive(t, l.MinPrice, "MinPrice should be positive")
assert.Positive(t, l.MaxPrice, "MaxPrice should be positive")
assert.Positive(t, l.PriceStepIncrementSize, "PriceStepIncrementSize should be positive")
assert.Positive(t, l.MinimumBaseAmount, "MinimumBaseAmount should be positive")
assert.Positive(t, l.MaximumBaseAmount, "MaximumBaseAmount should be positive")
assert.Positive(t, l.AmountStepIncrementSize, "AmountStepIncrementSize should be positive")
assert.Positive(t, l.MarketMaxQty, "MarketMaxQty should be positive")
assert.Positive(t, l.MaxTotalOrders, "MaxTotalOrders should be positive")
switch a {
case asset.Spot, asset.Margin:
assert.Positive(t, l.MaxIcebergParts, "MaxIcebergParts should be positive")
case asset.USDTMarginedFutures:
assert.Positive(t, l.MinNotional, "MinNotional should be positive")
fallthrough
case asset.CoinMarginedFutures:
assert.Positive(t, l.MultiplierUp, "MultiplierUp should be positive")
assert.Positive(t, l.MultiplierDown, "MultiplierDown should be positive")
assert.Positive(t, l.MarketMinQty, "MarketMinQty should be positive")
assert.Positive(t, l.MarketStepIncrementSize, "MarketStepIncrementSize should be positive")
assert.Positive(t, l.MaxAlgoOrders, "MaxAlgoOrders should be positive")
}
}
})
}
t.Run("unsupported asset", func(t *testing.T) {
t.Parallel()
require.ErrorIs(t, e.UpdateOrderExecutionLimits(t.Context(), asset.Binary), asset.ErrNotSupported)
})
}

func TestGetHistoricalFundingRates(t *testing.T) {
Expand Down
15 changes: 10 additions & 5 deletions exchanges/bitfinex/bitfinex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,24 @@ func TestUpdateTradablePairs(t *testing.T) {

func TestUpdateOrderExecutionLimits(t *testing.T) {
t.Parallel()
testexch.UpdatePairsOnce(t, e)
for _, a := range e.GetAssetTypes(false) {
t.Run(a.String(), func(t *testing.T) {
t.Parallel()
switch a {
case asset.Spot:
case asset.Spot, asset.Margin:
require.NoError(t, e.UpdateOrderExecutionLimits(t.Context(), a), "UpdateOrderExecutionLimits must not error")
pairs, err := e.CurrencyPairs.GetPairs(a, false)
require.NoError(t, err, "GetPairs must not error")
l, err := e.GetOrderExecutionLimits(a, pairs[0])
require.NoError(t, err, "GetOrderExecutionLimits must not error")
assert.Positive(t, l.MinimumBaseAmount, "MinimumBaseAmount should be positive")
for _, p := range pairs {
l, err := e.GetOrderExecutionLimits(a, p)
require.NoError(t, err, "GetOrderExecutionLimits must not error")
assert.Positive(t, l.MinimumBaseAmount, "MinimumBaseAmount should be positive")
}
case asset.MarginFunding:
require.ErrorIs(t, e.UpdateOrderExecutionLimits(t.Context(), a), asset.ErrNotSupported)
default:
require.ErrorIs(t, e.UpdateOrderExecutionLimits(t.Context(), a), common.ErrNotYetImplemented)
require.ErrorIs(t, e.UpdateOrderExecutionLimits(t.Context(), a), asset.ErrNotSupported)
}
})
}
Expand Down
21 changes: 15 additions & 6 deletions exchanges/bitfinex/bitfinex_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,26 @@ func (e *Exchange) UpdateTradablePairs(ctx context.Context) error {

// UpdateOrderExecutionLimits sets exchange execution order limits for an asset type
func (e *Exchange) UpdateOrderExecutionLimits(ctx context.Context, a asset.Item) error {
if a != asset.Spot {
return common.ErrNotYetImplemented
var queryAsset asset.Item
switch a {
case asset.Spot, asset.Margin:
// Bitfinex margin and spot trade the same markets and share limits.
queryAsset = asset.Spot
case asset.Futures:
queryAsset = asset.Futures
default:
return fmt.Errorf("%w %q", asset.ErrNotSupported, a)
}
l, err := e.GetSiteInfoConfigData(ctx, a)
l, err := e.GetSiteInfoConfigData(ctx, queryAsset)
if err != nil {
return err
}
if err := limits.Load(l); err != nil {
return fmt.Errorf("%s Error loading exchange limits: %v", e.Name, err)
if a != queryAsset {
for i := range l {
l[i].Key.Asset = a
}
}
return nil
return limits.Load(l)
}

// UpdateTickers updates the ticker for all currency pairs of a given asset type
Expand Down
13 changes: 10 additions & 3 deletions exchanges/bithumb/bithumb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,17 +545,24 @@ func TestGetHistoricTrades(t *testing.T) {

func TestUpdateOrderExecutionLimits(t *testing.T) {
t.Parallel()
testexch.UpdatePairsOnce(t, e)
for _, a := range e.GetAssetTypes(false) {
t.Run(a.String(), func(t *testing.T) {
t.Parallel()
require.NoError(t, e.UpdateOrderExecutionLimits(t.Context(), a), "UpdateOrderExecutionLimits must not error")
pairs, err := e.CurrencyPairs.GetPairs(a, false)
require.NoError(t, err, "GetPairs must not error")
l, err := e.GetOrderExecutionLimits(a, pairs[0])
require.NoError(t, err, "GetOrderExecutionLimits must not error")
assert.Positive(t, l.MinimumBaseAmount, "MinimumBaseAmount should be positive")
for _, p := range pairs {
l, err := e.GetOrderExecutionLimits(a, p)
require.NoError(t, err, "GetOrderExecutionLimits must not error")
assert.Positive(t, l.MinimumBaseAmount, "MinimumBaseAmount should be positive")
}
})
}
t.Run("unsupported asset", func(t *testing.T) {
t.Parallel()
require.ErrorIs(t, e.UpdateOrderExecutionLimits(t.Context(), asset.Binary), asset.ErrNotSupported)
})
}

func TestGetAmountMinimum(t *testing.T) {
Expand Down
24 changes: 24 additions & 0 deletions exchanges/bitmex/bitmex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,30 @@ func TestGetCurrencyTradeURL(t *testing.T) {
}
}

func TestUpdateOrderExecutionLimits(t *testing.T) {
t.Parallel()
testexch.UpdatePairsOnce(t, e)
for _, a := range e.GetAssetTypes(false) {
t.Run(a.String(), func(t *testing.T) {
t.Parallel()
err := e.UpdateOrderExecutionLimits(t.Context(), a)
require.NoError(t, err, "UpdateOrderExecutionLimits must not error")
pairs, err := e.CurrencyPairs.GetPairs(a, false)
require.NoError(t, err, "GetPairs must not error")
require.NotEmpty(t, pairs, "GetPairs must return pairs")
for _, p := range pairs {
l, err := e.GetOrderExecutionLimits(a, p)
require.NoError(t, err, "GetOrderExecutionLimits must not error")
assert.Positive(t, l.PriceStepIncrementSize, "PriceStepIncrementSize should be positive")
}
})
}
t.Run("unsupported asset", func(t *testing.T) {
t.Parallel()
require.ErrorIs(t, e.UpdateOrderExecutionLimits(t.Context(), asset.Binary), asset.ErrNotSupported)
})
}

func TestGenerateSubscriptions(t *testing.T) {
t.Parallel()

Expand Down
Loading
Loading