Stop loss limit OCO order executed and filled before price reach stopLimitPrice

Hello everyone.

I placed a buy order at market price and subsequently placed an OCO order to limit profit and loss.
The problem I encounter is that the stop loss order has been executed before reaching the stopLimitPrice.
I need your help to know if I am doing something wrong or if there is a reason why this is happening.
I attach the information of the respective orders and an image to exemplify the behavior, thank you very much.
Screenshot_24

Buy Order:
{
“symbol”: “BNBUSDT”,
“orderId”: 1596668,
“orderListId”: -1,
“clientOrderId”: “4HRuc7G8sy4y0LBZi0Il5L”,
“price”: “297.30000000”,
“origQty”: “0.29000000”,
“executedQty”: “0.29000000”,
“cummulativeQuoteQty”: “86.15900000”,
“status”: “FILLED”,
“timeInForce”: “IOC”,
“type”: “LIMIT”,
“side”: “BUY”,
“stopPrice”: “0.00000000”,
“icebergQty”: “0.00000000”,
“time”: 1668146408958,
“updateTime”: 1668146408958,
“isWorking”: true,
“origQuoteOrderQty”: “0.00000000”
},

Both orders from OCO:
{
“symbol”: “BNBUSDT”,
“orderId”: 1596724,
“orderListId”: 4572,
“clientOrderId”: “1FHWGqDa7HLIahCNxopoYB”,
“price”: “289.95000000”,
“origQty”: “0.28000000”,
“executedQty”: “0.28000000”,
“cummulativeQuoteQty”: “81.18600000”,
“status”: “FILLED”,
“timeInForce”: “GTC”,
“type”: “STOP_LOSS_LIMIT”,
“side”: “SELL”,
“stopPrice”: “289.90000000”,
“icebergQty”: “0.00000000”,
“time”: 1668146431330,
“updateTime”: 1668167212069,
“isWorking”: true,
“origQuoteOrderQty”: “0.00000000”
},

{
    "symbol": "BNBUSDT",
    "orderId": 1596725,
    "orderListId": 4572,
    "clientOrderId": "m3HF7CBW4Z0kon1hcqcOOk",
    "price": "312.10000000",
    "origQty": "0.28000000",
    "executedQty": "0.00000000",
    "cummulativeQuoteQty": "0.00000000",
    "status": "EXPIRED",
    "timeInForce": "GTC",
    "type": "LIMIT_MAKER",
    "side": "SELL",
    "stopPrice": "0.00000000",
    "icebergQty": "0.00000000",
    "time": 1668146431330,
    "updateTime": 1668167211105,
    "isWorking": true,
    "origQuoteOrderQty": "0.00000000"
}

It appears these orders were placed on spot test network, right?

Test network is completely separate from the main exchange. There are bots that place the orders with similar prices, but the price can fluctuate wildly on the testnet.

For example, during the 1668420046000–1668420047999 interval the lowest price was 101.80 and the highest was 282.60 on the test network. That could very well have triggered your OCO.

curl https://testnet.binance.vision/api/v3/klines?symbol=BNBUSDT&interval=1s&startTime=1668420046000&endTime=1668420047999 | jq

(endpoint docs)

1 Like

Yes, my orders are in spot testnet.

I thought testnet used mainnet prices. But if the prices are independent on both networks, that explains everything.
Thank you very much for your clear explanation and help!

Hello, how are you analysing the STOP_LOSS_LIMIT order being executed before reaching the stopPrice?

{
“symbol”: “BNBUSDT”,
“orderId”: 1596724,
“orderListId”: 4572,
“clientOrderId”: “1FHWGqDa7HLIahCNxopoYB”,
“price”: “289.95000000”,
“origQty”: “0.28000000”,
“executedQty”: “0.28000000”,
“cummulativeQuoteQty”: “81.18600000”,
“status”: “FILLED”,
“timeInForce”: “GTC”,
“type”: “STOP_LOSS_LIMIT”,
“side”: “SELL”,
“stopPrice”: “289.90000000”,
“icebergQty”: “0.00000000”,
“time”: 1668146431330,
“updateTime”: 1668167212069,
“isWorking”: true,
“origQuoteOrderQty”: “0.00000000”
},

You can refer to websocket user data stream to get an event for when your order status is updated.

Through postman, using the “Current Active Orders” endpoint (which returns an empty array since one of the two OCO orders was completed and the other expired).
To get the details I use the get endpoint “All Orders”.

Here is another example from few hours ago, same scenario.
The stop loss limit order was executed 2 hours after its creation but as of this writing, the price of the pair has not reached the stopPrice indicated in the order yet.

Maybe I am generating the OCO in the wrong way?

BUY ORDER:
{
“symbol”: “BNBUSDT”,
“orderId”: 2078876,
“orderListId”: -1,
“clientOrderId”: “mYaG0iveMOgbMtZ0yVpp1Y”,
“price”: “279.50000000”,
“origQty”: “0.31000000”,
“executedQty”: “0.31000000”,
“cummulativeQuoteQty”: “86.61400000”,
“status”: “FILLED”,
“timeInForce”: “IOC”,
“type”: “LIMIT”,
“side”: “BUY”,
“stopPrice”: “0.00000000”,
“icebergQty”: “0.00000000”,
“time”: 1668409209522,
“updateTime”: 1668409209522,
“isWorking”: true,
“origQuoteOrderQty”: “0.00000000”
},

OCO Orders:
{
“symbol”: “BNBUSDT”,
“orderId”: 2088892,
“orderListId”: 6170,
“clientOrderId”: “lFz2rWvQd3kEwdB1Ewq44V”,
“price”: “268.05000000”,
“origQty”: “0.30000000”,
“executedQty”: “0.30000000”,
“cummulativeQuoteQty”: “80.41500000”,
“status”: “FILLED”,
“timeInForce”: “GTC”,
“type”: “STOP_LOSS_LIMIT”,
“side”: “SELL”,
“stopPrice”: “268.00000000”,
“icebergQty”: “0.00000000”,
“time”: 1668412810956,
“updateTime”: 1668420047528,
“isWorking”: true,
“origQuoteOrderQty”: “0.00000000”
},
{
“symbol”: “BNBUSDT”,
“orderId”: 2088893,
“orderListId”: 6170,
“clientOrderId”: “dRD3MGhEKAM4vRIUxYdW6n”,
“price”: “302.50000000”,
“origQty”: “0.30000000”,
“executedQty”: “0.00000000”,
“cummulativeQuoteQty”: “0.00000000”,
“status”: “EXPIRED”,
“timeInForce”: “GTC”,
“type”: “LIMIT_MAKER”,
“side”: “SELL”,
“stopPrice”: “0.00000000”,
“icebergQty”: “0.00000000”,
“time”: 1668412810956,
“updateTime”: 1668420046759,
“isWorking”: true,
“origQuoteOrderQty”: “0.00000000”
}