订单管理 (Orders)
创建和管理交易订单。
创建订单
接口信息
- Method:
POST - Path:
/api/v1/orders - Authentication: 需要身份验证(JWT Token)
- Content-Type:
application/json
请求参数
| 参数 | 类型 | 必须 | 描述 |
|---|---|---|---|
| symbol | string | 是 | 交易对 (如 BTCUSDT) |
| side | string | 是 | 方向 (buy, sell) |
| order_type | string | 是 | 类型 (limit, market) |
| amount | string | 是 | 数量(Decimal 字符串) |
| price | string | 否 | 价格(限价单必传,Decimal 字符串) |
| leverage | number | 是 | 杠杆倍数 (1-50) |
| signature | string | 是 | 订单签名(0x开头) |
| timestamp | number | 是 | Unix 时间戳(秒) |
参数说明
- order_type:
limit或market - side:
buy或sell - leverage: 杠杆倍数 (1-50x)
- signature: 需要对订单消息进行签名,签名消息格式:
Create Order on ZTDX
Symbol: {symbol}
Side: {side}
Type: {order_type}
Price: {price}
Amount: {amount}
Leverage: {leverage}
Timestamp: {timestamp}
Address: {address}
请求示例
{
"symbol": "BTCUSDT",
"side": "buy",
"order_type": "limit",
"amount": "0.1",
"price": "65000",
"leverage": 10,
"signature": "0x...",
"timestamp": 1704067200
}
响应示例
{
"order_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "open",
"filled_amount": "0",
"remaining_amount": "0.1",
"average_price": null,
"created_at": "2024-01-01T00:00:00Z"
}
响应字段说明
| 字段 | 类型 | 描述 |
|---|---|---|
| order_id | string | 订单 UUID |
| status | string | 订单状态(pending/open/partially_filled/filled/cancelled/rejected) |
| filled_amount | string | 已成交数量 |
| remaining_amount | string | 剩余未成交数量 |
| average_price | string | null | 平均成交价格 |
| created_at | string | 创建时间(ISO 8601 格式) |
错误响应
| HTTP 状态码 | 错误码 | 描述 |
|---|---|---|
| 400 | INVALID_SYMBOL | 不支持的交易对 |
| 400 | TIMESTAMP_EXPIRED | 时间戳已过期 |
| 400 | INVALID_LEVERAGE | 杠杆倍数必须在1-50之间 |
| 400 | INVALID_AMOUNT | 订单数量必须大于0 |
| 400 | PRICE_REQUIRED | 限价单必须指定价格 |
| 400 | INSUFFICIENT_BALANCE | 可用余额不足 |
| 401 | ORDER_SIGNATURE_INVALID | 订单签名验证失败 |
| 500 | MATCHING_ERROR | 撮合引擎错误 |
查询订单
接口信息
- Method:
GET - Path:
/api/v1/orders/:order_id - Authentication: 需要身份验证
路径参数
| 参数 | 类型 | 必须 | 描述 |
|---|---|---|---|
| order_id | string | 是 | 订单 UUID |
响应示例
{
"order_id": "550e8400-e29b-41d4-a716-446655440000",
"symbol": "BTCUSDT",
"side": "buy",
"order_type": "limit",
"price": "65000",
"amount": "0.1",
"filled_amount": "0.05",
"remaining_amount": "0.05",
"leverage": 10,
"status": "partially_filled",
"created_at": "2024-01-01T00:00:00Z"
}
响应字段说明
| 字段 | 类型 | 描述 |
|---|---|---|
| order_id | string | 订单 UUID |
| symbol | string | 交易对 |
| side | string | 方向(buy/sell) |
| order_type | string | 订单类型(limit/market) |
| price | string | null | 订单价格 |
| amount | string | 订单数量 |
| filled_amount | string | 已成交数量 |
| remaining_amount | string | 剩余数量 |
| leverage | number | 杠杆倍数 |
| status | string | 订单状态 |
| created_at | string | 创建时间 |
订单状态说明
| 状态 | 描述 |
|---|---|
| pending | 待处理 |
| open | 已挂单(活动中) |
| partially_filled | 部分成交 |
| filled | 完全成交 |
| cancelled | 已取消 |
| rejected | 已拒绝 |
取消订单
接口信息
- Method:
DELETE - Path:
/api/v1/orders/:order_id - Authentication: 需要身份验证
- Content-Type:
application/json