I want to set up a spread on perpetuals using API and I don’t know if it is possible and how. Lets use an example to clarify.
Lets say that the market price is 100. If the market reaches 140 I want to be triggered the order 1, which is a BUY. Then, I want to set up order 2, which is a LIMIT SELL at 160, for profit taking, and order 3, which is a STOP LIMIT SELL at 120 for stop loss.
The point is that the 3 orders should be posted together in advance.
The orders 1 and 2 its OK, no problem. However, the number 3, if I post it as limit, it will be executed BEFORE the number 1. And if I post it as STOP LIMIT, it will be triggered TOGETHER with the number 1.
So, is there any way to do that, even combining other parameters and modes of the endpoint? Maybe not.
(In stocks and forex markets almost everybody has a way to do that, for instance, Interactive Brokers you will post a unique STOP LIMIT ORDER at 140, that includes also the TP and SL.)
I appreciate and thanks in advance any help.
If the market reaches 140 I want to be triggered the order 1, which is a BUY.
Order 1 is a STOP LOSS BUY order which can be placed at any point in time.
Then, I want to set up order 2, which is a LIMIT SELL at 160, for profit taking
Order 2 is a TAKE PROFIT SELL order which should be placed when Order 1 is filled.
and order 3, which is a STOP LIMIT SELL at 120 for stop loss.
Order 3 is a STOP LOSS LIMIT SELL order which should be placed when Order 1 is filled.
Therefore, you should first place order 1 via the API, listen to order changes via the websocket user data stream and place order 2 & 3 when order 1 is FILLED.
An example of the above can be found in this thread