Self Trade Prevention

Katana Perps includes built-in self-trade prevention (STP) logic in the matching engine. Two orders from the same wallet or API account cannot fill against each other. When a potential self-trade is detected, one or both orders are handled according to the taker order's specified STP policy.

STP Policies

When placing an order, traders can specify one of four self-trade prevention policies. If no policy is specified, the default is Decrement and Cancel (DC).

chevron-rightDecrement and Cancel (DC) — Defaulthashtag

If a self-trade would occur, the smaller order is canceled and the larger order's quantity is reduced by the smaller order's quantity. If both orders have the same open quantity, both are canceled. This is the default behavior.

chevron-rightCancel Oldest (CO)hashtag

The older, resting order on the book is canceled. The newer, taker order continues to execute against other orders in the book normally.

chevron-rightCancel Newest (CN)hashtag

The newer, taker order is canceled. The older, resting order remains on the book undisturbed.

chevron-rightCancel Both (CB)hashtag

Both the resting order and the taker order are canceled.

When STP Matters

Self-trade prevention is primarily relevant for:

  • Market makers running multiple strategies or order management systems on the same account, where buy and sell orders may overlap.

  • Algorithmic traders who rapidly place and replace orders across both sides of the book.

  • Fill-or-Kill (FOK) orders — FOK orders are required to use the CN (Cancel Newest) policy to be accepted by the matching engine.

For most retail traders placing orders manually, self-trade prevention rarely triggers, but the protections ensure fair and predictable behavior in all cases.