Authentication


Authentication for the REST API requires the same information as the WS Trading API. Instead of sending some initial message like Logon, each call to the REST Transfers API must contain 4 HTTP headers:

  • X-AUTH-API-KEY

  • X-AUTH-API-PAYLOAD

  • X-AUTH-API-SIGNATURE

  • X-AUTH-API-NONCE


Nonce (UNIX nanoseconds timestamp) must be unique for each request and no older than 60 seconds.

Learn how to get keys for API.


Library Repository


Python lib:    GitHub / PyPI


C# lib:     GitHub C#NuGet


Market watch

For getting comprehensive market data information use this link https://api.xena.exchange/api/market-data/market-watch

 

GET Account list


Returns a list of the accounts available for trading.

Information about the accounts can be obtained through the REST API.


GET https://api.xena.exchange/trading/accounts


Response:

{
    "accounts":[
        {
            "id":1000000,
            "kind":"Spot"
        },
        {
            "id":10000000000,
            "kind":"Margin",
            "currency":"BTC"
        }
    ]
}


Response parameters

Field


Type / possible values

Status Message

id

M

Integer

Account number

kind

M

String

“Spot” and “Margin” types are available

Account type

currency

O

String

Account currency. Returns for Margin accounts only


GET Balances (Portfolio)


Returns information about available balance.

Information can be obtained with the REST API.


GET https://api.xena.exchange/trading/accounts/<accountId>/balance

Response Spot:

{
    "balances": [
        {
            "available": "99488.01841315",
            "currency": "BTC",
            "lastUpdateTime": 1568283729773045000,
            "onHold": "0.018",
            "settled": "99488.03641315"
        },
        {
            "available": "0",
            "currency": "ETH",
            "lastUpdateTime": 1568283729775249748,
            "onHold": "0",
            "settled": "0"
        },    
        {
            "available": "1086758.01",
            "currency": "USDT",
            "lastUpdateTime": 1568283729773045000,
            "onHold": "1171.62",
            "settled": "1087929.63"
        }
    ],
    "msgType": "XAR"
}



Response Margin:

{
    "balances": [
        {
            "available": "479.88205594",
            "currency": "BTC",
            "equity": "479.88211027",
            "lastUpdateTime": 1568284320535383867,
            "onHold": "0.00005654",
            "settled": "479.88211248"
        }
    ],
    "msgType": "XAR"
}


Response parameters

Field


Type / possible values

Description

balances

M

Array

Contains account balance per currency

available

M

Decimal

Available for trading

onHold

M

Decimal

On hold

currency

M

String

Currency

settledM

Decimal

Settled balance
equityO

Decimal

Equity
msgTypeMStringXAR - Account Status Report Snapshot


GET Trade history

Returns a list of trades. 


GET https://api.xena.exchange/trading/accounts/<accountId>/trade-history
Supported parameters: trade_id, client_order_id ,symbol, from, to, page, limit



Spot Response:

[
    {
        "account": 8263440,
        "avgPx": "0",
        "calculatedCcyLastQty": "10",
        "capPrice": "0",
        "clOrdId": "kE8n97XMeSL4",
        "commCurrency": "USDT",
        "commRate": "0",
        "commission": "0.01",
        "cumQty": "0.001",
        "execId": "2c96d82a-be12-47db-ba84-5c93df405a1b",
        "execInst": [
            "x"
        ],
        "execType": "F",
        "lastLiquidityInd": "2",
        "lastPx": "10000",
        "lastQty": "0.001",
        "leavesQty": "0",
        "marginAmt": "0",
        "msgType": "8",
        "netMoney": "10.01",
        "ordStatus": "2",
        "ordType": "3",
        "orderId": "9ab1e2ad-269f-4abd-9dde-951a937816cb",
        "orderQty": "0.001",
        "pegOffsetValue": "0",
        "price": "0",
        "side": "1",
        "stopPx": "22",
        "symbol": "BTC/USDT",
        "tradeId": "220442185",
        "transactTime": 1568214568767469000
    },
    {
        "account": 8263440,
        "avgPx": "0",
        "calculatedCcyLastQty": "0.02",
        "capPrice": "0",
        "clOrdId": "7",
        "commCurrency": "USDT",
        "commRate": "0",
        "commission": "0.01",
        "cumQty": "0.001",
        "execId": "1f5171ac-9b34-44be-9632-0381dcd1c599",
        "execType": "F",
        "lastLiquidityInd": "1",
        "lastPx": "20",
        "lastQty": "0.001",
        "leavesQty": "0",
        "marginAmt": "0",
        "msgType": "8",
        "netMoney": "0.01",
        "ordStatus": "2",
        "ordType": "2",
        "orderId": "bf647964-02c3-4b0c-b355-b6a89e5daa87",
        "orderQty": "0.001",
        "pegOffsetValue": "0",
        "price": "13",
        "side": "2",
        "stopPx": "0",
        "symbol": "BTC/USDT",
        "tradeId": "220442184",
        "transactTime": 1568214568701857000
    }
]


Margin Response:

[
    {
        "account": 1012833743,
        "avgPx": "0",
        "calculatedCcyLastQty": "0",
        "capPrice": "0",
        "clOrdId": "PJqLQnwVd",
        "commCurrency": "BTC",
        "commRate": "0.00075",
        "commission": "0.00000009",
        "cumQty": "1",
        "execId": "28a9c3f10885b4e6644681063066dae97b6065b3",
        "execType": "F",
        "lastLiquidityInd": "2",
        "lastPx": "9200",
        "lastQty": "1",
        "leavesQty": "0",
        "marginAmt": "0",
        "marginAmtType": "11",
        "msgType": "8",
        "netMoney": "0",
        "ordStatus": "2",
        "ordType": "2",
        "orderId": "c30a51b1-562a-468b-bd84-93a877ae7177",
        "orderQty": "1",
        "pegOffsetValue": "0",
        "positionEffect": "O",
        "positionId": 130759223,
        "price": "9200",
        "side": "2",
        "stopPx": "0",
        "symbol": "XBTUSD",
        "tradeId": "d9ea703d-328a-4d49-ba3b-b4f8b80bd504",
        "transactTime": 1568270873902180000
    },
    {
        "account": 1012833743,
        "avgPx": "0",
        "calculatedCcyLastQty": "0",
        "capPrice": "0",
        "clOrdId": "8yMNxd6P2",
        "commCurrency": "BTC",
        "commRate": "0.00075",
        "commission": "0.00000009",
        "cumQty": "1",
        "execId": "8a0d854c9ed51d75d04809da9f965d48f7b82b4a",
        "execType": "F",
        "lastLiquidityInd": "2",
        "lastPx": "9200",
        "lastQty": "1",
        "leavesQty": "0",
        "marginAmt": "0",
        "marginAmtType": "11",
        "msgType": "8",
        "netMoney": "0",
        "ordStatus": "2",
        "ordType": "2",
        "orderId": "7c20e468-6e95-4394-b2b5-5436004d7ba4",
        "orderQty": "1",
        "pegOffsetValue": "0",
        "positionEffect": "O",
        "positionId": 130759221,
        "price": "9200",
        "side": "2",
        "stopPx": "0",
        "symbol": "XBTUSD",
        "tradeId": "a21a2c95-435e-4fee-a3ff-e25942542fcc",
        "transactTime": 1568270873534235000
    }
]



Response parameters

Field


Type / possible values

Status Message

orderId

M

String 


clOrdId

M

String


tradeId

C

String


symbol

M

String


side

M

Integer

1 Buy

2 Sell


price

C

Decimal

Conditionally required for limit orders.

orderQty

M

Decimal

In accordance with order status matrices.

leavesQty

M

Decimal

In accordance with order status matrices.

cumQty

M

Decimal

In accordance with order status matrices.

execId

M

String

Unique identifier of the execution message within a 24-hour range

lastQty

C

Decimal

In accordance with order status matrices.

lastPx

C

Decimal


calculatedCcyLastQty

C

Decimal

Net payment of the fill, not including commission.

netMoney

C

Decimal

Gross amount of the fill, including commission.

transactTime

M

Timestamp

Timestamp of the event in nanoseconds.

lastLiquidityInd

C

1 AddedLiquidity

2 RemovedLiquidity

Conditionally required when ExecType is Trade.

commission

O

Decimal


commCurrency

O

String


currency

M

String

Pair base currency

settlCurrency

M

String

Pair quote currency

positionId

O

Integer


positionEffect

O

Char

C Close

O Open


avgPx

O

Decimal

Average price


GET Positions history

Returns a list of positions.


GET https://api.xena.exchange/trading/accounts/<accountId>/positions-history

Supported parameters: openfrom, opento, closefrom, closeto, id, parentid, symbol, limit, page


Response:

[
    {
        "account": 1012833743,
        "avgPx": "9200",
        "msgType": "AP",
        "positionId": 130759223,
        "positionOpenTime": 1568270873905150976,
        "priorSettlPrice": "9200",
        "settlDate": 1568270931172423936,
        "settlPrice": "9200",
        "side": "2",
        "symbol": "XBTUSD",
        "transactTime": 1568286765072481237,
        "volume": "1",
        "payments": [
            {
                "paymentAmount": "0.00000009",
                "paymentCurrency": "BTC",
                "paymentType": "40"
            },
            {
                "paymentAmount": "0",
                "paymentCurrency": "BTC",
                "paymentType": "42"
            },
            {
                "paymentAmount": "0",
                "paymentCurrency": "BTC",
                "paymentType": "41"
            },
            {
                "paymentAmount": "-0.00000009",
                "paymentCurrency": "BTC",
                "paymentType": "43"
            }
        ],
        "relatedTrades": [
            {
                "relatedTradeId": "28a9c3f10885b4e6644681063066dae97b6065b3",
                "relatedTradeType": "1"
            },
            {
                "relatedTradeId": "f6f11bce-440d-407b-b870-9c02dbaae674",
                "relatedTradeType": "2"
            },
            {
                "relatedTradeId": "130759223",
                "relatedTradeType": "3"
            }
        ]
    },
    {
        "account": 1012833743,
        "avgPx": "9200",
        "msgType": "AP",
        "positionId": 130759221,
        "positionOpenTime": 1568270873536510976,
        "priorSettlPrice": "9200",
        "settlDate": 1568270931170775040,
        "settlPrice": "9200",
        "side": "2",
        "symbol": "XBTUSD",
        "transactTime": 1568286765072493115,
        "volume": "1",
        "payments": [
            {
                "paymentAmount": "0.00000009",
                "paymentCurrency": "BTC",
                "paymentType": "40"
            },
            {
                "paymentAmount": "0",
                "paymentCurrency": "BTC",
                "paymentType": "42"
            },
            {
                "paymentAmount": "0",
                "paymentCurrency": "BTC",
                "paymentType": "41"
            },
            {
                "paymentAmount": "-0.00000009",
                "paymentCurrency": "BTC",
                "paymentType": "43"
            }
        ],
        "relatedTrades": [
            {
                "relatedTradeId": "8a0d854c9ed51d75d04809da9f965d48f7b82b4a",
                "relatedTradeType": "1"
            },
            {
                "relatedTradeId": "d32e109d-d64e-45a2-a6ee-494f87dcb8e6",
                "relatedTradeType": "2"
            },
            {
                "relatedTradeId": "130759221",
                "relatedTradeType": "3"
            }
        ]
    }
]


Response parameters

Field

M/O/C

Type / possible values

Description

account

M

Integer


positionId

M

Integer


transactTime

M

Timestamp

Position timestamp

symbol

M

String


positionOpenDate

M

Timestamp


avgPx

M

Decimal

Open Price

volume

M

Decimal


side

M

String

“Buy” or “Sell”

priorSettlPrice

M


Settlement Price

settlDate

C


Close DT — filled for closed positions only

settlPrice

C


Close Price — filled for closed positions only

payments

paymentType

M

String

Possible values:

  • Commission (Commissions)

  • InterestPayments (Total Interest)

  • Settlement (RealizedPL)

  • CumulativePayments (CumulativePL)

paymentCurrency

M

String


paymentAmount

M

String


relatedTrades

relatedTradeId

M


Exec ID

relatedTradeType

M


Possible values:

  • OpenExecId

  • CloseExecId

  • ParentPositionId


GET Active orders

GET  https://api.xena.exchange/trading/accounts/<accountId>/orders


Response Spot:

[
    {
        "account": 8263440,
        "clOrdId": "1568100589.5962462",
        "cumQty": "0",
        "execId": "4c40c20a-0925-4193-9f3f-3bcda938fba9",
        "execType": "0",
        "lastQty": "0",
        "leavesQty": "0.001",
        "msgType": "8",
        "ordStatus": "0",
        "ordType": "2",
        "orderId": "adde0e28-d35d-4c76-9dcc-969ea8a73519",
        "orderQty": "0.001",
        "price": "10.6",
        "side": "1",
        "symbol": "BTC/USDT",
        "transactTime": 1568100589908017624
    },
    {
        "account": 8263440,
        "clOrdId": "4AZqQPE6dSL",
        "cumQty": "0",
        "execId": "a08d018a-4595-4b96-8714-f5b57598ad8c",
        "execInst": [
            "S"
        ],
        "execType": "9",
        "lastQty": "0",
        "leavesQty": "0.001",
        "listId": "ww3N79bk4",
        "msgType": "8",
        "ordStatus": "9",
        "ordType": "3",
        "orderId": "dceafc2f-d950-4c0e-a79a-79ffbb3f383f",
        "orderQty": "0.001",
        "side": "2",
        "stopPx": "9",
        "symbol": "BTC/USDT",
        "transactTime": 1568104082333650870
    }
]

Response Margin:

[
    {
        "account": 1012833743,
        "clOrdId": "38kw0Le2o",
        "cumQty": "0",
        "execId": "acb0f6323c9abcb96e9e6e67d201892096df69ad",
        "execType": "0",
        "lastQty": "0",
        "leavesQty": "1",
        "marginAmt": "0.00000544",
        "marginAmtType": "11",
        "msgType": "8",
        "ordStatus": "0",
        "ordType": "2",
        "orderId": "cb66271f-fdb2-41b0-9df9-663369346cce",
        "orderQty": "1",
        "price": "9200",
        "side": "1",
        "symbol": "XBTUSD",
        "transactTime": 1568287359544729914
    },
    {
        "account": 1012833743,
        "clOrdId": "9NmYdkl1M",
        "cumQty": "0",
        "execId": "9c9f8fd963799f5ee85d1820a2273fd6d9f0258b",
        "execType": "0",
        "lastQty": "0",
        "leavesQty": "1",
        "marginAmt": "0.00000444",
        "marginAmtType": "11",
        "msgType": "8",
        "ordStatus": "0",
        "ordType": "2",
        "orderId": "1fc7bc80-38e1-40fa-84ee-0c02ec9c6e4c",
        "orderQty": "1",
        "price": "11280.8",
        "side": "2",
        "symbol": "XBTUSD",
        "transactTime": 1568287363794538232
    }
]


Response parameters

Field

M/O/C

Type / possible values

Description

msgType

M

8 (ExecutionReport)


orderId

M

String / Guid


clOrdId

M

String


origClOrdId

O

String

ClOrdId of the order being cancelled, if OrigClOrdId has been submitted in the request.

tradeId

C

String

Conditionally required when ExecType = Trade

symbol

M

String


execType

M

A PendingNew

0 New

F Trade

6 PendingCancel

4 Cancelled

E PendingReplace

D Reastated

5 Replaced

8 Rejected

9 Suspended

In accordance with order status matrices.

ordStatus

M

0 New

1 Partially Filled

2 Filled

4 Cancelled

8 Rejected

E Pending replace

9 Suspended

In accordance with order status matrices.

side

M

1 Buy

2 Sell


ordType

M

int

1 Market

2 Limit

3 Stop


price

C

Decimal

Conditionally required for limit orders.

orderQty

M

Decimal

In accordance with order status matrices.

leavesQty

M

Decimal

In accordance with order status matrices.

cumQty

M

Decimal

In accordance with order status matrices.

execId

M

String / Guid

Unique identifier of the execution message within a 24-hour range

lastQty

C

Decimal

In accordance with order status matrices.

Conditionally required when ExecType is Trade.

lLastPx

C

Decimal

Conditionally required when ExecType is Trade.

calculatedCcyLastQty

C

Decimal

Net payment of the fill, not including commission.

Conditionally required when ExecType is Trade.

netMoney

C

Decimal

Gross amount of the fill, including commission.

Conditionally required when ExecType is Trade.

transactTime

M

Long — Unix timestamp in nanoseconds

Timestamp of the event.

lastLiquidityInd

C

Decimal

1 AddedLiquidity

2 RemovedLiquidity

Conditionally required when ExecType is Trade.

commission

O

Decimal


commCurrency

O

String


account

M

Integer


currency

M

String

Pair base currency

settlCurrency

M

String

Pair quote currency

settlType

M

1 Cash (TOD / T+0)


positionId

M

Integer


marginAmt

M



marginAmtType

M

11 — Initial Margin


Repeating group SLTP

ordType

M

2 — Limit (take-profit)

3 — Stop (stop-loss)

Limit orders are considered take-profit orders

Market orders are considered stop-loss orders

price

C


Required for take-profit orders

stopPx

C


Required for stop-loss orders

pegOffsetValue

C

Decimal

For trailing stop and attempt zero loss orders

pegPriceType

C

8 — TrailingStopPeg

For trailing stop and attempt zero loss orders

pegOffsetType

C

2 — BasisPoints

For trailing stop and attempt zero loss orders

capPrice

C

Decimal

For trailing stop orders — empty

For attempt zero loss orders — stop-loss price limit. If CapPrice = 0, CapPrice = Open price


GET Active positions

GET https://api.xena.exchange/trading/accounts/<accountId>/positions


Response:

[
{
"msgType":"AP",
"account":1012833747,
"positionID":130759165,
"transactTime":1568030546634898831,
"symbol":"ETHUSD",
"positionOpenTime":1568029293925376516,
"avgPx":"163.62",
"volume":"1",
"side":"1",
"priorSettlPrice":"183.31",
"marginAmounts":[
{
"marginAmt":"0.00000917",
"marginAmtType":"11",
"marginAmtCcy":"BTC"
},
{
"marginAmt":"0.0000023",
"marginAmtType":"7",
"marginAmtCcy":"BTC"
}
],
"payments":[
{
"paymentType":"40",
"paymentCurrency":"BTC",
"paymentAmount":"0"
},
{
"paymentType":"42",
"paymentCurrency":"BTC",
"paymentAmount":"0.00001969"
},
{
"paymentType":"41",
"paymentCurrency":"BTC",
"paymentAmount":"-0.00000011"
},
{
"paymentType":"43",
"paymentCurrency":"BTC",
"paymentAmount":"0.00001958"
}
],
"relatedTrades":[
{
"relatedTradeID":"e31bf599d694592c3ce37125353d53ef518315be",
"relatedTradeType":"1"
}
]
}
]


Response parameters

Field

M/O/C

Type / possible values

Description

msgType

M

AP (Position Report)


account

M

Integer


positionId

M

Integer


transactTime

M

Timestamp

Position timestamp

symbol

M

String


positionOpenDate

M

Timestamp


avgPx

M

Decimal

Open price

quantity

M

Decimal


side

M

1 — Buy

2 — Sell


priorSettlPrice

M


Settlement price

settlDate

C


Close DT — filled for closed positions only

settlPrice

C


Close price — filled for closed positions only

previousClearingBusinessDate

C


Previous variation margin timestamp

clearingBusinessDate

C


Next variation margin timestamp

repeating group MarginAmount

marginAmt

M



marginAmtType

M

11 — Initial Margin

7 — Core Margin (maintenance)


marginCurr

M



repeating group PaymentGrp

paymentType


40 — Commission (Commissions)

41 — Interest (Total Interest)

42 — Settlement (RealizedPL)

43 — CumulativePayments (CumulativePL)


paymentCurrency




paymentAmount




repeating group RelatedTradeGrp

relatedTradeId



Exec ID

relatedTradeType


1 — Open (OpenExecId)

2 — Close (CloseExecId)

3 — ParentPosition (ParentPositionId)



GET Margin requirements

GET https://api.xena.exchange/trading/accounts/<accountId>/margin-requirements


Response:

{
"msgType":"CJ",
"marginReqmtRptType":"0",
"account":1012833747,
"marginAmounts":[
{
"marginAmt":"0.00001397",
"marginAmtType":"11",
"marginAmtCcy":"BTC"
},
{
"marginAmt":"0.0000035",
"marginAmtType":"7",
"marginAmtCcy":"BTC"
},
{
"marginAmt":"60.06",
"marginAmtType":"11",
"marginAmtCcy":"USDT"
},
{
"marginAmt":"6.01",
"marginAmtType":"7",
"marginAmtCcy":"USDT"
}
]
}


Response parameters

Field

M/O/C

Type / possible values

Description

msgType

M

CJ (Margin Requirement Report)


marginReqmtRptType

M

0 — Summary


Repeating group MarginAmtGrp

marginAmt

M



marginAmtType

M

11 — Total margin (initial)

7 — Core margin (maintenance)

Contains multiple MarginAmts for different types of margins:

Total margin — net sum of initial margins

Core margin — net sum of maintenance margins

Margin requirements are grouped by margin currency

marginAmtCcy

M

String



POST Collapse positions

POST https://api.xena.exchange/trading/position/maintenance


Body:

{
"account": 1012833743,
"msgType": "AL",
"symbol": "XBTUSD",
"posTransType": "20",
"posReqId": "2",
"posMaintAction": "2"
}


Response:

{
"account": 1012833743,
"msgType": "AM",
"symbol": "XBTUSD",
"posTransType": "20",
"posReqId": "2"
}


Request parameters

Field

M/O/C

Type / possible values

Description

msgType

M

AL (Position Maintenance Request)


posReqId

O

String

Optional request ID. If set, the reply will contain the same ID.

posTransType

M

20 — Collapse


posMaintAction

M

2 — Replace

Maintenance action to be performed

account

M



symbol

M




Response parameters

Field

M/O/C

Type / possible values

Description

msgType

M

AM (Position Maintenance Report)


posReqId

C

String

PosReqID, if it was sent in the request

posTransType

M

20 — Collapse


posMaintAction

M

2 — Replace


account

M




POST New order

POST https://api.xena.exchange/trading/order/new


Spot Body:

{  
   "account":8263440,
   "clOrdId":"101",
   "msgType":"D",
   "orderQty":"1",
   "ordType":"2",
   "price":"110330",
   "side":"2",
   "symbol":"BTC/USDT",
   "transactTime":1568287793378004127,
   "settlType":"1"
}


Spot Response:

{  
   "msgType":"8",
   "account":8263440,
   "clOrdId":"101",
   "orderId":"c5a1a73d-df1b-4a31-86fa-6bc8acb6b95c",
   "symbol":"BTC/USDT",
   "ordType":"2",
   "price":"110330",
   "transactTime":1568287793378004127,
   "execId":"9971221a-8cd3-4530-b236-b5724b57528d",
   "execType":"0",
   "ordStatus":"0",
   "side":"2",
   "orderQty":"1",
   "leavesQty":"1",
   "cumQty":"0",
   "lastQty":"0"
}



Margin Body:

{
    "account": 1012833743,
    "clOrdId": 156811081333580288,
    "msgType": "D",
    "orderQty": "1",
    "ordType": "2",
    "price": "9245.6",
    "side": "1",
    "symbol": "XBTUSD",
    "transactTime": 1568108020708475447,
    "settlType": "1",
    "sltp":
        [
            {"ordType": "3","stopPx":"10000"},
            {"ordType": "2","price":"10000"}
        ]
}


Margin Response:

{  
   "msgType":"8",
   "account":1012833743,
   "clOrdId":"156810802032867008",
   "orderId":"69dd1e99-7f0d-47f9-add0-a43fb73cb778",
   "symbol":"XBTUSD",
   "ordType":"2",
   "price":"9245.6",
   "transactTime":1568108020708475447,
   "execId":"0921e38b-eb6d-41a9-b334-0b80cda24389",
   "execType":"A",
   "ordStatus":"A",
   "side":"1",
   "orderQty":"1",
   "leavesQty":"1",
   "cumQty":"0",
   "lastQty":"0",
   "positionEffect":"O",
   "marginAmt":"0.00000541",
   "marginAmtType":"11",
   "sltp":[  
      {  
         "stopPx":"9100"
      },
      {  
         "price":"10000"
      }
   ]
}


Request parameters

Field

M/O/C

Type / possible values

Description

msgType

M

D (NewOrderSingle)


clOrdId

M

String, 20 symbols max

ClOrdId must be unique within a moving frame of 24 hours.

symbol

M

String


side

M

1 Buy

2 Sell


settlType

M

1 Cash (TOD / T+0)


transactTime

M

Long — Unix timestamp in nanoseconds


orderQty

M

Decimal


ordType

M

1 Market

2 Limit

3 Stop


price

C

Decimal

Mandatory for limit orders; omitted for market orders.

account

M

Integer


timeInForce

O

1 Good Till Cancel (default value)

3 Immediate Or Cancel

4 Fill Or Kill


execInst

O

x IgnoreNotionalValueChecks

0 Stay On Offer Side

"x" For spot trading only

"0" Places order in DOM or cancels

listSeqNo

O

Integer

For spot trading only

positionEffect

O

Char

C Close

O Open


positionID

O

Integer


Repeating group Triggering Instructions (1114)

triggerType

M

1 — PartialExecution


triggerScope

M

1 — OtherOrder


triggerAction

M

1 — Activate

4 — SetCapPrice (custom)


refClOrdId

M



Repeating group SLTP (5000), can be used only for margin trading

ordType

M

2 — Limit (take profit)

3 — Stop (stop loss)

Limit orders are considered take-profit orders

Market orders are considered stop-loss orders

price

C


Required for take-profit orders

stopPx

C


Required for stop-loss orders

pegOffsetValue

C

Decimal

For trailing stop and attempt zero loss orders

pegPriceType

C

8 — TrailingStopPeg

For trailing stop and attempt zero loss orders

pegOffsetType

C

2 — BasisPoints

For trailing stop and attempt zero loss orders

capPrice

C

Price

For trailing stop orders — equals zero

For attempt zero loss  — price limit


Response parameters

Field

M/O/C

Type / possible values

Description

msgType

M

8 (ExecutionReport)


orderId

M

String / Guid


clOrdId

M

String


origClOrdId

O

String

ClOrdId of the order being cancelled, if OrigClOrdId has been submitted in the request.

tradeId

C

String

Conditionally required when ExecType = Trade

symbol

M

String


execType

M

A PendingNew

0 New

F Trade

6 PendingCancel

4 Cancelled

E PendingReplace

D Reastated

5 Replaced

8 Rejected

9 Suspended

In accordance with order status matrices.

ordStatus

M

0 New

1 Partially Filled

2 Filled

4 Cancelled

8 Rejected

E Pending replace

9 Suspended

In accordance with order status matrices.

side

M

1 Buy

2 Sell


ordType

M

Integer

1 Market

2 Limit

3 Stop


price

C

Decimal

Conditionally required for limit orders.

orderQty

M

Decimal

In accordance with order status matrices.

leavesQty

M

Decimal

In accordance with order status matrices.

cumQty

M

Decimal

In accordance with order status matrices.

execId

M

String / Guid

Unique identifier of the execution message within a 24-hour range

lastQty

C

Decimal

In accordance with order status matrices.

Conditionally required when ExecType is Trade.

lastPx

C

Decimal

Conditionally required when ExecType is Trade.

calculatedCcyLastQty

C

Decimal

Net payment of the fill, not including commission.

Conditionally required when ExecType is Trade.

netMoney

C

Decimal

Gross amount of the fill, including commission.

Conditionally required when ExecType is Trade.

transactTime

M

Long — Unix timestamp in nanoseconds

Timestamp of the event.

lastLiquidityInd

C

1 AddedLiquidity

2 RemovedLiquidity

Conditionally required when ExecType is Trade.

commission

O

Decimal


commCurrency

O

String


account

M

Integer


currency

M

String

Pair base currency

settlCurrency

M

String

Pair quote currency

settlType

M

1 Cash (TOD / T+0)


positionId

M

Integer


marginAmt

M



marginAmtType

M

11 — Initial Margin


Repeating group SLTP (5000)

ordType

M

2 — Limit (take-profit)

3 — Stop (stop-loss)

Limit orders are considered take-profit orders

Market orders are considered stop-loss orders

price

C


Required for take-profit orders

stopPx

C


Required for stop-loss orders

pegOffsetValue

C

Decimal

For trailing stop and attempt zero loss orders

pegPriceType

C

8 — TrailingStopPeg

For trailing stop and attempt zero loss orders

pegOffsetType

C

2 — BasisPoints

For trailing stop and attempt zero loss orders

capPrice

C

Price

For trailing stop orders — empty

For attempt zero loss orders — stop-loss price limit. If CapPrice = 0, CapPrice = Open price


POST Cancel order

POST https://api.xena.exchange/trading/order/cancel


Body

{  
   "account":1012833743,
   "clOrdId":156811081333580288,
   "msgType":"F",
   "orderId":"e283a361-f92c-410f-8aef-417be66bdfee",
   "origClOrdId":"1568108020708475447",
   "side":"2",
   "symbol":"XBTUSD",
   "transactTime":156810138025300000
}


Response

{  
   "msgType":"8",
   "account":1012833743,
   "clOrdId":"156828905906988640",
   "origClOrdId":"38kw0Le2o",
   "orderId":"cb66271f-fdb2-41b0-9df9-663369346cce",
   "symbol":"XBTUSD",
   "ordType":"2",
   "price":"9200",
   "transactTime":1568289059332770091,
   "execId":"5b5e020c54b44cb56150f080c90fdad9c0ea2045",
   "execType":"4",
   "ordStatus":"4",
   "side":"1",
   "orderQty":"1",
   "leavesQty":"0",
   "cumQty":"0",
   "lastQty":"0",
   "marginAmt":"0.00000544",
   "marginAmtType":"11"
}


Request parameters

Field

M/O/C

Type / possible values

Description

msgType

M

F (Order Cancel Request)


origClOrdId

C

String

One of these fields must be submitted.

orderId

C

String / Guid

clOrdId

M

String

ClOrdId must be unique within a moving frame of 24 hours.

side

M

1 Buy

2 Sell


symbol

M

String


transactTime

M

Long — Unix timestamp in nanoseconds


account

M

Integer



Response parameters

Field

 

Type / possible values

Description

msgType

M

8 (ExecutionReport)


orderId

M

String / Guid


clOrdId

M

String


origClOrdId

O

String

ClOrdId of the order being cancelled, if OrigClOrdId has been submitted in the request.

tradeId

C

String

Conditionally required when ExecType = Trade

symbol

M

String


execType

M

A PendingNew

0 New

F Trade

6 PendingCancel

4 Cancelled

E PendingReplace

D Reastated

5 Replaced

8 Rejected

9 Suspended

In accordance with order status matrices.

ordStatus

M

0 New

1 Partially Filled

2 Filled

4 Cancelled

8 Rejected

E Pending replace

9 Suspended

In accordance with order status matrices.

side

M

1 Buy

2 Sell


ordType

M

Integer

1 Market

2 Limit

3 Stop


price

C

Decimal

Conditionally required for limit orders.

orderQty

M

Decimal

In accordance with order status matrices.

leavesQty

M

Decimal

In accordance with order status matrices.

cumQty

M

Decimal

In accordance with order status matrices.

execId

M

String / Guid

Unique identifier of the execution message within a 24-hour range

lastQty

C

Decimal

In accordance with order status matrices.

Conditionally required when ExecType is Trade.

marginAmt

M

marginAmtType

M

11 — Initial Margin




POST Update/Replace order

POST https://api.xena.exchange/trading/order/replace


Body:

{  
   "account":1012833743,
   "clOrdId":"1111",
   "msgType":"G",
   "orderQty":"10",
   "orderId":"9ee35e2e-2dff-418d-9484-15fec38ea804",
   "side":"2",
   "symbol":"XBTUSD",
   "transactTime":1568101380253000000,
   "sltp":[  

   ]
}


Response:

{  
   "msgType":"8",
   "account":1012833743,
   "clOrdId":"156828988148386016",
   "origClOrdId":"2z1",
   "orderId":"9ee35e2e-2dff-418d-9484-15fec38ea804",
   "symbol":"XBTUSD",
   "ordType":"2",
   "price":"110330",
   "transactTime":1568289881784872327,
   "execId":"06209185-2c28-4758-b440-f5680ff76763",
   "execType":"E",
   "ordStatus":"0",
   "side":"2",
   "orderQty":"1",
   "leavesQty":"1",
   "cumQty":"0",
   "positionEffect":"O",
   "marginAmt":"0.00000046",
   "marginAmtType":"11"
}


Request parameters

Field

Tag

M/O/C

Type / possible values

Description

msgType

H / 35

M

G (Order Cancel Replace Request)


origClOrdId

41

C

String

One of these fields must be submitted.

orderId

37

C

String

clOrdId

11

M

String

ClOrdId must be unique within a moving frame of 24 hours.

side

54

M

1 — Buy

2 — Sell


symbol

55

M

String


transactTime

60

M

Long — Unix timestamp in nanoseconds


account

1

M

Integer


orderQty

38

O

Decimal


price

44

C

Decimal

For limit orders only

stopPx

99

C

Decimal

For stop and limit orders only

capPrice

1199

C

Decimal

For trailing stop orders and attempt zero loss orders only

Repeating group SLTP (5000)


Response parameters

See New order Response parameters


POST Mass order cancel

POST https://api.xena.exchange/trading/order/mass-cancel


Body:

{
            "msgType": "q",
            "clOrdId": 'myClOrdId_4',
            "massCancelRequestType": "7",
            "account": 1012833742,
            "symbol": "XBTUSD"
}

Response:


{  
     "msgType":"r",
     "clOrdId":"myClOrdId_4",
     "massActionReportID":"60570e01-7223-465db29b4608f144febd",
     "massCancelResponse":"7",
     "symbol":"XBTUSD",
     "transactTime":1574949039076937249,
     "totalAffectedOrders":12,
     "account":1012833742
}



Request parameters

Field
Tag
Type / possible values
Description
msgType
H/35
q(Order Mass Cancel Request)

MassCancelRequestType
530
1 - CancelOrdersForASecurity
7 - CancelAllOrders

Symbol
55
string
Required if MassCancelRequestType == 1
Side
54
1 — Buy
2 — Sell
Optional. If submitted, cancel orders only for the specified side
PositionEffect
77
D — Default
O — Open
Optional, ‘D’ is the default.‘D’ cancels all active orders
‘O’ cancels only orders without PositionEffect == Close
Account
1
uint64
Mandatory
ClOrdID
11
string
Unique ID of request


Response parameters

Field
Tag
Type / possible values
Description
msgType
H/35
r(Order Mass Cancel Report)

ClOrdID
11
ID of Order Mass Cancel Request

MassActionReportID
1369
string
Report ID
MassCancelResponse
531
0 — CancelRequestRejected
1— CancelOrdersForASecurity
7 — CancelAllOrders

MassCancelRejectReason
532
0 — MassCancelNotSupported (for spot trading)
1 — InvalidOrUnknownSecurity
10 — InvalidAccount
99 - Other

RejectText
1328

Reject reason description
Symbol
55
string
If provided in original request
Side

54
1 — Buy
2 — Sell
If provided in original request
TransactTime
60
timestamp

TotalAffectedOrders

533
int
Quantity of cancelled orders