# 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="../../introduction/getting-started" %}
[getting-started](https://docs.derivadex.io/introduction/getting-started)
{% 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="../../introduction/getting-started" %}
[getting-started](https://docs.derivadex.io/introduction/getting-started)
{% endcontent-ref %}
