Skip to content

Trading API

martin-nginio edited this page Aug 7, 2019 · 38 revisions

Trade API covers all order placement and trade management.

Order Status

Below is the list of possible order status values:

  • New
  • Placed
  • Failed
  • Error
  • Cancelled
  • Partially Cancelled
  • Fully Matched
  • Partially Matched

Number Conversion

All numbers, specifically for price and volume, must be converted to an integer for use in Trading API requests. The conversion is 100000000, or 1E8. For strongly typed programming languages, use of integer or long integer variable types is strongly recommended, as decimals will not be accepted by the API.

Create an order -UPDATED 03/14

Stop Limit orders can now be placed through the API for all currencies

Stop orders and Take Profit orders can now be placed through the API for the BTC/AUD market

path: /order/create

http POST

Please note:

  • The clientRequestId is not currently used but must be specified. Any string is valid.
  • Price of $130 = 13000000000 (i.e x 100000000)
  • Volume of 1 BTC = 100000000 (i.e x 100000000)
  • When passing AUD as currency, maximum 2 decimal points are allowed. In above example, $130 and $130.12 are allowed but $130.123 will return "invalid amount".
  • In case of placing Market orders, price is still required, however the price is ultimately set by matching engine depending on existing orders in the orderbook at the time of trade execution.
  • In the case of placing a Stop Limit order, the ordertype will be "Stop Limit", and an additional field triggerPrice must be supplied with the same number conversion as price.
  • In the case of placing a Stop order, the ordertype will be "Stop", and an additional field triggerPrice must be supplied with the same number conversion as price. When triggerPrice is reached, a market order will be executed.
  • In the case of placing a Take Profit order, the ordertype will be "Take Profit", and an additional field triggerPrice must be supplied with the same number conversion as price. When triggerPrice is reached, a market order will be executed.
  • For both Stop orders and Take Profit orders price is ultimately set by matching engine depending on existing orders in the orderbook at the time of trade execution (same as for market orders).

sample request:

{
  "currency": "AUD",
  "instrument": "BTC",
  "price": 13000000000,
  "volume": 10000000,
  "orderSide": "Bid",
  "ordertype": "Limit",
  "clientRequestId": "abc-cdf-1000"
}

sample success response:

{
  "success": true,
  "errorCode": null,
  "errorMessage": null,
  "id": 100,
  "clientRequestId": "abc-cdf-1000"
}

sample error response

{
  "success": false,
  "errorCode": 3,
  "errorMessage": "Invalid argument.",
  "id": 0,
  "clientRequestId": "abc-cdf-1000",
}

Cancel an order

path: /order/cancel

http post

sample request:

{"orderIds":[6840125478]}

The array of order ids can have maximum 10 items in it.

sample response:

{"success":true,"errorCode":null,"errorMessage":null,"responses":[{"success":false,"errorCode":3,"errorMessage":"order does not exist.","id":6840125478}]}

Order history

path: /order/history

http post

since parameter for this api method is the order id.

sample request:

{"currency":"AUD","instrument":"BTC","limit":10,"since":33434568724}

sample response:

{"success":true,"errorCode":null,"errorMessage":null,"orders":[{"id":1003245675,"currency":"AUD","instrument":"BTC","orderSide":"Bid","ordertype":"Limit","creationTime":1378862733366,"status":"Placed","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":10000000,"clientRequestId":null,"trades":[]},{"id":4345675,"currency":"AUD","instrument":"BTC","orderSide":"Ask","ordertype":"Limit","creationTime":1378636912705,"status":"Fully Matched","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":0,"clientRequestId":null,"trades":[{"id":5345677,"creationTime":1378636913151,"description":null,"price":13000000000,"volume":10000000,"fee":100000}]}]}

Open Orders

path: /order/open

http post

This is similar to the order history request and response. The only difference is that this method only returns open orders.

Trade History

path: /order/trade/history

http post

since parameter for this api method is the trade id.

sample request:

{"currency":"AUD","instrument":"BTC","limit":10,"since":33434568724}

sample response:

{"success":true,"errorCode":null,"errorMessage":null,"trades":[{"id":374367855,"creationTime":1492232900701,"price":159672000000,"volume":100000,"side":"Ask","fee":1357210,"orderId":374367838},{"id":229485482,"creationTime":1478837751322,"price":94299000000,"volume":100000,"side":"Bid","fee":801540,"orderId":229485469}]}

Order detail

path: /order/detail

http post

sample request:

{"orderIds":[698068, 698771, 698825]}

The value(s) for orderIds must always be in the format of an array, even if only one ID is included.

sample response:

{
  "success": true,
  "errorCode": null,
  "errorMessage": null,
  "orders": [
    {
      "id": 698068,
      "currency": "AUD",
      "instrument": "ETH",
      "orderSide": "Ask",
      "ordertype": "Market",
      "creationTime": 1516140997056,
      "status": "Fully Matched",
      "errorMessage": null,
      "price": 1200000000,
      "volume": 5000000,
      "openVolume": 0,
      "clientRequestId": null,
      "trades": [
        {
          "id": 698080,
          "creationTime": 1516140997301,
          "description": null,
          "price": 1200000000,
          "volume": 5000000,
          "side": "Ask",
          "fee": 509999,
          "orderId": 698068
        }
      ]
    },
    {
      "id": 698771,
      "currency": "AUD",
      "instrument": "BTC",
      "orderSide": "Bid",
      "ordertype": "Limit",
      "creationTime": 1516919450949,
      "status": "Partially Matched",
      "errorMessage": null,
      "price": 2700000000,
      "volume": 100000000,
      "openVolume": 4400000,
      "clientRequestId": null,
      "trades": [
        {
          "id": 698935,
          "creationTime": 1517808598156,
          "description": null,
          "price": 2700000000,
          "volume": 95600000,
          "side": "Bid",
          "fee": 21940174,
          "orderId": 698771
        }
      ]
    },
    {
      "id": 698825,
      "currency": "AUD",
      "instrument": "BTC",
      "orderSide": "Bid",
      "ordertype": "Limit",
      "creationTime": 1516923611252,
      "status": "Placed",
      "errorMessage": null,
      "price": 2700000000,
      "volume": 100000000,
      "openVolume": 100000000,
      "clientRequestId": null,
      "trades": []
    }
  ]
}

v2

Open Orders

http GET

path: /v2/order/open[/{instrument}/{currency}]

optional: To get all open orders, regardless of instrument and currency, simply leave them out of the path. See second example.

pagination: no

sample request: /v2/order/open/BTC/AUD

sample response:

{
    "success": true,
    "errorCode": null,
    "errorMessage": null,
    "orders": [
        {
            "id": 702587,
            "currency": "AUD",
            "instrument": "BTC",
            "orderSide": "Ask",
            "ordertype": "Limit",
            "creationTime": 1531518888090,
            "status": "Placed",
            "errorMessage": null,
            "price": 998700000000,
            "volume": 3000000,
            "openVolume": 3000000,
            "clientRequestId": null,
            "trades": []
        },
        {
            "id": 702590,
            "currency": "AUD",
            "instrument": "BTC",
            "orderSide": "Ask",
            "ordertype": "Limit",
            "creationTime": 1531518897518,
            "status": "Placed",
            "errorMessage": null,
            "price": 889800000000,
            "volume": 4000000,
            "openVolume": 4000000,
            "clientRequestId": null,
            "trades": []
        }
    ]
}

Open all orders

sample request: /v2/order/open

sample response:

{
    "success": true,
    "errorCode": null,
    "errorMessage": null,
    "orders": [
        {
            "id": 743363,
            "currency": "AUD",
            "instrument": "BTC",
            "orderSide": "Ask",
            "ordertype": "Limit",
            "creationTime": 1535659048351,
            "status": "Placed",
            "errorMessage": null,
            "price": 930706000000,
            "volume": 8404360,
            "openVolume": 8404360,
            "clientRequestId": null,
            "trades": []
        },
        {
            "id": 743565,
            "currency": "AUD",
            "instrument": "ETH",
            "orderSide": "Bid",
            "ordertype": "Limit",
            "creationTime": 1535660328066,
            "status": "Placed",
            "errorMessage": null,
            "price": 34791000000,
            "volume": 363507743,
            "openVolume": 363507743,
            "clientRequestId": null,
            "trades": []
        }
    ]
}

Cancel all orders

This method cancels all open orders for all markets or a specific markets (if marketIds parameter is provided as request body)

http POST

path: /v2/order/cancelall

If you want to cancel open orders for specific markets only, then please pass the following as the request body:

{
  "marketIds": ["BTC-AUD", "XRP-AUD"] 	
}

sample response:

{"success":true,"errorCode":null,"errorMessage":null,"orderIds":[3929899238,3929899017,3929705536]}

The response includes orderIds for which cancellation has been requested.

API authentication reminder: when calling the POST method and if no marketIds is provided, your string to sign would look like below (There should be an extra \n after the timestamp as per below)

/v2/order/cancelall
1565207864688

If marketIds is provided then string to sign would look like below:

/v2/order/cancelall
1565207864688
{"marketIds":["BTC-AUD"]}

Order History

http GET

path: /v2/order/history/{instrument}/{currency}

url parameters:

  • indexForward: Set to true to see orders more recent than the orderId in the since parameter, if a since parameter is used. Default is false.
  • limit: Number of results to return per "page". If not provided, default is 200.
  • since: an orderId. If provided, and indexForward is false, returned results will be trades earlier than the trade id provided, non-inclusive. If indexForward is true, returned results will be trades after the orderId provided, non-inclusive.

pagination: yes

sample request: /v2/order/history/BTC/AUD?limit=3&since=701336

sample response:

{
    "success": true,
    "errorCode": null,
    "errorMessage": null,
    "orders": [
        {
            "id": 701335,
            "currency": "AUD",
            "instrument": "BTC",
            "orderSide": "Ask",
            "ordertype": "Limit",
            "creationTime": 1525903561732,
            "status": "Fully Matched",
            "errorMessage": null,
            "price": 1000000000,
            "volume": 100000000,
            "openVolume": 0,
            "clientRequestId": null,
            "trades": [
                {
                    "id": 701347,
                    "creationTime": 1525903561932,
                    "description": null,
                    "price": 2600000000,
                    "volume": 100000000,
                    "side": "Ask",
                    "fee": 22099974,
                    "orderId": 701335
                }
            ]
        },
        {
            "id": 701308,
            "currency": "AUD",
            "instrument": "BTC",
            "orderSide": "Ask",
            "ordertype": "Limit",
            "creationTime": 1525903341150,
            "status": "Fully Matched",
            "errorMessage": null,
            "price": 1000000000,
            "volume": 100000000,
            "openVolume": 0,
            "clientRequestId": null,
            "trades": [
                {
                    "id": 701332,
                    "creationTime": 1525903341371,
                    "description": null,
                    "price": 2600000000,
                    "volume": 90000000,
                    "side": "Ask",
                    "fee": 19889976,
                    "orderId": 701308
                },
                {
                    "id": 701321,
                    "creationTime": 1525903341349,
                    "description": null,
                    "price": 2700000000,
                    "volume": 10000000,
                    "side": "Ask",
                    "fee": 2294997,
                    "orderId": 701308
                }
            ]
        },
        {
            "id": 701208,
            "currency": "AUD",
            "instrument": "BTC",
            "orderSide": "Bid",
            "ordertype": "Limit",
            "creationTime": 1525899345980,
            "status": "Fully Matched",
            "errorMessage": null,
            "price": 2700000000,
            "volume": 100000000,
            "openVolume": 0,
            "clientRequestId": null,
            "trades": [
                {
                    "id": 701316,
                    "creationTime": 1525903341332,
                    "description": null,
                    "price": 2700000000,
                    "volume": 10000000,
                    "side": "Bid",
                    "fee": 2294997,
                    "orderId": 701208
                },
                {
                    "id": 701298,
                    "creationTime": 1525899507793,
                    "description": null,
                    "price": 2700000000,
                    "volume": 90000000,
                    "side": "Bid",
                    "fee": 20654975,
                    "orderId": 701208
                }
            ]
        }
    ],
    "paging": {
        "newer": "/v2/order/history/BTC/AUD?limit=3&since=701335&indexForward=true",
        "older": "/v2/order/history/BTC/AUD?limit=3&since=701208&indexForward=false"
    }
}

Trade History

http GET

path: /v2/order/trade/history/{instrument}/{currency}

url parameters:

  • indexForward: Set to true to see orders more recent than the tradeId in the since parameter, if a since parameter is used. Default is false.
  • limit: Number of results to return per "page". If not provided, default is 200.
  • since: an tradeId. If provided, and indexForward is false, returned results will be trades earlier than the trade id provided, non-inclusive. If indexForward is true, returned results will be trades after the tradeId provided, non-inclusive.

pagination: yes

sample request: /v2/order/trade/history/BTC/AUD?limit=4&since=701333

sample response:

{
    "success": true,
    "errorCode": null,
    "errorMessage": null,
    "trades": [
        {
            "id": 701332,
            "creationTime": 1525903341371,
            "description": null,
            "price": 2600000000,
            "volume": 90000000,
            "side": "Ask",
            "fee": 19889976,
            "orderId": 701308
        },
        {
            "id": 701321,
            "creationTime": 1525903341349,
            "description": null,
            "price": 2700000000,
            "volume": 10000000,
            "side": "Ask",
            "fee": 2294997,
            "orderId": 701308
        },
        {
            "id": 701316,
            "creationTime": 1525903341332,
            "description": null,
            "price": 2700000000,
            "volume": 10000000,
            "side": "Bid",
            "fee": 2294997,
            "orderId": 701208
        },
        {
            "id": 701298,
            "creationTime": 1525899507793,
            "description": null,
            "price": 2700000000,
            "volume": 90000000,
            "side": "Bid",
            "fee": 20654975,
            "orderId": 701208
        }
    ],
    "paging": {
        "newer": "/v2/order/trade/history/BTC/AUD?limit=4&since=701332&indexForward=true",
        "older": "/v2/order/trade/history/BTC/AUD?limit=4&since=701298&indexForward=false"
    }
}

Introduction updated 9/28/18

Authentication

Pagination

WebSocket v2

WebSocket v1 deprecated

Market Data API updated 7/24/19

Trading API updated 08/19/19

Transaction API

Account API updated 3/14/19

Fund Transfer API updated 08/06/19

FAQ

Clone this wiki locally