Is it possible to create a limit buy order in combination with a stoploss order, so that the stoploss is active as soon as the buy order gets triggered?
Unfortunately when I tried this, I got an error message saying I have no funds available (since the buy order hadn’t been triggered yet)
I looked at every api endpoint and the only 2 possibilities I see are
Market buy instead of limit buy
Limit buy, then check every few seconds if it was triggered (or using the websocket order update endpoint) and then create the stoploss order
I think I was able to do this the last time I used the futures API but it doesn’t seem to work for spot or margin…
As far as I understand, OCO orders are only useful for having a take profit and a stop loss simultaneously…
But what I want is to create a limit buy order with an included stop loss, without having to check if the limit buy order got triggered.
For example let’s say BTC is at 50k. I would like a limit buy order at 45k with a stop loss at 40k. But I can’t create the stop loss order until the limit buy gets triggered (since I have no BTC to sell yet), so I would have to check every few seconds if the buy limit order got filled and then open the stop loss order… I was hoping there is a simpler solution than that.
Unfortunately, there isn’t an endpoint that can satisfy your requirements. However, what you can do is make use of the User Data Stream(Binance API Documentation) to receive order updates and immediately place a stop loss order once you own the asset.