> For the complete documentation index, see [llms.txt](https://docs.asterdex.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.asterdex.com/trading/perpetuals/fees-and-specs/self-trade-prevention/how-to-configure-stp.md).

# How to Configure STP

### **Option 1 — Global setting:**

1. Log in and go to the **Perp** trading page
2. Click the **Settings** icon in the top-right corner

<figure><img src="/files/791KQhdF8uCVypiygGVJ" alt=""><figcaption></figcaption></figure>

3. Under the "Trading" section, find **Self-Trade Prevention** and click to open

<figure><img src="/files/mP7iW2Rra5Dv6AGRQTNg" alt=""><figcaption></figcaption></figure>

4. Select your preferred strategy in the pop-up and click **Confirm**

*Changes take effect immediately after saving. Portions already filled are not affected — the selected STP strategy applies only to the remaining unfilled quantity.*

<figure><img src="/files/CfsTSOIUTR4GTeObYUX0" alt=""><figcaption></figcaption></figure>

### **Option 2 — API STP Strategy:**

* Add the `stpMode` parameter to the `POST /fapi/v3/order` endpoint
* API-level settings take priority over the global setting, but only apply to that specific order

### Specifying STP Strategy via API <a href="#specifying-stp-strategy-via-api" id="specifying-stp-strategy-via-api"></a>

Use the optional parameter `stpMode` in `POST /fapi/v3/order` to set a strategy for an individual order:

`stpMode: "EXPIRE_MAKER" // Cancel Maker Only stpMode: "EXPIRE_TAKER" // Cancel Taker Only stpMode: "EXPIRE_BOTH" // Cancel Both`

* If omitted, the account's global STP setting (`EXPIRE_MAKER`) is used automatically
* API-specified strategies take priority over the global setting, and apply to that order only

### Example: Cancel Maker Only in Action <a href="#example-cancel-maker-only-in-action" id="example-cancel-maker-only-in-action"></a>

A user runs two strategies simultaneously on the BTCUSDT perpetual contract, with STP set to **Cancel Maker Only**.

**Strategy A** places a limit sell order on the order book: sell 0.1 BTC at 69,000 USDT (maker)

**Strategy B** then places a market buy order: buy 0.1 BTC at market — the best available ask happens to be 69,000 USDT (Strategy A's order)

The matching engine detects that both orders belong to the same account and triggers STP:

`Maker sell order (69,000 limit) → Immediately cancelled, status: EXPIRE Taker buy order (market) → Continues execution, matches against the next ask on the book`

The taker order ultimately fills at 69,001 USDT or higher against another seller, and the strategy continues running as intended.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.asterdex.com/trading/perpetuals/fees-and-specs/self-trade-prevention/how-to-configure-stp.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
