Binance: Exchange Error {"code":-3028,"msg":"Not a valid margin pair."}
See original GitHub issueHi ccxt team!
I am getting constant {"code":-3028,"msg":"Not a valid margin pair."}
errors from Binance when executing market orders on them even tho I am using the ‘margin’ defaultType on initialization .
- OS: macOS
- Programming Language version: node 12.x
- CCXT version: ccxt@1.43.94
// init binance in margin mode
const binance = new ccxt.binance({
options: {
'defaultType': 'margin',
},
})
// fetch markets, with explicit refresh and explicit type
const allMarkets = await this.exchange.loadMarkets(true, {type: 'margin'})
// then I filter the markets to only give me margin=true pairs
const marginMarkets = markets.filter((m) => {
return m.active && m.margin && m.type === 'margin' && m.info.isMarginTradingAllowed
})
Even tho the filtered marginMarkets
now only contains pairs with margin: true
I still get the above mentioned error message from the exchange on some pairs.
Here is one of the pairs which are in marginMarkets
but should not be as they dont seem to be supported.
Also they do not show up in the Binance GET /sapi/v1/margin/allPairs
listing.
Notice how it has "isMarginTradingAllowed": true
, "margin": true
and "type": "margin"
set to indicate margin trading is allowed and possible.
// binance.markets["ENJ/BTC"]:
{
"limits": {
"amount": {
"min": 1,
"max": 90000000
},
"price": {
"min": 1e-8,
"max": 1000
},
"cost": {
"min": 0.0001
},
"market": {
"min": 0,
"max": 418478.30902778
}
},
"precision": {
"base": 8,
"quote": 8,
"amount": 0,
"price": 8
},
"tierBased": false,
"percentage": true,
"taker": 0.001,
"maker": 0.001,
"id": "ENJBTC",
"lowercaseId": "enjbtc",
"symbol": "ENJ/BTC",
"base": "ENJ",
"quote": "BTC",
"baseId": "ENJ",
"quoteId": "BTC",
"info": {
"symbol": "ENJBTC",
"status": "TRADING",
"baseAsset": "ENJ",
"baseAssetPrecision": 8,
"quoteAsset": "BTC",
"quotePrecision": 8,
"quoteAssetPrecision": 8,
"baseCommissionPrecision": 8,
"quoteCommissionPrecision": 8,
"orderTypes": ["LIMIT", "LIMIT_MAKER", "MARKET", "STOP_LOSS_LIMIT", "TAKE_PROFIT_LIMIT"],
"icebergAllowed": true,
"ocoAllowed": true,
"quoteOrderQtyMarketAllowed": true,
"isSpotTradingAllowed": true,
"isMarginTradingAllowed": true,
"filters": [{
"filterType": "PRICE_FILTER",
"minPrice": "0.00000001",
"maxPrice": "1000.00000000",
"tickSize": "0.00000001"
}, {
"filterType": "PERCENT_PRICE",
"multiplierUp": "5",
"multiplierDown": "0.2",
"avgPriceMins": 5
}, {
"filterType": "LOT_SIZE",
"minQty": "1.00000000",
"maxQty": "90000000.00000000",
"stepSize": "1.00000000"
}, {
"filterType": "MIN_NOTIONAL",
"minNotional": "0.00010000",
"applyToMarket": true,
"avgPriceMins": 5
}, {
"filterType": "ICEBERG_PARTS",
"limit": 10
}, {
"filterType": "MARKET_LOT_SIZE",
"minQty": "0.00000000",
"maxQty": "418478.30902778",
"stepSize": "0.00000000"
}, {
"filterType": "MAX_NUM_ORDERS",
"maxNumOrders": 200
}, {
"filterType": "MAX_NUM_ALGO_ORDERS",
"maxNumAlgoOrders": 5
}],
"permissions": ["SPOT", "MARGIN"]
},
"type": "margin",
"spot": false,
"margin": true,
"future": false,
"delivery": false,
"active": true
}
Executing a type MARKET trade on this pair results in the error mentioned above. The code works perfectly in all spot markets, so price and amount rounding issues are not the issue.
binance.createOrder(
order.symbol, // "ENJ/BTC"
order.type, // "MARKET"
order.side, // "buy"
order.amount, // 5
undefined,
{
sideEffectType: 'MARGIN_BUY' // enable auto-borrow
}
)
Does this problem arise from binance API delivering wrong results, by CCXT providing wrong data for market pairs or from my approach in getting margin-only markets? (I know, I could use the implicit method for sapi/v1/margin/allPairs
but I’d rather use the unified call - which should yield the same data)
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Small update:
I’ve checked the binance Website and API directly and it seems that, at least the above mentioned pair
ENJ/BTC
, does in fact allow margin trading, but only on isolated margin. I have not found any indication or differentiator via the API market data endpoint about this tho.@strikeout yes, that is possible, let me think a bit on how we can better unify this across the exchanges, i will be back to you shortly.