合约交易

合约交易信息

关键参数解释说明:

side

交易的方向

BUY_OPEN: 开多仓

SELL_CLOSE: 平多仓

SELL_OPEN: 开空仓

BUY_CLOSE: 平空仓

priceType

价格类型

INPUT: 系统将会用你输入的价格来撮合订单。

OPPONENT: 订单会以对手盘最优价格撮合。

假设你开多10张合约,盘口最佳买价为10最佳卖价为11,你将会下10张价格为11的合约订单。如果盘口数量不足成交10张,剩下的将留在盘口。

QUEUE: 订单会以相同方向的最优价格撮合。

假设你开多10张合约,盘口最佳买价为10最佳卖价为11,你将会下10张价格为10的合约订单。假设盘口原来有5张10的买单,加上你下的单现在一共有15张10的买单。

OVER: 订单会以对手盘的最优价格 + 超价(浮动)撮合

假设你开多10张合约,盘口最佳买价为10最佳卖价为11(超价现在为3),你将会下10张(11+3=)14的买单。如果盘口数量不足成交10张,剩下的将留在盘口。

MARKET: 订单会以 最新成交价 * (1 ± 5%) 撮合

假设你开多10张合约,最新成交价为10,你将会下10张(10*1.05=)10.5的买单。

timeInForce

时效单类型。

GTC: 一直有效直到撤销。订单会一直有效除非撤销。

IOC: 马上成交或者撤销。订单会在一个最佳可成交价执行尽量多的交易量, 此订单可能被部份执行,剩余的部份将会自动撤销。

FOK: 全部成交或者撤销。订单要么在一个最佳可成交价上全部成交,要么就会直接撤销。

LIMIT_MAKER: 如果订单会马上成交,订单会被撤销。

orderType

订单类型

LIMIT: 订单会以一个给定(或者更好)的价格成交

STOP: 一旦价格到达triggerPrice(触发价),订单会被触发

访问接口频率请参见BrokerInfo接口中的:

频率限制类型 (rateLimitType)

  • REQUESTS_WEIGHT

  • ORDERS

频率限制区间

  • SECOND

  • MINUTE

  • DAY

比如:

{
      "rateLimitType": "ORDERS",
      "interval": "SECOND",
      "limit": 20
    }

这表示每秒的下单频率限制为20。

公共

安全类型: None

公共下方的端点不需要API-Key或者签名就能自由访问

Broker交易信息(合约)

GET https://api.wenxpro.com/openapi/v1/brokerInfo

获取当前broker的交易规则和合约symbol的信息(精度单位等信息),包括合约的风险限额和乘数等信息。

Query Parameters

Name
Type
Description

type

string

交易类型,支持的类型现为token(币币)、options(期权)、contracts(合约)。如果没有发送此参数,所有交易类型的symbol信息都会被返回。

{
  "timezone":"UTC",
  "serverTime":"1570701444309",
  "brokerFilters":[],
  "rateLimits":[
    {
      "rateLimitType":"ORDERS",
      "interval":"SECOND",
      "limit":20
    },
    {"rateLimitType":"ORDERS",
    "interval":"DAY",
    "limit":350000
  },{
    "rateLimitType":"REQUEST_WEIGHT",
    "interval":"MINUTE",
    "limit":1500
  }],
  "contracts":[
    {
      "filters":[
        {"minPrice":"0.01",
        "maxPrice":"100000.00000000",
        "tickSize":"0.01",
        "filterType":"PRICE_FILTER"
      },
      {
        "minQty":"1",
        "maxQty":"100000.00000000",
        "stepSize":"1",
        "filterType":"LOT_SIZE"
      },{
        "minNotional":"0.000001",
        "filterType":"MIN_NOTIONAL"
      }],
      "exchangeId":"301",
      "symbol":"BTC-PERP-REV",
      "symbolName":"BTC-PERP-REV",
      "status":"TRADING",
      "baseAsset":"BTC-PERP-REV",
      "baseAssetPrecision":"1",
      "quoteAsset":"USDT",
      "quoteAssetPrecision":"0.01",
      "icebergAllowed":false,
      "inverse":true,
      "index":"BTCUSDT",
      "marginToken":"TBTC",
      "marginPrecision":"0.00000001",
      "contractMultiplier":"1.0",
      "riskLimits":[
        {
          "riskLimitId":"200000001",
          "quantity":"1000000.0",
          "initialMargin":"0.01",
          "maintMargin":"0.005"
        },
        {
          "riskLimitId":"200000002",
          "quantity":"2000000.0",
          "initialMargin":"0.02",
          "maintMargin":"0.01"
        },
        {
          "riskLimitId":"200000003",
          "quantity":"3000000.0",
          "initialMargin":"0.03",
          "maintMargin":"0.015"
        },
        {
          "riskLimitId":"200000004",
          "quantity":"4000000.0",
          "initialMargin":"0.04",
          "maintMargin":"0.02"
        }
      ]
    }
  ]
}

Response:

名称

类型

例子

描述

timezone

string

UTC

时间戳的时区。

serverTime

long

1554887652929

返回现在的服务器时间戳(毫秒)

rateLimits信息组里: 下单api的请求限制将会被展示。

名称

类型

例子

描述

rateLimitType

string

ORDERS

速度限制类型

interval

string

SECOND

速度限制区间

limit

string

1500

速度限制区间价值

contracts信息组里: 所有当前券商正在交易的合约的信息将会被返回:

名称

类型

例子

描述

symbol

string

BTC-PERP-REV

合约名称

status

string

TRADING

合约状态

baseAsset

string

BTC-PERP-REV

基础资产。对于合约来说,合约本身就是基础资产。

baseAssetPrecision

float

0.001

基础资产(合约数量)的精度

quoteAsset

string

USDT

定价资产。对于合约来说,这个是合约是以什么来定价的。

quoteAssetPrecision

float

0.001

定价资产(合约价格)的精度。

marginToken

string

BTC

结算资产。合约以什么来结算,计算保证金和盈亏。

marginPrecision

float

0.001

保证金(合约)的精度

inverse

bool

true

合约是否为反向合约(true=是反向合约,false=是正向合约)。

index

string

BTCUSDT

标的指数的名称。标的指数实时价格可在index端点访问得到。比如BTC-PERP-REV使用BTCUSDT为标的指数,那么可以在index端点寻找BTCUSDT的实时价格。

contractMultiplier

string

true

合约的乘数。

icebergAllowed

string

false

是否支持冰山订单。

contractsfilters信息组里:

名称

类型

例子

描述

filterType

string

PRICE_FILTER

过滤器类型。

minPrice

float

0.001

允许的最小价格。

maxPrice

float

100000.00000000

允许的最大价格。

tickSize

float

0.001

合约价格的精度。

minQty

float

0.01

允许的最小数量。

maxQty

float

100000.00000000

允许的最大数量。

stepSize

float

0.001

合约数量的精度。

minNotional

float

1

最小交易额限制(数量 * 价格)

riskLimits信息组里:

名称

类型

例子

描述

quantity

float

100

仓位小于此数且大于前一个档位的quantity的需要参照以下要求。

initialMargin

float

0.1

初始保证金率。

maintMargin

float

0.03

最小维持保证金率。

  • Weight: 0

合约信息

GET https://api.wenxpro.com/openapi/v1/contracts

返回所有合约币对的交易信息

[
    {
        "symbol": "BTC-PERP-REV",
        "symbolName": "BTC-PERP-REV",
        "baseToken": "BTC-PERP-REV",
        "quoteToken": "TBTC",
        "lastPrice": "11660.3",
        "baseVolume": "13024344",
        "quoteVolume": "1043.667478029211300416",
        "bid": "11660.9",
        "ask": "11661.8",
        "high": "11730.1",
        "low": "11567.1",
        "productType": "futures",
        "openInterest": "23980794",
        "indexPrice": "11655.7166666666666667",
        "index": "BTCUSDT",
        "indexBaseToken": "USD",
        "startTs": "1598786974",
        "endTs": "1598873374",
        "fundingRate": "0.000038494841395324",
        "nextFundingRate": "0.000088260431150408",
        "nextFundingRateTs": 1598875200
    },...
]

资金费率 (建设中)

GET https://api.wenxpro.com/openapi/contract/v1/fundingRate

获取当前资金费率 (历史资金费率正在建设)

Query Parameters

Name
Type
Description

symbol

string

合约名称。如果没有发送该参数,所有合约的资金费率都会被返回。E.g. BTC-PERP-REV

state

string

获取current(当前)或者past(历史)的资金费率。

from

number

开始时间戳

to

number

结束时间戳

limit

integer

返回条数。默认为 20.

[
  {
    'symbol': 'BTC-PERP-REV',
    'intervalStart': '1570708800000',
    'intervalEnd': '1570737600000',
    'rate': '-0.000048567445464006'
  },...
]

Response:

名称

类型

例子

描述

symbol

string

BTC-PERP-REV

合约名称。

intervalStart

long

1554710400000

本次结算开始时间。

intervalEnd

long

1554710400000

本次结算结束时间。

rate

float

0.00321

该次结算资金费率。

  • Weight: 0

行情

安全类型: None

行情下方的端点不需要API-Key或者签名就能自由访问

指数价格

GET https://api.wenxpro.com/openapi/quote/v1/contract/index

标的指数价格

Query Parameters

Name
Type
Description

symbols

string

标的指数名称。如果这个没有发送,所有标的指数的价格都会被返回。E.g. BTC-PERP-REV

{
  "index":{
    "BTCUSDT":"8243.21666667",
    "OKBUSDT":"1.482",
    "BNBUSDT":"31.2658",
    "HTUSDT":"3.1209",...
    },
  "edp":{
    "BTCUSDT":"8258.98505556",
    "OKBUSDT":"1.48578333",
    "BNBUSDT":"31.48741917",
    "HTUSDT":"3.14308",...
  }
}

Response:

名称

类型

例子

描述

index

float

8342.73

标的指数的价格。

EDP

float

8432.32

标的指数的EDP(预估交割价,过去10分钟指数价格的平均值)

订单簿

GET https://api.wenxpro.com/openapi/quote/v1/contract/depth

获取当前订单簿的数据。该端点3秒更新一次。

Query Parameters

Name
Type
Description

symbol

string

用来获取订单簿的合约名称。E.g. BTC-PERP-REV

limit

integer

返回bidsasks的数量 。默认 100; 最大 100.

{
  "time": 1555049455783,
  "bids": [
   ["78.82", "0.526"],//[Price, Quantity]
   ["77.24", "1.22"],
   ["76.65", "1.043"],
   ["76.58", "1.34"],
   ["75.67", "1.52"],
   ["75.12", "0.635"],
   ["75.02", "0.72"],
   ["75.01", "0.672"],
   ["73.73", "1.282"],
   ["73.58", "1.116"],
   ["73.45", "0.471"],
   ["73.44", "0.483"],
   ["72.32", "0.383"],
   ["72.26", "1.283"],
   ["72.11", "0.703"],
   ["70.61", "0.454"]],
   "asks": [
     ["122.96", "0.381"],//[Price, Quantity]
     ["144.46", "1"],
     ["155.55", "0.065"],
     ["160.16", "0.052"],
     ["200", "0.775"],
     ["249", "0.17"],
     ["250", "1"],
     ["300", "1"],
     ["400", "1"],
     ["499", "1"]]
   }

Response:

名称

类型

例子

描述

time

long

1550829103981

当前时间(Unix Timestamp,毫秒ms)

bids

list

(如下)

所有bid的价格和数量信息,最优bid价格由上到下排列。

asks

list

(如下)

所有ask的价格和数量信息,最优ask价格由上到下排列。

bidsasks所对应的信息组代表了订单簿的所有价格以及价格对应数量的信息,由最优价格从上到下排列。

名称

类型

例子

描述

''

float

123.10

价格

''

float

300

当前价格对应的数量

合并订单簿(推荐)

GET https://api.wenxpro.com/openapi/quote/v1/contract/depth/merged

获取当前订单簿的数据。该端点0.5秒更新一次。

Query Parameters

Name
Type
Description

symbol

string

用来获取订单簿的合约名称。E.g. BTC-PERP-REV

limit

integer

返回bidsasks的数量 。默认 40; 最大 40.

{
  "time": 1555049455783,
  "bids": [
   ["78.82", "0.526"],//[Price, Quantity]
   ["77.24", "1.22"],
   ["76.65", "1.043"],
   ["76.58", "1.34"],
   ["75.67", "1.52"],
   ["75.12", "0.635"],
   ["75.02", "0.72"],
   ["75.01", "0.672"],
   ["73.73", "1.282"],
   ["73.58", "1.116"],
   ["73.45", "0.471"],
   ["73.44", "0.483"],
   ["72.32", "0.383"],
   ["72.26", "1.283"],
   ["72.11", "0.703"],
   ["70.61", "0.454"]],
   "asks": [
     ["122.96", "0.381"],//[Price, Quantity]
     ["144.46", "1"],
     ["155.55", "0.065"],
     ["160.16", "0.052"],
     ["200", "0.775"],
     ["249", "0.17"],
     ["250", "1"],
     ["300", "1"],
     ["400", "1"],
     ["499", "1"]]
   }

Response:

名称

类型

例子

描述

time

long

1550829103981

当前时间(Unix Timestamp,毫秒ms)

bids

list

(如下)

所有bid的价格和数量信息,最优bid价格由上到下排列。

asks

list

(如下)

所有ask的价格和数量信息,最优ask价格由上到下排列。

bidsasks所对应的信息组代表了订单簿的所有价格以及价格对应数量的信息,由最优价格从上到下排列。

名称

类型

例子

描述

''

float

123.10

价格

''

float

300

当前价格对应的数量

最新成交

GET https://api.wenxpro.com/openapi/quote/v1/contract/trades

获取某个合约最近成交订单的信息。

Query Parameters

Name
Type
Description

symbol

string

Symbol名称 E.g. BTC-PERP-REV

limit

integer

返回的成交条数。 默认500; 最大 1000

[
  {
    "price": "4.00000100",
    "qty": "12.00000000",
    "time": 1499865549590,
    "isBuyerMaker": true
  },...
]

Response:

名称

类型

例子

描述

price

float

0.055

交易价格

time

long

1537797044116

当前Unix时间戳,毫秒(ms)

qty

float

5

数量(张数)

isBuyerMaker

string

true

卖方还是买方。true=订单创建时为买单,false=订单创建时为卖单

K线/蜡烛图数据

GET https://api.wenxpro.com/openapi/quote/v1/klines

获取某个合约的K线信息(高,低,开,收,交易量...)

Query Parameters

Name
Type
Description

symbol

string

Symbol名称 E.g. BTC-PERP-REV

interval

string

K线图区间。可识别发送的值为:1m, 5m, 15m, 30m, 1h, 1d, 1W, 1M (m=分钟, h=小时, d=天, w=星期, M=月)

to

number

最后一条返回的时间戳(毫秒)

limit

integer

默认500; 最大1000

[
  [
    1499040000000,      // Open time
    "0.01634790",       // Open
    "0.80000000",       // High
    "0.01575800",       // Low
    "0.01577100",       // Close
    "148976.11427815",  // Volume
    1499644799999,      // Close time
    "2434.19055334",    // Quote asset volume
    308,                // Number of trades
    "1756.87402397",    // Taker buy base asset volume
    "28.46694368"       // Taker buy quote asset volume
  ]
]

Response:

名称

类型

例子

描述

''

long

1538728740000

开始时间戳,毫秒(ms)

''

float

36.00000'

开盘价

''

float

36.00000

最高价

''

float

36.00000

最低价

''

float

36.00000

收盘价

''

float

148976.11427815

合约交易金额

''

long

1538728740000

停止时间戳,毫秒(ms)

''

float

2434.19055334

交易数量(张数)

''

integer

308

已成交数量(张数)

''

float

1756.87402397

买方购买金额

''

float

28.46694368

买方购买数量(张数)

  • base asset 代表买方收到了该数量的合约

    quote asset 代表该数量的token用来获得合约

24小时ticker价格变化数据

GET https://api.wenxpro.com/openapi/quote/v1/contract/ticker/24hr

24小时价格变化数据。注意 如果没有发送symbol,会返回很多数据。

Path Parameters

Name
Type
Description

symbol

string

Symbol 名称 E.g. BTC-SWAP

## Single ticker 
{
  "time":1579424880100,
  "symbol":"BTC-SWAP",
  "bestBidPrice":"9079.1",
  "bestAskPrice":"9079.5",
  "volume":"61684269",
  "quoteVolume":"553667621070",
  "openInterest": "12344245",
  "lastPrice":"9077.5",
  "highPrice":"9179.8",
  "lowPrice":"8840.8",
  "openPrice":"8861.7"
  }
## Multiple ticker info when symbol is omiited
[
  {
    "time":1579422004248,
    "symbol":"BTC-SWAP-USDT",
    "volume":"102696523",
    "quoteVolume":"918742352316.6",
    "openInterest": "12344245",
    "lastPrice":"9092.9",
    "highPrice":"9180.2",
    "lowPrice":"8817.7",
    "openPrice":"8817.7"
    },...
    ]

Response:

名称

类型

例子

描述

time

long

1538728740000

开始时间戳

symbol

string

BTC-SWAP

Symbol 名称

bestBidPrice

float

4.000002000

最佳买价

bestAskPrice

float

4.000002000

最佳卖价

lastPrice

float

4.000002000

最新成交价

openPrice

float

99.0000000

开盘价

highPrice

float

100.0000000

最高价

lowPrice

float

0.10000000

最低价

volume

float

8913.300000

交易量

openInterest

float

213933113

持仓数量

  • 如果symbol没有被发送,所有symbol的数据都会被返回。

交易

安全类型: USER_DATA/TRADE

交易下方的端点需要签名和API-Key验证

创建新订单

POST https://api.wenxpro.com/openapi/contract/v1/order

合约下单

Query Parameters

Name
Type
Description

clientOrderId

string

订单的ID,用户自己定义。E.g. 12094ahsihsiad

symbol

string

合约名称 E.g. BTC-PERP-REV

side

string

下单方向,方向类型为BUY_OPENSELL_OPENBUY_CLOSESELL_CLOSE

orderType

string

订单类型,支持订单类型为 LIMITSTOP

quantity

number

订单的合约数量。对于MARKET市价买单,quantity代表amount。

leverage

string

订单的杠杆。(对于 *_CLOSE"平仓订单不需要)

price

number

订单价格. (LIMIT&INPUT)订单 强制需要

priceType

string

价格类型,支持的价格类型为INPUT(默认)OPPONENTQUEUEOVERMARKET

triggerPrice

number

计划委托的触发价格。

timeInForce

string

LIMIT订单的时间指令(Time in Force),目前支持的类型为GTC(默认)FOKIOCLIMIT_MAKER

Headers

Name
Type
Description

X-BH-APIKEY

string

你的API-Key

Request Body

Name
Type
Description

signature

string

这个端点需要签名验证

timestamp

integer

当前时间戳(毫秒)

recvWindow

integer

当前请求的RecvWindow

{
  'time': '1570759718825',
  'updateTime': '0',
  'orderId': '469961015902208000',
  'clientOrderId': '6423344174',
  'symbol': 'BTC-PERP-REV',
  'price': '8200',
  'leverage': '12.08',
  'origQty': '5',
  'executedQty': '0',
  'avgPrice': '0',
  'marginLocked': '0.00005047',
  'orderType': 'LIMIT',
  'side': 'BUY_OPEN',
  'fees': [],
  'timeInForce': 'GTC',
  'status': 'NEW',
  'priceType': 'INPUT'
}

Response:

名称

类型

例子

描述

time

long

1570759718825

订单生成时的时间戳

updateTime

long

1551062936784

订单上次更新的时间戳

orderId

integer

469961015902208000

订单ID

clientOrderId

string

213443

用户定义的订单ID

symbol

string

BTC-PERP-REV

合约名称

price

float

8200

订单价格

leverage

float

4

订单杠杆

origQty

float

1.01

订单数量

executedQty

float

1.01

订单已执行数量

avgPrice

float

4754.24

平均交易价格

marginLocked

float

200

该订单锁定的保证金。这包括实际需要的保证金外加开仓和平仓所需的费用。

orderType

string

YES

订单类型(LIMITSTOP

priceType

string

INPUT

价格类型(INPUTOPPONENTQUEUEOVERMARKET

side

string

BUY

订单方向(BUY_OPENSELL_OPENBUY_CLOSESELL_CLOSE

status

string

NEW

订单状态(NEWPARTIALLY_FILLEDFILLEDCANCELEDREJECTED

timeInForce

string

GTC

时效单(Time in Force)类型(GTCFOKIOCLIMIT_MAKER)

fees

订单的手续费

  • 注意:

    • 对于 市价订单, 你需要设置orderTypeLIMIT 并且设置 priceTypeMARKET.

    • 你可以在brokerInfo端点获取合约价格,数量的精度配置信息。

    • 如果你的余额没有达到需要保证金的要求(初始保证金+开仓手续费+平仓手续费),将会有"insufficient balance"(余额不足)的错误返回

    • 对于 价格类型订单类型 的详细解释,请参见这里

  • Weight: 1

订单信息

GET https://api.wenxpro.com/openapi/contract/v1/getOrder

获取某个订单的详细信息

Query Parameters

Name
Type
Description

orderType

string

订单类型(LIMITSTOP

orderId

string

订单Id E.g. 507904211109878016

clientOrderId

string

用户定义的订单ID E.g. 12094ahsihsiad

Headers

Name
Type
Description

X-BH-APIKEY

string

你的API-Key

Request Body

Name
Type
Description

signature

string

这个端点需要签名验证

timestamp

integer

当前时间戳(毫秒)

recvWindow

integer

当前请求的RecvWindow

{
  'time': '1570760254539',
  'updateTime': '0',
  'orderId': '469965509788581888',
  'clientOrderId': '1570760253946',
  'symbol': 'BTC-PERP-REV',
  'price': '8502.34',
  'leverage': '20',
  'origQty': '222',
  'executedQty': '0',
  'avgPrice': '0',
  'marginLocked': '0.00130552',
  'orderType': 'LIMIT',
  'side': 'BUY_OPEN',
  'fees': [],
  'timeInForce': 'GTC',
  'status': 'NEW',
  'priceType': 'INPUT'
}

Response:

名称

类型

例子

描述

time

long

1570759718825

订单生成时的时间戳

updateTime

long

1551062936784

订单上次更新的时间戳

orderId

integer

469961015902208000

订单ID

clientOrderId

string

213443

用户定义的订单ID

symbol

string

BTC-PERP-REV

合约名称

price

float

8200

订单价格

leverage

float

4

订单杠杆

origQty

float

1.01

订单数量

executedQty

float

1.01

订单已执行数量

avgPrice

float

4754.24

平均交易价格

marginLocked

float

200

该订单锁定的保证金。这包括实际需要的保证金外加开仓和平仓所需的费用。

orderType

string

YES

订单类型(LIMITSTOP

priceType

string

INPUT

价格类型(INPUTOPPONENTQUEUEOVERMARKET

side

string

BUY

订单方向(BUY_OPENSELL_OPENBUY_CLOSESELL_CLOSE

status

string

NEW

订单状态(NEWPARTIALLY_FILLEDFILLEDCANCELEDREJECTED

timeInForce

string

GTC

时效单(Time in Force)类型(GTCFOKIOCLIMIT_MAKER)

fees

订单的手续费

fees信息组里:

名称

类型

例子

描述

feeToken

string

USDT

手续费计价类型

fee

float

0

实际手续费

  • Weight: 1

  • orderId 或者 clientOrderId 必须发送其中之一

  • 对于某些历史数据 cummulativeQuoteQty 可能会 < 0, 这说明数据当前不可用。

撤销订单

DELETE https://api.wenxpro.com/openapi/contract/v1/order/cancel

取消某个订单,需要发送orderId或者clientOrderId其中之一。这个API端点需要你的请求签名。

Query Parameters

Name
Type
Description

orderType

string

订单类型(LIMITSTOP

orderId

string

订单Id E.g. 507904211109878016

clientOrderId

string

用户定义的订单ID E.g. 12094ahsihsiad

Headers

Name
Type
Description

X-BH-APIKEY

string

你的API-Key

Request Body

Name
Type
Description

signature

string

这个端点需要签名验证

timestamp

integer

当前时间戳(毫秒)

recvWindow

integer

当前请求的RecvWindow

{
  'time': '1570759718825',
  'updateTime': '0',
  'orderId': '469961015902208000',
  'clientOrderId': '6423344174',
  'symbol': 'BTC-PERP-REV',
  'price': '8200',
  'leverage': '12.08',
  'origQty': '5',
  'executedQty': '0',
  'avgPrice': '0',
  'marginLocked': '0',
  'orderType': 'LIMIT',
  'side': 'BUY_OPEN',
  'fees': [],
  'timeInForce': 'GTC',
  'status': 'CANCELED',
  'priceType': 'INPUT' //status will always be `CANCELED` for cancel request
}

Response:

名称

类型

例子

描述

time

long

1570759718825

订单生成时的时间戳

updateTime

long

1551062936784

订单上次更新的时间戳

orderId

integer

469961015902208000

订单ID

clientOrderId

string

213443

用户定义的订单ID

symbol

string

BTC-PERP-REV

合约名称

price

float

8200

订单价格

leverage

float

4

订单杠杆

origQty

float

1.01

订单数量

executedQty

float

1.01

订单已执行数量

avgPrice

float

4754.24

平均交易价格

marginLocked

float

200

该订单锁定的保证金。这包括实际需要的保证金外加开仓和平仓所需的费用。

orderType

string

YES

订单类型(LIMITSTOP

priceType

string

INPUT

价格类型(INPUTOPPONENTQUEUEOVERMARKET

side

string

BUY

订单方向(BUY_OPENSELL_OPENBUY_CLOSESELL_CLOSE

status

string

NEW

订单状态(NEWPARTIALLY_FILLEDFILLEDCANCELEDREJECTED)。该端点返回的订单状态都是CANCELED

timeInForce

string

GTC

时效单(Time in Force)类型(GTCFOKIOCLIMIT_MAKER)

fees

订单的手续费

fees信息组里:

名称

类型

例子

描述

feeToken

string

USDT

手续费计价类型

fee

float

0

实际手续费

  • Weight: 1

  • orderId 或者 clientOrderId 必须发送其中之一

批量撤销订单

DELETE https://api.wenxpro.com/openapi/contract/v1/order/batchCancel

批量撤销订单(正在建设中: 计划委托的批量撤单)

Query Parameters

Name
Type
Description

symbol

string

合约名称(或者用,分割的合约名称的list)E.g. BTC-PERP-REV

Headers

Name
Type
Description

X-BH-APIKEY

string

你的API-Key

Request Body

Name
Type
Description

signature

string

这个端点需要签名验证

timestamp

integer

当前时间戳(毫秒)

recvWindow

integer

当前请求的RecvWindow

{
  'message':'success',
  'timestamp':1541161088303
}

Response:

名称

类型

例子

描述

message

string

success

撤单请求的返回消息

timestamp

long

1541161088303

返回时的时间戳

当前订单

GET https://api.wenxpro.com/openapi/contract/v1/openOrders

获取当前单个或者多个symbol的当前订单。注意 如果没有发送symbol,会返回很多数据。

Query Parameters

Name
Type
Description

orderType

string

订单类型(LIMITSTOP

symbol

string

合约名称。如果没有在请求里发送,所有合约的未完成委托都会被返回。E.g. BTC-PERP-REV

orderId

string

订单Id E.g. 507904211109878016

limit

integer

默认 20; 最大 1000

Headers

Name
Type
Description

X-BH-APIKEY

string

你的API-Key

Request Body

Name
Type
Description

signature

string

这个端点需要签名验证

timestamp

integer

当前时间戳(毫秒)

recvWindow

integer

当前请求的RecvWindow

[
  {
    'time': '1570760254539',
    'updateTime': '0',
    'orderId': '469965509788581888',
    'clientOrderId': '1570760253946',
    'symbol': 'BTC-PERP-REV',
    'price': '8502.34',
    'leverage': '20',
    'origQty': '222',
    'executedQty': '0',
    'avgPrice': '0',
    'marginLocked': '0.00130552',
    'orderType': 'LIMIT',
    'side': 'BUY_OPEN',
    'fees': [],
    'timeInForce': 'GTC',
    'status': 'NEW',
    'priceType': 'INPUT'
  },...
]

Response:

名称

类型

例子

描述

time

long

1570759718825

订单生成时的时间戳

updateTime

long

1551062936784

订单上次更新的时间戳

orderId

integer

469961015902208000

订单ID

clientOrderId

string

213443

用户定义的订单ID

symbol

string

BTC-PERP-REV

合约名称

price

float

8200

订单价格

leverage

float

4

订单杠杆

origQty

float

1.01

订单数量

executedQty

float

1.01

订单已执行数量

avgPrice

float

4754.24

平均交易价格

marginLocked

float

200

该订单锁定的保证金。这包括实际需要的保证金外加开仓和平仓所需的费用。

orderType

string

YES

订单类型(LIMITSTOP

priceType

string

INPUT

价格类型(INPUTOPPONENTQUEUEOVERMARKET

side

string

BUY

订单方向(BUY_OPENSELL_OPENBUY_CLOSESELL_CLOSE

status

string

NEW

订单状态(NEWPARTIALLY_FILLEDFILLEDCANCELEDREJECTED

timeInForce

string

GTC

时效单(Time in Force)类型(GTCFOKIOCLIMIT_MAKER)

fees

订单的手续费

fees信息组里:

名称

类型

例子

描述

feeToken

string

USDT

手续费计价类型

fee

float

0

实际手续费

  • Weight: 1

  • 如果发送了orderId,会返回所有< orderId的订单。如果没有则会返回最新的未完成订单

历史订单

GET https://api.wenxpro.com/openapi/contract/v1/historyOrders

获取当前账户的历史订单。注意如果没有发送symbol,会返回很多数据。

Query Parameters

Name
Type
Description

orderType

string

订单类型(LIMITSTOP

symbol

string

Symbol 名称 E.g. BTC-PERP-REV

orderId

integer

订单Id E.g. 507904211109878016

limit

integer

默认 500; 最大 1000

Headers

Name
Type
Description

X-BH-APIKEY

string

你的API-KEY

Request Body

Name
Type
Description

signature

string

这个端点需要签名验证

timestamp

integer

当前时间戳(毫秒)

recvWindow

integer

当前请求的RecvWindow

[
  {
    'time': '1570759718825',
    'updateTime': '0',
    'orderId': '469961015902208000',
    'clientOrderId': '6423344174',
    'symbol': 'BTC-PERP-REV',
    'price': '8200',
    'leverage': '12.08',
    'origQty': '5',
    'executedQty': '0',
    'avgPrice': '0',
    'marginLocked': '0',
    'orderType': 'LIMIT',
    'side': 'BUY_OPEN',
    'fees': [],
    'timeInForce': 'GTC',
    'status': 'CANCELED',
    'priceType': 'INPUT'
  },...
]

GET https://api.wenxpro.com/openapi/contract/v1/historyOrders

Headers

Name
Type
Description

X-BH-APIKEY

string

需要

Response:

名称

类型

例子

描述

time

long

1570759718825

订单生成时的时间戳

updateTime

long

1551062936784

订单上次更新的时间戳

orderId

integer

469961015902208000

订单ID

clientOrderId

string

213443

用户定义的订单ID

symbol

string

BTC-PERP-REV

合约名称

price

float

8200

订单价格

leverage

float

4

订单杠杆

origQty

float

1.01

订单数量

executedQty

float

1.01

订单已执行数量

avgPrice

float

4754.24

平均交易价格

marginLocked

float

200

该订单锁定的保证金。这包括实际需要的保证金外加开仓和平仓所需的费用。

orderType

string

YES

订单类型(LIMITSTOP

priceType

string

INPUT

价格类型(INPUTOPPONENTQUEUEOVERMARKET

side

string

BUY

订单方向(BUY_OPENSELL_OPENBUY_CLOSESELL_CLOSE

status

string

NEW

订单状态(FILLEDCANCELEDREJECTED

timeInForce

string

GTC

时效单(Time in Force)类型(GTCFOKIOCLIMIT_MAKER)

fees

订单的手续费

fees信息组里:

名称

类型

例子

描述

feeToken

string

USDT

手续费计价类型

fee

float

0

实际手续费

  • Weight: 5

  • 如果发送了orderId,会返回所有< orderId的订单。如果没有则会返回最新的未完成订单

交易记录

GET https://api.wenxpro.com/openapi/contract/v1/myTrades

获取当前账户历史成交记录

Query Parameters

Name
Type
Description

symbol

string

Symbol名称 E.g. BTC-PERP-REV

fromId

integer

从此Trade Id开始查询

toId

integer

以此Trade Id结束

limit

integer

默认 20; 最大 1000

Headers

Name
Type
Description

X-BH-APIKEY

string

你的API-Key

Request Body

Name
Type
Description

signature

string

这个端点需要签名验证

timestamp

integer

当前时间戳(毫秒)

recvWindow

integer

当前请求的RecvWindow

[
  {
    'time': '1570760582848',
    'tradeId': '469968263995080704',
    'orderId': '469968263793737728',
    'accountId': '456552319339779840',
    'symbolId': 'BTC-PERP-REV',
    'price': '8531.17',
    'quantity': '100',
    'feeTokenId': 'TBTC',
    'fee': '0.00000586',
    'type': 'LIMIT',
    'side': 'BUY_OPEN'
  },...
]

Response:

名称

类型

例子

描述

time

long

1551062936784

订单生成是的时间戳

tradeId

long

49366

成交ID

orderId

integer

891

成交ID

symbolId

string

BTC-PERP-REV

合约名称

price

float

4765.29

成交价格

quantity

float

1.01

成交数量

feeTokenId

string

USDT

手续费类型(Token名称)

fee

实际手续费

side

string

BUY

订单方向(BUY_OPENSELL_OPENBUY_CLOSESELL_CLOSE

orderType

string

LIMIT

订单类型(LIMITMARKET)

  • Weight: 5

  • 如果只有fromId,会返回订单号小于fromId的,倒序排列。

  • 如果只有toId,会返回订单号小于toId的,升序排列。

  • 如果同时有fromIdtoId, 会返回订单号在fromIdtoId的,倒序排列。

  • 如果fromIdtoId都没有,会返回最新的成交记录,倒序排列。

当前持仓

GET https://api.wenxpro.com/openapi/contract/v1/positions

获取当前仓位信息

Query Parameters

Name
Type
Description

symbol

string

合约名称。如果没有发送,所有的合约仓位信息都会被返回。E.g. BTC_PERP-REV

side

string

仓位方向,LONG(多仓)或者SHORT(空仓)。如果没有发送,两个方向的仓位信息都会被返回。

Headers

Name
Type
Description

X-BH-APIKEY

string

你的API-Key

Request Body

Name
Type
Description

signature

string

这个端点需要签名验证

timestamp

integer

当前时间戳(毫秒)

recvWindow

integer

当前请求的RecvWindow

[
  {
    'symbol': 'BTC-PERP-REV',
    'side': 'LONG',
    'avgPrice': '8183.11',
    'position': '1100',
    'available': '1100',
    'leverage': '6',
    'lastPrice': '8572.53',
    'positionValue': '0.12833346',
    'flp': '7523.65',
    'margin': '0.01251335',
    'marginRate': '0.14',
    'unrealizedPnL': '0.00608975',
    'profitRate': '0.0000333',
    'realizedPnL': '-0.00006721'
  },...
]

Response:

名称

类型

例子

描述

symbol

string

BTC-PERP-REV

合约名称

side

string

LONG

仓位方向(LONGSHORT

avgPrice

float

100

平均开仓价格

position

float

20

开仓数量(张)

available

float

15

可平仓数量(张)

leverage

float

5

仓位现在杠杆

lastPrice

float

100

合约最新市场成交价

positionValue

float

2000

仓位价值

flp

float

80

强制平仓价格

margin

float

20

仓位保证金

marginRate

float

0.2

当前仓位的保证金率

unrealizedPnL

float

0.0

当前仓位的未实现盈亏

profitRate

float

0.0000333

当前仓位的盈利率

realizedPnL

float

6.8

当前 合约 的已实现盈亏

  • Weight: 1

更改仓位保证金

POST https://api.wenxpro.com/openapi/contract/v1/modifyMargin

更改某个合约仓位的保证金。

Query Parameters

Name
Type
Description

symbol

string

合约名称 E.g. BTC-PERP-REV

side

string

仓位方向,LONG(多仓)或者SHORT(空仓)。

amount

number

增加(正值)或者减少(负值)保证金的数量。请注意这个数量指的是合约标的定价资产(即合约结算的标的)

Headers

Name
Type
Description

X-BH-APIKEY

string

你的API-Key

Request Body

Name
Type
Description

signature

string

这个端点需要签名验证

timestamp

integer

当前时间戳(毫秒)

recvWindow

integer

当前请求的RecvWindow

{
  'symbol':'BTC-PERP-REV',
  'margin': 15,
  'timestamp': 1541161088303
}

Response:

名称

类型

例子

描述

symbol

string

BTC-PERP-REV

合约名称

margin

float

12.3

更新后的仓位保证金

timestamp

long

1541161088303

更新时间戳

  • Weight: 1

账户

安全类型: USER_DATA/TRADE

账户下方的端点需要签名和API-Key验证

账户信息

GET https://api.wenxpro.com/openapi/contract/v1/account

返回合约账户余额

Headers

Name
Type
Description

X-BH-APIKEY

string

你的API-Key

Request Body

Name
Type
Description

signature

string

这个端点需要签名验证

timestamp

integer

当前时间戳(毫秒)

recvWindow

integer

当前请求的RecvWindow

{
  "TBTC": {
    "total":"131.06671401",
    "availableMargin":"131.0545541",
    "positionMargin":"0.01215991",
    "orderMargin":"0"
  },...
}

Response:

名称

类型

例子

描述

total

float

131.06671401

总余额

availableMargin

float

131.0545541

可用保证金

positionMargin

float

0.01215991

仓位保证金

orderMargin

float

0

委托保证金(下单锁定)

  • Weight: 5

转账 (建设中)

POST https://api.wenxpro.com/openapi/v1/transfer

在用户不同账户中转账

Query Parameters

Name
Type
Description

from

string

当前只支持在wallet(币币), option(期权), 和 contract(合约)之间转账

to

string

同上

currency

string

需要转账的币种(USDT, BTC, etc.)

amount

number

需要转账的数量

Headers

Name
Type
Description

X-BH-APIKEY

string

你的API-Key

Request Body

Name
Type
Description

signature

string

这个端点需要签名验证

timestamp

integer

当前时间戳(毫秒)

recvWindow

integer

当前请求的RecvWindow

{
  'message': 'success',
  'timestamp': 1541161088303
}
  • Weight: 1

最后更新于

这有帮助吗?