Bulk Order
Submit orders in bulk. This endpoint is recommended when you need to submit more than 5 orders at once.
By using this endpoint you will only consume a single rate limit request and not 5. It will also be much faster than submitting the orders individually.
There are certain restrictions in place for orders submitted through this endpoint:
1) The orders must have the same market 2) The orders can not be reduce only
To submit bulk orders for different markets you will need to split your orders into separate requests (one request for each market).
A minimum of 1 order and a maximum of 50 orders can be submitted per request. The endpoint is currently rate limited at 1200 orders per minute. Contact us if you require higher limits.
The endpoint is all-or-nothing. If one of the included orders cannot be accepted (i.e. due to balance issues), all orders will be rejected.
The endpoint requires a signed payload in HMAC-SHA256 form to be appended to the x-signature header. The signed payload must be base64-encoded.
Javascript example:
const formurlencoded = require('form-urlencoded').default;
const crypto = require("crypto-js");
const fetch = require("node-fetch");
const API_KEY = "<YOUR_API_KEY>";
const SECRET_KEY = "<YOUR_SECRET_KEY>";
(async function() {
const payload = {orders: [{pair: 'USD_BTCCALL_PERP', side: 'BUY', price: 1, qty: 0.001, timestamp: Date.now()}, {pair: 'USD_BTCCALL_PERP', side: 'BUY', price: 0.5, qty: 0.002, timestamp: Date.now()}]}
const payload_url_encoded = formurlencoded(payload);
const HMAC = crypto.HmacSHA256(payload_url_encoded, SECRET_KEY).toString(crypto.enc.Base64);
const submitted = await fetch('https://api.testnet.everstrike.io/auth/order/bulk', {method: 'POST', body: payload_url_encoded, headers: {'content-type': 'application/x-www-form-urlencoded', 'x-api-key': API_KEY, 'x-signature': HMAC}});
const response = await submitted.json();
console.log(response);
})();
Body Required
-
An array of orders to submit. Each order must be a valid JSON object. The properties available for each order can be seen in the description of the /auth/order endpoint.
-
is_test boolean
Whether the bulk order request is a test or not. Tests will just validate that the submitted orders are well-formed. The orders will not be sent to the matching engine and your account balance is not debited.
-
Timestamp in milliseconds. As trading is all about timing, orders that reach the API 15 seconds or more after this timestamp will be rejected.
-
recv_window integer(int32)
A custom time window. Order is accepted if timestamp + recv_window <= now
curl \
-X POST https://api.testnet.everstrike.io/auth/order/bulk \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d 'orders=string&is_test=true×tamp=42&recv_window=42'
{
"code": 200,
"msg": "null",
"result": {
"orders": [
{
"id": "849cdea0395411e98f54b395ae9c7bb6",
"pair": "USD_BTCCALL_PERP",
"side": "SELL",
"time": 1551137077642,
"type": "LIMIT",
"fills": [],
"price": 120,
"hidden": false,
"status": "ACTIVE",
"leverage": 1,
"qty_orig": 0.002,
"post_only": false,
"price_orig": 120,
"customer_id": "5f9ca5f0-380e-11e9-bf51-91a076098e19",
"reduce_only": false,
"qty_orig_usd": 0.28101585963,
"qty_remaining": 0.002,
"time_in_force": "GTC"
},
{
"id": "249cdea0395411e98f54b395ae9c7bc7",
"pair": "USD_BTCCALL_PERP",
"side": "SELL",
"time": 1551137077642,
"type": "LIMIT",
"fills": [],
"price": 130,
"hidden": false,
"status": "ACTIVE",
"leverage": 1,
"qty_orig": 0.005,
"post_only": false,
"price_orig": 130,
"customer_id": "5f9ca5f0-380e-11e9-bf51-91a076098e19",
"reduce_only": false,
"qty_orig_usd": 0.29101585963,
"qty_remaining": 0.005,
"time_in_force": "GTC"
}
],
"balances": {
"BTC": {
"free": 21,
"locked": 2,
"withdrawn": 0
}
},
"position": {
"free": 1,
"size": 1,
"fills": [],
"stats": {
"lp": 3.7,
"pnl": 0,
"roe": 0,
"mark": 2.1,
"size": 1,
"equity": 1,
"margin": 1,
"bankrupt": 3.78,
"leverage": 2.82,
"notional": 0.14,
"avg_entry": 3.4,
"direction": "BUY"
},
"locked": 0,
"realized": 0
}
}
}
{
"code": 503,
"msg": "Invalid request",
"result": {}
}