> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whitebit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Self Trade Prevention (STP)

> 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](/glossary#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.

> [!WARNING]
>
> 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:

* [Limit orders](/glossary#limit-order)
* [Market orders](/glossary#market-order)
* [Stop-limit orders](/glossary#stop-limit-order)
* [Stop-market orders](/glossary#stop-market-order)
* [OCO orders](/glossary#oco-orders) (One Cancels Other)
* [Collateral orders](/glossary#collateral)

### Example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "market": "BTC_USDT",
  "side": "buy",
  "amount": "0.001",
  "price": "40000",
  "stp": "cb"
}
```

## Supported Endpoints

STP is supported on the following API endpoints:

* [POST `/api/v4/order/new`](/api-reference/trading/create-limit-order) (Limit orders)
* [POST `/api/v4/order/market`](/api-reference/trading/create-market-order) (Market orders)
* [POST `/api/v4/order/stock_market`](/api-reference/trading/create-buy-stock-market-order) (Stock market orders)
* [POST `/api/v4/order/stop_limit`](/api-reference/trading/create-stop-limit-order) (Stop-limit orders)
* [POST `/api/v4/order/stop_market`](/api-reference/trading/create-stop-market-order) (Stop-market orders)
* [POST `/api/v4/order/bulk`](/api-reference/trading/bulk-limit-order) (Bulk limit orders — per order item)
* [POST `/api/v4/order/modify`](/api-reference/trading/modify-order) (Modify order)
* [POST `/api/v4/order/collateral/limit`](/api-reference/trading/collateral-limit-order) (Collateral limit orders)
* [POST `/api/v4/order/collateral/market`](/api-reference/trading/collateral-market-order) (Collateral market orders)
* [POST `/api/v4/order/collateral/stop-limit`](/api-reference/trading/collateral-stop-limit-order) (Collateral stop-limit orders)
* [POST `/api/v4/order/collateral/trigger-market`](/api-reference/trading/collateral-trigger-market-order) (Collateral trigger market orders)
* [POST `/api/v4/order/collateral/oco`](/api-reference/trading/create-collateral-oco-order) (Collateral OCO orders)

## Best Practices

1. **Default Behavior**: If no STP mode is specified, the system defaults to `no`, allowing self-trades.
2. **Risk Management**: For automated trading systems or when running multiple strategies, use `cb` or `cn` to prevent unintentional self-trades.
3. **Market Making**: When running [market making](/glossary#maker) 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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.