創建訂單
接口信息
接口: POST /api/v1/orders
描述: 創建一個新的訂單。訂單創建者需要確保有足夠的餘額和授權額度。
鑑權: Authorization請求頭附加JWT令牌
請求參數
| 字段 | 類型 | 必填 | 說明 |
|---|---|---|---|
| order | object | 是 | 訂單信息 |
| order.maker | string | 是 | 訂單創建者地址(必須與JWT令牌中的用戶地址一致) |
| order.principal | string | 是 | 接收者地址 |
| order.is_buy | bool | 是 | 是否是買入 |
| order.ticker | string | 是 | 股票代碼 |
| order.exchange | int | 是 | 交易所代碼。詳見Exchange枚舉類型說明 |
| order.asset | string | 是 | 資產代幣地址 |
| order.price | string | 是 | 價格(以wei為單位,18位精度)。考慮到平台只接受穩定幣,下單價格需要考慮匯率換算。建議使用預估訂單手續費接口獲取匯率換算後的價格 |
| order.quantity | string | 是 | 數量 |
| order.incentive | string | 是 | 激勵金額(Maker提供的手續費)。這是Maker為訂單執行提供的手續費。只有當 order.incentive >= 預估手續費 時,券商才會鎖單並執行訂單。請使用預估訂單手續費接口獲取預估手續費 |
| order.deadline | long | 是 | 訂單簽名有效期截止時間戳(Unix時間戳,秒)。必須至少為當前時間 + 720小時(30天)。建議限價單設置更長的有效期以確保有足夠時間成交 |
| order.nonce | long | 是 | 防重放數字 |
| signature | string | 是 | 訂單簽名 |
響應參數
| 字段 | 類型 | 說明 |
|---|---|---|
| id | uuid | 訂單唯一標識 |
| maker | string | 訂單創建者地址 |
| principal | string | 接收者地址 |
| is_buy | bool | 是否是買入 |
| ticker | string | 股票代碼 |
| exchange | int | 交易所代碼。詳見Exchange枚舉類型說明 |
| asset | string | 資產代幣地址 |
| price | string | 價格 |
| quantity | string | 數量 |
| incentive | string | 激勵金額 |
| deadline | long | 截止時間戳 |
| nonce | long | 防重放數字 |
| signature | string | 訂單簽名 |
| order_hash | string | 訂單哈希值 |
| status | enum | 訂單狀態。詳見OrderStatus枚舉類型說明 |
| filled_quantity | string | 已成交數量 |
| created_at | string | 創建時間 |
| updated_at | string | 更新時間 |
請求示例
bash
curl -X POST "/api/v1/orders" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json" \
-d '{
"order": {
"maker": "0x1234567890123456789012345678901234567890",
"principal": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
"is_buy": true,
"ticker": "AAPL",
"exchange": 0,
"asset": "0x0000000000000000000000000000000000000001",
"price": "150250000000000000000",
"quantity": "100",
"incentive": "1000000000000000000",
"deadline": 1735689600,
"nonce": 1
},
"signature": "0x..."
}'響應示例
json
{
"code": 0,
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"maker": "0x1234567890123456789012345678901234567890",
"principal": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
"is_buy": true,
"ticker": "AAPL",
"exchange": 0,
"asset": "0x0000000000000000000000000000000000000001",
"price": "150250000000000000000",
"quantity": "100",
"incentive": "1000000000000000000",
"deadline": 1735689600,
"nonce": 1,
"signature": "0x...",
"order_hash": "0x1234567890abcdef...",
"status": "pending",
"filled_quantity": "0",
"created_at": "2025-01-17T03:00:24Z",
"updated_at": "2025-01-17T03:00:24Z"
}
}