> For the complete documentation index, see [llms.txt](https://docs.derivadex.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.derivadex.io/trading/position-management/order-types.md).

# Order types

## Market Orders

{% hint style="info" %}
Use this type of order when you are interested in executing a trade on a given market for a specific quantity irrespective of price. The best available prices will be given to you upon execution, and any unmatched quantity will be canceled.
{% endhint %}

### **Market&#x20;*****Buy*****&#x20;Order**&#x20;

#### buy a specific quantity of perpetual contracts at any price level.

* The matching engine will match this order against existing *ask (sell)* orders in the order book, starting with the most favorable ones (i.e., lowest-priced sell orders).
* Any unmatched amount is cancelled.&#x20;

### **Market&#x20;*****Sell*****&#x20;Order**&#x20;

#### &#x20;sell a specific quantity of perpetual contracts at any price level

* The matching engine will match this order against existing *bid (buy)* orders in the order book, starting with the most favorable ones (i.e., highest-priced buy orders).
* Any unmatched amount is cancelled.

{% content-ref url="/pages/-MZVKrkatjw41q7aiAmx" %}
[Getting started](/introduction/getting-started.md)
{% endcontent-ref %}

## Limit Orders&#x20;

{% hint style="info" %}
Use this type of order when you are interested in executing a trade on a given market for a specific quantity, with a limit to how unfavorable of a price you are willing to go (i.e., the highest price you are willing to buy for in the case of a *bid (buy)* or the lowest you are willing to sell for in the case of an *ask (sell)*. In the case of a match, the best available prices will be given to you upon execution, and any unmatched quantity will be posted to the order book.
{% endhint %}

### **Limit&#x20;*****Buy*****&#x20;Order**&#x20;

#### buy a specific quantity of perpetual contracts with a ceiling (maximum) price level.

* The matching engine will match this order against any existing *ask (sell)* orders in the order book that are at any price less than or equal to the incoming limit order's price, starting with the most favorable ones (i.e., lowest-priced sell orders).
* Any left-over amount that went unmatched will be posted to the order book as a *bid* at the price level specified in the limit order.

### **Limit&#x20;*****Sell*****&#x20;Order**&#x20;

#### sell a specific quantity of perpetual contracts with a floor (minimum) price level.

* The matching engine will match this order against any existing *bid (buy)* orders in the order book that are at any price greater than or equal to the incoming limit order's price, starting with the most favorable ones (i.e., highest-priced buy orders).
* Any left-over amount that went unmatched will be posted to the order book as an *ask* at the price level specified in the limit order.

{% hint style="danger" %}
**Self Match Prevention**

This safeguard makes it so you cannot trade with yourself. Limit and market orders will be filled as much as they can until they would otherwise inflict a self-match, at which point the remainder of the incoming order will be canceled. The existing order in the book will remain intact.
{% endhint %}

{% content-ref url="/pages/-MZVKrkatjw41q7aiAmx" %}
[Getting started](/introduction/getting-started.md)
{% endcontent-ref %}


---

# 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.derivadex.io/trading/position-management/order-types.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.
