Hello,
How can i make an order (buy or sell) for 25% or 50% or 100%.
I can get the amount in fund i have but let's say im buying on NAVBTC then i need to enter the amount of NAV i want to buy i at this time and i don't know how many NAV coins are 50% of my BTC fund.
Hi @Fredrik81 there is no simple way to do this.
It helps if you're using BNB for fees as then you don't have to factor in fees into the coins your trading, well unless that includes BNB... Anyway it's generally recommended to use BNB to pay fees.
If you make a limit order then you know the price you want to buy or sell and then you just have to divide the relevant balance by that to get the quantity.
What if you want to place a market order? @sammchardy
Why do you have to ask the hard questions @sm00v :)
Ok, if you have a recent order book update and can place a market order very soon after receiving that order book update then you may be able to assume it will go through at the price you see.
If so then you follow the above, dividing your balance by the price to get a quantity.
There's no getting around having to send an actual quantity value, you can't send quantity "100%". If you think you should then you'll have to take it up with Binance!
Thanks @sammchardy
I got a little further so now i have done this:
truncate(MyBTCFund / BuyCoinPrice, 8)
That will get me the quantity of coins i can buy (100%) to buy but i totally missed the fee part so thanks i will add something for that aswell.
So i belive i have to reduce the the total amount of coins with the fee so there are some spare room for binance.
Where i strugle at the moment is adding the correct (just now) price.
At this time the market POEBTC is at 0.00001154 and when i enter that price it will fail. if i add 0.0000115 then it works but that will no go thru...
Any is this a API issue or am i doing it wrong?
Hi Fredrik81, have you tried to set at market in that moment as suggested by Sam?
Also how long after the price fetch are you placing the order?
You rock @sammchardy. Thanks for the timely response!
I might write something explaining how to do this, and how to make sure you're working within all the filters.
@sammchardy Did you end up writing a bit on the buy sell max amount? I keep runing into this problem myself and would appreciate some insight as to getting all the filters approved so I stop seeing this error
Thanks for your time
Were you guys ever able to implement this selling of a max amount in Python?
Following ^
I genuinely cannot believe Binance's oversight on this, especially with a market order. Do I really have to divide balance by price?
This is really frustrating. I have to round the buy and sell amounts with precision of 6.. but in Binance BTC has precision of 8. so even if I get the balance of a BTC and try to sell them I can't because I need to truncate my float to precision 6.
This is really frustrating. I have to round the buy and sell amounts with precision of 6.. but in Binance BTC has precision of 8. so even if I get the balance of a BTC and try to sell them I can't because I need to truncate my float to precision 6.
Yes had that issue, ended up using this little string formatting snippet amount = '{:.{}f}'.format(amount, precisions)
No you actually don’t need to do the calculation when it comes to market
orders . Check out quoteAssetQuantity. It allows you to put in your quote
asset balance and submit that as your buy order and it’ll do the
calculation for you. Only market orders
On Sun, Feb 21, 2021 at 10:38 AM hichiaty notifications@github.com wrote:
This is really frustrating. I have to round the buy and sell amounts with
precision of 6.. but in Binance BTC has precision of 8. so even if I get
the balance of a BTC and try to sell them I can't because I need to
truncate my float to precision 6.Yes had that issue, ended up using this little string formatting snippet amount
= '{:.{}f}'.format(amount, precisions)—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/sammchardy/python-binance/issues/89#issuecomment-782877220,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AOW3YCJT7TPA2SAGWNSYTFDTAESHTANCNFSM4EK2VORA
.
balanceBNB = client.get_asset_balance(asset='BNB')
TotalBNB=float(balanceBNB['free'])
round(((TotalBNB/Price) * 0,25),precision) #Buy/Sell 25% of a total
Most helpful comment
@sammchardy Did you end up writing a bit on the buy sell max amount? I keep runing into this problem myself and would appreciate some insight as to getting all the filters approved so I stop seeing this error
Thanks for your time