> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ocx.global/llms.txt
> Use this file to discover all available pages before exploring further.

# Orders, fills & fees

> Order types, time-in-force, the order lifecycle, how fills work, and the maker–taker fee model on OCX.

Every OCX venue runs a **central limit order book (CLOB)** with price-time priority: the best price trades first, and at the same price the earlier order trades first. This page covers the order options you can set, what happens across an order's life, and how fees are charged.

## Order types

<ParamField body="type" type="string">
  `limit` rests at a price you set. `market` executes immediately against the book at the best available prices.
</ParamField>

<ParamField body="side" type="string">
  `buy` or `sell`.
</ParamField>

<ParamField body="timeInForce" type="string">
  How long an order stays active: `gtc` rests until filled or cancelled, `ioc` fills what it can immediately then cancels the rest, `fok` fills fully or cancels entirely.
</ParamField>

<ParamField body="postOnly" type="boolean">
  Rejects the order if it would take liquidity — guarantees you stay on the maker side.
</ParamField>

<ParamField body="reduceOnly" type="boolean">
  Prevents the order from increasing your position — used for exit-only orders.
</ParamField>

<ParamField body="clientOrderId" type="string">
  Your own id for idempotent tracking of an order.
</ParamField>

Perpetuals and futures additionally accept a `marginMode` (`isolated` or `cross`) and optional protective triggers (`stopPrice`, `takeProfitPrice`, `stopLossPrice`).

## Preview before you trade

Every order endpoint has a **preview** sibling that dry-runs the order with no side effects. It returns the notional, estimated fee, your fee role and tier, the margin required, and whether the order would be approved. Use it to size safely.

<CodeGroup>
  ```bash Perp preview theme={null}
  curl -b cookies.txt -X POST "https://<api-host>/perps/orders/preview" \
    -H "Content-Type: application/json" \
    -d '{ "marketId":"BTC-PERP","side":"buy","type":"limit","price":"68000","quantity":"0.5" }'
  ```

  ```json Response theme={null}
  {
    "marketId": "BTC-PERP",
    "side": "buy",
    "quantity": "0.5",
    "price": "68000",
    "notional": "34000",
    "marginRequired": "...",
    "estFee": "...",
    "feeBps": "...",
    "feeRole": "maker",
    "user30dVolume": "...",
    "approved": true
  }
  ```
</CodeGroup>

## Placing orders

<CodeGroup>
  ```bash Perp / futures order theme={null}
  curl -b cookies.txt -X POST "https://<api-host>/perps/orders" \
    -H "Content-Type: application/json" \
    -d '{ "marketId":"BTC-PERP","side":"buy","type":"limit","price":"68000","quantity":"0.5","timeInForce":"gtc","postOnly":true }'
  ```

  ```bash Option / spot order theme={null}
  curl -b cookies.txt -X POST "https://<api-host>/orders" \
    -H "Content-Type: application/json" \
    -d '{ "marketId":"BTC-2026-05-15-40000-C","side":"buy","type":"limit","price":"1240","quantity":"5","timeInForce":"gtc" }'
  ```

  ```js EventSource (react to fills) theme={null}
  const es = new EventSource(
    "https://<api-host>/perps/stream/events?marketId=BTC-PERP",
    { withCredentials: true }
  );
  es.addEventListener("snapshot", e => init(JSON.parse(e.data).payload));
  es.addEventListener("delta",    e => apply(JSON.parse(e.data).payload)); // trades + position updates
  ```
</CodeGroup>

<Note>
  Perp and futures orders share the same API (`/perps/orders`). Option and spot orders use `/orders` (with an `/options/orders` alias). Multi-leg option strategies use `/orders/strategy`.
</Note>

## Multi-leg option strategies

Combine 2–8 option legs into a single strategy (for example a call spread or straddle). Strategies are **all-or-none-immediate**: every leg must fully fill or the whole strategy is rejected.

```bash theme={null}
curl -b cookies.txt -X POST "https://<api-host>/orders/strategy" \
  -H "Content-Type: application/json" \
  -d '{
    "strategyName": "call-spread",
    "legs": [
      { "market": "BTC-2026-05-15-40000-C", "side": "buy",  "quantity": "5", "price": "1240" },
      { "market": "BTC-2026-05-15-45000-C", "side": "sell", "quantity": "5", "price": "430" }
    ]
  }'
```

## Order lifecycle

<Steps>
  <Step title="Submit">
    You place (or preview) an order. It passes a margin check before acceptance; a rejected order returns an insufficient-margin error.
  </Step>

  <Step title="Match or rest">
    A marketable order matches immediately against the book. Any unfilled remainder either rests (`gtc`), cancels (`ioc`), or voids the whole order (`fok`). A `postOnly` order that would take liquidity is rejected outright.
  </Step>

  <Step title="Fill">
    As the order executes, fills are generated. Each fill records its price, quantity, and whether you were the maker or taker (`liquidity`). Fills update your position in real time.
  </Step>

  <Step title="Amend or cancel">
    Cancel one order by id, cancel all your orders (optionally scoped to a market), and for options amend a resting order's price or quantity.
  </Step>
</Steps>

Cancellation endpoints:

<CodeGroup>
  ```bash Cancel one theme={null}
  curl -b cookies.txt -X POST "https://<api-host>/perps/orders/<id>/cancel"
  ```

  ```bash Cancel all theme={null}
  curl -b cookies.txt -X POST "https://<api-host>/perps/orders/cancel-all" \
    -H "Content-Type: application/json" -d '{ "marketId": "BTC-PERP" }'
  ```
</CodeGroup>

## Fees: the maker–taker model

OCX uses a standard **maker–taker** fee model with **volume-based tiers** — the higher your rolling 30-day volume, the better your rates. On the top tiers the maker side can be a **rebate** (a negative maker fee), rewarding you for providing liquidity.

* **Maker** — your order rests on the book and is filled by someone else. Lower fee, and potentially a rebate.
* **Taker** — your order removes liquidity from the book. Higher fee.

Query the live schedule rather than hardcoding it:

```bash theme={null}
curl "https://<api-host>/perps/fees"
# -> [ { "min30dVolumeUsd": ..., "makerBps": ..., "takerBps": ... }, ... ]
```

<Tip>
  Your personal tier, fee role, and estimated fee for a specific order are all returned by the order **preview** endpoint — the most reliable way to know what you'll pay before trading. Options have their own schedule at `GET /options/fees`.
</Tip>
