> 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.md).

# Self-Trade Prevention

### What Is Self-Trading? <a href="#what-is-self-trading" id="what-is-self-trading"></a>

Self-trading occurs when your own buy and sell orders match against each other in the matching engine. This can happen unintentionally when you run multiple strategies at the same time.

**How self-trading affects you:**

* **Strategy disruption** — One strategy's buy order fills against another strategy's sell order. Both sides move, yet no actual entry or exit is achieved.
* **Unnecessary fee loss** — No real gain is made, but fees are still charged on both sides.
* **Unexpected position changes** — Especially on low-liquidity pairs, self-trading can cause your position to drift from its intended target.

The **Self-Trade Prevention (STP)** feature automatically handles self-trade situations according to your preset strategy, preventing the above issues.

The **STP** will apply to **futures order**. The following are all considered self-trades: orders **within the same account**, orders between a master-account and its sub-accounts, and orders between sub-accounts under the **same master account**.

### What happens when STP is triggered?

| Strategy                        | Behavior                                                                               | Best For                                                 |
| ------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------- |
| **Cancel Maker Only** (Default) | Cancels the maker order; the taker continues to match against the next available level | Prioritizing the execution of the **taker side**         |
| **Cancel Taker Only**           | Cancels **the taker order**; the **maker order remains** on the book                   | Protecting **existing maker** orders                     |
| **Cancel Both**                 | **Cancels both orders** simultaneously                                                 | Most **conservative** — eliminates self-trading entirely |

**Reminder:** Accounts default to the **Cancel Maker Only** strategy.

### FAQs

\
Q: **Does STP affect the portion of an order that has already been filled?**\
No. STP only applies to the remaining unfilled quantity at the moment it is triggered.

Q: **What happens if I don't include the stpMode parameter when placing an order via API?**\
The system will automatically apply the account's current global STP setting.

Q: **Is STP supported for FOK orders?**\
No. Orders with timeInForce set to FOK or GTX are not subject to STP.

<br>


---

# 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.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.
