How can I attach TP/SL to binance.futuresSell/buy

Hi,

I’m trying to build Binance Futures API on self project that I can buy/sell add tp/sl levergae…
every thing work perfect expect the Futures Limit Buy and sell , I trying to search every where but I couldn’t find the answer.

I’m using I’m using Node Binance API on this doc : https://www.npmjs.com/package/node-binance-api

this is the code :

async function onfuturesOrders() {

if (selectedSymbols.length > 0) {

selectedSymbols.forEach(async (symbol) => {

  // Futures Limit Buy/Sell

  if (side === 'BUY') {

    console.info(await binance.futuresBuy(symbol, 5000, investValue));

  } else {

    console.info(await binance.futuresSell(symbol, 20000, investValue));

  }

});

}

}

any idea how can I connect the tp/ls to this code. many time the code giving me errors

Refer to the Docs for creating a new Futures Order: Binance API Documentation

You need to adjust the order type to STOP/TAKE_PROFIT or STOP_MARKET/TAKE_PROFIT_MARKET depending if you want to place a limit or market order.

According to the JS library you’re using, you can set the parameters as shown in the screenshot (captured on the page you linked):

1 Like

first of all thank toy for your quick answer, I’m confused here in this API , What I have understand from the doc that I can use Tp or Sl for each order , I mean I can put the type: STOP or type:TAKE_PROFIT.
So if I choose type: TAKE_PROFIT it’s means that the stopPrice is the “take profit” value.
and if I choose type: STOP it’s means that the stopPrice is the “stop” value.

Dose the API works like that ? is there any way that I can gave the “symbole” a tp price and a sl price?

@Dubi_Avigeni - Yes you are correct. The stopPrice is dynamic and acts either the TP target price or SL trigger price based on what TYPE is used.

As for the second part of your question, I don’t quite understand. What do you mean exactly by giving the symbol a TP/SL price? Can you give some more context?

Thank you for your reply , I guess I’ve understand the problem , I just need to put two orders one with type: TAKE_PROFIT and anther one for type: STOP.

Thanks a lot again ,you’ve help me to understand hows its works.

in this case I have to send order like this :