binance-api-node
binance-api-node copied to clipboard
How to create valid takeprofit and stoploss in futures?
I am writing a trading bot, but faced with such a problem that my stoploss and takeprofit by binance itself for the reason: "Expired", no time limits I do not set. Most likely I create the order incorrectly, so I want to ask how to do it correctly? At the moment I create them one by one all together like this:
` const order = await this.client.futuresOrder({
type: "STOP",
price: this.formatByPrecision(orderPrice, pricePrecision),
symbol: pair.ticker,
stopPrice: enterStopPrice,
quantity,
side: logSide,
priceProtect: "TRUE",
});
await this.client.futuresOrder({
type: "STOP_MARKET",
stopPrice: loseStopPrice,
symbol: pair.ticker,
side: leaveSide,
closePosition: "true",
});
await this.client.futuresOrder({
type: "TAKE_PROFIT",
stopPrice: this.formatByPrecision(tp + cf, pricePrecision),
quantity,
price: this.formatByPrecision(tp, pricePrecision),
symbol: pair.ticker,
side: leaveSide,
});`
The model of work of these orders is as follows, for example, I want to open a buy transaction on the coin "AAAUSDT", the entry point I assign the price of 101, calculate take profit at the price of 105, and stop loss at the price of 100. I need that there was no slippage, so I want all these orders triggered immediately when entering the transaction, what am I doing wrong?
After opening a trade binance closes my stoplosses and takeprofits, thus I do not control my losses. Who can help me how to place such orders correctly?