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 769 forks source link

Futures Order with type STOP_LOSS_LIMIT not working #833

Closed mikecheung closed 2 years ago

mikecheung commented 2 years ago

I am trying to create a futures STOP_LOSS_LIMIT order.

I have tried to do so with this code:

    tradeType = 'STOP_LOSS_LIMIT';
    options = {
      closePosition : true,
      stopPrice       : stopPrice,
      type                : tradeType,
      timeInForce   : 'GTC',
      priceProtect  : true,
    };

    if ( position.toLowerCase() === 'short' ) {
      orderRes = await binance.futuresBuy( symbol, trade_quantity, tradePrice, options );
    } else {
      orderRes = await binance.futuresSell( symbol, trade_quantity, tradePrice, options );
    }

Whenever I try this, i get the the error [Object: null prototype] { code: -1116, msg: 'Invalid orderType.' }

I have also tried to create it using binance.futuresMultipleOrders( orders ) and this has also returned an invalid orderType error.

Checking https://github.com/jaggedsoft/node-binance-api/blob/master/node-binance-api.js line 488, it does not seem to take STOP_LOSS_LIMIT as a order type for futures orders. Am I doing something wrong or have I hit a deadend?

mikecheung commented 2 years ago

Found my answer. Instead of STOP_LOSS_LIMIT, i have to just use STOP and specify a stopPrice. Also can't include closePosition in the call.