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

Futures take profit and stop loss orders not working

Open marioanloru opened this issue 4 years ago • 7 comments

I cannot find how to place a stop_loss and take_profit order for an open position in futures using node-binance-api.

I create my order using: await binance.futuresMarketSell( 'BTCUSDT', 1); // market price is 60000

And try to take profit as follows: await binance.futuresBuy( 'BTCUSDT', 1, 65000); And this for stop loss: await binance.futuresBuy( 'BTCUSDT', 1, 58000);

Using type: 'STOP_LOSS' as 4th param does not work and returns errors. Current approach creates orders in finance history with "EXPIRED", which lets the position open without take_profit neither stop_loss active.

Thanks for the help!

marioanloru avatar Nov 05 '21 18:11 marioanloru

all is working, my example:

to place buy limit

ret = await binance.futuresBuy(future_profit_obj.pair, future_profit_obj.bought_coins, current_price, {
  newClientOrderId: my_order_id_market,
  timeInForce: "GTC"
});

to place stop loss market

let ret2 = await binance.futuresMarketSell(future_profit_obj.pair, future_profit_obj.bought_coins, {
  newClientOrderId: my_order_id_sl,
  type: "STOP_MARKET",
  stopPrice: future_profit_obj.stop_loss_price,
  priceProtect: true 
});

to place take profit limit

let ret3 = await binance.futuresSell(future_profit_obj.pair, future_profit_obj.bought_coins, future_profit_obj.take_profit_price, {
	newClientOrderId: my_order_id_tp,
	stopPrice: future_profit_obj.take_profit_price,
	type: "TAKE_PROFIT",
	timeInForce: "GTC",
	priceProtect: true
});

mr-smit avatar Nov 07 '21 19:11 mr-smit

@marioanloru did you manage to solve this?

c0sm1cdus7 avatar Dec 17 '21 13:12 c0sm1cdus7

@franalt no I did not, I did try again and it somehow it did not work either, I have another version using the Binance python SDK which is the one I am finally using at least for now

marioanloru avatar Dec 20 '21 08:12 marioanloru

Whats your Telegram?

c0sm1cdus7 avatar Dec 20 '21 22:12 c0sm1cdus7

Whats your Telegram?

@TehRibbon

marioanloru avatar Dec 28 '21 08:12 marioanloru

Whats your Telegram?

Hey, could you help me as well with something? I'm trying to put stop loss and take profit on trade but can only do 1 of them.

MishiMish avatar Jan 05 '22 10:01 MishiMish

Yeah, I got to the exact same problem, I want to give stop loss and take profit at the same time but it just seems unavailable. If there is an answer please make it public.

sAliSajjady avatar Mar 04 '22 23:03 sAliSajjady

I am also having this issue, a solution would be greatly appreciated!

caiowakamatsu avatar Sep 14 '23 20:09 caiowakamatsu