Articles in this category

Introduction to Self-Trade Prevention (STP)

1. What is self-trade prevention (STP)?


Self-Trade Prevention (STP) is a trading mechanism designed to prevent buy and sell orders from the same user (or different accounts belonging to the same entity) from unintentionally matching with each other in the trading system. The STP mechanism is especially important for maintaining a fair and transparent trading environment, helping to prevent market price manipulation and ensuring that trading activity accurately reflects genuine market interest.

MEXC's Self-Trade Prevention (STP) mechanism is used to prevent orders from the same user or users within the same "tradeGroupId" from matching with each other.

2. What is self-trading?


Possible situations where self-trading can occur:
1) Trades between orders from the same account.
2) Trades between different sub-accounts under the same main account.

3. What happens when STP is triggered?


When an order triggers the self-trade prevention mechanism, the system may apply one of the following four modes:

1) NONE Mode: The order is not affected by the STP mechanism. The system does not check the account or tradeGroupId, and the trade executes normally.

2) CANCEL_TAKER Mode: The remaining quantity of the taker order is immediately canceled to prevent the trade from executing.

3) CANCEL_MAKER Mode: The remaining quantity of the maker order is immediately canceled to prevent the trade from executing.

4) CANCEL_BOTH Mode: The remaining quantities of both the taker and maker orders are simultaneously canceled to prevent the trade from executing.

4. How to set the STP Mode for an order


STP mode can be set using the stpMode parameter in the following API calls:
  • POST /api/v3/order
  • POST /api/v3/batchOrders

5. What is "tradeGroupId"?


Accounts sharing the same tradeGroupId are treated as belonging to the same trading group. Orders submitted by members of the same trading group may trigger STP depending on the taker order's STP mode.

6. Which trading pairs support STP?


All trading pairs.

7. Which order types Support STP?


Only the following order types support STP:
  • LIMIT orders
  • MARKET orders
  • LIMIT_MAKER (post-only) orders
  • IMMEDIATE_OR_CANCEL (IOC) orders
Note: STP is not effective when the type is set to FOK (Fill-Or-Kill).