REST API

CEX.IO REST API allows to access market data and manage trades using custom written software.

All POST requests should be in JSON format only.

Public Functions

Private Functions

Public Data Functions

Currency Limits

GET https://cex.io/api/currency_limits

Returns min/max amounts and prices for placing orders

  • ok - response status: 'ok' or 'error'
  • e - event type ('currency_limits')
  • data - data on limits for all pairs

Response Example:

 {
    'e': 'currency_limits', 
    'data': {
        'pairs': [
            {
                'minPrice': '1',
                'symbol2': 'USD',
                'minLotSize': 0.01,
                'minLotSizeS2': 2.5,
                'maxPrice': '4096',
                'symbol1': 'BTC'
            },
            ...
        ]
    },
    'ok': 'ok'
}

Ticker

GET https://cex.io/api/ticker/BTC/USD

Returns JSON dictionary:

  • bid - highest buy order
  • ask - lowest sell order
  • low - last 24 hours price low
  • high - last 24 hours price high
  • last - last BTC price
  • volume - last 24 hours volume
  • volume30d - last 30 days volume

The results are shown according to first currency in request.

Tickers for all pairs by market(s)

GET https://cex.io/api/tickers/USD/EUR/RUB/BTC

Returns JSON dictionary representing data for all pairs by requested market(s). Market is counted by the second symbol in the pair. Minimum one currency is required for request.

{
    "e": "tickers",
    "ok": "ok",
    "data": [
        {
            "timestamp": "1456396076",
            "pair": "BTC:USD",
            "low": "419",
            "high": "431.44",
            "last": "425.0979",
            "volume": "1741.98721901",
            "volume30d": "46030.94459512",
            "bid": 425.262,
            "ask": 427.0979
        }, {
            "timestamp": "1456396076",
            "pair": "GHS:USD",
            "low": "0.04954999",
            "high": "0.051942",
            "last": "0.051598",
            "volume": "2393.90763138",
            "volume30d": "163968.17276732",
            "bid": 0.051598,
            "ask": 0.0515992
        }, {
            "timestamp": "1456396076",
            "pair": "LTC:USD",
            "low": "3.3399",
            "high": "3.3399",
            "last": "3.3399",
            "volume": "1.51617462",
            "volume30d": "3921.99135827",
            "bid": 3.3399,
            "ask": 3.38
        }, {
            "timestamp": "1456396076",
            "pair": "BTC:EUR",
            "low": "379.228",
            "high": "389.7599",
            "last": "385.2574",
            "volume": "493.06491684",
            "volume30d": "9746.05813339",
            "bid": 382.8055,
            "ask": 387.7079
        }, {
            "timestamp": "1456396076",
            "pair": "LTC:EUR",
            "low": "2.8",
            "high": "2.80020003",
            "last": "2.80010003",
            "volume": "19.70279402",
            "volume30d": "1781.81047874",
            "bid": 2.8001,
            "ask": 3.1429
        }, {
            "timestamp": "1456396076",
            "pair": "BTC:RUB",
            "low": "33158.4",
            "high": "33158.4",
            "last": "33158.4",
            "volume": "18.05800000",
            "volume30d": "46.11432504",
            "bid": 32501,
            "ask": 33422.8
        }, {
            "timestamp": "1456396076",
            "pair": "GHS:BTC",
            "low": "0.00011701",
            "high": "0.00012297",
            "last": "0.00011919",
            "volume": "7040.73330492",
            "volume30d": "734478.64342721",
            "bid": 1.1918E-4,
            "ask": 1.1919E-4
        }, {
            "timestamp": "1456396076",
            "pair": "LTC:BTC",
            "low": "0.0078",
            "high": "0.00802082",
            "last": "0.00780058",
            "volume": "94.19443462",
            "volume30d": "11645.73021891",
            "bid": 0.00780055,
            "ask": 0.00795
        }
    ]
}

Last Price

Last Price for each trading pair will be defined as price of the last executed order for this pair.

GET https://cex.io/api/last_price/BTC/USD

Returns JSON example:

{ 
    "curr1": "BTC", 
    "curr2": "USD", 
    "lprice": "400.00" 
}

Returns params:

  • curr1 — the first currency code;
  • curr2 — the second currency code;
  • lprice — last price of selling/buying the first currency relative to the second one

If there are no such executed orders, then “lprice” will equal to “0”.

Last Prices for given market(s)

Last Price for each trading pair will be defined as price of the last executed order for this pair.

GET https://cex.io/api/last_prices/BTC/USD/LTC

Returns JSON example:

{
    e: "last_prices",
    ok: "ok",
    data: [
        {
            symbol1: "BTC",
            symbol2: "USD",
            lprice: "247"
        }, {
            symbol1: "GHS",
            symbol2: "USD",
            lprice: "0.06300002"
        },
        ...
        {
            symbol1: "FTC",
            symbol2: "LTC",
            lprice: "0"
        }
    ]
}

Returns params:

  • symbol1 — the first currency code;
  • symbol2 — the second currency code;
  • lprice — last price of selling/buying the first currency relative to the second one

If there are no such executed orders, then “lprice” will equal to “0”.

Converter

Converts any amount of the currency to any other currency by multiplying the amount by the last price of the chosen pair according to the current exchange rate.

POST https://cex.io/api/convert/BTC/USD

In this example, BTC is the convertible currency, USD is target currency.

Request example:

{ 
    "amnt": "2.5" 
}

Request Params:

  • amnt — convertible amount

Returns JSON example:

{ 
    "amnt": "1000.00" 
}

Returns Params:

  • amnt — amount in the target currency

Chart

Allows building price change charts (daily, weekly, monthly) and showing historical point in any point of the chart

POST https://cex.io/api/price_stats/BTC/USD

In this example, BTC and USD are currencies for getting stats.

{ 
    "lastHours": "24", 
    "maxRespArrSize": 100 
}

Request Params:

  • lastHours — past tense period till the current date in hours;
  • maxRespArrSize — maximal amount of price values in return.

Returns JSON example:

[ 
    { 
        "tmsp": "1411985700", 
        "price": "400.00" 
    }, 
    ... 
    { 
        "tmsp": "1412072100", 
        "price": "380.00" 
    }
]

Returns Params:

  • tmsp — UNIX timestamp
  • price — price value

Historical 1m OHLCV Chart

Returns dataset to build 1m OHLCV chart for a given date. Relies on historical data, is not working for current date

GET https://cex.io/api/ohlcv/hd/20160228/BTC/USD

URI Params:

  • data as string 'YYYYMMDD'
  • pair /symbol1/symbol2

Returns JSON example:

{
    "time":20160228,
    "data1m":" [
        [1456617600, 434.3867, 434.3867, 433.781, 433.781, 4.15450000]
        [1456617660, 433.747, 433.747, 433.7306, 433.7306, 3.00010001],
        [1456617720, 433.7302, 433.7302, 433.73, 433.73, 0.46760000],
        ...
    ]
}

Returns Params:

  • time — UNIX timestamp
  • data1m — 1440 candle data sets with:
    • UNIX timestamp
    • Open price
    • High price
    • Low price
    • Close price
    • Volume

Orderbook

GET https://cex.io/api/order_book/BTC/USD/?depth=1

Params:

  • depth - limit the number of bid/ask records returned (optional parameter, all existing elements are returned if omitted)

Returns JSON example:

{
    "timestamp":1459161809,
    "bids":[[250.00,0.02000000]],
    "asks":[[280.00,20.51246433]],
    "pair":"BTC:USD",
    "id":66478,
    "sell_total":"707.40555590",
    "buy_total":"68788.80"
}

Returns Params:

  • timestamp - UNIX timestamp
  • bids and asks - lists of open orders, each order is represented as a list of price and amount.
  • pair - Pair name
  • id - Incremental version id of order-book snapshot, may be used to check if order-book changed
  • sell_total - Total available in symbol1 (ex.BTC)
  • buy_total - Total available in symbol2 (ex.USD)

Trade history

GET https://cex.io/api/trade_history/BTC/USD/?since=1

Params:

  • since - return trades with tid >= since (optional parameter, 1000 or all existing (if less than 1000), elements are returned if omitted)

Returns a list of recent trades, where each trade is a JSON dictionary:

  • tid - trade id
  • type - type: buy/sell
  • amount - trade amount
  • price - price
  • date - UNIX timestamp

Private Functions

API authentication

All private API calls require authentication. You need to provide 3 parameters to authenticate a request:

  • API key
  • Nonce
  • Signature

API key

To get an API key, go to Account -> API Access Tab. Set permissions and click "Generate key".

Nonce

Nonce is a regular integer number. It must be increasing with every request you make. Read more about it here. Example: if you set nonce to 1 in your first request, you must set it to at least 2 in your second request. You are not required to start with 1. A common practice is to use unix time for that parameter.

Signature

Signature is a HMAC-SHA256 encoded message containing: nonce, user ID and API key. The HMAC-SHA256 code must be generated using a secret key that was generated with your API key. This code must be converted to it's hexadecimal representation (64 uppercase characters).

Example (Python):

message = nonce + userID + api_key
signature = hmac.new(API_SECRET, msg=message, digestmod=hashlib.sha256).hexdigest().upper()

Account balance

POST https://cex.io/api/balance/

Params:

  • key - API key
  • signature - signature
  • nonce - nonce

Returns JSON dictionary:

  • available - available balance
  • orders - balance in pending orders
  • bonus - referral program bonus

Open orders

POST https://cex.io/api/open_orders/BTC/USD
POST https://cex.io/api/open_orders/

Params:

  • key - API key
  • signature - signature
  • nonce - nonce

Returns JSON example:

[
    {
        "id": "13837040",
        "time": "1460020144872",
        "type": "sell",
        "price": "411.626",
        "amount": "1.00000000",
        "pending": "1.00000000",
        "symbol1": "BTC",
        "symbol2": "EUR"
    },
    {
        "id": "16452929",
        "time": "1462355019816",
        "type": "buy",
        "price": "400",
        "amount": "1.00000000",
        "pending": "1.00000000",
        "symbol1": "BTC",
        "symbol2": "USD"
    }
]

Returns params:

  • id - order id
  • time - timestamp
  • type - buy or sell
  • price - price
  • amount - amount
  • pending - pending amount (if partially executed)
  • symbol1 — the first currency code
  • symbol2 — the second currency code

Active Order Status

POST https://cex.io/api/active_orders_status

Params:

  • key - API key
  • signature - signature
  • nonce - nonce
  • orders_list - list of order IDs to get status of
    • Note: the number of requested orders should not be more than 20

Returns JSON list of open orders. Each order is represented as dictionary:

  • ok - response status: 'ok' or 'error'
  • e - event type ('active_orders_status')
  • data - list of status items for requested orders, each item is list of:
    • order_id
    • amount
    • remains (in case if order executed partially, it is less than amount, equal otherwize)
    • Note: If the order is not found among active orders, [order_id, 0, 0] will be returned

Reqest Parameters Example:

{ 
    orders_list: [
        '8550492',
        '8550495',
        '8550497'
    ], 
    key: 'h93JJSCtgrvDrPPplVtcJKSDs5g',
    nonce: 14582263046846,
    signature: '381C9485FDCB4027B880016E7E5B585EF18738B61D34A70EF9EE84FABA18BA61'
}

Response Example:

{
    e: 'active_orders_status',
    ok: 'ok',
    data: [ 
        [ '8550408', '0', '0' ],                   # not active (cancelled or executed)
        [ '8550495', '0.02000000', '0.02000000' ], # open  
        [ '8550497', '0.04000000', '0.02700000' ]  # open, partially executed
    ]
}

Archived orders

POST https://cex.io/api/archived_orders/BTC/USD

Params:

  • limit – limit the number of entries in response (1 to 100)
  • dateTo – end date for open orders filtering (timestamp in seconds, 10 digits)
  • dateFrom – start date for open order filtering (timestamp in seconds, 10 digits)

Returns JSON list of archived orders. Check the example below:

  • status - "d" — done (fully executed), "c" — canceled (not executed), "cd" — cancel-done (partially executed)
  • ta:USD/tta:USD – total amount in current currency (Maker/Taker)
  • fa:USD/tfa:USD – fee amount in current currency (Maker/Taker)
  • a:BTC:cds – credit, debit and saldo merged amount in current currency
  • tradingFeeMaker,tradingFeeTaker – fee % value of Maker/Taker transactions
[
    {
        "id": "22348164",
        "type": "buy",
        "time": "2016-08-04T09:28:24.669Z",
        "lastTxTime": "2016-08-04T09:28:58.762Z",
        "lastTx": "22348407",
        "status": "d",
        "symbol1": "BTC",
        "symbol2": "USD",
        "amount": "1.00000000",
        "price": "564",
        "fa:USD": "0.00",
        "ta:USD": "563.98",
        "remains": "0.00000000",
        "a:BTC:cds": "1.00000000",
        "a:USD:cds": "565.13",
        "f:USD:cds": "0.00",
        "tradingFeeMaker": "0",
        "tradingFeeTaker": "0.2",
        "orderId": "22348164"
    },
    {
        "id": "22347874",
        "type": "buy",
        "time": "2016-08-04T09:27:40.316Z",
        "lastTxTime": "2016-08-04T09:27:47.527Z",
        "lastTx": "22347950",
        "status": "cd",
        "symbol1": "BTC",
        "symbol2": "USD",
        "amount": "1.00000000",
        "price": "564",
        "fa:USD": "0.00",
        "ta:USD": "359.72",
        "remains": "0.36219371",
        "a:BTC:cds": "0.63780629",
        "a:USD:cds": "565.13",
        "f:USD:cds": "0.00",
        "tradingFeeMaker": "0",
        "tradingFeeTaker": "0.2",
        "orderId": "22347874"
    }
] 

Cancel order

POST https://cex.io/api/cancel_order/

Params:

  • key - API key
  • signature - signature
  • nonce - nonce
  • id - order ID

Returns 'true' if order has been found and canceled.

Cancel all orders for given pair

POST https://cex.io/api/cancel_orders/BTC/USD

Params:

  • key - API key
  • signature - signature
  • nonce - nonce

Returns JSON response with list of cancelled order ids. Check the example below:

{
    "e": "cancel_orders",
    "ok": "ok",
    "data": [
        "2407314",
        "2407317",
        "2407320",
        "2407323"
    ]
}

Place order

POST https://cex.io/api/place_order/BTC/USD

Params:

  • key - API key
  • signature - signature
  • nonce - nonce
  • type - 'buy' or 'sell'
  • amount - amount
  • price - price

Returns JSON dictionary representing order:

  • id - order id
  • time - timestamp
  • type - buy or sell
  • price - price
  • amount - amount
  • pending - pending amount (if partially executed)

Place instant order

POST https://cex.io/api/place_order/BTC/USD

Params:

  • key - API key
  • signature - signature
  • nonce - nonce
  • type - 'buy' or 'sell'
  • amount - amount
  • order_type - "market"

Returns JSON dictionary representing order:

  • id - order id
  • time - timestamp
  • type - buy or sell
  • message - Description of order execution
  • symbol1Amount - amount in currency of symbol 1
  • symbol2Amount - amount in currency of symbol 2

Get order details

POST https://cex.io/api/get_order/

Params:

  • key - API key
  • signature - signature
  • nonce - nonce
  • id - order id

Returns JSON dictionary representing order details:

{
    "id": "22347874",
    "type": "buy",
    "time": 1470302860316,
    "lastTxTime": "2016-08-04T09:27:47.527Z",
    "lastTx": "22347950",
    "pos": null,
    "user": "userId",
    "status": "cd",
    "symbol1": "BTC",
    "symbol2": "USD",
    "amount": "1.00000000",
    "price": "564",
    "fa:USD": "0.00",
    "ta:USD": "359.72",
    "remains": "0.36219371",
    "a:BTC:cds": "0.63780629",
    "a:USD:cds": "565.13",
    "f:USD:cds": "0.00",
    "tradingFeeMaker": "0",
    "tradingFeeTaker": "0.2",
    "tradingFeeStrategy": "Promo000Maker",
    "orderId": "22347874"
}

Get order transactions

POST https://cex.io/api/get_order_tx/

Params:

  • key - API key
  • signature - signature
  • nonce - nonce
  • id - order id

Returns JSON dictionary representing order details and transactions list:

{
    "e": "get_order_tx",
    "ok": "ok",
    "data": {
        "id": "22347874",
        "type": "buy",
        "time": 1470302860316,
        "lastTxTime": "2016-08-04T09:27:47.527Z",
        "lastTx": "22347950",
        "user": "userId",
        "status": "cd",
        "symbol1": "BTC",
        "symbol2": "USD",
        "amount": "1.00000000",
        "price": "564",
        "fa:USD": "0.00",
        "ta:USD": "359.72",
        "remains": "0.36219371",
        "a:BTC:cds": "0.63780629",
        "a:USD:cds": "565.13",
        "f:USD:cds": "0.00",
        "tradingFeeMaker": "0",
        "tradingFeeTaker": "0.2",
        "tradingFeeStrategy": "Promo000Maker",
        "orderId": "22347874",
        "next": false,
        "vtx": [
            {
                "id": "22347950",
                "type": "cancel",
                "time": "2016-08-04T09:27:47.527Z",
                "user": "userId",
                "c": "user:userId:a:USD",
                "d": "order:22347874:a:USD",
                "a": "204.28000000",
                "amount": "204.28000000",
                "balance": "1391212.24000000",
                "symbol": "USD",
                "order": "22347874",
                "buy": null,
                "sell": null,
                "pair": null,
                "pos": null,
                "cs": "1391212.24",
                "ds": 0
            },
            {
                "id": "22347949",
                "type": "buy",
                "time": "2016-08-04T09:27:40.972Z",
                "user": "userId",
                "c": "user:userId:a:BTC",
                "d": "order:22347874:a:BTC",
                "a": "0.63780629",
                "amount": "0.63780629",
                "balance": "7633.93075975",
                "symbol": "BTC",
                "order": "22347874",
                "buy": "22347874",
                "sell": "22347877",
                "pair": null,
                "pos": null,
                "cs": "7633.93075975",
                "ds": 0,
                "price": 564,
                "symbol2": "USD",
                "fee_amount": 0
            },
            {
                "id": "22347876",
                "type": "buy",
                "time": "2016-08-04T09:27:40.316Z",
                "user": "userId",
                "c": "user:userId:a:USD",
                "d": "order:22347874:a:USD",
                "a": "1.13000000",
                "amount": "-564.00000000",
                "balance": "1391007.96000000",
                "symbol": "USD",
                "order": "22347874",
                "buy": null,
                "sell": null,
                "pair": null,
                "pos": null,
                "cs": "1391007.96",
                "ds": "564.00"
            }
        ],
        "next": false,
        "prev": false
    }
}

Get crypto address

POST https://cex.io/api/get_address

Params:

  • key - API key
  • signature - signature
  • nonce - nonce
  • currency - crypto currency, ex."BTC"

Returns JSON dictionary representing order:

  • e - "get_address"
  • ok - "ok" or "error"
  • data - Crypto address

Get my fee

POST https://cex.io/api/get_myfee

Params:

  • key - API key
  • signature - signature
  • nonce - nonce

Returns JSON dictionary with trading fee information. Example:

{
      'e': "get_myfee",
      'ok': "ok",
      'data': {
        "BTC:USD": {
            "buy": "0.2",
            "sell": "0.2",
            "buyMaker": "0",
            "sellMaker": "0"
        },
        "BTC:EUR": {
            "buy": "0.2",
            "sell": "0.2",
            "buyMaker": "0",
            "sellMaker": "0"
        }
    }
} 

Cancel replace order

POST https://cex.io/api/cancel_replace_order/BTC/USD

Do nothing if:

  • order with order_id does not exist, cancelled or done
  • order type in order with order_id does not equals to given type
  • order with given parameters cannot be placed (invalid price/amount/pair/insufficient funds/...)

Params:

  • key - API key
  • signature - signature
  • nonce - nonce
  • type - buy or sell
  • amount - amount
  • price - price
  • order_id - order to replace

Returns JSON dictionary representing order (the same as in place_order):

  • id - order id
  • time - timestamp
  • type - buy or sell
  • price - price
  • amount - amount
  • pending - pending amount (if partially executed)

Open position

POST https://cex.io/api/open_position/BTC/USD

Does nothing if:

  • key does not provide permission for margin trading
  • pair in URL or 'symbol' in params is invalid
  • leverage is invalid
  • amount is higher or less than allowed
  • stop-loss price is higher or less than valid (warrantable)
  • anySlippage is false and market data changed in a way that position can not be opened as requested

Params:

{   
    'key': ...,
    'signature': ..., 
    'nonce': ...,
    'amount': '1',
    'symbol': 'BTC',
    'leverage': '2',
    'ptype': 'long',
    'anySlippage': 'true',
    'eoprice': '650.3232',
    'stopLossPrice': '600.3232',
} 
  • key - API key
  • signature - signature
  • nonce - nonce
  • symbol - currency to buy (product)
  • amount - total amount of 'product' to buy using borrowed funds and user's funds
  • msymbol - currency of user funds used, may be one of cirrencies in the pair, default is second currency in the pair
  • leverage - leverage ratio of total funds (user's and borrowed) to user's funds; for example: leverage=3 means: ratio total/user's=3:1, margin=33.(3)%, 1/3 is user's, 2/3 are borrowed; Note that in UI it will be presented as '1:3'
  • ptype - position type: 'long' - buying 'product', profitable if product price grows; 'short' - selling 'product', profitable if product price falls;
  • anySlippage - allows to open position at changed price
  • eoprice - estimated price at which your position will be opened
  • stopLossPrice - price near which your position will be closed automatically in case of unfavorable market conditions

Stop-loss Price:

  • Stop-loss price is bound to the minimum amount of the funds in the position you would like to get back in case of loss. Thus, if R is minimum amount in percents of user's funds to remain the stop-loss price may be computed as:
    • Long position (symbol='BTC', msymbol: 'EUR'):
      stoploss = (leverage - 1 + R% / 100%) / leverage * eoprice
    • Short position (symbol='BTC', msymbol: 'EUR'):
      stoploss = (leverage - R% / 100%) / (leverage - 1) * eoprice
    • Long position (symbol='BTC', msymbol: 'BTC'):
      stoploss = (leverage - 1 + R% / 100%) / leverage * eoprice
    • Short position (symbol='BTC', msymbol: 'BTC'):
      stoploss = leverage / (leverage - 1 + R% / 100%) * eoprice

Returns JSON dictionary representing the position as in the sample:

{   
    'e': 'open_position',
    'ok': 'ok',
    'data': {
        'id': 104034,
        'otime': 1475484979608,

        'psymbol': 'BTC', 
        'msymbol': 'USD',
        'lsymbol': 'USD',
        'pair': {
            'symbol1': 'BTC'
            'symbol2': 'USD',
        },
        'pamount': '1.00000000',
        'omamount': '303.99',
        'lamount': '303.99'
        'oprice': '607.9800',
        'ptype': 'long',
        'stopLossPrice': '520.3232',

        'pfee': '3', 
        'cfee': '4',
        'tfeeAmount': '3.04'
    }
} 
  • id - the position id
  • otime - timestamp the position was opened at
  • psymbol - currency, in which the position was opened (product)
  • msymbol - currency, in which user is going to gain profit, can be one of currencies, presented in the pair
  • lsymbol - currency of borrowed funds, can be one of currencies, presented in the pair
  • pair - trading pair as a list of two symbols, presents the pair according to requested URL
  • pamount - total position amount, presented in 'psymbol'
  • omamount - ('open money amount') user's amount used in the position, presented in 'msymbol'
  • lamount - amount of borrowed funds in the position, presented in 'lsymbol'
  • oprice - price the position was opened at, calculated as average of underlying executed orders
  • ptype - position type: 'long' or 'short'
  • stopLossPrice - price near which your position will be closed automatically in case of unfavorable market conditions
  • pfee - estimated fee (in %) from user's amount, that will be charged for position rollover for the next 4 hours
  • cfee - fee (in %) from user's amount, that will be charged for position closing
  • tfeeAmount - total fees paid by user, it is equal to opening fee amount, when position has been just opened

Note: the response does not contain all info on the position - use open-positions call to get complete information on open positions


Open positions

POST https://cex.io/api/open_positions/BTC/USD

Does nothing if:

  • key does not provide permission for margin trading
  • pair in URL is invalid

Params:

  • key - API key
  • signature - signature
  • nonce - nonce

Returns JSON dictionary representing detailed open positions for requested pair:

{
    'e': 'open_positions',
    'ok': 'ok',
    'data': [
        {
            'user': 'ud100036721',
            'id': '104102',
            'otime': 1475602208467,
            'symbol': 'BTC',
            'amount': '1.00000000',
            'leverage': '2',
            'ptype': 'long',
            'psymbol': 'BTC',
            'msymbol': 'USD',
            'lsymbol': 'USD',
            'pair': 'BTC:USD',
            'oprice': '607.5000'
            'stopLossPrice': '520.3232',

            'ofee': '1',
            'pfee': '3',
            'cfee': '4',
            'tfeeAmount': '3.04',

            'pamount': '1.00000000',
            'omamount': '303.75',
            'lamount': '303.75',

            'oorder': '34106774',            
            'rinterval': '14400000',

            'dfl': '520.32320000',
            'slamount': '520.33',
            'slremains': '520.33',
            'lremains': '303.75',
            'flPrice': '303.75000000',
            'a:BTC:c': '1.00000000',
            'a:BTC:s': '1.00000000',
            'a:USD:cds': '610.54',
        },
        ...
    ]
} 
  • user - user Id
  • id - position id
  • otime - timestamp the position was opened at
  • symbol - position currency (product)
  • amount - total amount of 'product' in the position
  • leverage - leverage, with which the position was opened
  • ptype - position type: 'short' or 'long'
  • psymbol - currency, in which the position was opened (product)
  • msymbol - currency, in which user is going to gain profit, can be one of currencies, presented in the pair
  • lsymbol - currency of borrowed funds, can be one of currencies, presented in the pair
  • pair - trading pair as a string like 'XXX:XXX'
  • oprice - price the position was opened at, calculated as average of underlying executed orders
  • stopLossPrice - price, near which your position will be closed automatically in case of unfavorable market conditions
  • ofee - fee (in %) from user's amount, that was charged for position opening
  • pfee - estimated fee (in %) from user's amount, that will be charged for position rollover for the next 4 hours
  • cfee - fee (in %) from user's amount, that will be charged for position closing
  • tfeeAmount - total fees paid by user, it is equal to opening fee amount, when position has been just opened
  • pamount - total position amount, presented in 'psymbol'
  • omamount - ('open money amount') user's amount used in the position, presented in 'msymbol'
  • lamount - amount of borrowed funds in the position, presented in 'lsymbol'
  • oorder - underlying order id for position opening
  • corder - list of underlying orders for position closing
  • rinterval - rollover interval in miliseconds
  • (tech) dfl - 'desired fast liquidation' price
  • (tech) slamount - ('stop-loss amount') amount that will be returned, including user's and borrowed funds
  • (tech) slremains - remains of slamount to return
  • (tech) lremains - amount of borrowed funds to be returned by user
  • (tech) flPrice - estimated price of total loss
  • (tech) a:BTC:c - credit in psymbol
  • (tech) a:BTC:d - debit in psymbol
  • (tech) a:BTC:s - saldo in psymbol
  • (tech) a:USD:cds - aquation c==d, s==0

Close position

POST https://cex.io/api/close_position/BTC/USD 

Does nothing if:

  • key does not provide permission for margin trading
  • position with 'id' does not exist, cancelled or done

Params:

{   
    'key': ...,
    'signature': ..., 
    'nonce': ...,
    'id': '104034',
} 
  • key - API key
  • signature - signature
  • nonce - nonce
  • id - id of the position

Returns JSON response with information on closing position, or error:

{   
    'e': 'close_position',
    'ok': 'ok',
    'data': {
        'id': 104034,
        'ctime': 1475484981063,
        'ptype': 'long',
        'msymbol': 'USD'
        'pair': {
            'symbol1': 'BTC',
            'symbol2': 'USD'
        }
        'price': '607.1700',
        'profit': '-12.48',
    }
} 
  • id - position id
  • ctime - timestamp the position was closed at
  • ptype - position type: 'long' or'short'
  • msymbol - currency, in wich user gained or lost
  • price - price the position was closed at, calculated as average of underlying executed orders
  • pair - trading pair
  • profit - positive if user gained, negative - if lost, presented in currency 'msymbol'

Please, address your feedbacks and feature requests to [email protected].