Self Trade Prevention (STP) is a mechanism to prevent traders from executing trades against the same trader’s orders. The feature helps maintain market integrity and avoid unintentional self-trading scenarios.
Overview
When placing orders, specify how the system should handle potential self-trades using the stp parameter. This parameter determines the behavior when an order would match against another order from the same account. System-generated balance normalization orders are not subject to STP and can match the account’s own resting orders.
Deprecation notice: the long-form mode values cancel_both, cancel_new, and cancel_old are deprecated. The long-form values remain accepted and behave identically to the abbreviated equivalents (cb, cn, co) until a migration deadline is announced, after which the API rejects the long-form values. Responses already return only the abbreviated values. Migrate integrations to the abbreviated forms now.
STP Modes
The following STP modes are available:
Mode
Description
no
Default mode. Self-trades are allowed
cb
Cancel both: the new order and the existing order will be canceled
cn
Cancel new: the new order will be canceled, and the existing order will remain
co
Cancel old: the existing order will be canceled, and the new order will be placed
Usage
Specify the STP mode when placing any type of order:
Default Behavior: If no STP mode is specified, the system defaults to no, allowing self-trades.
Risk Management: For automated trading systems or when running multiple strategies, use cb or cn to prevent unintentional self-trades.
Market Making: When running market making strategies, consider using cn to maintain existing orders’ queue position.
Response Handling
When an order is affected by STP rules, the order response includes the stp field indicating the applied mode. The stp field always returns the abbreviated value (no, cb, cn, co), even when the request used a deprecated long-form value. The order status will reflect the outcome based on the STP mode:
Orders canceled due to STP will have a “CANCELED” status
Successfully placed orders will proceed with normal status progression
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.