- ago
Hello, so auto-stage, auto-place and quotes and price signals is a great tool to buy and sell cryptocurrencies, but the problem I am having is that the software tries to match buy and sell orders.



It doesn't work and brings me "your account has insufficient balance to perform this action".

"Binance Broker: Error Placing Order: Account has insufficient balance for requested action." "Account has insufficient balance for requested action."

I went into detail as to why this could possibly happen, and I noticed that if you try to market sell and buy on binance, (at least at market buys and sells), there is always a tiny amount of balance that is left when attempting to sell the coin.





Because of this issue, I cannot use any auto-stage / auto-place orders, as the sells won't go through!

Is there any way to bypass this issue inside of software, so that the matching sell order tries to sell 99,99% of the bought shares?
1
725
Solved
15 Replies

Reply

Bookmark

Sort
- ago
#1
I believe the software does not take into account the fee of the broker.




In this case, I bought 10 shares of API3USDT, but after 0,1% fee, only 9,99 is availible. Strategy monitor tries to match the sell order, but the problem is, it cannot sell 10 shares, as 0,01 is missing. Is there an option to take fee into the account when placing the orders?

0
Glitch8
 ( 10.65% )
- ago
#2
You could try the Portfolio Sync Trading Preferences, there is an option to reduce the exit size to match your existing position.
0
- ago
#3
I will try to uncheck the "always set exit order quantity to full position quantity" and see what happens.
0
Cone8
 ( 4.72% )
- ago
#4
QUOTE:
is there is an option to reduce the exit size to match your existing position.
yes, but not after taking commission into account. Does Binance have a preference to take the fee from a cash balance?
0
- ago
#5
Binance takes the commission from the crypto coin that you trade. So if you limit buy 10 of "insertyourCoin", you will have 9,99 of "insertyourCoin" when the trade is done. It does not take extra usdt to make the transaction, rather, it takes away from the coins you bought.
0
- ago
#6
Portfolio sync did not work as expected, meaning exit orders cannot go through. i believe every binance user here has the same issue. It's something you can replicate.





The good thing is, I think all spot trades are 0,1 percent commission fee. But as it is, trigger and quotes window and autotrading is unusable for binance.
0
- ago
#7
Okay, so I went a bit further into this, I actually believe the problem is a bit more complicated, "Reduce size of exit orders to match position quantity" works just fine. it does seem to take into account the fee as it simply re-scans how much currency you have, so that's a non-issue.

The problem is, there is what's called "Dust"

https://www.binance.com/en/support/faq/how-to-convert-small-account-balance-to-bnb-360003012371

"Dust" is created every time a trade is made, but cannot be sold, only converted to BNB. But if you try to match the bought position with exit, I believe the amount of dust that's left prevents you from filling the order, because it has to stay there. I tried selling the ordes with same amount on binance, but the broker simply doesn't allow me to do it as it just rounds the value down.

provided are three examples of this happening on phone:





The workaround that could work is maybe rounding down after X decimal places? However the problem is that every cryptocurrency has different coin cost values...

0
- ago
#8
I have gone and attempted to replicate the problem with python-binance API script. I had the same issue there. I could not sell the same amount as I bought, even after compensating for fee.

Binance has what's so called "Step Size" for each currency trading pair, so I have gone and asked chatGPT4 about this issue, and successfully managed to fix the problem.




I basically bought the pairs that are provided here for 15 dollars, then use this script to sell them. It did so successfully. Before adding step size, it could not do so.

from binance.client import Client
import math

api_key = 'INSERT AP IKEY HERE'
api_secret = 'INSERT API SECRET HERE
'
client = Client(api_key, api_secret)

symbols_to_sell = ["1INCHUSDT", "AAVEUSDT", "ACHUSDT", "ADAUSDT", "AGIXUSDT", "ALGOUSDT", "ALICEUSDT"]

def truncate(number: float, decimals: int) -> float:
"""Truncate a float to the specified number of decimal places."""
factor = 10.0 ** decimals
return math.trunc(factor * number) / factor

for symbol in symbols_to_sell:
# Get account's balance for the specific asset
balance = client.get_asset_balance(asset=symbol[:-4])

# Get symbol info
symbol_info = client.get_symbol_info(symbol)

# Get step size (precision)
step_size_info = [f for f in symbol_info['filters'] if f['filterType'] == 'LOT_SIZE'][0]
step_size = float(step_size_info['stepSize'])
precision = int(-math.log10(step_size))

# Calculate sell quantity with correct precision
sell_quantity = truncate(float(balance['free']), precision)

try:
# Create a test order first
order = client.create_test_order(
symbol=symbol,
side=Client.SIDE_SELL,
type=Client.ORDER_TYPE_MARKET,
quantity=sell_quantity
)
print(f'Successfully created test order for {symbol}. Ready to sell {sell_quantity}.')

# Uncomment the following lines when you are ready to place actual sell order.
# order = client.order_market_sell(
# symbol=symbol,
# quantity=sell_quantity
# )
# print(f'Successfully sold {sell_quantity} of {symbol}')
except Exception as e:
print(f'Could not sell {symbol}. Error: {e}')
0
Cone8
 ( 4.72% )
- ago
#9
QUOTE:
if you limit buy 10 of "insertyourCoin", you will have 9,99 of "insertyourCoin" when the trade is done. It does not take extra usdt to make the transaction, rather, it takes away from the coins you bought.
Yes, but after the initial transaction, Portfolio Sync will use the 9,99.

Re: "Step Size"
Just check your Quotes tool image above. You can see that we're using the proper decimal sizes for each of the instruments. Some sizes have no decimals, others have 1, 2, and 3 (like PEPEUDST).

While I'm sure this is applied to sizing entry trades, I'll check to ensure that it's applied after synchronizing the Position to the portfolio for an exit trade.
0
Cone8
 ( 4.72% )
- ago
#10
Resolved. Here's what we'll change in the next build...

Currently, we're synching quantity to the full quantity precision reported by Binance (or any broker). We'll change that to truncate any part of the quantity that is beyond the "Quantity Decimals" for the crypto pair (it can change with respect to the base currency).

1. Portfolio Sync can then synchronize an exiting position at the precision required for the trade, which could leave some residual position that cannot be traded. (This might be good enough to cover the transaction cost.)

2. Like the VTHOUSDT position below, residual positions that don't have the required quantity to be traded will be completely ignored by WealthLab.

Here's our test account before and after the change, as reported by WealthLab's Accounts tool.



If the transaction cost really comes from the traded currency, but the entire position is exited, there's potential for a failure. We'll have to see how that scenario plays out.
1
- ago
#11
Thank you for checking out the issue!

One thing I wish to point out though, even though buy orders are now downsized to the according decimal per coin, what about sell/exit orders? Did you do the same for them aswell so that it rounds them down? Because after buying, you can still potentially get the long decimal numbers, as transaction fee is involved. For example, 0.003 can quickly become 0,002997 after the limit order (0,1% transaction fee) and if you try to sync portfolio with it, the sell/exit order will still most likely error out.
0
Cone8
 ( 4.72% )
- ago
#12
Entry orders are already sized to the proper quantity decimals (if there's evidence that's not happening, let me know).

What's demonstrated above is that a position like BTCUSDT with a size 0.00103197 will now "read in" to WealthLab with a size that conforms to the minimum order quantity decimals, e.g. 0.00001, so the previous size becomes 0.00103. You can trade that size. The 0.00000197 part is completely ignored by WealthLab.

Consequently, the full position to exit will sync to 0.00103, which you can trade. If you sell the 0.00103, WealthLab won't even show you that you have a residual position. Like the VTHOUSDT residual position, you'll only be able to see it in your Binance app(s).
1
- ago
#13
Thank you for the answer. By the way, is this something that's included in the next patch or is this something you can fix from server-side?
0
Cone8
 ( 4.72% )
- ago
#14
It'll be in Binance Build 24 with the next release round.
1
Best Answer
Cone8
 ( 4.72% )
- ago
#15
I'd like to hear some good news on this today. Binance Build 24 is ready.
0

Reply

Bookmark

Sort