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 take profit and stop loss orders not working #754

Open marioanloru opened 3 years ago

marioanloru commented 3 years ago

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!

mr-smit commented 3 years ago

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
});
c0sm1cdus7 commented 2 years ago

@marioanloru did you manage to solve this?

marioanloru commented 2 years ago

@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

c0sm1cdus7 commented 2 years ago

Whats your Telegram?

MishiMish commented 2 years ago

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.

sAliSajjady commented 2 years ago

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.

caiowakamatsu commented 1 year ago

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