Positions

Receive a snapshot and updates for any position events on your account.

Subscribe to the account information channel to keep track of your positions. The account information channel provides a snapshot and updates on the positions in your account. The snapshot is delivered upon subscribing and any changes to your positions will be provided as updates for as long as the channel remains open. Any authenticated connection is automatically subscribed to the account information channel.

Example code to open an authenticated connection can be found on our Authenticated Channels Page.

Position events are sent with CHAN_ID = 0 and can be identified by looking at the TYPE stream field. Positions events will use one of the following abbreviations: 'ps' (positions snapshot), 'pn' (position new), 'pu' (position update), and 'pc' (position close).

[
  0, //CHAN_ID
  "ps", //TYPE
  [
    [
      "tETHUST", //SYMBOL
      "ACTIVE", //STATUS
      0.2, //AMOUNT
      153.71, //BASE_PRICE
      0, //MARGIN_FUNDING
      0, //MARGIN_FUNDING_TYPE
      null, //PL
      null, //PL_PERC
      null, //PRICE_LIQ
      null, //LEVERAGE
      null, //FLAGS
      142420429, //POSITION_ID
      null, //MTS_CREATE
      null, //MTS_UPDATE
      null, //PLACEHOLDER
      0, //TYPE
      null, //PLACEHOLDER
      0, //COLLATERAL
      null, //COLLATERAL_MIN
      {
        "reason":"TRADE",
        "order_id":34934099168,
        "order_id_oppo":34934090814,
        "liq_stage":null,
        "trade_price":"153.71",
        "trade_amount":"0.2"
      } //META
    ], //POSITION_ARRAY
    ...
  ] //POSITION_SNAPSHOT
]
[
  0, //CHAN_ID
  "pu", //MSG_TYPE
  [
    "tETHUST", //SYMBOL
    "ACTIVE", //STATUS
    0.2, //AMOUNT
    153.71, //BASE_PRICE
    0, //MARGIN_FUNDING
    0, //MARGIN_FUNDING_TYPE
    -0.07944800000000068, //PL
    -0.05855181835925015, //PL_PERC
    67.52755254906451, //PRICE_LIQ
    1.409288545397275, //LEVERAGE
    null, //FLAGS
    142420429, //POSITION_ID
    null, //MTS_CREATE
    null, //MTS_UPDATE
    null, //PLACEHOLDER
    0, //TYPE
    null, //PLACEHOLDER
    0, //COLLATERAL
    0, //COLLATERAL_MIN
    {
      "reason":"TRADE",
      "order_id":34934099168,
      "order_id_oppo":34934090814,
      "liq_stage":null,
      "trade_price":"153.71",
      "trade_amount":"0.2"
    } //META
  ] //POSITION_ARRAY
]

Position snapshot data

IndexFieldTypeDescription
[0]CHANNEL_IDIntIdentification number assigned to the channel for the duration of this connection.
[1]MSG_TYPEString'ps' (position snapshot)
[2]POSITION_SNAPSHOTArrayArray with an array of active positions (Indices [0...n] will be positions)
[2][0...n]POSITION_ARRAYArrayPosition array

Position update data

IndexFieldTypeDescription
[0]CHANNEL_IDIntIdentification number assigned to the channel for the duration of this connection.
[1]MSG_TYPEString'pn' (position new), 'pu' (position update), 'pc' (position close).
[2]POSITION_ARRAYArrayPosition array

Position arrays

Index Field Type Description
[0]SYMBOLStringPair (tBTCUSD, …).
[1]STATUSStringStatus (ACTIVE, CLOSED).
[2]AMOUNTFloatSize of the position. Positive values means a long position, negative values means a short position. 0 means position closed.
[3]BASE_PRICEFloatThe price at which you entered your position.
[4]MARGIN_FUNDINGFloatThe amount of funding being used for this position.
[5]MARGIN_FUNDING_TYPEInt0 for daily, 1 for term.
[6]PLFloatProfit & Loss
[7]PL_PERCFloatProfit & Loss Percentage
[8]PRICE_LIQFloatLiquidation price ('null' if the value is not updated yet (see notice below))
[9]LEVERAGEFloatFor derivative positions
[10]FLAGSIntSpecial flags for position
[11]POSITION_IDIntPosition ID
[12]MTS_CREATEIntMillisecond timestamp of creation
[13]MTS_UPDATEIntMillisecond timestamp of update
[ . . . ]
[15]TYPEIntIdentifies the type of position, 0 = Margin position, 1 = Derivatives position
[16]COLLATERALFloatThe amount of collateral applied to the open position
[17]COLLATERAL_MINFloatThe minimum amount of collateral required for the position
[18]METAJson stringAdditional meta information about the position including trade and order IDs

📘

NOTE

These messages have gained the ability to send the calculation values (liquidation price). If the value is equal to "null" this means that the newly calculated value is not yet available.

A calc request can be sent to request that the value be updated. See calc input dedicated section for more details.