I now got it working through the UI (using the TP/SL checkbox). But still no success using the API, so I’m 99% sure this is unwanted behaviour.
This is my api request:
val endpoint = "/sapi/v1/margin/order/otoco"
val parameters = mutableMapOf(
"symbol" to "OMUSDT",
"isIsolated" to "FALSE",
"sideEffectType" to "MARGIN_BUY",
//working
"workingType" to "LIMIT",
"workingSide" to "SELL",
"workingPrice" to "6.2",
"workingQuantity" to "2",
"workingTimeInForce" to "GTC",
//pending
"pendingSide" to "BUY",
"pendingQuantity" to "2",
//sl
"pendingAboveType" to "STOP_LOSS",
"pendingAboveStopPrice" to "9",
//tp
"pendingBelowType" to "LIMIT_MAKER",
"pendingBelowPrice" to "3"
)
This is the fetch request from the UI:
fetch("https://www.binance.com/bapi/margin/v1/private/margin/place-order", {
...
"body": "{\"side\":\"SELL\",\"symbol\":\"OMUSDT\",\"quantity\":\"2\",\"price\":\"6.2\",\"type\":\"LIMIT\",\"timeInForce\":\"GTC\",\"stopType\":\"MARKET\",\"sideEffectType\":\"MARGIN_BUY\",\"spOrderType\":\"OTO\",\"tpLimitPrice\":\"3\",\"stopPrice\":\"9\",\"stopLimitPrice\":\"\"}",
"method": "POST",
...
});
And this is part of the response from the UI:
"orders": [
{
"symbol": "OMUSDT",
"orderId": "***",
"clientOrderId": "***"
},
{
"symbol": "OMUSDT",
"orderId": "***",
"clientOrderId": "***"
},
{
"symbol": "OMUSDT",
"orderId": "***",
"clientOrderId": "***"
}
],
"orderReports": [
{
"symbol": "OMUSDT",
"orderId": "***",
"orderListId": "***",
"clientOrderId": "***",
"transactTime": "1738952990995",
"price": "6.20000000",
"origQty": "2.00000000",
"executedQty": "0.00000000",
"cummulativeQuoteQty": "0.00000000",
"status": "NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "SELL",
"stopPrice": null,
"selfTradePreventionMode": "EXPIRE_MAKER",
"workingTime": "1738952990995"
},
{
"symbol": "OMUSDT",
"orderId": "***",
"orderListId": "***",
"clientOrderId": "***",
"transactTime": "1738952990995",
"price": "0.00000000",
"origQty": "2.00000000",
"executedQty": "0.00000000",
"cummulativeQuoteQty": "0.00000000",
"status": "PENDING_NEW",
"timeInForce": "GTC",
"type": "STOP_LOSS",
"side": "BUY",
"stopPrice": "9.00000000",
"selfTradePreventionMode": "EXPIRE_MAKER",
"workingTime": "-1"
},
{
"symbol": "OMUSDT",
"orderId": "***",
"orderListId": "***",
"clientOrderId": "***",
"transactTime": "1738952990995",
"price": "3.00000000",
"origQty": "2.00000000",
"executedQty": "0.00000000",
"cummulativeQuoteQty": "0.00000000",
"status": "PENDING_NEW",
"timeInForce": "GTC",
"type": "LIMIT_MAKER",
"side": "BUY",
"stopPrice": null,
"selfTradePreventionMode": "EXPIRE_MAKER",
"workingTime": "-1"
}
]
Judging from the order reports, my api call should be correct, no?
Is there a place where we can report bugs?