跳转至

Spot Trading

现货下单、撤单、全部撤单、撤单重挂与查询。

典型流程:下单(POST /openapi/v1/order)→ 查询挂单/历史 → 撤单、全部撤单(POST /openapi/v1/order/cancelAll)或撤单重挂。

重要: POST /openapi/v1/order 的业务字段全部放在 URL query(与常见交易所 OpenAPI 一致),没有 JSON request body。HMAC 签名覆盖整段 query(不含 signature)。

下单前请先读 GET /openapi/v1/exchangeInfo,按该交易对的 filters(PRICE_FILTER、LOT_SIZE、MIN_NOTIONAL / NOTIONAL 以及可能的价格带)核对数量与价格。精度与上下限不会写死在下单接口上。

按订单类型下单

POST /openapi/v1/order 支持六种 type。每种类型对数量、价格字段的必填 / 互斥 / 禁止规则不同;传了禁止字段会返回参数错误。POST /openapi/v1/order/cancelReplace 中新单部分遵循同一套规则。

图例:必填 · 二选一 · 按方向 · 禁止 · 可选(传了仍会按规则校验)。

type 含义 quantity(基础币) quoteOrderQty(计价币) price stopPrice timeInForce
LIMIT 限价 必填 禁止 必填 禁止 可选,默认 GTC
MARKET 市价 二选一 二选一(互斥) 勿传 禁止 不使用
STOP_LOSS 止损市价 SELL 必填 BUY 必填 勿传 必填 不使用
TAKE_PROFIT 止盈市价 SELL 必填 BUY 必填 勿传 必填 不使用
STOP_LOSS_LIMIT 止损限价 必填 禁止 必填 必填 可选,默认 GTC
TAKE_PROFIT_LIMIT 止盈限价 必填 禁止 必填 必填 可选,默认 GTC

每种类型都要传 symbol、side(BUY / SELL)、type,以及 timestamp、signature(和 API Key 请求头)。可选公共参数:newClientOrderId、newOrderRespType(ACK / RESULT / FULL)、stpFlag(CB / CN / CO,默认 CB)、recvWindow。

条件市价触发后的数量按方向选择:

  • BUY + STOP_LOSS / TAKE_PROFIT → 只传 quoteOrderQty(花多少计价币)
  • SELL + STOP_LOSS / TAKE_PROFIT → 只传 quantity(卖多少基础币)

stopPrice 相对最新价(last)的触发方向:

type BUY 触发 SELL 触发
STOP_LOSS / STOP_LOSS_LIMIT last ≥ stopPrice last ≤ stopPrice
TAKE_PROFIT / TAKE_PROFIT_LIMIT last ≤ stopPrice last ≥ stopPrice

若交易对 allowPlan=false,四种条件单都会被拒绝。

下列示例为完整 curl。请替换 {host}、{apiKey}、{ts}、{signature}。签名时对不含 signature 的 query 串计算 HMAC,参数顺序与实际发送一致。

LIMIT — 按 price 挂限价单,数量用 quantity(基础币)。timeInForce:GTC 挂到撤;IOC 能成多少成多少,剩余撤销;FOK 不能全成则整单拒绝。

curl -X POST "https://{host}/openapi/v1/order?symbol=BTCUSDT&side=BUY&type=LIMIT&timeInForce=GTC&quantity=0.001&price=50000&timestamp={ts}&signature={signature}" \
  -H "x-ptrader-apikey: {apiKey}"

MARKET — 立即成交。quantity 与 quoteOrderQty 必须二选一(不能同时传,也不能都不传)。只传 quantity 表示固定基础币数量;只传 quoteOrderQty 表示固定计价币金额。不要传 price / stopPrice。

按计价币金额买入:

curl -X POST "https://{host}/openapi/v1/order?symbol=BTCUSDT&side=BUY&type=MARKET&quoteOrderQty=100&timestamp={ts}&signature={signature}" \
  -H "x-ptrader-apikey: {apiKey}"

按基础币数量卖出:

curl -X POST "https://{host}/openapi/v1/order?symbol=BTCUSDT&side=SELL&type=MARKET&quantity=0.001&timestamp={ts}&signature={signature}" \
  -H "x-ptrader-apikey: {apiKey}"

STOP_LOSS — 触发后变成市价单。数量规则见上:买入用 quoteOrderQty,卖出用 quantity。必须传 stopPrice;不要传 price。

价格下跌时卖出:

curl -X POST "https://{host}/openapi/v1/order?symbol=BTCUSDT&side=SELL&type=STOP_LOSS&quantity=0.001&stopPrice=48000&timestamp={ts}&signature={signature}" \
  -H "x-ptrader-apikey: {apiKey}"

价格上涨时买入:

curl -X POST "https://{host}/openapi/v1/order?symbol=BTCUSDT&side=BUY&type=STOP_LOSS&quoteOrderQty=100&stopPrice=52000&timestamp={ts}&signature={signature}" \
  -H "x-ptrader-apikey: {apiKey}"

TAKE_PROFIT — 字段规则与 STOP_LOSS 相同,触发方向相反(见上方触发表)。

价格上涨时卖出:

curl -X POST "https://{host}/openapi/v1/order?symbol=BTCUSDT&side=SELL&type=TAKE_PROFIT&quantity=0.001&stopPrice=55000&timestamp={ts}&signature={signature}" \
  -H "x-ptrader-apikey: {apiKey}"

价格下跌时买入:

curl -X POST "https://{host}/openapi/v1/order?symbol=BTCUSDT&side=BUY&type=TAKE_PROFIT&quoteOrderQty=100&stopPrice=45000&timestamp={ts}&signature={signature}" \
  -H "x-ptrader-apikey: {apiKey}"

STOP_LOSS_LIMIT — 触发后按 price 挂限价。必须传 quantity、price、stopPrice;禁止 quoteOrderQty。price 与 stopPrice 都要对齐 exchangeInfo 的 tickSize。timeInForce 默认 GTC。

curl -X POST "https://{host}/openapi/v1/order?symbol=BTCUSDT&side=SELL&type=STOP_LOSS_LIMIT&quantity=0.001&price=47900&stopPrice=48000&timeInForce=GTC&timestamp={ts}&signature={signature}" \
  -H "x-ptrader-apikey: {apiKey}"

TAKE_PROFIT_LIMIT — 字段与 STOP_LOSS_LIMIT 相同,触发方向为止盈。

curl -X POST "https://{host}/openapi/v1/order?symbol=BTCUSDT&side=SELL&type=TAKE_PROFIT_LIMIT&quantity=0.001&price=55100&stopPrice=55000&timeInForce=GTC&timestamp={ts}&signature={signature}" \
  -H "x-ptrader-apikey: {apiKey}"

Pepperstone Crypto Public OpenAPI — Spot Trading 1.0.0

Pepperstone Crypto 公开 REST API。

需鉴权的接口使用 HMAC。签名规则见开发者文档「鉴权」章节。WebSocket 行情与私有流另见 WebSocket 文档。除另行说明外,时间均为 UTC 毫秒。


Servers

Description URL
Production https://api.pcrypto.com

Spot Trading


GET /openapi/v1/historyOrders

查询历史订单

Description

所需类型:现货交易(GET 亦接受 Read only)

Historical orders.

输入参数

参数 位置 类型 必填 默认值 说明
x-ptrader-apikey header string 是 API Key。
limit query integer 否 500 返回条数,范围 1–1000。
recvWindow query integer 否 5000 请求有效时间窗(毫秒),范围 1–60000。
signature query string 是 HMAC-SHA256 签名(十六进制)。见「鉴权 → HMAC 签名」。
symbol query string 否 交易对(如 BTCUSDT)。大小写不敏感,建议大写。
timestamp query integer 是 请求时间戳(Unix 毫秒)。

Responses

Success

Response fields

Array of QueryOrder:

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (BigDecimal on the wire).
executedQty number Decimal amount as a JSON number (BigDecimal on the wire).
isWorking boolean
orderId integer(int64) Order id. JSON numbers may exceed JavaScript Number.MAX_SAFE_INTEGER (9007199254740991); parse losslessly (JSON reviver, json-bigint, or BigInt) before cancel or query by id.
origQty number Decimal amount as a JSON number (BigDecimal on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (BigDecimal on the wire).
price number Decimal amount as a JSON number (BigDecimal on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. null for LIMIT/MARKET (no trigger); a number for the four conditional types.
symbol string
time integer(int64)
timeInForce string
type string
updateTime integer(int64)

invalid_parameter

{
    "code": -1025,
    "msg": "Parameter 'limit' is not valid."
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string

rate_limited

{
    "code": -1003,
    "msg": "Too many requests; current request has limited."
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string


GET /openapi/v1/myTrades

查询我的成交

Description

所需类型:现货交易(GET 亦接受 Read only)

Historical trades. symbol required.

输入参数

参数 位置 类型 必填 默认值 说明
x-ptrader-apikey header string 是 API Key。
limit query integer 否 500 返回条数,范围 1–1000。
recvWindow query integer 否 5000 请求有效时间窗(毫秒),范围 1–60000。
signature query string 是 HMAC-SHA256 签名(十六进制)。见「鉴权 → HMAC 签名」。
symbol query string 是 交易对(如 BTCUSDT)。大小写不敏感,建议大写。
timestamp query integer 是 请求时间戳(Unix 毫秒)。

Responses

Success

Response fields

Array of Trade:

Name Type Description
commission number Decimal amount as a JSON number (BigDecimal on the wire).
commissionAsset string
id integer(int64)
isBestMatch boolean
isBuyer boolean
isMaker boolean
orderId integer(int64) Order id. JSON numbers may exceed JavaScript Number.MAX_SAFE_INTEGER (9007199254740991); parse losslessly (JSON reviver, json-bigint, or BigInt) before cancel or query by id.
price number Decimal amount as a JSON number (BigDecimal on the wire).
qty number Decimal amount as a JSON number (BigDecimal on the wire).
quoteQty number Decimal amount as a JSON number (BigDecimal on the wire).
symbol string
time integer(int64)

missing_parameter

{
    "code": -1010,
    "msg": "Missing required parameter 'symbol'"
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string

rate_limited

{
    "code": -1003,
    "msg": "Too many requests; current request has limited."
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string


GET /openapi/v1/openOrders

查询当前挂单

Description

所需类型:现货交易(GET 亦接受 Read only)

List open orders. symbol optional.

输入参数

参数 位置 类型 必填 默认值 说明
x-ptrader-apikey header string 是 API Key。
recvWindow query integer 否 5000 请求有效时间窗(毫秒),范围 1–60000。
signature query string 是 HMAC-SHA256 签名(十六进制)。见「鉴权 → HMAC 签名」。
symbol query string 否 交易对(如 BTCUSDT)。大小写不敏感,建议大写。
timestamp query integer 是 请求时间戳(Unix 毫秒)。

备注

  • 不传 symbol 时返回所有交易对的当前挂单。

Responses

Success

Response fields

Array of QueryOrder:

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (BigDecimal on the wire).
executedQty number Decimal amount as a JSON number (BigDecimal on the wire).
isWorking boolean
orderId integer(int64) Order id. JSON numbers may exceed JavaScript Number.MAX_SAFE_INTEGER (9007199254740991); parse losslessly (JSON reviver, json-bigint, or BigInt) before cancel or query by id.
origQty number Decimal amount as a JSON number (BigDecimal on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (BigDecimal on the wire).
price number Decimal amount as a JSON number (BigDecimal on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. null for LIMIT/MARKET (no trigger); a number for the four conditional types.
symbol string
time integer(int64)
timeInForce string
type string
updateTime integer(int64)

rate_limited

{
    "code": -1003,
    "msg": "Too many requests; current request has limited."
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string


POST /openapi/v1/order

下单

Description

所需类型:现货交易

现货下单。参数全部走 query(无 JSON body)。数量/价格字段随 type 变化——见 REST → Spot Trading(按订单类型下单)。须传 symbol、side、type。下单前先读 exchangeInfo.filters。六种类型:LIMIT、MARKET、STOP_LOSS、TAKE_PROFIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT。

输入参数

参数 位置 类型 必填 默认值 说明
x-ptrader-apikey header string 是 API Key。
newClientOrderId query string 否 客户端订单号。缺省时由服务端生成 UUID。
newOrderRespType query string 否 ACK、RESULT 或 FULL。
price query string 否 限价(小数字符串)。
quantity query string 否 基础币数量(小数字符串)。
quoteOrderQty query string 否 计价币金额(小数字符串)。
recvWindow query integer 否 5000 请求有效时间窗(毫秒),范围 1–60000。
side query string 是 BUY 或 SELL。
signature query string 是 HMAC-SHA256 签名(十六进制)。见「鉴权 → HMAC 签名」。
stopPrice query string 否 触发价(小数字符串)。
stpFlag query string 否 CB 防自成交:CB(双方取消)、CN(撤新单)或 CO(撤旧单)。
symbol query string 是 交易对(如 BTCUSDT)。大小写不敏感,建议大写。
timeInForce query string 否 GTC GTC、IOC 或 FOK。
timestamp query integer 是 请求时间戳(Unix 毫秒)。
type query string 是 取值为 LIMIT、MARKET、STOP_LOSS、TAKE_PROFIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT。

备注

  • 必填的数量和价格字段取决于 type,见按类型下单。
  • quantity:LIMIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT 必填;STOP_LOSS / TAKE_PROFIT 在 SELL 时必填。MARKET 与 quoteOrderQty 二选一。
  • quoteOrderQty:STOP_LOSS / TAKE_PROFIT 在 BUY 时必填。LIMIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT 不可传。
  • price:LIMIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT 必填;MARKET、STOP_LOSS、TAKE_PROFIT 勿传。
  • stopPrice:STOP_LOSS、TAKE_PROFIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT 必填;LIMIT、MARKET 不可传。
  • timeInForce 仅用于 LIMIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT。
  • newOrderRespType 默认值:LIMIT 与 MARKET 为 FULL,其他类型为 ACK。

Responses

Success

Response fields

Place-order response. Shape depends on newOrderRespType: ACK → NewOrderAck, RESULT → NewOrderResult, FULL → NewOrderFull.

Variant 1 — NewOrderAck

Name Type Description
clientOrderId string
orderId integer(int64) Order id. JSON numbers may exceed JavaScript Number.MAX_SAFE_INTEGER (9007199254740991); parse losslessly (JSON reviver, json-bigint, or BigInt) before cancel or query by id.
symbol string
transactTime integer(int64)

Variant 2 — NewOrderResult

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (BigDecimal on the wire).
executedQty number Decimal amount as a JSON number (BigDecimal on the wire).
orderId integer(int64) Order id. JSON numbers may exceed JavaScript Number.MAX_SAFE_INTEGER (9007199254740991); parse losslessly (JSON reviver, json-bigint, or BigInt) before cancel or query by id.
origQty number Decimal amount as a JSON number (BigDecimal on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (BigDecimal on the wire).
price number Decimal amount as a JSON number (BigDecimal on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. null for LIMIT/MARKET (no trigger); a number for the four conditional types.
symbol string
timeInForce string
transactTime integer(int64)
type string

Variant 3 — NewOrderFull

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (BigDecimal on the wire).
executedQty number Decimal amount as a JSON number (BigDecimal on the wire).
fills Array<FillTrade>
orderId integer(int64) Order id. JSON numbers may exceed JavaScript Number.MAX_SAFE_INTEGER (9007199254740991); parse losslessly (JSON reviver, json-bigint, or BigInt) before cancel or query by id.
origQty number Decimal amount as a JSON number (BigDecimal on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (BigDecimal on the wire).
price number Decimal amount as a JSON number (BigDecimal on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. null for LIMIT/MARKET (no trigger); a number for the four conditional types.
symbol string
timeInForce string
transactTime integer(int64)
type string

missing_parameter

{
    "code": -1010,
    "msg": "Missing required parameter 'symbol'"
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string

rate_limited

{
    "code": -1003,
    "msg": "Too many requests; current request has limited."
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string


GET /openapi/v1/order

查询订单

Description

所需类型:现货交易(GET 亦接受 Read only)

查询单笔订单。提供 orderId 或 origClientOrderId(二选一)。

输入参数

参数 位置 类型 必填 默认值 说明
x-ptrader-apikey header string 是 API Key。
orderId query string 否 交易所订单号。
origClientOrderId query string 否 下单时的客户端订单号(newClientOrderId)。
recvWindow query integer 否 5000 请求有效时间窗(毫秒),范围 1–60000。
signature query string 是 HMAC-SHA256 签名(十六进制)。见「鉴权 → HMAC 签名」。
timestamp query integer 是 请求时间戳(Unix 毫秒)。

备注

  • orderId 与 origClientOrderId 至少传一个。
  • 两者都传时以 orderId 为准。

Responses

Success

Response fields

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (BigDecimal on the wire).
executedQty number Decimal amount as a JSON number (BigDecimal on the wire).
isWorking boolean
orderId integer(int64) Order id. JSON numbers may exceed JavaScript Number.MAX_SAFE_INTEGER (9007199254740991); parse losslessly (JSON reviver, json-bigint, or BigInt) before cancel or query by id.
origQty number Decimal amount as a JSON number (BigDecimal on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (BigDecimal on the wire).
price number Decimal amount as a JSON number (BigDecimal on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. null for LIMIT/MARKET (no trigger); a number for the four conditional types.
symbol string
time integer(int64)
timeInForce string
type string
updateTime integer(int64)

rate_limited

{
    "code": -1003,
    "msg": "Too many requests; current request has limited."
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string


POST /openapi/v1/order/cancelReplace

撤单并改单

Description

所需类型:现货交易

先撤后下。新单的数量/价格字段与 POST /openapi/v1/order 的 type 规则相同(见 REST → Spot Trading)。另需 cancelReplaceMode,以及 cancelOrderId 或 cancelOrigClientOrderId。

输入参数

参数 位置 类型 必填 默认值 说明
x-ptrader-apikey header string 是 API Key。
cancelOrderId query string 否 要撤销订单的交易所订单号。
cancelOrigClientOrderId query string 否 要撤销订单的客户端订单号。
cancelReplaceMode query string 是 STOP_ON_FAILURE 或 ALLOW_FAILURE。
newClientOrderId query string 否 客户端订单号。缺省时由服务端生成 UUID。
newOrderRespType query string 否 ACK、RESULT 或 FULL。
price query string 否 限价(小数字符串)。
quantity query string 否 基础币数量(小数字符串)。
quoteOrderQty query string 否 计价币金额(小数字符串)。
recvWindow query integer 否 5000 请求有效时间窗(毫秒),范围 1–60000。
side query string 是 BUY 或 SELL。
signature query string 是 HMAC-SHA256 签名(十六进制)。见「鉴权 → HMAC 签名」。
stopPrice query string 否 触发价(小数字符串)。
stpFlag query string 否 CB 防自成交:CB(双方取消)、CN(撤新单)或 CO(撤旧单)。
symbol query string 是 交易对(如 BTCUSDT)。大小写不敏感,建议大写。
timeInForce query string 否 GTC GTC、IOC 或 FOK。
timestamp query integer 是 请求时间戳(Unix 毫秒)。
type query string 是 取值为 LIMIT、MARKET、STOP_LOSS、TAKE_PROFIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT。

备注

  • 用 cancelOrderId 或 cancelOrigClientOrderId 指定要撤销的订单。
  • 必填的数量和价格字段取决于 type,见按类型下单。
  • quantity:LIMIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT 必填;STOP_LOSS / TAKE_PROFIT 在 SELL 时必填。MARKET 与 quoteOrderQty 二选一。
  • quoteOrderQty:STOP_LOSS / TAKE_PROFIT 在 BUY 时必填。LIMIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT 不可传。
  • price:LIMIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT 必填;MARKET、STOP_LOSS、TAKE_PROFIT 勿传。
  • stopPrice:STOP_LOSS、TAKE_PROFIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT 必填;LIMIT、MARKET 不可传。
  • timeInForce 仅用于 LIMIT、STOP_LOSS_LIMIT、TAKE_PROFIT_LIMIT。
  • newOrderRespType 默认值:LIMIT 与 MARKET 为 FULL,其他类型为 ACK。

Responses

Success

Response fields

Cancel-replace result: CancelReplaceBothSuccess when both sides succeed, or CancelReplaceWithError (code / msg / data) when cancel and/or the new order fails.

Variant 1 — CancelReplaceBothSuccess

Cancel-replace success: cancelResult and newOrderResult are both SUCCESS.

Name Type Description
cancelResponse CancelReplaceCancelResponse
cancelResult string
newOrderResponse NewOrderResponse
newOrderResult string

Variant 2 — CancelReplaceWithError

code / msg plus data when cancel-replace partially or fully fails.

Name Type Description
code integer
data CancelReplaceFailedData
msg string

missing_parameter

{
    "code": -1010,
    "msg": "Missing required parameter 'symbol'"
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string

rate_limited

{
    "code": -1003,
    "msg": "Too many requests; current request has limited."
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string


POST /openapi/v1/order/cancel

撤单

Description

所需类型:现货交易

按 orderId 或 origClientOrderId 撤销单笔订单。

输入参数

参数 位置 类型 必填 默认值 说明
x-ptrader-apikey header string 是 API Key。
orderId query string 否 交易所订单号。
origClientOrderId query string 否 下单时的客户端订单号(newClientOrderId)。
recvWindow query integer 否 5000 请求有效时间窗(毫秒),范围 1–60000。
signature query string 是 HMAC-SHA256 签名(十六进制)。见「鉴权 → HMAC 签名」。
timestamp query integer 是 请求时间戳(Unix 毫秒)。

备注

  • orderId 与 origClientOrderId 至少传一个。

Responses

Success

Response fields

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (BigDecimal on the wire).
executedQty number Decimal amount as a JSON number (BigDecimal on the wire).
orderId integer(int64) Order id. JSON numbers may exceed JavaScript Number.MAX_SAFE_INTEGER (9007199254740991); parse losslessly (JSON reviver, json-bigint, or BigInt) before cancel or query by id.
origQty number Decimal amount as a JSON number (BigDecimal on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (BigDecimal on the wire).
price number Decimal amount as a JSON number (BigDecimal on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. null for LIMIT/MARKET (no trigger); a number for the four conditional types.
symbol string
timeInForce string
type string

rate_limited

{
    "code": -1003,
    "msg": "Too many requests; current request has limited."
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string


POST /openapi/v1/order/cancelAll

撤销全部挂单

Description

所需类型:现货交易

撤销指定交易对的全部挂单。必须传 confirmCancelAll=true。

输入参数

参数 位置 类型 必填 默认值 说明
x-ptrader-apikey header string 是 API Key。
confirmCancelAll query boolean 是 必须为 true,以确认撤销该交易对的全部挂单。
recvWindow query integer 否 5000 请求有效时间窗(毫秒),范围 1–60000。
signature query string 是 HMAC-SHA256 签名(十六进制)。见「鉴权 → HMAC 签名」。
symbol query string 是 交易对(如 BTCUSDT)。大小写不敏感,建议大写。
timestamp query integer 是 请求时间戳(Unix 毫秒)。

Responses

Success

Response fields

Array of CancelOrder:

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (BigDecimal on the wire).
executedQty number Decimal amount as a JSON number (BigDecimal on the wire).
orderId integer(int64) Order id. JSON numbers may exceed JavaScript Number.MAX_SAFE_INTEGER (9007199254740991); parse losslessly (JSON reviver, json-bigint, or BigInt) before cancel or query by id.
origQty number Decimal amount as a JSON number (BigDecimal on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (BigDecimal on the wire).
price number Decimal amount as a JSON number (BigDecimal on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. null for LIMIT/MARKET (no trigger); a number for the four conditional types.
symbol string
timeInForce string
type string

missing_parameter

{
    "code": -1010,
    "msg": "Missing required parameter 'symbol'"
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string

rate_limited

{
    "code": -1003,
    "msg": "Too many requests; current request has limited."
}

Response fields

Error payload. Most API errors (including auth failures such as -1002) return HTTP 200 — see Error codes → HTTP status mapping. HTTP 400 for missing or invalid request parameters. HTTP 429 when rate limited.

Name Type Description
code integer
msg string


Schemas

CancelOrder

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
executedQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
orderId integer(int64) Order id. JSON numbers may exceed JavaScript `Number.MAX_SAFE_INTEGER` (9007199254740991); parse losslessly (JSON reviver, json-bigint, or `BigInt`) before cancel or query by id.
origQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
price number Decimal amount as a JSON number (`BigDecimal` on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. `null` for `LIMIT`/`MARKET` (no trigger); a number for the four conditional types.
symbol string
timeInForce string
type string

CancelReplaceBothSuccess

Name Type Description
cancelResponse CancelReplaceCancelResponse
cancelResult string
newOrderResponse NewOrderResponse
newOrderResult string

CancelReplaceCancelResponse

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
executedQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
orderId integer(int64) Order id. JSON numbers may exceed JavaScript `Number.MAX_SAFE_INTEGER` (9007199254740991); parse losslessly (JSON reviver, json-bigint, or `BigInt`) before cancel or query by id.
origQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
price number Decimal amount as a JSON number (`BigDecimal` on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. `null` for `LIMIT`/`MARKET` (no trigger); a number for the four conditional types.
stpFlag string
symbol string
timeInForce string
transactTime integer(int64)
type string

CancelReplaceFailedData

Name Type Description
cancelResponse
cancelResult string
newOrderResponse `NewOrder*` on success, `ErrorRet` on failure, or null if not attempted.
newOrderResult string

CancelReplaceResponse

Cancel-replace result: `CancelReplaceBothSuccess` when both sides succeed, or `CancelReplaceWithError` (`code` / `msg` / `data`) when cancel and/or the new order fails.

One of:

CancelReplaceWithError

Name Type Description
code integer
data CancelReplaceFailedData
msg string

ErrorBody

Name Type Description
code integer
msg string

ErrorRet

Name Type Description
code integer
msg string

FillTrade

Name Type Description
commission number Decimal amount as a JSON number (`BigDecimal` on the wire).
commissionAsset string
price number Decimal amount as a JSON number (`BigDecimal` on the wire).
qty number Decimal amount as a JSON number (`BigDecimal` on the wire).
tradeId integer(int64) Trade id (`Long`). May exceed JavaScript `Number.MAX_SAFE_INTEGER`; parse losslessly when correlating fills.

NewOrderAck

Name Type Description
clientOrderId string
orderId integer(int64) Order id. JSON numbers may exceed JavaScript `Number.MAX_SAFE_INTEGER` (9007199254740991); parse losslessly (JSON reviver, json-bigint, or `BigInt`) before cancel or query by id.
symbol string
transactTime integer(int64)

NewOrderFull

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
executedQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
fills Array<FillTrade>
orderId integer(int64) Order id. JSON numbers may exceed JavaScript `Number.MAX_SAFE_INTEGER` (9007199254740991); parse losslessly (JSON reviver, json-bigint, or `BigInt`) before cancel or query by id.
origQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
price number Decimal amount as a JSON number (`BigDecimal` on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. `null` for `LIMIT`/`MARKET` (no trigger); a number for the four conditional types.
symbol string
timeInForce string
transactTime integer(int64)
type string

NewOrderResponse

Place-order response. Shape depends on `newOrderRespType`: `ACK` → `NewOrderAck`, `RESULT` → `NewOrderResult`, `FULL` → `NewOrderFull`.

One of:

NewOrderResult

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
executedQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
orderId integer(int64) Order id. JSON numbers may exceed JavaScript `Number.MAX_SAFE_INTEGER` (9007199254740991); parse losslessly (JSON reviver, json-bigint, or `BigInt`) before cancel or query by id.
origQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
price number Decimal amount as a JSON number (`BigDecimal` on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. `null` for `LIMIT`/`MARKET` (no trigger); a number for the four conditional types.
symbol string
timeInForce string
transactTime integer(int64)
type string

QueryOrder

Name Type Description
clientOrderId string
cummulativeQuoteQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
executedQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
isWorking boolean
orderId integer(int64) Order id. JSON numbers may exceed JavaScript `Number.MAX_SAFE_INTEGER` (9007199254740991); parse losslessly (JSON reviver, json-bigint, or `BigInt`) before cancel or query by id.
origQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
origQuoteOrderQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
price number Decimal amount as a JSON number (`BigDecimal` on the wire).
side string
status string
stopPrice number | null Stop/trigger price as a JSON number. `null` for `LIMIT`/`MARKET` (no trigger); a number for the four conditional types.
symbol string
time integer(int64)
timeInForce string
type string
updateTime integer(int64)

Trade

Name Type Description
commission number Decimal amount as a JSON number (`BigDecimal` on the wire).
commissionAsset string
id integer(int64)
isBestMatch boolean
isBuyer boolean
isMaker boolean
orderId integer(int64) Order id. JSON numbers may exceed JavaScript `Number.MAX_SAFE_INTEGER` (9007199254740991); parse losslessly (JSON reviver, json-bigint, or `BigInt`) before cancel or query by id.
price number Decimal amount as a JSON number (`BigDecimal` on the wire).
qty number Decimal amount as a JSON number (`BigDecimal` on the wire).
quoteQty number Decimal amount as a JSON number (`BigDecimal` on the wire).
symbol string
time integer(int64)

Security schemes

Name Type Scheme Description
ApiKeyHmac apiKey 需要请求头 `x-ptrader-apikey`,以及 `timestamp` 与 `signature`。签名规则见「鉴权」文档。
ApiKeyOnly apiKey 仅需 API Key 请求头(无需 HMAC)。用于 listenKey 的创建、续期与关闭。

Tags

Name Description
Spot Trading