bitcoinvsalts / node-binance-trader

💰 Cryptocurrency Trading Strategy & Portfolio Management Development Framework for Binance. đŸ€–
https://bitcoinvsalts.com
MIT License
1.17k stars 379 forks source link

No margin pair available for some coins #81

Closed 5queezer closed 3 years ago

5queezer commented 3 years ago

For some coins, the trader.js script fails to margin buy them. Since they are not available for margin trading, the script fails to trade with them. An example of such coins is MTLBTC and ENJBTC.

The error looks like this: ERROR 55555555555 ENJ 177 {"statusCode":500,"body":"{\"code\":-3027,\"msg\":\"Not a valid margin asset.\"}", ...

I made a pull request #80 for an automatic update of the margin pairs, but this doesn't solve the problem. In line 354 bnb_client.mgBorrow( the script should be checking if the pair is available as a margin buy/sell first.

dargmuesli commented 3 years ago

made a pull request #80 for an automatic update of the margin pairs, but this doesn't solve the problem

What problem does the PR solve then?

5queezer commented 3 years ago

The hardcoded  margin list was outdated. The PR should be a step in the right direction. Checking if a pair is available as a margin buy can be implemented at a later stage.

⁣BlueMail for Android herunterladen ​

Am 1. MĂ€rz 2021, 21:36, um 21:36, Jonas Thelemann notifications@github.com schrieb:

made a pull request #80 for an automatic update of the margin pairs, but this doesn't solve the problem

What problem does the PR solve then?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jsappme/node-binance-trader/issues/81#issuecomment-788554427

dargmuesli commented 3 years ago

Ok, gotcha. So why do margin trades still fail? You mention bnb_client.mgBorrow. Is it because the margin tradable pairs could be outdated again by when the trade is executed or what do you see there?

5queezer commented 3 years ago

Because some coins are not available for cross margin trading, such as ENJ or MTL. Opening a Long on them would be easy: buy them in the Spot wallet. But a Short on a coin you don't own would be only possible as an isolated margin or as a future. Both options are USDT paired, as far as I know.

⁣BlueMail for Android herunterladen ​

Am 2. MĂ€rz 2021, 14:49, um 14:49, Jonas Thelemann notifications@github.com schrieb:

Ok, gotcha. So why do margin trades still fail? You mention bnb_client.mgBorrow. Is it because the margin tradable pairs could be outdated again by when the trade is executed or what do you see there?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jsappme/node-binance-trader/issues/81#issuecomment-789205686

dargmuesli commented 3 years ago

Please excuse my confusion, but what's the difference between available margin pairs and coins available for cross margin trading? When we fetch the pairs, no matter what they're quoted against, that are available for margin trading, under which circumstances will there be an error?

5queezer commented 3 years ago

Please excuse my confusion, but what's the difference between available margin pairs and coins available for cross margin trading?

The script uses cross margin trading only. There's no difference between those two. There's also isolated margin, which is not used in our script.

When we fetch the pairs, no matter what they're quoted against, that are available for margin trading, under which circumstances will there be an error?

The error occurs when the signal from BVA contains a coin that is not available for cross margin trading.

For example, go to https://www.binance.com/en/my/wallet/account/margin and type into the search coin field ENJ, which you won’t find. Then go to isolated margin https://www.binance.com/en/my/wallet/account/margin/isolated and type ENJ again, and there you can find the coin.

dargmuesli commented 3 years ago

For example, go to https://www.binance.com/en/my/wallet/account/margin and type into the search coin field ENJ, which you won’t find. Then go to isolated margin https://www.binance.com/en/my/wallet/account/margin/isolated and type ENJ again, and there you can find the coin.

Ok, understood so far. But https://www.binance.com/gateway-api/v1/friendly/margin/symbols only returns margin symbols so if a symbol isn't included there, the script should already fall back to normal trading. But it doesn't for you and that's the error you experience?

5queezer commented 3 years ago

Obviously, the error affects short trades only that aren't in the margin pair list. Therefore a fallback to normal trading isn't possible. Possible workarounds: using futures or isolated margin.

dargmuesli commented 3 years ago

Ohh, we're talking about selling 😄 Well, I think we can exclude unsellable pairs from execution. I doubt that using isolated margin is a good choice for now, because you'd need to have funds there for every possibly tradable pair, don't we? At least for now. I currently don't have experience with future trading, so I can't say if that's currently a desired workaround. @jsappme that'd be your decision.