There are four possible modes for what the system will do if an order could create a self-trade.
NONE - This mode exempts the order from self-trade prevention. Accounts or Trade group IDs will not be compared, no orders will be expired, and the trade will occur.
EXPIRE_TAKER - This mode prevents a trade by immediately expiring the taker order's remaining quantity.
EXPIRE_MAKER - This mode prevents a trade by immediately expiring the potential maker order's remaining quantity.
EXPIRE_BOTH - This mode prevents a trade by immediately expiring both the taker and the potential maker orders' remaining quantities.
The STP event will occur depending on the STP mode of the taker order. Thus, the STP mode of an order that goes on the book is no longer relevant and will be ignored for all future order processing.
Different accounts with the same tradeGroupId are considered part of the same "trade group". Orders submitted by members of a trade group are eligible for STP according to the taker-order's STP mode.
A user can confirm if their accounts are under the same tradeGroupId from the API either from GET fapi/v2/account (REST API).
If the value is -1, then the tradeGroupId has not been set for that account, so the STP may only take place between orders of the same account.
We will release feature for user to group subaccounts to same tradeGroupId on website in future updates.
LIMIT/MARKET/STOP/TAKE_PROFIT/STOP_MARKET/TAKE_PROFIT_MARKET/TRAILING_STOP_MARKET all supports STP when Time in force(timeInForce) set to GTC/ IOC/ GTD.
STP won't take effect for Time in force(timeInForce) FOK or GTX
In user data stream event ORDER_TRADE_UPDATE, field X would be EXPIRED_IN_MATCH if order is expired due to STP
{"e":"ORDER_TRADE_UPDATE",// Event Type"E":1568879465651,// Event Time"T":1568879465650,// Transaction Time"o":{"s":"BTCUSDT",// Symbol"c":"TEST",// Client Order Id// special client order id:// starts with "autoclose-": liquidation order// "adl_autoclose": ADL auto close order// "settlement_autoclose-": settlement order for delisting or delivery"S":"SELL",// Side"o":"TRAILING_STOP_MARKET",// Order Type"f":"GTC",// Time in Force"q":"0.001",// Original Quantity"p":"0",// Original Price"ap":"0",// Average Price"sp":"7103.04",// Stop Price. Please ignore with TRAILING_STOP_MARKET order"x":"EXPIRED",// Execution Type"X":"EXPIRED_IN_MATCH",// Order Status"i":8886774,// Order Id"l":"0",// Order Last Filled Quantity"z":"0",// Order Filled Accumulated Quantity"L":"0",// Last Filled Price"N":"USDT",// Commission Asset, will not push if no commission"n":"0",// Commission, will not push if no commission"T":1568879465650,// Order Trade Time"t":0,// Trade Id"b":"0",// Bids Notional"a":"9.91",// Ask Notional"m":false,// Is this trade the maker side?"R":false,// Is this reduce only"wt":"CONTRACT_PRICE",// Stop Price Working Type"ot":"TRAILING_STOP_MARKET",// Original Order Type"ps":"LONG",// Position Side"cp":false,// If Close-All, pushed with conditional order"AP":"7476.89",// Activation Price, only puhed with TRAILING_STOP_MARKET order"cr":"5.0",// Callback Rate, only puhed with TRAILING_STOP_MARKET order"pP":false,// ignore"si":0,// ignore"ss":0,// ignore"rp":"0"// Realized Profit of the trade"V":"NONE".// selfTradePreventionMode"pm":"QUEUE"// price match type"gtd":1768879465650// good till date}}
Scenario E - A user has an order on the book with EXPIRE_MAKER, and then sends a new order with EXPIRE_TAKER which would match with the existing order.
Result: The existing order expires with the status EXPIRED_IN_MATCH, due to STP.
The new order also expires but with status EXPIRED, due to low liquidity on the order book.