> For the complete documentation index, see [llms.txt](https://docs.v12.trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.v12.trade/trade/getting-started-as-a-trader/creating-orders/order-book/market-order.md).

# Market Order

<details>

<summary><strong>What is a Market Order?</strong></summary>

A market order is an order to buy or sell an asset at the current market price. Unlike a limit order, it does not specify a price and aims for immediate execution (in one transaction)

</details>

<details>

<summary><strong>How to Create a Market Order</strong></summary>

Currently Market Orders on Spark are available only via the SDK. \
\
We are currently working on adding the Market Order functionality to the frontend via the Swap page. Market orders will also be available through the standard order book page.

<img src="/files/ehh0bRMu3LvZPIpPx1F9" alt="" data-size="original">

</details>

<details>

<summary><strong>How Do Market Orders Work?</strong></summary>

1. **Order Creation:** When a trader or algorithm creates a market order, it immediately enters the exchange's order book.
2. **Matching:** The exchange matches the market order with limit orders already in the order book.
3. **Execution:** The market order is executed at the best available prices from the opposite side's limit orders:
   * **For a buy market order:** It is executed at the lowest available price from the sell order book.
   * **For a sell market order:** It is executed at the highest available price from the buy order book.
4. **Partial Execution:** If the market order volume is too large to be fully executed at the current best price, it is partially executed across multiple prices until fully satisfied:
   * For example, if you want to buy 1000 tokens but only 500 are available at the best price, 500 tokens are bought at that price, and the remaining 500 at the next best available price.

**Example of Market Order Execution:**

1. **Creating a market order to buy 1000 tokens**.
2. **Order book before execution:**
   * Sell limit orders:
     * 500 tokens at $10.00
     * 300 tokens at $10.05
     * 200 tokens at $10.10
3. **Order execution:**
   * 500 tokens bought at $10.00 (first price level)
   * 300 tokens bought at $10.05 (second price level)
   * 200 tokens bought at $10.10 (third price level)
4. **Result:**
   * Average purchase price: (500 \* $10.00 + 300 \* $10.05 + 200 \* $10.10) / 1000 = $10.03

Market orders ensure fast execution but may result in less favorable prices with large volumes or insufficient liquidity. This makes market orders suitable when speed is more important than exact price.

<br>

</details>


---

# 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.v12.trade/trade/getting-started-as-a-trader/creating-orders/order-book/market-order.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.
