I've somewhat drawback, I exploit the https://fapi.binance.com base API for the Binance Futures, we've got a signal to open Lengthy position on BTCUSDT at 16485.853 entry goal, and place 5 Take Income orders at 16733.087, 16897.945, 17062.803, 17310.092, 17474.948, 17722.235 and Stop Loss at 50% with Leverage 20x. I acquire the tickSize for BTCUSDT is 'tickSize': 'zero.10' meaning for the worth parameter we will add after the comma simply 1 decimal, for example for the entry goal 16485.853 we will set the worth 16485.8. I gather the minQty for BTCUSDT is 'minQty': 'zero.001' meaning for the quantity parameter we will add after the comma simply three decimals, for example if i need to purchase BTCUSDT for 30$ with leverage 20x, the quantity is the same as 30 * 20 / 16485.853 = zero.0363948410798034 and we set the amount parameter to 0.036.
So, I start with 30$ at leverage 20x, I open a Long place on BTCUSDT at 16485.853 (16485.eight after transformed with tickSize) meaning i receive zero.0363948410798034 (0.036 after converted with minQty) quantity, this is the json for payload on the /fapi/v1/order endpoint:
After that I put the 5 Take Income orders and I would like every Take Revenue Order to have 20% of the amount so let's give instance of the first Take Profit, we now have zero.036 / 5 = zero.0072 (zero.007 after converted with minQty) for each of the Take Profit Order at 16733.087 (16733.0 after transformed to tickSize). For instance:
And the remainder of four Take Income shall be with the same amount at their worth.
After that I put the Cease Loss at 50% so, we now have to set the stopPrice and worth parameters, for that I exploit the entry goal 16485.853 * (1 - the stop loss % 50% for that we've zero.5 / leverage 20x). 16485.853 * (1 - 0.5 / 20) = 16073.706675 ( 16073.7 converted with the tickSize). For instance:
And now my drawback is :
Why after all the 5 Take Profit Orders completed I still have the Cease Loss Order lively and the BTCUSDT place lively? I feel as a result of:
0.036 / 5 take income = zero.0072 quantity per take profit but we will use simply 3 decimals and we set 0.007 quantity per take revenue but right here we stay 0.0002 quantity for every of take profit in complete we now have 0.0010 quantity remaining within the air and for that cause we nonetheless have the place opened because we still have zero.0010 quantity there and in addition the Stop Loss continues to be there.
And in addition in the other case if the Cease Loss is executed, the place is closed because i set the amount for the Stop Loss similar with the position quantity however the 5 Take Income continues to be there lively.
Why after all of the Take Income executed doesn't close the position and the Stop Loss order? And vice versa after the Cease Loss executed the place closed and we nonetheless have the Take Income?
How can I remedy this drawback?
Thanks verry much, Nameless Billionaires!