When orders from your main account and sub-accounts conflict with each other, OKX's Self-Trade Prevention (STP) kicks in. The default behavior is to cancel the maker order that is already resting on the order book, allowing the taker order to continue matching with orders from other market participants. This means the conflict will not end in a "self-trade," but the canceled resting order will disappear from the order book. You need to understand why it was canceled and whether you can change the rules.

A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!
What STP Covers on OKX
OKX defines self-trading simply: a user or their sub-account accidentally matches against their own order, becoming both the buyer and the seller. Starting March 14, 2024, OKX enabled mandatory STP at the main account level, covering trades between the main account and itself, between sub-accounts under the same main account, and between the main account and all of its sub-accounts. For example, if your main account places a buy order and a sub-account places a sell order, and their prices cross, the system will recognize this as a self-trade risk within the same main account structure and trigger STP instead of letting those two orders match.
The default action after triggering is to cancel the maker order. Suppose the main account's buy order is resting on the order book first (maker), and the sub-account's sell order arrives later (taker) at a matching price. In that case, the main account's buy order will be canceled, and the sub-account's sell order will continue to fill against other people's buy orders. Conversely, if the sub-account's resting order is the maker and the main account's new order is the taker, the sub-account's resting order will be canceled.
Only API Users Can Change the STP Mode
Web and mobile app users do not have an option to switch STP modes. According to OKX's official documentation, only API users can specify an STP mode for certain order types on new orders using the stpMode parameter. API documentation and community submissions show that OKX supports stpMode values including cancel_maker, cancel_taker, and cancel_both, which correspond to canceling the resting order, canceling the taker order, or canceling both. If you do not place orders via API, STP is forced on and fixed to the cancel-maker mode for you, and it cannot be modified in the interface.
This has a practical consequence: if you run separate strategies on your main account and sub-accounts, and the two sides accidentally place opposite orders at similar prices, the order canceled by STP may be part of one of your strategies. The canceled order will not fill, but the strategy itself may still be running and could place similar orders again, which get canceled again, creating a loop. This is not an STP malfunction; it is a strategy design issue that fails to account for order isolation within the same main account structure.
How to Check if an Order Was Canceled by STP
On the web and mobile app, you can check in the order history whether an order was canceled due to self-trade prevention. API users can retrieve cancellation information by querying the order history REST endpoint or subscribing to the order WebSocket channel. If you see an order status change to "canceled" without your manual action, and you check whether there was an opposite order from the main account or a sub-account at a similar price during the same time period, you can generally conclude that STP was triggered. Do not treat it as a system failure and repeatedly submit support tickets. First check the order distribution within the same main account structure.
More Practical Ways to Avoid It
If your trading style does not require placing orders with price overlap between your main account and sub-accounts, STP will not actively interfere with you. What you really need to watch out for is running multiple strategies in parallel: the same coin, similar prices, opposite directions, spread across different sub-accounts or between the main account and a sub-account. That is what triggers it. The solution is not to turn off STP (you cannot anyway), but to separate your order placement. For example, assign different sub-accounts to different coins or different price ranges, and avoid having counterparty orders from the same main account structure at the same position on the order book.
For users who must use the API and need a specific STP behavior, you can pass stpMode in the order request. However, note that cancel_both may be rejected in combinations such as FOK orders. CCXT submissions show that OKX returns errors for certain parameter combinations. If you are not familiar with how API parameters interact, keeping the default cancel_maker and avoiding conflicts through order placement is safer than changing a parameter that may introduce new errors.

A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!


