# 交易介面

# 下單

介面

    POST /openApi/spot/v1/trade/order

參數

參數名 類型 是否必填 備註
symbol string 交易品種, 例如: BTC-USDT, 請使用大寫字母
side string 交易類型, BUY買 SELL賣
type string 訂單類型, MARKET市價 LIMIT限價
timeInForce string IOC, POC
quantity float64 下單數量, 例如: 0.1BTC
quoteOrderQty float64 下單金額, 例如: 100USDT
price float64 委託價格, 例如: 10000USDT
recvWindow int64 請求有效時間空窗值, 單位:毫秒
timestamp int64 請求時間戳, 單位:毫秒

注意

  • 限價單必須傳price參數。
  • 限價單必須傳quantityquoteOrderQty其中一個,當兩個參數同時傳遞時,服務端優先使用參數quantity
  • 市價買單必須傳quoteOrderQty參數。
  • 市價賣單必須傳quantity參數。
  • 介面創建的訂單在APP和Web頁面不會顯示。

響應

參數名 類型 備註
symbol string 交易品種
orderId int64 訂單號
transactTime int64 交易時間戳
price string 委託價格
origQty string 下單數量
executedQty string 成交數量
cummulativeQuoteQty string 成交額
status string 訂單狀態, NEW新訂單 PENDING委託中 PARTIALLY_FILLED部分成交 FILLED完全成交 CANCELED已撤銷 FAILED失敗
type string 訂單類型, MARKET市價 LIMIT限價
side string 交易類型, BUY買 SELL賣
{
    "code": 0,
    "msg": "",
    "data": {
        "symbol": "XRP-USDT",
        "orderId": 1514090846268424192,
        "transactTime": 1649822362855,
        "price": "0.5",
        "origQty": "10",
        "executedQty": "0",
        "cummulativeQuoteQty": "0",
        "status": "PENDING",
        "type": "LIMIT",
        "side": "BUY"
    }
}

# 撤單

介面

    POST /openApi/spot/v1/trade/cancel

參數

參數名 類型 是否必填 備註
symbol string 交易品種, 例如: BTC-USDT, 請使用大寫字母
orderId int64 訂單id
recvWindow int64 請求有效時間空窗值, 單位:毫秒
timestamp int64 請求時間戳, 單位:毫秒

響應

參數名 類型 備註
symbol string 交易品種
orderId int64 訂單號
price string 委託價格
origQty string 下單數量
executedQty string 成交數量
cummulativeQuoteQty string 成交額
status string 訂單狀態, NEW新訂單 PENDING委託中 PARTIALLY_FILLED部分成交 FILLED完全成交 CANCELED已撤銷 FAILED失敗
type string 訂單類型, MARKET市價 LIMIT限價
side string 交易類型, BUY買 SELL賣
{
    "code": 0,
    "msg": "",
    "data": {
        "symbol": "XRP-USDT",
        "orderId": 1514090846268424192,
        "price": "0.5",
        "origQty": "10",
        "executedQty": "0",
        "cummulativeQuoteQty": "0",
        "status": "CANCELED",
        "type": "LIMIT",
        "side": "BUY"
    }
}

# 查詢訂單

介面

    GET /openApi/spot/v1/trade/query

參數

參數名 類型 是否必填 備註
symbol string 交易品種, 例如: BTC-USDT, 請使用大寫字母
orderId int64 訂單id
recvWindow int64 請求有效時間空窗值, 單位:毫秒
timestamp int64 請求時間戳, 單位:毫秒

響應

參數名 類型 備註
symbol string 交易品種
orderId int64 訂單號
price string 委託價格
origQty string 下單數量
executedQty string 成交數量
cummulativeQuoteQty string 成交額
status string 訂單狀態, NEW新訂單 PENDING委託中 PARTIALLY_FILLED部分成交 FILLED完全成交 CANCELED已撤銷 FAILED失敗
type string 訂單類型, MARKET市價 LIMIT限價
side string 交易類型, BUY買 SELL賣
time int64 下單時間戳
updateTime int64 更新時間戳
origQuoteOrderQty string 下單金額
fee string 手續費
feeAsset string 手續費資產類型
{
    "code": 0,
    "msg": "",
    "data": {
        "symbol": "XRP-USDT",
        "orderId": 1514087361158316032,
        "price": "0.5",
        "origQty": "10",
        "executedQty": "0",
        "cummulativeQuoteQty": "0",
        "status": "CANCELED",
        "type": "LIMIT",
        "side": "BUY",
        "time": 1649821532000,
        "updateTime": 1649821543000,
        "origQuoteOrderQty": "0",
        "fee": "0",
        "feeAsset": "XRP"
    }
}

# 查詢委託訂單列表

介面

    GET /openApi/spot/v1/trade/openOrders

參數

參數名 類型 是否必填 備註
symbol string 交易品種, 例如: BTC-USDT, 請使用大寫字母
recvWindow int64 請求有效時間空窗值, 單位:毫秒
timestamp int64 請求時間戳, 單位:毫秒

響應

參數名 類型 備註
orders array 訂單列表,最大長度為2000, 訂單欄位參考下表
參數名 類型 備註
symbol string 交易品種
orderId int64 訂單號
price string 委託價格
origQty string 下單數量
executedQty string 成交數量
cummulativeQuoteQty string 成交額
status string 訂單狀態, NEW新訂單 PENDING委託中 PARTIALLY_FILLED部分成交 FILLED完全成交 CANCELED已撤銷 FAILED失敗
type string 訂單類型, MARKET市價 LIMIT限價
side string 交易類型, BUY買 SELL賣
time int64 下單時間戳
updateTime int64 更新時間戳
origQuoteOrderQty string 下單金額
{
    "code": 0,
    "msg": "",
    "data": {
        "orders": [
            {
                "symbol": "XRP-USDT",
                "orderId": 1514073325788200960,
                "price": "0.5",
                "origQty": "20",
                "executedQty": "0",
                "cummulativeQuoteQty": "0",
                "status": "PENDING",
                "type": "LIMIT",
                "side": "BUY",
                "time": 1649818185647,
                "updateTime": 1649818185647,
                "origQuoteOrderQty": "0"
            }
        ]
    }
}

# 查詢歷史訂單列表

介面

    GET /openApi/spot/v1/trade/historyOrders

參數

參數名 類型 是否必填 備註
symbol string 交易品種, 例如: BTC-USDT, 請使用大寫字母
orderId int64
startTime int64 開始時間戳, 單位:毫秒
endTime int64 結束時間戳, 單位:毫秒
pageIndex int64 分頁頁碼,必須大於0
pageSize int64 分頁數量,必須大於0,最大值為100
recvWindow int64 請求有效時間空窗值, 單位:毫秒
timestamp int64 請求時間戳, 單位:毫秒

注意

  • 如設置 orderId , 訂單將 >= orderId。否則將返回最新訂單。
  • 如果設置 startTime 和 endTime, orderId 就不需要設置。

響應

參數名 類型 備註
orders array 訂單列表, 訂單欄位參考下表
參數名 類型 備註
symbol string 交易品種
orderId int64 訂單號
price string 委託價格
origQty string 下單數量
executedQty string 成交數量
cummulativeQuoteQty string 成交額
status string 訂單狀態, NEW新訂單 PENDING委託中 PARTIALLY_FILLED部分成交 FILLED完全成交 CANCELED已撤銷 FAILED失敗
type string 訂單類型, MARKET市價 LIMIT限價
side string 交易類型, BUY買 SELL賣
time int64 下單時間戳
updateTime int64 更新時間戳
origQuoteOrderQty string 下單金額
{
    "code": 0,
    "msg": "",
    "data": {
        "orders": [
            {
                "symbol": "XRP-USDT",
                "orderId": 1502203895118561280,
                "price": "0.74011",
                "origQty": "0",
                "executedQty": "13.5",
                "cummulativeQuoteQty": "9.9927",
                "status": "FILLED",
                "type": "MARKET",
                "side": "BUY",
                "time": 1646988293000,
                "updateTime": 1646988293000,
                "origQuoteOrderQty": "10"
            }
        ]
    }
}

# 查詢資產

介面

    GET /openApi/spot/v1/account/balance

參數

參數名 類型 是否必填 備註
recvWindow int64 請求有效時間空窗值, 單位:毫秒
timestamp int64 請求時間戳, 單位:毫秒

響應

參數名 類型 備註
balances array 資產列表, 元素欄位參考下表
參數名 類型 備註
asset string 資產名
free string 可用資金
locked string 凍結資金
{
    "code": 0,
    "msg": "",
    "ttl": 1,
    "data": {
        "balances": [
            {
                "asset": "USDT",
                "free": "16.73971130673954",
                "locked": "0"
            }
        ]
    }
}
Last Updated: 6/10/2022, 5:53:34 PM