Closed tavindev closed 3 years ago
Hi, Pretty sure futuresMarketBuy/futuresMarketSell functionality requires you to calculate the absolute value. The official binance futures API does not accept percentage as input. https://binance-docs.github.io/apidocs/futures/en/#new-order-trade. The calculation of this value is not so straightforward, and will depend on the leverage bracket selected. Each leverage bracket (see futuresLeverageBracket) contains a notionalCap and notionalFloor values that can be used to determine the max size. Then you would take a percentage of that.
Hey @tonyth00, thank you for your response, but I have a question. I did some digging and came to this calculation:
balance * 0.05 * leverage / BTC Price (Best Bid or Best Ask)
What's the difference between the calculation you described and this one? I'm sorry if this is a stupid question, I have minimal knowledge about cryptos and trading. And one last thing, how would I do this in code? Is there any socket stream for this "leverage bracket" or do I need to make a request every time I place a trade, and should I multiply notionalCap or notionalFloor?
Hi,
If you adjust the leverage to 125x, notice that the maximum position is 50,000 USDT. This is the notionalCap
. So no matter how much money you have in your account, the maximum size will be this amount. You can increase position size by reducing your leverage to the next bracket (250,000 USDT at 100x).
futuresLeverageBracket
is a single request, you only need to call it once at initialization. It returns leverage brackets for all coins. Leverage brackets don't change very often. Once you have selected a leverage, you can access this object to get notionalCap
.
The formula you provided returns the number of BTC to buy. If this value exceeds notionalCap / BTC price
, the order will be rejected. In this case you might consider the minimum of the two values to make sure the order executes.
Ohh I get it :) Tysm for your help and the explanation @tonyth00, I'll close this issue now
I'm new to this API and I'm developing a bot for a customer.
He said to me to place orders with 5% of the balance. So should I calculate the 5% or does the Future API accept percentages? If I do need to calculate, how could I do it?
Thanks in advance