跳轉到內容

創建訂單

接口信息

接口: POST /api/v1/orders

描述: 創建一個新的訂單。訂單創建者需要確保有足夠的餘額和授權額度。

鑑權: Authorization請求頭附加JWT令牌

請求參數

字段類型必填說明
orderobject訂單信息
order.makerstring訂單創建者地址(必須與JWT令牌中的用戶地址一致)
order.principalstring接收者地址
order.is_buybool是否是買入
order.tickerstring股票代碼
order.exchangeint交易所代碼。詳見Exchange枚舉類型說明
order.assetstring資產代幣地址
order.pricestring價格(以wei為單位,18位精度)。考慮到平台只接受穩定幣,下單價格需要考慮匯率換算。建議使用預估訂單手續費接口獲取匯率換算後的價格
order.quantitystring數量
order.incentivestring激勵金額(Maker提供的手續費)。這是Maker為訂單執行提供的手續費。只有當 order.incentive >= 預估手續費 時,券商才會鎖單並執行訂單。請使用預估訂單手續費接口獲取預估手續費
order.deadlinelong訂單簽名有效期截止時間戳(Unix時間戳,秒)。必須至少為當前時間 + 720小時(30天)。建議限價單設置更長的有效期以確保有足夠時間成交
order.noncelong防重放數字
signaturestring訂單簽名

響應參數

字段類型說明
iduuid訂單唯一標識
makerstring訂單創建者地址
principalstring接收者地址
is_buybool是否是買入
tickerstring股票代碼
exchangeint交易所代碼。詳見Exchange枚舉類型說明
assetstring資產代幣地址
pricestring價格
quantitystring數量
incentivestring激勵金額
deadlinelong截止時間戳
noncelong防重放數字
signaturestring訂單簽名
order_hashstring訂單哈希值
statusenum訂單狀態。詳見OrderStatus枚舉類型說明
filled_quantitystring已成交數量
created_atstring創建時間
updated_atstring更新時間

請求示例

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"
    }
}