> For the complete documentation index, see [llms.txt](https://ocx.gitbook.io/ocx-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ocx.gitbook.io/ocx-doc/ocx/api/options-trading.md).

# options trading

Place, preview, and cancel options orders; manage option positions and trades.

***

## POST /orders

Place a single options order.

**Auth**: required (`trade` scope).

**Request**

```json
{
  "marketId":      "BTC-2026-06-26-60000-C",
  "clientOrderId": "my-order-42",
  "type":          "limit",
  "side":          "buy",
  "price":         "0.05",
  "quantity":      "1",
  "timeInForce":   "gtc",
  "postOnly":      false,
  "reduceOnly":    false
}
```

| Field           | Type                          | Description                                                   |
| --------------- | ----------------------------- | ------------------------------------------------------------- |
| `marketId`      | string                        | Option market in `{BASE}-{YYYY-MM-DD}-{STRIKE}-{C\|P}` format |
| `clientOrderId` | string?                       | Your idempotency key. Recommended.                            |
| `type`          | `"limit"` \| `"market"`       | Default `"limit"`                                             |
| `side`          | `"buy"` \| `"sell"`           |                                                               |
| `price`         | string                        | Required for limit orders                                     |
| `quantity`      | string                        |                                                               |
| `timeInForce`   | `"gtc"` \| `"ioc"` \| `"fok"` | Default `"gtc"`                                               |
| `postOnly`      | boolean                       | Cancels if the order would cross                              |
| `reduceOnly`    | boolean                       | Cannot increase position                                      |

**Response**

```json
{
  "id":             "01HW...",
  "userId":         "01HW...",
  "marketId":       "BTC-2026-06-26-60000-C",
  "clientOrderId":  "my-order-42",
  "side":           "buy",
  "type":           "limit",
  "price":          "0.05",
  "quantity":       "1",
  "filledQuantity": "0",
  "status":         "open",
  "createdAt":      "2026-04-24T12:00:00Z",
  "updatedAt":      "2026-04-24T12:00:00Z"
}
```

`status` is one of `open`, `filled`, `canceled`, `rejected`.

***

## POST /orders/preview

Dry-run an order and return its margin impact. Same request body as `/orders`.

**Auth**: required (`trade` scope).

**Response**

```json
{
  "approved":     true,
  "reason":       null,
  "marginImpact": {
    "initialMargin":     "105.20",
    "maintenanceMargin": "70.10"
  }
}
```

If `approved` is `false`, `reason` is the error code (e.g., `"INSUFFICIENT_MARGIN"`).

***

## POST /quotes

Place a two-sided quote atomically. Useful for market makers — either both sides rest or neither does.

**Auth**: required (`trade` scope).

**Request**

```json
{
  "marketId": "BTC-2026-06-26-60000-C",
  "bid": { "price": "0.045", "quantity": "1", "clientOrderId": "q-bid" },
  "ask": { "price": "0.055", "quantity": "1", "clientOrderId": "q-ask" },
  "quoteId": "q-batch-7"
}
```

Either side may be omitted for a one-sided quote.

**Response**

```json
{
  "marketId": "BTC-2026-06-26-60000-C",
  "results": [
    { "side": "buy",  "response": { /* order */ } },
    { "side": "sell", "response": { /* order */ } }
  ]
}
```

***

## POST /quotes/bulk

Post many quotes on the same market in one call. The fastest way to refresh a quote ladder.

**Auth**: required (`trade` scope).

**Request**

```json
{
  "marketId": "BTC-2026-06-26-60000-C",
  "quoteId": "q-batch-7",
  "cancelAll": true,
  "quotes": [
    { "side": "buy",  "price": "0.044", "quantity": "1" },
    { "side": "buy",  "price": "0.045", "quantity": "2" },
    { "side": "sell", "price": "0.055", "quantity": "2" },
    { "side": "sell", "price": "0.056", "quantity": "1" }
  ]
}
```

`cancelAll: true` cancels your existing orders on this market before posting the new batch.

***

## POST /orders/:id/cancel

Cancel a single options order.

**Auth**: required (`trade` scope).

**Response**: the updated order with `status: "canceled"`.

**Errors**

| Status | When                                   |
| ------ | -------------------------------------- |
| 404    | Order not found or not owned by caller |
| 409    | Order is already filled or canceled    |

***

## POST /orders/cancel-all

Cancel open options orders. Filters are optional.

**Auth**: required (`trade` scope).

**Request**

```json
{
  "marketId":      "BTC-2026-06-26-60000-C",
  "quoteId":       "q-batch-7",
  "clientOrderId": "my-order-42"
}
```

**Response**

```json
{
  "canceled": 3,
  "ids": ["01HW...", "01HW...", "01HW..."]
}
```

***

## POST /orders/:id/modify

Amend an open order's price and/or quantity.

**Auth**: required (`trade` scope).

**Request**

```json
{ "price": "0.048", "quantity": "1.5" }
```

Either field is optional.

**Response**: the updated order.

***

## GET /orders/me

Your orders (open, filled, canceled).

**Auth**: required.

**Query**

| Parameter | Type   | Description            |
| --------- | ------ | ---------------------- |
| `limit`   | number | Max rows (default 100) |

**Response**: array of order objects.

***

## GET /balances/me

Options trading balance.

**Auth**: required.

**Response**

```json
{ "available": "180.00", "locked": "20.00", "total": "200.00" }
```

***

## GET /positions/me

Open option positions.

**Auth**: required.

**Response**

```json
[
  {
    "marketId":      "BTC-2026-06-26-60000-C",
    "quantity":      "1",
    "avgPrice":      "0.045",
    "realizedPnl":   "0",
    "unrealizedPnl": "0.0125"
  }
]
```

***

## GET /trades/me

Your option fills.

**Auth**: required.

**Response**

```json
[
  {
    "tradeId":   "01HW...",
    "marketId":  "BTC-2026-06-26-60000-C",
    "orderId":   "01HW...",
    "side":      "buy",
    "price":     "0.045",
    "quantity":  "1",
    "fee":       "0.000225",
    "feeBps":    "5",
    "createdAt": "2026-04-24T12:00:00Z"
  }
]
```


---

# 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:

```
GET https://ocx.gitbook.io/ocx-doc/ocx/api/options-trading.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
