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).
Decrement and Cancel (DC) — Default
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.
Cancel Oldest (CO)
The older, resting order on the book is canceled. The newer, taker order continues to execute against other orders in the book normally.
Cancel Newest (CN)
The newer, taker order is canceled. The older, resting order remains on the book undisturbed.
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.

