hand-point-leftSelf Trade Prevention

Self Trade Prevention (STP) is a mechanism that prevents a user's orders from matching against their own orders in the order book. This can occur when a user has multiple active orders on both sides of the book, or when an automated trading strategy submits an order that would inadvertently fill against an existing resting order from the same subaccount.

When STP is triggered, the resting (maker) order is canceled. The incoming (taker) order remains active and can continue to match against other orders in the book. The canceled resting order will have the result code MakerCanceledByTaker. STP is always enabled and cannot be disabled.

Example

  1. Account A places a sell limit order at $100 (resting in the book)

  2. Account A places a buy market order that would match at $100

  3. Instead of trading against itself, the resting sell order is canceled

  4. The buy order continues and matches against other sellers in the book

Behavior With Order Types

STP applies regardless of order type. Some notable interactions:

  • Post-only: A post-only order that would rest and later be matched by an aggressing order from the same account, the resting post-only order is canceled.

  • Fill or Kill: If the only available liquidity is the same account's resting orders, the FOK order is unfilled

  • Reduce-only / Close: Resting reduce-only or close orders are canceled if the same account aggresses against them

  • Stop orders: If a triggered stop order would match a resting order from the same account, the resting order is canceled

  • OCO / OTO: Contingent orders follow the same rules. if one leg is canceled due to STP, contingency behavior applies as normal

API Considerations

Since STP prevents self-matches from executing, no fill or trade record is produced when a resting order is canceled due to STP.

When STP is triggered during order submission, the response for the aggressing (taker) order will indicate a successful submission, the taker order is not rejected. The resting (maker) order is canceled asynchronously with the result code MakerCanceledByTaker.

Block Executions Interplay

Orders submitted during a block window are held internally with a status of PENDING until the block is released. STP is evaluated when the block is processed.

If an aggressing order in a block would match against a resting order from the same subaccount, the resting order is canceled as part of the same block. This means a resting order can be canceled by STP before the aggressing order even becomes active.

In this scenario, the resting order's lifecycle is NEW to CANCELED with the result code MakerCanceledByTaker, and the aggressing order transitions from PENDING to NEW - both occurring atomically within the same block.

Read more on Block Execution.

FAQ

Can I disable STP?

No. STP is always enabled to ensure market integrity.

Does STP apply across different subaccounts on the same account?

No. STP only applies within the same subaccount. Orders from different subaccounts on the same account can match against each other.

Are there any fees when STP cancels an order?

No. Since no trade occurs, no fees are charged.

Last updated