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

# Order book and matching

Exliquid uses a native central-limit order book (CLOB). Orders interact according to explicit price and priority rules, and fills update the corresponding account and position state as part of the same trading result.

## Price-time priority

Matching follows two basic rules:

1. better prices execute before worse prices;
2. orders at the same price execute in their established priority order.

This gives clients a predictable order-book model: improving price has priority over queue position, while queue position matters among orders at the same price.

## Order lifecycle

A typical order moves through these user-visible states:

```
create and sign order
      ↓
submit transaction
      ↓
order accepted for execution
      ↓
open / partially filled / filled
      └──────────────→ cancelled or rejected where applicable
```

Clients should use the transaction result and account/order queries to distinguish protocol submission from the resulting trading state.

## Fills

When an incoming order crosses eligible resting liquidity, fills are produced at the matched order-book prices according to the current order rules.

A fill can update:

* remaining order quantity;
* account balances and fees;
* position quantity and entry price;
* realized PnL when exposure is reduced;
* margin and risk state.

## Cancellation

Cancellation removes eligible open quantity from the book. A cancellation can fail when the target order does not exist, is no longer open, belongs to another account, or otherwise violates the current action rules.

## Risk-aware execution

Perpetual orders are subject to margin and market-risk checks. An order that would increase exposure can be rejected if the resulting account state would violate the applicable rules.

Reduce-only and other risk-reducing actions have stricter semantics: they must not increase the absolute exposure they are intended to reduce.

## Order types and exact fields

The set of supported order actions evolves with the versioned API and SDK. Do not infer support for an advanced order type from another exchange.

Use the current [REST API](/docs/developers/rest-api.md) and [SDK](/docs/developers/sdk.md) contract for exact request fields and supported actions.


---

# 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://exliquid.gitbook.io/docs/trading/order-book-and-matching.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.
