NAV
python

Parallel Trading REST API

Background

The Parallel Trading REST API allows direct access to the Parallel trading system 24/7/365 and features the following capabilities:

  1. Fetch your account balance for all tradeable currencies
  2. Fetch all historical account transactions
  3. Execute trades

Endpoints

The base Parallel Trading REST API endpoints is located at:

Production: https://trade.parallelcapital.co/api

Versioning

Note that the Parallel Trading REST API is versioned, so you'll need to include the version number as part of the URL:

https://trade.parallelcapital.co/api/v1

API Clients

We have sample API clients available for your usage at https://github.com/parallel-capital/sample-api-clients.

Authentication

headers = {"Authorization": f"Token {api_token}"}

Parallel Trading uses an API token to allow access to the REST API. You will receive your API token via customer support.

In addition, you will need to supply the IP addresses from which you wish to access the REST API so that we can whitelist them to ensure the security of the platform.

To authenticate a request, the API token must be included in its Authorization HTTP header. The token must be prefixed by the string literal "Token ". For example:

Authorization: Token xxxxxxxxxxxxxxxxxxx

Currency Support

By default, we currently only enable BTC/USD trading. Please contact Parallel Support to request access to additional trading currencies.

Precisions

Currency Price Precision Size Precision Minimum Order Size
BTC $0.1 0.0001 BTC 0.01 BTC
ETH $0.01 0.0001 ETH 0.1 ETH

Fees

Parallel Trading charges no fees - the price quotes and the fill prices are net of commissions; we trade on a principal basis.

Balances

Fetch Balances

import requests

response = requests.get("https://trade.parallelcapital.co/api/v1/balances", headers=headers)

Successful Response Format

{
  "USD": "0",
  "BTC": "0",
  "ETH": "0"
}

Retrieve your account balances for all tradeable currencies; a positive number indicates that Parallel owes you the amount shown of the currency while a negative number means that you owe Parallel the stated amount.

Rate limit: 2 requests per second

HTTP Request

GET https://trade.parallelcapital.co/api/v1/balances

Request Parameters

None

Orders

Create A New Order

import uuid

customer_order_id = str(uuid.uuid4())
order = {
  "customer_order_id": customer_order_id,
  "side": "buy",
  "symbol": "BTC/USD",
  "quantity": "1.25",
  "price": "38497.12",
  # "slippage_bps": "1", # optional!
  "order_type": "FOK",
  "quote_id": "e82e7102-5791-436e-ae88-a670b545d783",
}
response = requests.post("https://trade.parallelcapital.co/api/v1/orders", json=order, headers=headers)

Successful Response Format


# Response for order that successfully executed:
{
  "order_id": "cb46df63-b807-4aeb-a8a2-7e2df7631a5a",
  "customer_order_id": "anything-you-want-my-dear",
  "symbol": "BTC/USD",
  "side": "buy",
  "quantity": "1.25",
  "price": "38497.12",
  "executed_price": "38490.12",
  "trades": [
      {
        "trade_id": "0ac12045-82e2-493f-9925-abf12f039afd",
        "order_id": "cb46df63-b807-4aeb-a8a2-7e2df7631a5a",
        "source": "rest",
        "side": "buy",
        "symbol": "BTC/USD",
        "quantity": "1.25",
        "price": "38490.12",
      }
  ],
  "created_at": "2021-06-04T09:08:12.753182Z"
}


# Response for order that did not execute:
{
  "order_id": "f7e47d8e-d44a-43e9-8dfb-21b59a501a3c",
  "customer_order_id": "this-one-was-too-far-away",
  "symbol": "BTC/USD",
  "side": "buy",
  "quantity": "3.0",
  "price": "11000.12",
  "executed_price": null,
  "trades": [],
  "created_at": "2021-06-05T09:08:12.753182Z"
}

Send an order to the trading system; the order will either be fully filled or not executed based on the provided quantity.

We currently only support Fill Or Kill (FOK) orders. You may specify the maximum slippage in basis points that you are willing to accept on the order via the slippage_bps parameter, which will help reduce rejected orders if the market is volatile. Please rest assured that we will provide the best price possible in the market so there is no danger in using this option.

Rate limit: 10 requests per second

HTTP Request

POST https://trade.parallelcapital.co/api/v1/orders

Request Parameters

Parameter Type Required? Description
customer_order_id string false Order identifier set by client; ideally unique, can be up to 128 characters. We recommend using UUID. Will be null in response if not provided.
side string enum true Can be either 'buy' or 'sell', case insensitive - we will transform any uppercase to lowercase and return lowercase. If any other strings are input, the result set will include both buy and sell orders.
symbol string true Symbol of the product to be traded.
quantity string true Up to four decimals
price string true Up to . We will automatically round to nearest decimal place.
slippage_bps string false Maximum amount of acceptable slippage in basis points.
order_type string enum true Right now the only option is 'FOK', please note that this is a required field still.
quote_id string (UUID) false quote_id UUID from Quotes Websocket streaming quote updates. Only used as a reference and has no impact on the order itself.

List Historical Orders

response = requests.get("https://trade.parallelcapital.co/api/v1/orders", headers=headers)

Successful Response Format


# Response containing list of orders:
[
  {
    "order_id": "43484470-ac40-4971-90fc-ddb575388d4d",
    "side": "sell",
    "customer_order_id": "1234567",
    "order_type": "FOK",
    "symbol": "BTC/USD",
    "base_currency": "BTC",
    "quote_currency": "USD",
    "price": "46200.1",
    "quantity": "0.01",
    "slippage_bps": "1.0",
    "fill_price": "47742.5",
    "quote_id": null,
    "created_at": "2021-09-16T04:12:33.726Z"
  },
  {
    "order_id": "16dc2c45-f117-431f-b504-4a7792d734bf",
    "side": "buy",
    "customer_order_id": null,
    "order_type": "FOK",
    "symbol": "BTC/USD",
    "base_currency": "BTC",
    "quote_currency": "USD",
    "price": "93000.1",
    "quantity": "0.01",
    "slippage_bps": "1.0",
    "fill_price": null,
    "quote_id": null,
    "created_at": "2021-09-16T01:55:18.251Z"
  },
  ...
]

Retrieve a list of orders that were received by the trading system.

Note that results will always be returned in descending chronological order.

Rate limit: 5 requests per second

HTTP Request

GET https://trade.parallelcapital.co/api/v1/orders

Request Parameters

Parameter Type Required? Description
is_filled string false Filters; if the string "true" or "1" are input, then the result set will only contain filled orders (i.e. those with a non-null fill_price). If any other strings are input, then the result set will only contain unfilled orders. If this parameter is not present, the result set will not filter by whether or not the order was filled.
order_type string enum false Filters; right now the only option is 'FOK'.
base_currency string false Filters; only return orders with the specified base currency.
quote_currency string false Filters; only return orders with the specified quote currency.
start_time string unix epoch timestamp (in seconds) false Filters; from time, up to 6 decimal places, i.e., microsecond precision
end_time string unix epoch timestamp (in seconds) false Filters; to time, up to 6 decimal places, i.e., microsecond precision
limit integer false Number of results to return, default of 100, max of 500

Transactions

Fetch Transactions

import requests

response = requests.get("https://trade.parallelcapital.co/api/v1/transactions", headers=headers)

Successful Response Format


[
  {
    "transaction_id": "ef69dz9f-5ade-4aa4-87c2-e2eaef37d8bc",
    "transaction_type": "trade",
    "currency": "BTC",
    "quantity": "1.00000000",
    "created_at": "2016-12-14T14:17:03Z"
  }, {
    "transaction_id": "393f9373-8a9a-478b-8669-6fc443a36780",
    "transaction_type": "trade",
    "currency": "USD",
    "quantity": "-50000.00",
    "created": "2017-03-10T17:17:56Z"
  }, {
    "transaction_id": "4526d8e5z-8a9a-478b-8669-6fc443a36936",
    "transaction_type": "transfer",
    "currency": "BTC",
    "quantity": "-1.00000000",
    "created_at": "2018-01-10T17:17:56Z",
  }, {
    "transaction_id": "4526d8e5z-8a9a-478b-8669-6fc443a36936",
    "transaction_type": "transfer",
    "currency": "USD",
    "quantity": "50000.00",
    "created_at": "2018-01-10T17:17:56Z",
  }
]

Transactions are any events that occur that change your balance; currently there are only two types of transactions:

  1. trade (representing balance change due to a trade)
  2. transfer (representing funds sent to you from Parallel or funds you sent to Parallel for settlement)

Rate limit: 5 requests per second

HTTP Request

GET https://trade.parallelcapital.co/api/v1/transactions

Request Parameters

Parameter Type Required? Description
currency string false Filters; only return transactions of the specified currency.
transaction_type string enum false Filters (trade, transfer); if this field is not present, defaults to all transaction types.
start_time string unix epoch timestamp (in seconds) false Filters; from time, up to 6 decimal places, i.e., microsecond precision
end_time string unix epoch timestamp (in seconds) false Filters; to time, up to 6 decimal places, i.e., microsecond precision
limit integer false Number of results to return, default of 100, max of 500
page integer false Page number of return, starts from 1

Note that results will always be returned in descending chronological order.

Parallel Trading WebSocket API

Background

The Parallel Trading WebSocket API streams quotes from our trading systems for counterparties to obtain indicative prices.

You can connect to the WebSocket API via the following endpoint:

Production: wss://trade-ws.parallelcapital.co/v1/quotes

Upon opening a connection to our WebSocket server, you must send a message to subscribe to a symbol within 30 seconds to avoid getting disconnected.

It is highly recommended that you configure your WebSocket clients to detect disconnections and automatically reconnect.

You may only have three concurrent WebSocket connections live per account per environment at any given time.

Authentication

import websockets

api_token = ""
headers = {"Authorization": f"Token {api_token}"}

async with websockets.connect('wss://trade-ws.parallelcapital.co/v1/quotes', extra_headers=headers) as ws:
    response = await websocket.recv()

Parallel Trading uses an API token to allow access to the WebSocket API. You will receive your API token via customer support.

In addition, you will need to supply the IP addresses from which you wish to access the WebSocket API so that we can whitelist them to ensure the security of the platform.

To authenticate a request, the API token must be included in the Authorization HTTP header. The token must be prefixed by the string literal "Token ". For example:

Authorization: Token xxxxxxxxxxxxxxxxxxx

Quotes

import json

subscription_request = {
    "request": "quotes",
    "symbol": "BTC/USD",
    "quantities": ["1.25", "5"]
}
websocket.send(json.dumps(subscription_request))
response = await websocket.recv()
print(response)
{
    "response": "quotes",
    "symbol": "BTC/USD",
    "quantities": ["1.25", "5"],
    "success": true,
    "errors": []
}
response = await websocket.recv()
print(response)
{
    "quotes": {
        "buy": [
            {"quantity": "1.25", "price": "38497.13"},
            {"quantity": "5", "price": "38499.38"}
        ],
        "sell": [
            {"quantity": "1.25", "price": "38502.94"},
            {"quantity": "5", "price": "38500.25"}
        ]
    },
    "subscription": "quotes",
    "symbol": "BTC/USD",
    "quote_id": "e82e7102-5791-436e-ae88-a670b545d783",
    "timestamp": 1623802143.510
}

Upon subscribing to a symbol, you will receive streaming quote updates.

Currently there is only support for up to 5 levels of quantities.

The response will contain buy and sell prices. These are prices that Parallel is buying and selling at. If a customer is sending a buy order they will need to buy at the sell price that is being streamed and vice versa.

Parameter Type Required? Description
request string True Should be the string "quotes".
symbol string True Should be the string version of the symbol representing the product you wish to receive streaming quotes for.
quantities List[string] True Should be a list of quantities to receive stream price quotes for; currently up to 5 levels of quantities are supported. Please provide the levels in ascending order. Note that the same price may appear on different levels based on market conditions and internal configuration.