> For the complete documentation index, see [llms.txt](https://docs.opinion.trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.opinion.trade/developer-guide/opinion-clob-typescript-sdk/core-concepts/order.md).

# Order

This section explains how orders work in the Opinion prediction market, including order types, sides, and amount specifications.

## Order Types

<table><thead><tr><th width="130">Type</th><th>Enum Value</th><th width="213">Description</th><th>Price Parameter</th></tr></thead><tbody><tr><td><strong>Market Order</strong></td><td><code>OrderType.MARKET_ORDER</code></td><td>Execute immediately at best available price</td><td>Ignored, price is always  <code>"0"</code> for market order.</td></tr><tr><td><strong>Limit Order</strong></td><td><code>OrderType.LIMIT_ORDER</code></td><td>Execute only at specified price or better</td><td>Required (e.g., <code>"0.50"</code>)</td></tr></tbody></table>

## Order Sides

| Side     | Enum Value       | Description                                    |
| -------- | ---------------- | ---------------------------------------------- |
| **BUY**  | `OrderSide.BUY`  | Purchase outcome tokens (predict event occurs) |
| **SELL** | `OrderSide.SELL` | Sell outcome tokens (close position or short)  |

## Price

Prices represent implied probability:

* Valid range: `0.01` to `0.99`
* Maximum 4 decimal places
* `"0.50"` = 50% probability, costs $0.50 per token, pays $1.00 if correct

## Amount Specifications

You must specify exactly **one** of:

| Parameter                 | Type     | Usage                         |
| ------------------------- | -------- | ----------------------------- |
| `makerAmountInQuoteToken` | `string` | Specify USDT to spend/receive |
| `makerAmountInBaseToken`  | `string` | Specify exact token quantity  |

Examples:

* BUY order at price `0.60`, spending `100` USDT -> receives \~166.67 tokens
* SELL order at price `0.60`, selling `200` tokens -> receives 120 USDT

### Restrictions

| Side | Order Type | Allowed Amount                 |
| ---- | ---------- | ------------------------------ |
| BUY  | Market     | `makerAmountInQuoteToken` only |
| SELL | Market     | `makerAmountInBaseToken` only  |
| BUY  | Limit      | Either                         |
| SELL | Limit      | Either                         |

## Placing Orders

{% code title="place-orders.ts" %}

```typescript
import { OrderSide, OrderType, type PlaceOrderDataInput } from '@opinion-labs/opinion-clob-sdk';

// Limit BUY: spend 10 USDT on YES tokens at 0.5
const buyOrder: PlaceOrderDataInput = {
  marketId: 123,
  tokenId: 'yes_token_id',
  side: OrderSide.BUY,
  orderType: OrderType.LIMIT_ORDER,
  price: '0.5',
  makerAmountInQuoteToken: '10',
};
const result = await client.placeOrder(buyOrder);

// Market BUY: spend 10 USDT at market price
const marketBuy: PlaceOrderDataInput = {
  marketId: 123,
  tokenId: 'yes_token_id',
  side: OrderSide.BUY,
  orderType: OrderType.MARKET_ORDER,
  price: '0',
  makerAmountInQuoteToken: '10',
};
const result2 = await client.placeOrder(marketBuy);

// Limit SELL: sell 20 YES tokens at 0.6
const sellOrder: PlaceOrderDataInput = {
  marketId: 123,
  tokenId: 'yes_token_id',
  side: OrderSide.SELL,
  orderType: OrderType.LIMIT_ORDER,
  price: '0.6',
  makerAmountInBaseToken: '20',
};
const result3 = await client.placeOrder(sellOrder);
```

{% endcode %}

## Cancelling Orders

{% code title="cancel-orders.ts" %}

```typescript
// Cancel single order
await client.cancelOrder('order_123');

// Cancel multiple orders
const results = await client.cancelOrdersBatch(['order_1', 'order_2', 'order_3']);

// Cancel all open orders (optionally filter by market/side)
const summary = await client.cancelAllOrders({ marketId: 123, side: OrderSide.BUY });
console.log(`Cancelled: ${summary.cancelled}, Failed: ${summary.failed}`);
```

{% endcode %}

## Batch Operations

{% code title="batch-operations.ts" %}

```typescript
// Place multiple orders at once
const orders = [order1, order2, order3];
const results = await client.placeOrdersBatch(orders, true);

for (const r of results) {
  if (r.success) {
    console.log(`Order ${r.index}: placed successfully`);
  } else {
    console.log(`Order ${r.index}: failed - ${r.error}`);
  }
}
```

{% endcode %}

Note: The `placeOrdersBatch` method accepts an optional second parameter `checkApproval` (default `false`). When set to `true`, it calls `enableTrading()` once before placing any orders.

## Best Practices

* Review orderbook before placing market orders to assess slippage
* Break large orders into smaller limit orders to minimize market impact
* Validate price is within `[0.01, 0.99]` range before submission
* Use batch methods for multiple orders to reduce latency


---

# 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://docs.opinion.trade/developer-guide/opinion-clob-typescript-sdk/core-concepts/order.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.
