jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.58k stars 768 forks source link

Futures Short "Order would immediately trigger" #777

Closed cosmicdust471 closed 2 years ago

cosmicdust471 commented 2 years ago

I am trying to place a new SHORT trade on the futures market, and place a stop loss immediatly after.

Lets say the current price of BTCUSDT is 40.000

I place my inital SELL order at 40.000 like this:

await binance.futuresSell('BTCUSDT',0.001,40.000,{
    timeInForce: 'GTC'
})

Now I want to place a STOP LOSS order at 41.000, so I run:

await binance.futuresBuy('BTCUSDT',0.001,41000,{
    timeInForce: 'GTC',
    stopPrice: 41000,
    type: 'STOP'
}

Im expecting that when the price rises from 40.000 to 41.000 the BUY order would trigger. However I get the following message:

{
    code: -2021,
    msg: 'Order would immediately trigger.'
}

How do I place a stop loss for a SHORT?

neody commented 2 years ago

binance.futuresOrder('BUY', 'BTCUSDT', 0.001,41000, { type: 'STOP',side:'BUY',positionSide:'SHORT'})

/*
side : LIMIT
      MARKET
      STOP
      STOP_MARKET
      TAKE_PROFIT
      TAKE_PROFIT_MARKET
      TRAILING_STOP_MARKET
*/