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

# 提交订单

> 通过 Prediction API 创建事件市场私有订单。

> [!NOTE]
>
> 以下私有接口示例使用 Broker API Key。每次请求都需携带 `KEY`、`Timestamp`、`SIGN` 和 `X-User-Wallet-Address`；签名使用实际外部请求路径、Query String 和 Body。 [Broker API 认证与签名](https://dexbuilder.mintlify.site/zh/event-markets/api/broker-authentication.md)。

在确认 Market 当前接受订单后，可以针对指定 Outcome Token 提交交易。公开市场数据无需认证；下单属于私有操作，需要完成认证。

生产环境 Base URL：

```text theme={null}
https://api.dexbuilder.com
```

## 1. 读取 Market 交易限制

先查询 Market，并从 `outcomes[].token_id` 中选择要交易的 Token：

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/markets/<market_id>"
```

再读取公开订单簿：

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/tokens/<token_id>/order_book?depth=20"
```

提交订单前应根据响应中的 `min_order_size` 和 `tick_size` 做数量和价格校验。

## 2. 提交订单

```bash cURL theme={null}
curl -X POST "https://api.dexbuilder.com/api/v4/broker/prediction/orders" \
  -H "Content-Type: application/json" \
  -H "KEY: ${BROKER_API_KEY}" \
  -H "SIGN: ${SIGN}" \
  -H "Timestamp: ${TIMESTAMP}" \
  -H "X-User-Wallet-Address: ${WALLET}" \
  --data '{
    "token_id": "<token_id>",
    "side": "BUY",
    "price": "0.52",
    "size": "10",
    "total_cost": "5.20",
    "order_type": "GTC",
    "order_mode": "LIMIT",
    "client_order_id": "client-order-001",
    "post_only": false,
    "sell_all": false,
    "expire_time": 0
  }'
```

## 请求字段

| 字段 | 说明 |
| - | - |
| `token_id` | 要交易的 Outcome Token |
| `side` | 订单方向，例如 `BUY` / `SELL` |
| `price` | 限价，decimal string |
| `size` | 下单数量，decimal string |
| `total_cost` | 某些订单模式下使用的订单总成本 |
| `order_type` | 订单有效方式：`GTC`、`GTD`、`FOK` 或 `FAK` |
| `order_mode` | 下单模式：`LIMIT` 或 `MARKET` |
| `client_order_id` | 可选的客户端幂等 / 跟踪 ID |
| `post_only` | 是否只作为 Maker 提供流动性 |
| `sell_all` | 卖出时是否使用全部可用持仓 |
| `expire_time` | 适用时的过期时间，Unix 秒 |

## 接受响应

```json theme={null}
{
  "order_id": "order-123",
  "client_order_id": "client-order-001",
  "status": "processing",
  "created_at": 1782753357
}
```

`processing` 表示订单请求已受理并开始处理，不代表订单已成交。后续应通过订单查询接口读取当前 REST 状态。

## 下单前检查

* Market 必须满足 `accepting_orders: true`；
* `token_id` 应来自 Market 的 `outcomes` 数组；
* `size` 必须满足 `min_order_size`；
* `price` 必须符合 `tick_size`；
* 价格、数量、金额建议始终使用字符串，避免浮点精度误差；
* 私有请求必须使用正式认证方案。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.