node-binance-api icon indicating copy to clipboard operation
node-binance-api copied to clipboard

Error on placing a futures limit order (msg: "Order's position side does not match user's setting.").

Open anaamnizami opened this issue 6 years ago • 4 comments

On placing the limit order, I get the following error, market order is working perfectly fine and I have tested all remaining end points, can you please explain, whats this issue. binance.futuresBuy ( 'BTCUSDT', 0.004, 6222 ) .then(result => console.log(result)) { code: -4061, msg: "Order's position side does not match user's setting." }

anaamnizami avatar Apr 15 '20 19:04 anaamnizami

In preference position was set to hedge, whereas default mode of futures api is one-way Mode, on selecting one-way Mode order was placed successfully. image

Although I could not find this status code in documentation, it would be nice to include it.

anaamnizami avatar Apr 16 '20 17:04 anaamnizami

I fixed this issue by adding options named hedgeMode. I only don't know how to add this to the repository. I am not familiar with the rule of this repo and actually this will be my first pull request, but as you might be able to see in pull request number #442 or this commit it is fixed. Notice that in order to use this you need to enable hedgeMode in your instantiation like this:

const binance = new Binance().options({
    APIKEY: "<api_key>",
    APISECRET: "<api_secret>",
    hedgeMode: true
  });

nimanr avatar Jun 07 '20 18:06 nimanr

Hello,got same issues when i use biance.futuresBuy(symbol,count,price) image

ChenYCL avatar Mar 01 '21 15:03 ChenYCL

although I've changed to hedge mode on binance site, the api endpoint was saying that I was not in hedge mode, so I've put this function to check if I was in hedge mode and if not to change it.

checkHedgeMode();

async function checkHedgeMode() {
  positionMode = await binance.futuresPositionSideDual().then(data => {
    if(!data.dualSidePosition) {
      console.log('not in hedge mode');
      changeHedgeMode();
    }
    else {
      console.log('in hedge mode');
    }
  }).catch((err) => console.log(err));
}

async function changeHedgeMode() {
  changeMode = await binance.futuresChangePositionSideDual(true).then(data => {
    console.log(data);
  }).catch((err) => console.log(err));
}

ronateds avatar Mar 11 '21 21:03 ronateds