Closed francoasc closed 2 years ago
I have the same problem
@Jaabg6 You can use the reduceOnly parameter when opening or closing a position and that would do the trick
I have a problem, I use the binance futures testnet, and I can't open a position with reduce Only, but I can use it to close it.
In the event that I am in a Long, and I want to close the position, do I have to use two shorts? one with reduce Only and another normal?😅 my only problem is that, when closing trades, there should be an api function that closes all positions, just like it is on the binance website
I don't know how to close all the positions at the same time but that would be really useful, So if you are in a long position and you wanna close it you can apply this code to your case
if (trade.marketPosition === 'long') {
await binance.futuresMarketSell(
trade.token,
trade.tokenQuantity,
{ reduceOnly: true }
)
} else if (trade.marketPosition === 'short') {
await binance.futuresMarketBuy(
trade.token,
trade.tokenQuantity,
{ reduceOnly: true }
)
}
In the first case you want to close your long position, to do that you need the token that you used to open the long that could be "BTCUSDT", the second parameter would be the tokenQuantity that you bought for the position that it can also be a string "0.231" and obviously the reduceOnly: true
as a third parameter so Binance knows that you want to close your short/long.
The same applies for a short position but insted of using binance.futuresMarketSell
you use binance.futuresMarketBuy
hope this help you with your issue :smile:
The only option available I've seen is to cancel an order but not to close an order