how to fix: code: -2019, msg: 'Margin is insufficient.'

I am trying to open a simple short position on coin-m futures.
I am using node-binance-api for this
I read this margin_insufficient however in my case initialMargin + orderMargin != marginBalance

Here’s the code:

const Binance = require('node-binance-api');

const binance = new Binance().options({
APIKEY: 'some api key',
APISECRET: 'some secrets',
'family': 4,

let temp = async () => {
// await binance.universalTransfer("MAIN_CMFUTURE","XRP",10) ); binance.deliveryMarginType("XRPUSD_PERP", "CROSSED")); binance.deliveryLeverage("XRPUSD_PERP", 1)); binance.deliveryMarketSell("XRPUSD_PERP", 70, { positionSide: "SHORT"}));


I have also checked the balance, here is the result:

[Object: null prototype] { 
     asset: 'XRP', 
     walletBalance: '104.91600000', 
     unrealizedProfit: '0.00000000', 
     marginBalance: '104.91600000', 
     maintMargin: '0.00000000', 
     initialMargin: '0.00000000', 
     positionInitialMargin: '0.00000000', 
     openOrderInitialMargin: '0.00000000', 
     maxWithdrawAmount: '104.91600000', 
     crossWalletBalance: '104.91600000', 
     crossUnPnl: '0.00000000', 
     availableBalance: '104.91600000', 
     updateTime: 1696236724456 

Not sure why the margin insufficient. How can i fix this error?

The quantity is measured by contract amount. I see you’re sending Short Position with quantity=70, and knowing 1 contract = 10 USD, the cost in settling coin XRP, is probably way above your XRP margin balance.

is there any way to put in amount as plain USDT or do i just need to convert the current coin price to usdt amount?

Talked with binance customer support, the only way (from the api, not ui) is to specify the quantity measured by contract amount.