Order

POST /auth/order

Submit a new order. 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 = {pair: 'USD_BTCCALL_PERP', side: 'BUY', price: 1, qty: 0.001, 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', {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);
  })();

Python example (Python3):

  import requests
  import urllib
  import hmac
  import hashlib
  import base64
  from time import time

  api_key = '<YOUR_API_KEY>'
  secret_key = '<YOUR_SECRET_KEY>'
  url='https://api.testnet.everstrike.io/auth/order'
  payload = {'pair': 'USD_BTCCALL_PERP', 'side': 'BUY', 'price': 1, 'qty': 0.001, 'timestamp': time()*1000.0}
  urlencoded_payload = urllib.parse.urlencode(payload)
  hmac_signature = hmac.new(bytes(secret_key , 'utf-8'), msg = bytes(urlencoded_payload , 'utf-8'), digestmod = hashlib.sha256).digest()
  hmac_signature_base64 = base64.b64encode(hmac_signature)
  headers = {'content-type': 'application/x-www-form-urlencoded', 'x-api-key': api_key, 'x-signature': hmac_signature_base64}

  response = requests.post(url, data=payload, headers=headers)

  print(response.text)
  print(response.status_code, response.reason)

application/x-www-form-urlencoded

Body Required

  • pair string Required

    Market for order (e.g. "USD_BTCCALL_PERP")

  • qty number Required

    Quantity of order (e.g. 1000)

  • side string Required

    Whether to buy or sell. Accepted values are ["BUY","SELL"]

  • price number

    Price of order (e.g. 7500). To make the order a market order, exclude this field.

  • timestamp integer(int32) Required

    UNIX timestamp in milliseconds. As trading is all about timing, orders that reach the API 15 seconds or more after this timestamp will be rejected.

  • leverage number

    The leverage to use for your order. If not supplied, this will be set to the minimum leverage available on the market. Only relevant for Isolated Margin users.

  • trigger_price number

    An optional trigger price for your order. Your order will be triggered and sent to the matching engine once the Mark Price, Last Price or Index Price (depending on what you choose for the 'trigger_event' parameter) reaches this price. This parameter can be used to enable both stop and take profit orders. A "SELL" order with a trigger price below the current market price (when you are long) is a stop order. A "SELL" order with a trigger price above the current market price (when you are long) is a take profit order. The opposite is true when you are short.

  • time_in_force string

    Time in force. Can be either "GTC" (Good Till Cancelled), "FOK" (Fill or Kill) or "IOC" (Immediate or Cancel). Default is "GTC".

  • recv_window integer(int32)

    A custom time window. Order is accepted if timestamp + recv_window <= now.

  • is_test boolean

    Whether the order is a test order or not. Test orders are free and are not sent to the matching engine. By submitting test orders you can ensure that your payload is valid and well-formed.

  • reduce_only boolean

    Set this to true to make the order a reduce-only order. Reduce-only orders cannot increase the size of your position. They do not subtract from your balance.

  • post_only boolean

    Set this to true to make the order a post-only order. Post-only orders can only match passively and will never pay taker fees.

  • hidden boolean

    Set this to true to make the order a hidden order. Hidden orders are not shown in the order book.

  • icebergs integer(int32)

    Number of icebergs for the order. Visible Order Quantity = Order Quantity / Icebergs. Use this to only partially hide your order.

  • oco string

    One Cancels the Others. Set this to a specific string to make it cancel all other orders with the same string when filled. The string must be of size at most 5 characters.

  • trigger_event string

    The price event that triggers the order. For derivatives, it can be either MARK_PRICE, INDEX_PRICE or LAST_PRICE. The default is MARK_PRICE. For spot markets, it can only be LAST_PRICE.

  • close_on_trigger boolean

    Whether to submit the order as a Close on Trigger order. Close on Trigger orders cancel open reduce-only orders on the position upon being triggered in an attempt to free up margin, making them less likely to encounter insufficient balance issues. Only relevant if you have an existing position for the given market.

Responses

  • 200 application/json

    OK

    Hide response attributes Show response attributes object
    • code integer

      Response code

    • msg string

      Diagnostic message

    • result object

      Request result

      Hide result attributes Show result attributes object
      • order object

        If your order is accepted, this field will contain information about the order

        Hide order attributes Show order attributes object
        • id string

          Unique identifier of order

        • pair string

          Market of order

        • price number

          Current price of order

        • price_orig number

          Original price of order

        • qty_orig number

          Original quantity of order

        • qty_orig_usd number

          Original USD quantity of order

        • qty_remaining number

          Quantity not yet filled

        • qty_filled number

          Quantity that has been filled

        • side string

          BUY or SELL

        • status string

          ACTIVE, CANCELLED or COMPLETED

        • time number

          Time of last update, in milliseconds

        • time_in_force string

          Time in force. Can be GTC (Good Till Cancelled), FOK (Fill Or Kill) or IOC (Immediate Or Cancel).

        • type string

          Type of order. Can be LIMIT or MARKET.

        • oco string

          OCO ID of order

        • icebergs number

          Icebergs on order

        • trigger_price number

          Trigger price of order

        • trigger_event string

          Trigger event of order. Can be MARK_PRICE, INDEX_PRICE, LAST_PRICE or null.

        • close_on_trigger boolean
        • reduce_only boolean

          If true, the order can only decrease the size of your position.

        • post_only boolean

          If true, the order can only trade as maker.

        • hidden boolean

          If true, the order does not show in the order book.

      • balances object

        Account balances

        Hide balances attribute Show balances attribute object
        • ETH object

          ETH balance

          Hide ETH attributes Show ETH attributes object
          • free number

            Available ETH balance

          • locked number

            ETH balance in use for open orders

          • withdrawn number

            ETH balance in use for pending withdrawals

          • pnl number

            ETH P&L. This number is updated every time you close an ETH-related position.

          • margin number

            ETH position margin.

          • fees number

            Fees paid since account creation.

      • positions object

        Account positions

        Hide positions attribute Show positions attribute object
        • USD_BTCCALL_PERP object

          Market of position

          Hide USD_BTCCALL_PERP attributes Show USD_BTCCALL_PERP attributes object
          • size number

            Size of position

          • free number

            Margin assigned to the position

          • locked number

            Margin locked within the position

          • realized number

            Realised P&L (USD)

          • funding number

            Funding P&L (USD)

          • fees number

            Fee P&L (USD)

          • stats object

            Detailed Position Information

            Hide stats attributes Show stats attributes object
            • size number

              Size of position

            • notional number

              Notional size of position

            • margin number

              Margin assigned to the position

            • pnl number

              Total P&L (USD)

            • upnl number

              Unrealised P&L (USD)

            • rpnl number

              Realised P&L (USD)

            • equity number

              Unrealised P&L + Margin

            • roe number

              P&L / Initial Margin

            • mark number

              Mark Price

            • avg_entry number

              VWAP Entry Price

            • leverage number

              Effective Leverage

            • lp number

              Liquidation Price

            • bankrupt number

              Bankruptcy Price

            • direction string

              BUY or SELL

  • 503 application/json

    Error

    Hide response attributes Show response attributes object
    • code integer
    • msg string
    • result object
POST /auth/order
curl \
 --request POST 'https://api.testnet.everstrike.io/auth/order' \
 --header "x-api-key: $API_KEY" \
 --header "Content-Type: application/x-www-form-urlencoded" \
 --data 'pair=string&qty=42.0&side=string&price=42.0&timestamp=42&leverage=42.0&trigger_price=42.0&time_in_force=string&recv_window=42&is_test=true&reduce_only=true&post_only=true&hidden=true&icebergs=42&oco=string&trigger_event=string&close_on_trigger=true'
Response examples (200)
{
  "code": 200,
  "msg": "null",
  "result": {
    "order": {
      "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"
    },
    "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
    }
  }
}
Response examples (503)
{
  "code": 503,
  "msg": "Invalid request",
  "result": {}
}