# Order types


Source: https://docs.stxapp.io/concepts/order-types/

STX supports two order types: **limit** and **market**. The type is set via the
`order_type` field when calling [`POST /api/v1/orders`](/api/rest/orders/place-order/).

---

## Limit Orders

A limit order specifies the worst price you are willing to accept:

- **Buy limit**: sets a price ceiling. You will pay no more than your limit price per
  contract. The exchange fills you at the best available price up to your limit.
- **Sell limit**: sets a price floor. You will receive no less than your limit price per
  contract.

If the full quantity cannot be filled at the limit price or better, the unfilled remainder
is placed in the order book and waits for a matching counterparty. It stays there until
fully filled or explicitly cancelled.

**Use a limit order to name your price.** If you want an order to rest on the book and have
others trade against it, it must be a limit order.

---

## Market Orders

A market order does not constrain the price:

- **Buy market**: buys at the best available offer price, sweeping through the book until
  filled or no more contracts are available.
- **Sell market**: sells at the best available bid, sweeping downward.

Any quantity that cannot be filled immediately is **cancelled**; market orders never rest
in the book. They are used to take existing liquidity, not to provide it.

:::caution
On a thin book, a large market order can fill across a wide price range. Always check
current depth via `bids` and `offers` on the [`GET /api/v1/markets`](/api/rest/markets/list-markets/)
query before placing a large market order.
:::

---

## Placing an Order

See [Place an order](/api/rest/orders/place-order/) for the request, response and a runnable curl.

Prices are **dollar amounts sent as strings**, with at most two decimal places: `"0.45"` means $0.45.

:::note
`POST /api/v1/orders` is a **request**, not a guarantee. By the time your order reaches the
matching engine, market conditions may have changed. Check the `order.status` in the
response and subscribe to the [`orders`](/websockets/channels/orders/) channel
to receive fill and cancellation events in real time.
:::

---

## Cancelling Orders

Single cancel:

See [Cancel an order](/api/rest/orders/cancel-order/) for the request, response and a runnable curl.

Batch cancel:

See [Cancel several orders](/api/rest/orders/cancel-multiple-orders/) for the request, response and a runnable curl.

Cancel all open orders on your account:

See [Cancel all open orders](/api/rest/orders/cancel-all-orders/) for the request, response and a runnable curl.

A cancel is also a request: by the time it reaches the engine the order may already be
fully filled. The response per order tells you the actual status after the attempt.

---

## Auto-Cancel on Disconnect

If your integration relies on continuous connectivity to manage order risk, you can instruct
the server to cancel your open orders automatically if your WebSocket connection drops. See
[`cancel_on_disconnect`](/risk-controls/#cancel-orders-on-disconnect).
