Futures market order bug / misunderstanding

Hello, I wrote a small program which takes care of some of the tasks that I’ve been doing manually. However I keep running into an issue which seems to be a bug, but it can very be caused by the fact that I don’t understand something in the API.

The problem is that I’m trying to place some sell orders on the delivery market. To do this, I’m calculating how many contracts can I short based on the price of the underlying tokens and the contract size. Even though most of the times this works just perfectly, sometimes I get a “Margin is insufficient” (-2019) error.
To check if this is an actual bug in my code, I’ve logged in to the web interface of binance, and tried to make a short from there (the only difference is that here I typed in the exact number of tokens that I had on my futures account, since binance can calculate the number of contracts from this). The strangest thing is that I got the same error, even though I manually typed in the number of tokens, and I’ve double checked if the value was right.

Could someone help me with this issue, please?

Hi @szabolcs,

On the website you should see “Cost” to know how much it will cost you and you can compare that with “Avbl” shown in the same section to make sure you indeed have enough balance to short.
If you still have questions, it might be better to reach out to CS since we don’t have permission to know your account details here and this seems to be not only API based.

Thanks for your response @aisling. That is what I did, I made sure that the Avbl is equals to what I typed in to the input field too. I actually hoped that there’s some extra math which I didn’t know about.

I am getting “Margin is insufficient” (-2019) error, event i have enough funds. I am getting this error when i am using around 80%to 90% of my wallet balance to make order, and i am not getting any issue when i am using small percent like around 70% and below.

please help me