Open strikeout opened 3 years ago
@strikeout thx for your report, we will investigate and will be back to you asap.
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 thanks for pointing that out, it really helps save the time. Apparently, we can only throw an exception from the exchange at this point...
Can we maybe introduce a new property (array) or two (bools), like I did, to the market to indicate which "type" of margin is supported?
I'm now doing the following locally:
// fetch isolated margin pairs, sets .marginIso = true
let isos = await this.exchange.sapiGetMarginIsolatedAllPairs();
isos = isos.forEach((m) => {
const mm = this.exchange.markets_by_id[m.symbol];
this.exchange.markets[mm.symbol].marginIso = true
});
// fetch cross margin pairs, sets .marginCross = true
let cross = await this.exchange.sapiGetMarginAllPairs();
cross = cross.forEach((m) => {
const mm = this.exchange.markets_by_id[m.symbol];
this.exchange.markets[mm.symbol].marginCross = true
});
@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.
I am facing the same issue, can't distinguish between altcoins with leverage
@Piercarlomaia have you set your defaultType
to 'margin'
? Can you paste your versions, your code and your request+response output in verbose mode? https://github.com/ccxt/ccxt/wiki/FAQ#what-is-required-to-get-help
it's probably that the pair does not support cross margin, and is only tradable in isolated margin. Sadly been looking at ccxt and binanace API's to find out if the pair is cross margin or isolated with no luck.
there are official api endpoints for them, i.e.:
A) Get all marginable assets - https://binance-docs.github.io/apidocs/spot/en/#get-all-margin-assets-market_data , using ccxt you can call: data = binance.sapiGetMarginAllAssets();
B) Get all cross-margin pairs: https://binance-docs.github.io/apidocs/spot/en/#get-all-cross-margin-pairs-market_data , using ccxt you can call: data = binance.sapiGetMarginAllPairs();
C) Get all isoslated-margin pairs: https://binance-docs.github.io/apidocs/spot/en/#get-all-isolated-margin-symbol-user_data , using ccxt you can call: data = binance.sapiGetMarginIsolatedAllPairs();
let us know if you have any questions
Hi 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 .Even tho the filtered
marginMarkets
now only contains pairs withmargin: 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 BinanceGET /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.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.
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)