ABOUT Multiexchange API
Multiexchange REST & Streaming API version 2.0 provides programmatic access to Multiexchange’s next generation trading engine.
We strongly recommend that our new customers use API version 2.0 to get the best trading experience. We also recommend that our current traders switch to the newest version 2.0.
By using the Multiexchange API you confirm that you have read and accept API License Agreement.
DEVELOPMENT GUIDE
API Explorer
You can explore the API using SwaggerUI including methods requiring authorization.
API URLs
Environment | REST | Streaming |
---|---|---|
PROD | https://api.bequant.io/api/2 | wss://api.bequant.io/api/2/ws |
DateTime Format
All timestamps are returned in ISO 8601 format (UTC).
Example: "2017-04-03T10:20:49.315Z"
Number Format
All finance data, i.e. price, quantity, fee etc., should be arbitrary precision numbers and have a string representation.
Example: "10.2000058"
Pagination
Parameters:
Parameter | Description |
---|---|
limit | Number of results per call Accepted range: 0 - 1000 Default value: 100 |
offset | Number of results offset Default value: 0 |
sort | Sort direction Accepted values: ASC (ascending order), DESC (descending order) Default value: DESC |
by | Defines filter type Accepted values: id , timestamp |
from | Interval initial value (optional parameter) If filter by timestamp is used, then parameter type is datetime , otherwise object id |
till | Interval end value (optional parameter) If filter by timestamp is used, then parameter type is datetime , otherwise object id |
RATE LIMITING
The following Rate Limits are applied:
- For the Market data, the limit is 100 requests per second for one IP;
- For Trading, the limit is 300 requests per second for one user;
- For other requests, including Trading history, the limit is 10 requests per second for one user.
Significantly exceeding the Rate Limits can lead to suspension.
BEST PRACTICES
The Multiexchange API development team strives to bring the best trading experience to API users. This manual contains a set of best practices for using the API as efficiently as possible.
HTTP Persistent Connection
The underlying TCP connection is kept active for multiple requests/responses. Subsequent requests will result in reduced latency as the TCP handshaking process is no longer required.
If you use the HTTP 1.0 client, please ensure it supports the Keep-Alive directive and submit the ''Connection: Keep-Alive'' header with your request.
Keep-Alive is a part of the HTTP 1.1 protocol and enabled by default on compliant clients. However, you will have to ensure your implementation does not set other values as the connection header.
Retrieving and updating account state
Use the Streaming API for real-time updates of your orders, trades and any transaction changes.
REST API Reference
HTTP Status codes
- 200 OK. Successful request
- 400 Bad Request. Returns JSON with the error message
- 401 Unauthorised. Authorisation is required or has been failed
- 403 Forbidden. Action is forbidden for API key
- 429 Too Many Requests. Your connection has been rate limited
- 500 Internal Server. Internal Server Error
- 503 Service Unavailable. Service is down for maintenance
- 504 Gateway Timeout. Request timeout expired
Error response
All error responses have error code
and human readable message
fields. Some errors contain an additional description
field.
Example of error response:
{
"error": {
"code": 20001,
"message": "Insufficient funds",
"description": "Check that the funds are sufficient, given commissions"
}
}
Market data
Currencies
curl "https://api.bequant.io/api/2/public/currency"
The above command returns JSON structured like this:
[
{
"id": "BTC",
"fullName": "Bitcoin",
"crypto": true,
"payinEnabled": true,
"payinPaymentId": false,
"payinConfirmations": 2,
"payoutEnabled": true,
"payoutIsPaymentId": false,
"transferEnabled": true,
"delisted": false,
"payoutFee": "0.00958"
},
{
"id": "ETH",
"fullName": "Ethereum",
"crypto": true,
"payinEnabled": true,
"payinPaymentId": false,
"payinConfirmations": 2,
"payoutEnabled": true,
"payoutIsPaymentId": false,
"transferEnabled": true,
"delisted": false,
"payoutFee": "0.001"
}
]
GET /api/2/public/currency
GET /api/2/public/currency/{currency}
Return the actual list of available currencies, tokens, ICO etc.
Requires no API key Access Rights.
Responses:
Name | Type | Description |
---|---|---|
id | String | Currency identifier (code), for example, ''BTC'' Note: description will simply use currency in the future. |
fullName | String | Currency full name, for example, ''Bitcoin'' |
crypto | Boolean | Determines whether currency belongs to blockchain |
payinEnabled | Boolean | Determines whether it is allowed to generate addresses for a deposit |
payinPaymentId | Boolean | Determines whether it is required to provide additional information other than the address for deposit |
payinConfirmations | Number | Count of blocks confirmations, which are needed for deposit |
payoutEnabled | Boolean | Determines whether withdraw is allowed |
payoutIsPaymentId | Boolean | Determines whether providing of additional information for withdraw is allowed |
transferEnabled | Boolean | Determines whether transfer between trading account and bank account is allowed (may be disabled on maintenance) |
delisted | Boolean | true if currency is delisted (deposit and trading are stopped) |
payoutFee | Number | Default withdraw fee |
Symbols
curl "https://api.bequant.io/api/2/public/symbol"
The above command returns JSON structured like this:
[
{
"id": "ETHBTC",
"baseCurrency": "ETH",
"quoteCurrency": "BTC",
"quantityIncrement": "0.001",
"tickSize": "0.000001",
"takeLiquidityRate": "0.001",
"provideLiquidityRate": "-0.0001",
"feeCurrency": "BTC"
}
]
GET /api/2/public/symbol
GET /api/2/public/symbol/{symbol}
Return the actual list of currency symbols (currency pairs) traded on exchange. The first listed currency of a symbol is called the base currency, and the second currency is called the quote currency. The currency pair indicates how much of the quote currency is needed to purchase one unit of the base currency. Read more
Requires no API key Access Rights.
Responses:
Name | Type | Description |
---|---|---|
id | String | Symbol (currency pair) identifier, for example, ''ETHBTC'' Note: description will simply use symbol in the future. |
baseCurrency | String | Name (code) of base currency, for example, ''ETH'' |
quoteCurrency | String | Name of quote currency |
quantityIncrement | Number | Symbol quantity should be divided by this value with no remainder |
tickSize | Number | Symbol price should be divided by this value with no remainder |
takeLiquidityRate | Number | Default fee rate |
provideLiquidityRate | Number | Default fee rate for market making trades |
feeCurrency | String | Value of charged fee |
Tickers
curl "https://api.bequant.io/api/2/public/ticker"
The above command returns JSON structured like this:
[
{
"ask": "0.050043",
"bid": "0.050042",
"last": "0.050042",
"open": "0.047800",
"low": "0.047052",
"high": "0.051679",
"volume": "36456.720",
"volumeQuote": "1782.625000",
"timestamp": "2017-05-12T14:57:19.999Z",
"symbol": "ETHBTC"
}
]
GET /api/2/public/ticker
GET /api/2/public/ticker/{symbol}
Returns ticker information.
Requires no API key Access Rights.
Responses:
Name | Type | Description |
---|---|---|
ask | Number or null | Best ask price. Can return 'null' if no data |
bid | Number or null | Best bid price. Can return 'null' if no data |
last | Number or null | Last trade price. Can return 'null' if no data |
open | Number or null | Last trade price 24 hours ago. Can return 'null' if no data |
low | Number | Lowest trade price within 24 hours |
high | Number | Highest trade price within 24 hours |
volume | Number | Total trading amount within 24 hours in base currency |
volumeQuote | Number | Total trading amount within 24 hours in quote currency |
timestamp | Datetime | Last update or refresh ticker timestamp |
symbol | String | Symbol name |
Trades
curl "https://api.bequant.io/api/2/public/trades/ETHBTC?sort=DESC"
The above command returns JSON structured like this:
[
{
"id": 9533117,
"price": "0.046001",
"quantity": "0.220",
"side": "sell",
"timestamp": "2017-04-14T12:18:40.426Z"
},
{
"id": 9533116,
"price": "0.046002",
"quantity": "0.022",
"side": "buy",
"timestamp": "2017-04-14T11:56:37.027Z"
}
]
GET /api/2/public/trades/{symbol}
Returns trades information for a symbol with a symbol Id.
Requires no API key Access Rights.
Parameters:
Name | Type | Description |
---|---|---|
sort | String | Sort direction Accepted values: ASC , DESC Default value: DESC |
by | String | Defines filter type Accepted values: id , timestamp Default value: timestamp |
from | Datetime or Number | Interval initial value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value |
till | Datetime or Number | Interval end value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value |
limit | Number | Default value: 100 Max value: 1000 |
offset | Number | Default value: 0 Max value: 100000 |
Responses:
Name | Type | Description |
---|---|---|
id | Number | Trade identifier |
price | Number | Trade price |
quantity | Number | Trade quantity |
side | String | Trade side Accepted values: sell or buy |
timestamp | Datetime | Trade timestamp |
Order Book
curl "https://api.bequant.io/api/2/public/orderbook/ETHBTC"
The above command returns JSON structured like this:
{
"ask": [
{
"price": "0.046002",
"size": "0.088"
},
{
"price": "0.046800",
"size": "0.200"
}
],
"bid": [
{
"price": "0.046001",
"size": "0.005"
},
{
"price": "0.046000",
"size": "0.200"
}
],
"timestamp": "2018-11-19T05:00:28.193Z"
}
GET /api/2/public/orderbook/{symbol}
An Order Book is an electronic list of buy and sell orders for a specific symbol, structured by price level.
Requires no API key Access Rights.
Parameters:
Name | Type | Description |
---|---|---|
limit | Number | Limit of Order Book levels Default value: 100 Set 0 to view full list of Order Book levels. |
Responses:
Name | Type | Description |
---|---|---|
ask | Array | Ask side array of levels |
bid | Array | Bid side array of levels |
size | Number | Total volume of orders with the specified price |
price | Number | Price level |
Candles
curl "https://api.bequant.io/api/2/public/candles/ETHBTC?period=M30"
The above command returns JSON structured like this:
[
{
"timestamp": "2017-10-20T20:00:00.000Z",
"open": "0.050459",
"close": "0.050087",
"min": "0.050000",
"max": "0.050511",
"volume": "1326.628",
"volumeQuote": "66.555987736"
},
{
"timestamp": "2017-10-20T20:30:00.000Z",
"open": "0.050108",
"close": "0.050139",
"min": "0.050068",
"max": "0.050223",
"volume": "87.515",
"volumeQuote": "4.386062831"
}
]
GET /api/2/public/candles/{symbol}
Candles are used for the representation of a specific symbol as an OHLC chart.
Requires no API key Access Rights.
Parameters:
Name | Type | Description |
---|---|---|
period | String | Accepted values: M1 (one minute), M3 , M5 , M15 , M30 , H1 (one hour), H4 , D1 (one day), D7 , 1M (one month) Default value: M30 (30 minutes) |
sort | String | Sort direction Accepted values: ASC , DESC Default value: ASC |
from | Datetime or Number | Interval initial value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value. |
till | Datetime or Number | Interval end value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value. |
limit | Number | Limit of candles Default value: 100 Max value: 1000 |
offset | Number | Default value: 0 Max value: 100000 |
Responses:
Name | Type | Description |
---|---|---|
timestamp | Datetime | Candle timestamp |
open | Number | Open price |
close | Number | Closing price |
min | Number | Lowest price for the period |
max | Number | Highest price for the period |
volume | Number | Volume in base currency |
volumeQuote | Number | Volume in quote currency |
Authentication
curl -u "publicKey:secretKey" https://api.bequant.io/api/2/trading/balance
import requests
session = requests.session()
session.auth = ("publicKey", "secretKey")
Public market data are available without authentication. Authentication is required for other requests.
You should create API keys on the API Setting page. You can create multiple API keys with different access rights for your applications.
Use Basic Authentication to access the REST API.
Trading
Trading Balance
curl -X GET -u "ff20f250a7b3a414781d1abe11cd8cee:fb453577d11294359058a9ae13c94713" \
"https://api.bequant.io/api/2/trading/balance"
import requests
session = requests.session()
session.auth = ("ff20f250a7b3a414781d1abe11cd8cee", "fb453577d11294359058a9ae13c94713")
b = session.get('https://api.bequant.io/api/2/trading/balance').json()
print(b)
The above command returns JSON structured like this:
[
{
"currency": "ETH",
"available": "10.000000000",
"reserved": "0.560000000"
},
{
"currency": "BTC",
"available": "0.010205869",
"reserved": "0"
}
]
GET /api/2/trading/balance
Returns the user's trading balance.
Requires the "Orderbook, History, Trading balance" API key Access Right.
Responses:
Name | Type | Description |
---|---|---|
currency | String | Currency code |
available | Number | Amount available for trading or transfer to main account |
reserved | Number | Amount reserved for active orders or incomplete transfers to main account |
Order model
Order model consists of:
Name | Type | Description |
---|---|---|
id | Number | Order unique identifier as assigned by exchange |
clientOrderId | String | Order unique identifier as assigned by trader. Uniqueness must be guaranteed within a single trading day, including all active orders. |
symbol | String | Trading symbol name |
side | String | Trade side Accepted values: sell or buy |
status | String | Order state Accepted values: new , suspended , partiallyFilled , filled , canceled , expired |
type | String | Accepted values: limit , market , stopLimit , stopMarket |
timeInForce | String | Time in Force is a special instruction used when placing a trade to indicate how long an order will remain active before it is executed or expired. GTC - ''Good-Till-Cancelled'' order won't be closed until it is filled. IOC - ''Immediate-Or-Cancel'' order must be executed immediately. Any part of an IOC order that cannot be filled immediately will be cancelled. FOK - ''Fill-Or-Kill'' is a type of ''Time in Force'' designation used in securities trading that instructs a brokerage to execute a transaction immediately and completely or not execute it at all. Day - keeps the order active until the end of the trading day (UTC). GTD - ''Good-Till-Date''. The date is specified in expireTime . |
quantity | Number | Order quantity |
price | Number | Order price |
cumQuantity | Number | Cumulative executed quantity |
createdAt | Datetime | Order creation date |
updatedAt | Datetime | Date of order's last update |
stopPrice | Number | Required for stop-limit orders |
postOnly | Boolean | A post-only order is an order that does not remove liquidity. If your post-only order causes a match with a pre-existing order as a taker, then the order will be cancelled. |
expireTime | Datetime | Date of order expiration for timeInForce = GTD |
Get active orders
curl -X GET -u "ff20f250a7b3a414781d1abe11cd8cee:fb453577d11294359058a9ae13c94713" \
"https://api.bequant.io/api/2/order"
import requests
session = requests.session()
session.auth = ("ff20f250a7b3a414781d1abe11cd8cee", "fb453577d11294359058a9ae13c94713")
b = session.get('https://api.bequant.io/api/2/order').json()
print(b)
The above command returns JSON structured like this:
[
{
"id": 840450210,
"clientOrderId": "c1837634ef81472a9cd13c81e7b91401",
"symbol": "ETHBTC",
"side": "buy",
"status": "partiallyFilled",
"type": "limit",
"timeInForce": "GTC",
"quantity": "0.020",
"price": "0.046001",
"cumQuantity": "0.005",
"postOnly": "false",
"createdAt": "2017-05-12T17:17:57.437Z",
"updatedAt": "2017-05-12T17:18:08.610Z"
}
]
GET /api/2/order
Return array of active orders.
Requires the "Place/cancel orders" API key Access Right.
Parameters:
Name | Type | Description |
---|---|---|
symbol | String | Optional parameter to filter active orders by symbol |
Response: Array of orders
Get active order by clientOrderId
curl -X GET -u "ff20f250a7b3a414781d1abe11cd8cee:fb453577d11294359058a9ae13c94713" \
"https://api.bequant.io/api/2/order/c1837634ef81472a9cd13c81e7b91401"
import requests
session = requests.session()
session.auth = ("ff20f250a7b3a414781d1abe11cd8cee", "fb453577d11294359058a9ae13c94713")
// wait 20 sec for execution reports
b = session.get('https://api.bequant.io/api/2/order/c1837634ef81472a9cd13c81e7b91401?wait=20000').json()
print(b)
The above command returns JSON structured like this:
{
"id": 840450210,
"clientOrderId": "c1837634ef81472a9cd13c81e7b91401",
"symbol": "ETHBTC",
"side": "buy",
"status": "partiallyFilled",
"type": "limit",
"timeInForce": "GTC",
"quantity": "0.020",
"price": "0.046001",
"cumQuantity": "0.005",
"postOnly": false,
"createdAt": "2017-05-12T17:17:57.437Z",
"updatedAt": "2017-05-12T17:18:08.610Z"
}
GET /api/2/order/{clientOrderId}
Requires the "Place/cancel orders" API key Access Right.
Parameters:
Name | Type | Description |
---|---|---|
wait | Number | Time in milliseconds (optional parameter) Max value: 60000 Default value: none While using long polling request: if order is filled, cancelled or expired order info will be returned instantly. For other order statuses, actual order info will be returned after specified wait time. |
Response: order
Create new order
curl -X PUT -u "ff20f250a7b3a414781d1abe11cd8cee:fb453577d11294359058a9ae13c94713" \
"https://api.bequant.io/api/2/order/d8574207d9e3b16a4a5511753eeef175" \
-d 'symbol=ETHBTC&side=sell&quantity=0.063&price=0.046016'
import requests
session = requests.session()
session.auth = ("ff20f250a7b3a414781d1abe11cd8cee", "fb453577d11294359058a9ae13c94713")
orderData = {'symbol':'ethbtc', 'side': 'sell', 'quantity': '0.063', 'price': '0.046016' }
r = session.post('https://api.bequant.io/api/2/order', data = orderData)
print(r.json())
The above command returns JSON structured like this:
{
"id": 0,
"clientOrderId": "d8574207d9e3b16a4a5511753eeef175",
"symbol": "ETHBTC",
"side": "sell",
"status": "new",
"type": "limit",
"timeInForce": "GTC",
"quantity": "0.063",
"price": "0.046016",
"cumQuantity": "0.000",
"postOnly": false,
"createdAt": "2017-05-15T17:01:05.092Z",
"updatedAt": "2017-05-15T17:01:05.092Z"
}
Error response example:
{
"error": {
"code": 20001,
"message": "Insufficient funds",
"description": "Check that the funds are sufficient, given commissions"
}
}
POST /api/2/order
PUT /api/2/order/{clientOrderId}
Requires the "Place/cancel orders" API key Access Right.
Price accuracy and quantity
Symbol config contains the tickSize
parameter which means that price
should be divided by tickSize
with no remainder. quantity
should be divided by quantityIncrement
with no remainder.
By default, if strictValidate
is not enabled, the Server rounds half down the price
and quantity
for tickSize
and quantityIncrement
.
Example of ETHBTC: tickSize
= '0.000001', then price '0.046016' is valid, '0.0460165' is invalid.
Fees
Charged fee is determined in symbol's feeCurrency
. Maker-taker fees offer a transaction rebate provideLiquidityRate
to those who provide liquidity (the market maker), while charging customers who take that liquidity takeLiquidityRate
.
To create buy orders, you must have sufficient balance including fees.Available balance > price * quantity * (1 + takeLiquidityRate)
Order result status
For orders with timeInForce
= IOC
or FOK
, the REST API returns final order state: filled
or expired
.
If order can be instantly executed, then the REST API returns a status of filled
or partiallyFilled
in the order's info.
Parameters:
Name | Type | Description |
---|---|---|
clientOrderId | String | Optional parameter. If it is skipped, it will be generated by the Server. Uniqueness must be guaranteed within a single trading day, including all active orders. |
symbol | String | Trading symbol |
side | String | Trade side Accepted values: sell or buy |
type | String | Optional parameter Accepted values: limit , market , stopLimit , stopMarket Default value: limit |
timeInForce | String | Optional parameter Accepted values: GTC , IOC , FOK , Day , GTD Default value: GDC |
quantity | Number | Order quantity |
price | Number | Order price. Required for limit order types |
stopPrice | Number | Required for stop-limit orders |
expireTime | Datetime | Required for orders with timeInForce = GTD |
strictValidate | Boolean | Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step.. See the symbol's tickSize and quantityIncrement . |
postOnly | Boolean | If your post-only order causes a match with a pre-existing order as a taker, then the order will be cancelled. |
Response: order
Cancel orders
DELETE /api/2/order
Cancel all active orders, or all active orders for a specified symbol.
Requires the "Place/cancel orders" API key Access Right.
Parameters:
Name | Type | Description |
---|---|---|
symbol | String | Optional parameter to filter active orders by symbol |
Response: Array of orders
Cancel order by clientOrderId
curl -X DELETE -u "ff20f250a7b3a414781d1abe11cd8cee:fb453577d11294359058a9ae13c94713" \
"https://api.bequant.io/api/2/order/d8574207d9e3b16a4a5511753eeef175"
The above command returns JSON structured like this:
{
"id": 0,
"clientOrderId": "d8574207d9e3b16a4a5511753eeef175",
"symbol": "ETHBTC",
"side": "sell",
"status": "canceled",
"type": "limit",
"timeInForce": "GTC",
"quantity": "0.000",
"price": "0.046016",
"cumQuantity": "0.000",
"postOnly": false,
"createdAt": "2017-05-15T17:01:05.092Z",
"updatedAt": "2017-05-15T18:08:57.226Z"
}
Example of Order not found error response:
{
"error": {
"code": 20002,
"message": "Order not found",
"description": ""
}
}
DELETE /api/2/order/{clientOrderId}
Requires the "Place/cancel orders" API key Access Right.
Response: order
Get trading commission
curl -X GET -u "ff20f250a7b3a414781d1abe11cd8cee:fb453577d11294359058a9ae13c94713" \
"https://api.bequant.io/api/2/trading/fee/ETHBTC"
The above command returns JSON structured like this:
{
"takeLiquidityRate": "0.001",
"provideLiquidityRate": "-0.0001"
}
GET /api/2/trading/fee/{symbol}
Get personal trading commission rate.
Requires the "Place/cancel orders" API key Access Right.
Trading history
Orders history
curl -X GET -u "ff20f250a7b3a414781d1abe11cd8cee:fb453577d11294359058a9ae13c94713" \
"https://api.bequant.io/api/2/history/order?symbol=ETHBTC"
GET /api/2/history/order
All orders older than 24 hours without trades are deleted.
Requires the "Orderbook, History, Trading balance" API key Access Right.
Parameters:
Name | Type | Description |
---|---|---|
symbol | String | Optional parameter to filter orders by symbol. |
clientOrderId | String | If set, other parameters will be ignored, including limit and offset . |
from | Datetime or Number | Interval initial value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value. |
till | Datetime or Number | Interval end value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value. |
limit | Number | Default value: 100 Max value: 1000 |
offset | Number | Default value: 0 Max value: 100000 |
Response: Array of orders
Trades history
curl -X GET -u "ff20f250a7b3a414781d1abe11cd8cee:fb453577d11294359058a9ae13c94713" \
"https://api.bequant.io/api/2/history/trades?symbol=ETHBTC"
[
{
"id": 9535486,
"clientOrderId": "f8dbaab336d44d5ba3ff578098a68454",
"orderId": 816088377,
"symbol": "ETHBTC",
"side": "sell",
"quantity": "0.061",
"price": "0.045487",
"fee": "0.000002775",
"timestamp": "2017-05-17T12:32:57.848Z"
},
{
"id": 9535437,
"clientOrderId": "27b9bfc068b44194b1f453c7af511ed6",
"orderId": 816088021,
"symbol": "ETHBTC",
"side": "buy",
"quantity": "0.038",
"price": "0.046000",
"fee": "-0.000000174",
"timestamp": "2017-05-17T12:30:57.848Z"
}
]
GET /api/2/history/trades
Get the user's trading history.
Requires the "Orderbook, History, Trading balance" API key Access Right.
Parameters:
Name | Type | Description |
---|---|---|
symbol | String | Optional parameter to filter active orders by symbol |
sort | String | Sort direction Accepted values: DESC , ASC Default value: DESC |
by | String | Defines filter type Accepted values: timestamp , id . Default value: timestamp |
from | Datetime or Number | Interval initial value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value. |
till | Datetime or Number | Interval end value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value. |
limit | Number | Default value: 100 Max value: 1000 |
offset | Number | Default value: 0 Max value: 100000 |
Responses:
Name | Type | Description |
---|---|---|
id | Number | Trade unique identifier as assigned by exchange |
orderId | Number | Order unique identifier as assigned by exchange |
clientOrderId | String | Order unique identifier as assigned by trader |
symbol | String | Trading symbol |
side | String | Trade side Accepted values: sell or buy |
quantity | Number | Trade quantity |
price | Number | Trade price |
fee | Number | Trade commission Can be negative (''rebate'' - reward paid to a trader). See fee currency in the symbol config. |
timestamp | Datetime | Trade timestamp |
Trades by order
curl -X GET -u "ff20f250a7b3a414781d1abe11cd8cee:fb453577d11294359058a9ae13c94713" \
"https://api.bequant.io/api/2/history/order/816088021/trades"
GET /api/2/history/order/{orderId}/trades
Returns the user's trading order with a specified orderId.
Requires the "Orderbook, History, Trading balance" API key Access Right.
Parameters:
Name | Type | Description |
---|---|---|
orderId | Number | Order id |
orderId
is required in cause ofclientOrderId
can be non-unique during long period.
Responses:
Name | Type | Description |
---|---|---|
id | Number | Trade unique identifier as assigned by exchange |
orderId | Number | Order unique identifier as assigned by exchange |
clientOrderId | String | Order unique identifier as assigned by trader |
symbol | String | Trading symbol |
side | String | Trade side Accepted values: sell or buy |
quantity | Number | Trade quantity |
price | Number | Trade price |
fee | Number | Trade commission Can be negative (''rebate'' - reward paid to a trader). See fee currency in the symbol config. |
timestamp | Datetime | Trade timestamp |
Account management
Account balance
[
{
"currency": "BTC",
"available": "0.0504600",
"reserved": "0.0000000"
},
{
"currency": "ETH",
"available": "30.8504600",
"reserved": "0.0000000"
}
]
GET /api/2/account/balance
Returns the user's account balance.
Requires the "Payment information" API key Access Right.
Responses:
Name | Type | Description |
---|---|---|
currency | String | Currency code |
available | Number | Amount available for withdraw or transfer to trading account |
reserved | Number | Amount reserved for incomplete transactions |
Deposit crypto address
{
"address": "NXT-G22U-BYF7-H8D9-3J27W",
"paymentId": "616598347865"
}
GET /api/2/account/crypto/address/{currency}
- Get current address
Requires the "Payment information" API key Access Right.
POST /api/2/account/crypto/address/{currency}
- Create new address
Requires the "Payment information" API key Access Right.
Responses:
Name | Type | Description |
---|---|---|
address | String | Address for deposit |
paymentId | String | Optional parameter If this parameter is set, it is required for deposit. |
Withdraw crypto
{
"id": "d2ce578f-647d-4fa0-b1aa-4a27e5ee597b"
}
POST /api/2/account/crypto/withdraw
Requires the "Withdraw cryptocurrencies" API key Access Right.
Parameters:
Name | Type | Description |
---|---|---|
currency | String | Currency code |
amount | Number | The amount that will be sent to the specified address |
address | String | Address identifier |
paymentId | String | Optional parameter |
networkFee | Number or String | Optional parameter. A commission value that is too low or too high will be rounded to a valid value. |
includeFee | Boolean | Default value: false If true is set, then total spent value will include fee and networkFee . |
autoCommit | Boolean | Default value: true If false is set, then you should commit or rollback transaction in an hour. Used in two phase commit schema. |
Responses:
Name | Type | Description |
---|---|---|
id | String | Transaction unique identifier as assigned by exchange |
Withdraw crypto commit or rollback
{
"result": true
}
PUT /api/2/account/crypto/withdraw/{id}
- Commit
DELETE /api/2/account/crypto/withdraw/{id}
- Rollback
Requires the "Withdraw cryptocurrencies" API key Access Right.
Both methods are idempotent
Responses:
Name | Type | Description |
---|---|---|
result | Boolean | True , if request is completed |
Check if crypto address belongs to current account
{
"result": true
}
GET /api/2/account/crypto/is-mine/{address}
Requires the "Payment information" API key Access Right.
Responses:
Name | Type | Description |
---|---|---|
result | Boolean | True , if address belongs to current account |
Transfer money between trading account and bank account
{
"id": "d2ce578f-647d-4fa0-b1aa-4a27e5ee597b"
}
POST /api/2/account/transfer
Requires the "Payment information" API key Access Right.
Parameters:
Name | Type | Description |
---|---|---|
currency | String | Currency code |
amount | Number | The amount that will be transferred between balances |
type | String | Accepted values: bankToExchange , exchangeToBank |
Responses:
Name | Type | Description |
---|---|---|
id | String | Transaction unique identifier as assigned by exchange |
Get transactions history
[
{
"id": "6a2fb54d-7466-490c-b3a6-95d8c882f7f7",
"index": 20400458,
"currency": "ETH",
"amount": "38.616700000000000000000000",
"fee": "0.000880000000000000000000",
"address": "0xfaEF4bE10dDF50B68c220c9ab19381e20B8EEB2B",
"hash": "eece4c17994798939cea9f6a72ee12faa55a7ce44860cfb95c7ed71c89522fe8",
"status": "pending",
"type": "payout",
"createdAt": "2017-05-18T18:05:36.957Z",
"updatedAt": "2017-05-18T19:21:05.370Z"
}
]
GET /api/2/account/transactions
GET /api/2/account/transactions/{id}
- get transaction by transaction id
Requires the "Payment information" API key Access Right.
Parameters:
Name | Type | Description |
---|---|---|
currency | String | Currency code |
sort | String | Sort direction Accepted values: DESC , ASC Default value: DESC |
by | String | Defines filter type Accepted values: timestamp or index Default value timestamp |
from | Datetime or Number | Interval initial value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value. |
till | Datetime or Number | Interval end value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value. |
limit | Number | Default value: 100 Max value: 1000 |
offset | Number | Default value: 0 Max value: 100000 |
Responses:
Name | Type | Description |
---|---|---|
id | String | Transaction unique identifier as assigned by exchange |
index | Number | Internal index value that represents when the entry was updated |
currency | String | Currency code |
amount | Number | Amount of traded currency |
fee | Number | Payment commission value |
address | String | Address identifier |
paymentId | String | Optional parameter |
hash | String | Transaction hash |
status | String | Accepted values: created , pending , failed , success |
type | String | Accepted values: payout (crypto withdraw transaction), payin (crypto deposit transaction), deposit , withdraw , bankToExchange , exchangeToBank |
createdAt | Datetime | Transaction creation date |
updatedAt | Datetime | Date of transactions's last update |
Socket API Reference
Use JSON-RPC 2.0 over WebSocket connection as transport.
Request object
{
"method": "newOrder",
"params": {
"clientOrderId": "57d5525562c945448e3cbd559bd068c4",
"symbol": "ETHBTC",
"side": "sell",
"price": "0.059837",
"quantity": "0.015"
},
"id": 123
}
An RPC call is represented by sending a Request object to a Server.
The Request object has the following members:
method
- a String containing the name of the method to be invoked.params
- a Structured value that holds the parameter values to be used during the invocation of the method.id
- An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD NOT be Null.
Notification
{
"jsonrpc": "2.0",
"method": "updateTrades",
"params": {
"data": [
{
"id": 54469813,
"price": "0.054670",
"quantity": "0.183",
"side": "buy",
"timestamp": "2017-10-19T16:34:25.041Z"
}
],
"symbol": "ETHBTC"
}
}
A Notification is a Request object without an id
member. A Request object (a Notification) signifies the lack of the Client's interest in the corresponding Response object. Therefore no Response objects need to be returned to the Client.
The Notification object has the following members:
method
- a string containing the name of the method to be invoked.params
- a structured value holding the parameter values to be used during the method invocation.
Response object
When RPC call is made, the Server MUST reply with a Response, except for Notifications cases.
Server responses for each request. Response on success subscription is true
. Example:
{
"jsonrpc": "2.0",
"result": true,
"id": 123
}
Response error
{
"jsonrpc": "2.0",
"error": {
"code": 2001,
"message": "Symbol not found",
"description": "Try get /api/2/public/symbol, to get list of all available symbols."
},
"id": 123
}
The Response is represented as a single JSON Object, with the following members:
result
- this member is REQUIRED on success. This member MUST NOT exist if there was an error during method invocation. The value of this member is determined by the method invoked on the Server.error
- this member is REQUIRED on error. This member MUST NOT exist if there was no error triggered during method invocation. The value for this member MUST be an Object as defined in the Error response section.
Socket Market Data
The parameters of requests, responses, and errors correspond to REST, but have different usage procedures.
First, you should subscribe for the required data. Then the Server will send a full snapshot of the data. After that, the Server sends an update notification.
Get Currencies
wscat -c wss://api.bequant.io/api/2/ws
{
"method": "getCurrency",
"params": {
"currency": "ETH"
},
"id": 123
}
Response
{
"jsonrpc": "2.0",
"result": {
"id": "ETH",
"fullName": "Ethereum",
"crypto": true,
"payinEnabled": true,
"payinPaymentId": false,
"payinConfirmations": 2,
"payoutEnabled": true,
"payoutIsPaymentId": false,
"transferEnabled": true,
"delisted": false,
"payoutFee": "0.001"
},
"id": 123
}
Request methods: getCurrencies
,getCurrency
{ "method": "getCurrency", "params": { "currency": "ETH" }, "id": 123 }
Get Symbols
wscat -c wss://api.bequant.io/api/2/ws
{
"method": "getSymbol",
"params": {
"symbol": "ETHBTC"
},
"id": 123
}
Response
{
"jsonrpc": "2.0",
"result": {
"id": "ETHBTC",
"baseCurrency": "ETH",
"quoteCurrency": "BTC",
"quantityIncrement": "0.001",
"tickSize": "0.000001",
"takeLiquidityRate": "0.001",
"provideLiquidityRate": "-0.0001",
"feeCurrency": "BTC"
},
"id": 123
}
Request methods: getSymbols
,getSymbol
Subscribe to Ticker
wscat -c wss://api.bequant.io/api/2/ws
{
"method": "subscribeTicker",
"params": {
"symbol": "ETHBTC"
},
"id": 123
}
Notification ticker
{
"jsonrpc": "2.0",
"method": "ticker",
"params": {
"ask": "0.054464",
"bid": "0.054463",
"last": "0.054463",
"open": "0.057133",
"low": "0.053615",
"high": "0.057559",
"volume": "33068.346",
"volumeQuote": "1832.687530809",
"timestamp": "2017-10-19T15:45:44.941Z",
"symbol": "ETHBTC"
}
}
Request methods: subscribeTicker
, unsubscribeTicker
Notification method: ticker
Subscribe to Order Book
wscat -c wss://api.bequant.io/api/2/ws
{
"method": "subscribeOrderbook",
"params": {
"symbol": "ETHBTC"
},
"id": 123
}
Notification snapshot
{
"jsonrpc": "2.0",
"method": "snapshotOrderbook",
"params": {
"ask": [
{
"price": "0.054588",
"size": "0.245"
},
{
"price": "0.054590",
"size": "0.000"
},
{
"price": "0.054591",
"size": "2.784"
}
],
"bid": [
{
"price": "0.054558",
"size": "0.500"
},
{
"price": "0.054557",
"size": "0.076"
},
{
"price": "0.054524",
"size": "7.725"
}
],
"symbol": "ETHBTC",
"sequence": 8073827,
"timestamp": "2018-11-19T05:00:28.193Z"
}
}
Notification update
{
"jsonrpc": "2.0",
"method": "updateOrderbook",
"params": {
"ask": [
{
"price": "0.054590",
"size": "0.000"
},
{
"price": "0.054591",
"size": "0.000"
}
],
"bid": [
{
"price": "0.054504",
"size": "0.000"
}
],
"symbol": "ETHBTC",
"sequence": 8073830,
"timestamp": "2018-11-19T05:00:28.700Z"
}
}
Request methods: subscribeOrderbook
, unsubscribeOrderbook
Notification snapshot
Message contains a full snapshot of the Order Book.
Notification method: snapshotOrderbook
Notification update
Message contains incremental changes.
size
= 0 means that level has been deleted.
sequence
is monotonically increased for each update, each symbol has its own sequence.
Notification method: updateOrderbook
Subscribe to Trades
wscat -c wss://api.bequant.io/api/2/ws
{
"method": "subscribeTrades",
"params": {
"symbol": "ETHBTC",
"limit: 100
},
"id": 123
}
Request methods: subscribeTrades
, unsubscribeTrades
Notification snapshot
{
"jsonrpc": "2.0",
"method": "snapshotTrades",
"params": {
"data": [
{
"id": 54469456,
"price": "0.054656",
"quantity": "0.057",
"side": "buy",
"timestamp": "2017-10-19T16:33:42.821Z"
},
{
"id": 54469497,
"price": "0.054656",
"quantity": "0.092",
"side": "buy",
"timestamp": "2017-10-19T16:33:48.754Z"
},
{
"id": 54469697,
"price": "0.054669",
"quantity": "0.002",
"side": "buy",
"timestamp": "2017-10-19T16:34:13.288Z"
}
],
"symbol": "ETHBTC"
}
}
Notification method: snapshotTrades
Notification update
{
"jsonrpc": "2.0",
"method": "updateTrades",
"params": {
"data": [
{
"id": 54469813,
"price": "0.054670",
"quantity": "0.183",
"side": "buy",
"timestamp": "2017-10-19T16:34:25.041Z"
}
],
"symbol": "ETHBTC"
}
}
Notification method: updateTrades
Get Trades
wscat -c wss://api.bequant.io/api/2/ws
{
"method": "getTrades",
"params": {
"symbol": "ETHBTC",
"limit": 3,
"sort": "DESC",
"by": "id"
},
"id": 123
}
Response
{
"jsonrpc": "2.0",
"result": {
"data": [
{
"id": 54472171,
"price": "0.054443",
"quantity": "2.213",
"side": "sell",
"timestamp": "2017-10-19T16:39:20.796Z"
},
{
"id": 54472170,
"price": "0.054453",
"quantity": "0.030",
"side": "sell",
"timestamp": "2017-10-19T16:39:20.796Z"
},
{
"id": 54472169,
"price": "0.054454",
"quantity": "0.052",
"side": "sell",
"timestamp": "2017-10-19T16:39:20.796Z"
}
],
"symbol": "ETHBTC"
},
"id": 123
}
Request method: getTrades
Parameters:
Name | Type | Description |
---|---|---|
symbol | String | Optional parameter to filter active orders by symbol |
sort | String | Sort direction Accepted values: DESC or ASC Default value DESC |
by | String | Defines filter type Accepted values: timestamp or id Default value: timestamp |
from | Datetime or Number | Interval initial value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value. |
till | Datetime or Number | Interval end value (optional parameter) If sorting by timestamp is used, then Datetime , otherwise Number of index value. |
limit | Number | Default value: 100 Max value: 1000 |
offset | Number | Default value: 0 Max value: 100000 |
Subscribe to Candles
Request methods: subscribeCandles
, unsubscribeCandles
wscat -c wss://api.bequant.io/api/2/ws
{
"method": "subscribeCandles",
"params": {
"symbol": "ETHBTC",
"period": "M30",
"limit": 100
},
"id": 123
}
Notification snapshot
{
"jsonrpc": "2.0",
"method": "snapshotCandles",
"params": {
"data": [
{
"timestamp": "2017-10-19T15:00:00.000Z",
"open": "0.054801",
"close": "0.054625",
"min": "0.054601",
"max": "0.054894",
"volume": "380.750",
"volumeQuote": "20.844237223"
},
{
"timestamp": "2017-10-19T15:30:00.000Z",
"open": "0.054616",
"close": "0.054618",
"min": "0.054420",
"max": "0.054724",
"volume": "348.527",
"volumeQuote": "19.011854364"
},
{
"timestamp": "2017-10-19T16:00:00.000Z",
"open": "0.054587",
"close": "0.054626",
"min": "0.054408",
"max": "0.054768",
"volume": "194.014",
"volumeQuote": "10.595416973"
},
{
"timestamp": "2017-10-19T16:30:00.000Z",
"open": "0.054614",
"close": "0.054443",
"min": "0.054339",
"max": "0.054724",
"volume": "141.213",
"volumeQuote": "7.706358298"
}
],
"symbol": "ETHBTC",
"period": "M30"
}
}
Notification method: snapshotCandles
Notification update
{
"jsonrpc": "2.0",
"method": "updateCandles",
"params": {
"data": [
{
"timestamp": "2017-10-19T16:30:00.000Z",
"open": "0.054614",
"close": "0.054465",
"min": "0.054339",
"max": "0.054724",
"volume": "141.268",
"volumeQuote": "7.709353873"
}
],
"symbol": "ETHBTC",
"period": "M30"
}
}
Notification method: updateCandles
Socket Session Authentication
Example with BASIC algo:
wscat -c wss://api.bequant.io/api/2/ws
{
"method": "login",
"params": {
"algo": "BASIC",
"pKey": "3ef4a9f8c8bf04bd8f09884b98403eae",
"sKey": "2deb570ab58fd553a4ed3ee249fd2d51"
}
}
Example with HS256 algo:
wscat -c wss://api.bequant.io/api/2/ws
{
"method": "login",
"params": {
"algo": "HS256",
"pKey": "3ef4a9f8c8bf04bd8f09884b98403eae",
"nonce": "N1g287gL8YOwDZr",
"signature": "b1c0ae399c2d341866a214f7d3ed755b821c1c36fc6f17083ef05fbb55b7f986"
}
}
Request method: login
Params:
Name | Type | Description |
---|---|---|
algo | String | Encryption algorithm Accepted values: BASIC or HS256 |
pKey | String | API public key |
sKey | String | API secret key, required on BASIC algo |
nonce | String | Random string, required on HS256 algo |
signature | String | HMAC SHA256 sign nonce with API secret key, required on HS256 algo |
Socket Trading
Trade via socket has some major differences compared to REST:
- Quickness. The time to place a new order is a bit higher than network latency.
- The Server notifies you of any order updates.
- FIFO. Your requests are executed on a First In First Out basis.
Subscribe to reports
wscat -c wss://api.bequant.io/api/2/ws
{
"method": "subscribeReports",
"params": {}
}
Notification with currently active orders
{
"jsonrpc": "2.0",
"method": "activeOrders",
"params": [
{
"id": "4345613661",
"clientOrderId": "57d5525562c945448e3cbd559bd068c3",
"symbol": "BCCBTC",
"side": "sell",
"status": "new",
"type": "limit",
"timeInForce": "GTC",
"quantity": "0.013",
"price": "0.100000",
"cumQuantity": "0.000",
"postOnly": false,
"createdAt": "2017-10-20T12:17:12.245Z",
"updatedAt": "2017-10-20T12:17:12.245Z",
"reportType": "status"
}
]
}
Method: subscribeReports
Method: activeOrders
Notification report
{
"jsonrpc": "2.0",
"method": "report",
"params": {
"id": "4345697765",
"clientOrderId": "53b7cf917963464a811a4af426102c19",
"symbol": "ETHBTC",
"side": "sell",
"status": "filled",
"type": "limit",
"timeInForce": "GTC",
"quantity": "0.001",
"price": "0.053868",
"cumQuantity": "0.001",
"postOnly": false,
"createdAt": "2017-10-20T12:20:05.952Z",
"updatedAt": "2017-10-20T12:20:38.708Z",
"reportType": "trade",
"tradeQuantity": "0.001",
"tradePrice": "0.053868",
"tradeId": 55051694,
"tradeFee": "-0.000000005"
}
}
Method: report
Params:
Name | Type | Description |
---|---|---|
id | Number | Order unique identifier as assigned by exchange |
clientOrderId | String | Order unique identifier as assigned by trader |
symbol | String | Trading symbol |
side | String | Trade side Accepted values: sell , buy |
status | String | Accepted values: new , suspended , partiallyFilled , filled , canceled , expired |
type | String | Accepted values: limit , market , stopLimit , stopMarket |
timeInForce | String | Time in Force is a special instruction used when placing a trade to indicate how long an order will remain active before it is executed or expired. GTC - ''Good-Till-Cancel'' order won't close until it is filled. IOC - ''Immediate-Or-Cancel'' order must be executed immediately. Any part of an IOC order that cannot be filled immediately will be cancelled. FOK - ''Fill-Or-Kill'' is a type of ''Time in Force'' designation used in securities trading that instructs a brokerage to execute a transaction immediately and completely or not execute it at all. Day - keeps the order active until the end of the trading day (UTC). GTD - ''Good-Till-Date''. The date is specified in expireTime . |
quantity | Number | Order quantity |
price | Number | Order price |
cumQuantity | Number | Cumulative executed quantity |
postOnly | Boolean | A post-only order is an order that does not remove liquidity. If your post-only order causes a match with a pre-existing order as a taker, then the order will be cancelled. |
createdAt | Datetime | Report creation date |
updatedAt | Datetime | Date of the report's last update |
stopPrice | Number | Required for stop-limit orders |
expireTime | Datetime | Date of order expiration for timeInForce = GTD |
reportType | String | Accepted values: status , new , canceled , expired , suspended , trade , replaced |
tradeId | Number | Trade identifier. Required for reportType = trade |
tradeQuantity | Number | Quantity of trade. Required for reportType = trade |
tradePrice | Number | Trade price. Required for reportType = trade |
tradeFee | Number | Fee paid for trade. Required for reportType = trade |
originalRequestClientOrderId | String | Identifier of replaced order |
Place new order
Request:
{
"method": "newOrder",
"params": {
"clientOrderId": "57d5525562c945448e3cbd559bd068c4",
"symbol": "ETHBTC",
"side": "sell",
"price": "0.059837",
"quantity": "0.015"
},
"id": 123
}
Success response:
{
"jsonrpc": "2.0",
"result": {
"id": "4345947689",
"clientOrderId": "57d5525562c945448e3cbd559bd068c4",
"symbol": "ETHBTC",
"side": "sell",
"status": "new",
"type": "limit",
"timeInForce": "GTC",
"quantity": "0.001",
"price": "0.093837",
"cumQuantity": "0.000",
"postOnly": false,
"createdAt": "2017-10-20T12:29:43.166Z",
"updatedAt": "2017-10-20T12:29:43.166Z",
"reportType": "new"
},
"id": 123
}
Example error response:
{
"jsonrpc": "2.0",
"error": {
"code": 20001,
"message": "Insufficient funds",
"description": "Check that the funds are sufficient, given commissions"
},
"id": 123
}
Method: newOrder
Params:
Name | Type | Description |
---|---|---|
clientOrderId | String | Required parameter. Uniqueness must be guaranteed within a single trading day, including all active orders. |
symbol | String | Trading symbol |
side | String | Trade side. Accepted values: sell , buy |
type | String | Optional parameter Accepted values: limit , market , stopLimit , stopMarket Default value: limit |
timeInForce | String | Optional parameter Accepted values: GTC , IOC , FOK , Day , GTD Default value: GTC |
quantity | Number | Order quantity |
price | Number | Order price. Required for limit types |
stopPrice | Number | Required for stop-limit orders |
expireTime | Datetime | Required for timeInForce = GTD |
strictValidate | Boolean | Price and quantity will be checked for incrementation within the symbol's tick size and quantity step. See the symbol's tickSize and quantityIncrement |
postOnly | Boolean | A post-only order is an order that does not remove liquidity. If your post-only order causes a match with a pre-existing order as a taker, then order will be cancelled. |
Cancel order
{
"jsonrpc": "2.0",
"result": {
"id": "4345947689",
"clientOrderId": "57d5525562c945448e3cbd559bd068c4",
"symbol": "ETHBTC",
"side": "sell",
"status": "canceled",
"type": "limit",
"timeInForce": "GTC",
"quantity": "0.001",
"price": "0.093837",
"cumQuantity": "0.000",
"postOnly": false,
"createdAt": "2017-10-20T12:29:43.166Z",
"updatedAt": "2017-10-20T12:31:26.174Z",
"reportType": "canceled"
},
"id": 123
}
Method: cancelOrder
Example:
{
"method": "cancelOrder",
"params": {
"clientOrderId": "57d5525562c945448e3cbd559bd068c4"
},
"id": 123
}
Cancel/Replace order
{
"jsonrpc": "2.0",
"result": {
"id": "4346371528",
"clientOrderId": "9cbe79cb6f864b71a811402a48d4b5b2",
"symbol": "ETHBTC",
"side": "sell",
"status": "new",
"type": "limit",
"timeInForce": "GTC",
"quantity": "0.002",
"price": "0.083837",
"cumQuantity": "0.000",
"postOnly": false,
"createdAt": "2017-10-20T12:47:07.942Z",
"updatedAt": "2017-10-20T12:50:34.488Z",
"reportType": "replaced",
"originalRequestClientOrderId": "9cbe79cb6f864b71a811402a48d4b5b1"
},
"id": 123
}
The Cancel/Replace request is used to change the parameters of an existing order and to change the quantity or price attribute of an open order.
Do not use this request to cancel the quantity remaining in an outstanding order. Use the Cancel request message for this purpose.
It is stipulated that a newly entered order cancels a prior order that has been entered, but not yet executed.
Method: cancelReplaceOrder
Params:
Name | Type | Description |
---|---|---|
clientOrderId | String | Replaced order (required parameter) |
requestClientId | String | clientOrderId for new order (required parameter) Uniqueness must be guaranteed within a single trading day, including all active orders. |
quantity | Number | New order quantity |
price | Number | New order price |
strictValidate | Boolean | Price and quantity will be checked for the incrementation within tick size and quantity step. See symbol's tickSize and quantityIncrement |
Example:
{
"method": "cancelReplaceOrder",
"params": {
"clientOrderId": "9cbe79cb6f864b71a811402a48d4b5b1",
"requestClientId": "9cbe79cb6f864b71a811402a48d4b5b2",
"quantity": "0.002",
"price": "0.083837"
},
"id": 123
}
Get active orders
{
"jsonrpc": "2.0",
"result": [
{
"id": "4346371528",
"clientOrderId": "9cbe79cb6f864b71a811402a48d4b5b2",
"symbol": "ETHBTC",
"side": "sell",
"status": "new",
"type": "limit",
"timeInForce": "GTC",
"quantity": "0.002",
"price": "0.083837",
"cumQuantity": "0.000",
"postOnly": false,
"createdAt": "2017-10-20T12:47:07.942Z",
"updatedAt": "2017-10-20T12:50:34.488Z",
"reportType": "replaced",
"originalRequestClientOrderId": "9cbe79cb6f864b71a811402a48d4b5b1"
}
],
"id": 123
}
Method: getOrders
Example:
{
"method": "getOrders",
"params": {},
"id": 123
}
Get trading balance
{
"jsonrpc": "2.0",
"result": [
{
"currency": "BCN",
"available": "100.000000000",
"reserved": "0"
},
{
"currency": "BTC",
"available": "0.013634021",
"reserved": "0"
},
{
"currency": "ETH",
"available": "0",
"reserved": "0.00200000"
}
],
"id": 123
}
Method: getTradingBalance
Example:
{
"method": "getTradingBalance",
"params": {},
"id": 123
}
Errors
The Multiexchange API uses the following error codes:
Error code | HTTP Status Code | Message | Note |
---|---|---|---|
403 | 401 | Action is forbidden for this account | |
429 | 429 | Too many requests | Action has been rate limited for account |
500 | 500 | Internal Server Error | |
503 | 503 | Service Unavailable | Try it again later |
504 | 504 | Gateway Timeout | Check the result of your request later |
1001 | 401 | Authorization required | |
1002 | 401 | Authorization failed | |
1003 | 403 | Action is forbidden for this API key | Check Access Rights for API key |
1004 | 401 | Unsupported authorization method | Use Basic authentication |
2001 | 400 | Symbol not found | |
2002 | 400 | Currency not found | |
2010 | 400 | Quantity not a valid number | |
2011 | 400 | Quantity too low | |
2012 | 400 | Bad quantity | See more details in error description field |
2020 | 400 | Price is not a valid number | |
2021 | 400 | Price too low | |
2022 | 400 | Bad price | See more details in error description field |
20001 | 400 | Insufficient funds | Insufficient funds for creating order or any account operation |
20002 | 400 | Order not found | One of the following variants: - Attempted to get active order that does not exist or has not been filled, cancelled, or expired. - Attempted to cancel order that does not exist. - Attempted to cancel already filled or expired order. |
20003 | 400 | Limit exceeded | Withdrawal limit has been exceeded |
20004 | 400 | Transaction not found | Requested transaction is not found |
20005 | 400 | Payout is not found | |
20006 | 400 | Payout is already committed | |
20007 | 400 | Payout is already rolled back | |
20008 | 400 | Duplicate of clientOrderId |
|
20009 | 400 | Price and quantity have not been changed | |
20010 | 400 | Exchange temporary closed | Exchange market for this symbol is temporary closed |
20013 | 400 | Active order limit exceeded | 30000 total or 1000 per pair |
10001 | 400 | Validation error | Invalid input data, see more in message field |
Guide & Code Samples
Fetch all public trades
Fetch all trades history for a symbol and keep it updated.
General idea: the fetch trades are sorted by ASC
from latest id
.
import requests
import time
session = requests.session()
def get_trades(symbol_code, from_id):
return session.get("https://api.bequant.io/api/2/public/trades/%s?sort=ASC&by=id&from=%d&limit=1000" % (symbol_code, from_id)).json()
symbol = 'ETHDAI'
from_trade_id = 1
while True:
trades = get_trades(symbol, from_trade_id)
if len(trades) > 0:
from_trade_id = trades[-1]['id'] + 1
print('Loaded trades till', trades[-1]['id'], trades[-1]['timestamp'])
if len(trades) < 1000:
time.sleep(5)
else:
time.sleep(30)
Get trades updated
First version
The fastest way is use the socket API. Subscribe for reports (method subscribeReports
) and handle reportType
== trade
.
Second version
Fetch trades as in the example above but with small changes.
import requests
import time
session = requests.session()
session.auth = ('3ef4a9f8c8bf04bd8f09884b98403eae', '2deb570ab58fd553a4ed3ee249fd2d51')
def get_my_trades(from_id):
return session.get("https://api.bequant.io/api/2/history/trades?sort=ASC&by=id&limit=100&from=%d" % (from_id)).json()
def get_recent_my_trades():
return session.get("https://api.bequant.io/api/2/history/trades?sort=DESC&by=id&limit=10").json()
from_trade_id = 0
while True:
if from_trade_id == 0:
recent_trades = get_recent_my_trades()
if len(recent_trades) > 0:
from_trade_id = recent_trades[0]['id'] + 1
print('Last recent trade', recent_trades[0])
else:
print('You do not have any trades')
else:
trades = get_my_trades(from_trade_id)
if len(trades) > 0:
from_trade_id = trades[-1]['id'] + 1
print('new trades', trades)
else:
print('No new trades')
time.sleep(30)
Getting new transactions
The code in the example allows you to get all of your new deposits, withdrawals and transfers.
The index is a 64-bit integer, that increases on any transaction update. To get all new updates of transactions you will need to request transactions with an index value which is greater than the latest one.
For example, if you have created a withdrawal, then you get an update with a transaction hash and committed status after receiving the required number of confirmations.
import requests
import time
session = requests.session()
session.auth = ('3ef4a9f8c8bf04bd8f09884b98403eae', '2deb570ab58fd553a4ed3ee249fd2d51')
def get_my_transactions(from_index):
return session.get("https://api.bequant.io/api/2/account/transactions?sort=ASC&by=index&limit=100&from=%d" % (from_index)).json()
def get_recent_my_transactions():
return session.get("https://api.bequant.io/api/2/account/transactions?sort=DESC&by=index&limit=100").json()
from_index = 0
while True:
if from_index == 0:
recent_transactions = get_recent_my_transactions()
if len(recent_transactions) > 0:
from_index = recent_transactions[0]['index'] + 1
print('Last recent trade', recent_transactions[0])
else:
print('You do not have any transactions')
else:
transactions = get_my_transactions(from_index)
if len(transactions) > 0:
from_index = transactions[-1]['index'] + 1
print('New and Updated transactions', transactions)
else:
print('No new updates')
time.sleep(60)