explanition of “margin is insufficient“

Hi!

I’m facing the same problem, getting error:
{"code":-2019,msg:"Margin is insufficient."}.

I do understand the following:

When placing a market (buy) order, we set the quantity of the symbol we want to buy, not the amount of USDT we want to “spend”. During high market volatility, when price changes fast, it is easy to miscalculate the quantity we can buy. Example:
I have 120 USDT in my balance. I want to buy $XYZ coin (with 10x leverage) which price was 0.3 USDT the last time my script checked. This means with leverage I can use 120x10=1200 USDT for the trade meaning that I can buy 1200/0.3=4000 XYZ. The problem is that if I send the market buy order for 4000 XYZ (trying to use 100% of my balance), and the price increased only just a little bit (for example to 0.301) this means that the 4000 XYZ coin will cost 4000x0.301=1204 USDT - which (with 10x leverage) would require 1204/10=120.4 USDT in my balance and this way it will result in a “Margin is insufficient” error.

Because of this I edited my algorithm to use only 75% of my balance, but I STILL got the “Margin is insufficient” error. In my case I’ve checked the price of the coin in a 1 second(!) chart and even if the price spiked, using only 75% of my balance for the calculations, the order should have been successful. I also tested my algorithm in a non volatile market, and the order was successful every single time, so the problem is NOT with my algorithm.

Really looking for a solution!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值