> For the complete documentation index, see [llms.txt](https://docs.lighter.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lighter.xyz/trading/self-trade-prevention.md).

# Self-Trade Prevention

Lighter imposes a self-trade prevention mechanism. Trades between the same account cancel the resting order (maker) instead of executing the respective trade. Without this mechanism, self-trades would result in no position change and fees being paid unnecessarily.

Default (cancel maker): The resting order is cancelled in full, and the incoming order continues filling against the rest of the book.

Under the default behavior, the taker order fills as intended against the rest of the book, instead of being silently reduced. This only affects orders that don't explicitly specify a self-trade behavior. All four modes (cancel maker, cancel taker, cancel both, reduce both) are available as explicit transaction attributes when placing the order. For more details, see [examples](https://github.com/elliottech/lighter-python/blob/main/examples/orders/self_trade_create_modify_order.py) in our Python SDK.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.lighter.xyz/trading/self-trade-prevention.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
