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).

[
  CHAN_ID, 
  TYPE, // 'ps'
  [
    [
      SYMBOL, 
      STATUS, 
      AMOUNT, 
      BASE_PRICE, 
      MARGIN_FUNDING, 
      MARGIN_FUNDING_TYPE,
      PL,
      PL_PERC,
      PRICE_LIQ,
      LEVERAGE,
      FLAG,
      POSITION_ID,
      MTS_CREATE,
      MTS_UPDATE,
      PLACEHOLDER,
      TYPE,
      PLACEHOLDER,
      COLLATERAL,
      COLLATERAL_MIN,
      META
    ], 
    ...
  ]
]
  
[0,"ps",[["tETHUST","ACTIVE",0.2,153.71,0,0,null,null,null,null,null,142420429,null,null,null,0,null,0,null,{"reason":"TRADE","order_id":34934099168,"order_id_oppo":34934090814,"liq_stage":null,"trade_price":"153.71","trade_amount":"0.2"}]]]
[
  CHAN_ID, 
  TYPE, // <‘pn’, ’pu’, ‘pc’>
  [
      SYMBOL, 
      STATUS, 
      AMOUNT, 
      BASE_PRICE, 
      MARGIN_FUNDING, 
      MARGIN_FUNDING_TYPE,
      PL,
      PL_PERC,
      PRICE_LIQ,
      LEVERAGE,
      FLAG,
      POSITION_ID,
      MTS_CREATE,
      MTS_UPDATE,
      PLACEHOLDER,
      TYPE,
      PLACEHOLDER,
      COLLATERAL,
      COLLATERAL_MIN,
      META
  ]
]

[0,"pu",["tETHUST","ACTIVE",0.2,153.71,0,0,-0.07944800000000068,-0.05855181835925015,67.52755254906451,1.409288545397275,null,142420429,null,null,null,0,null,0,0,{"reason":"TRADE","order_id":34934099168,"order_id_oppo":34934090814,"liq_stage":null,"trade_price":"153.71","trade_amount":"0.2"}]]

Stream Fields

TermTypeDescription
CHAN_IDintIdentification number for the channel subscribtion. Position events are always sent through the account information channel with CHAN_ID = 0
TYPEstring'ps' (position snapshot), 'pn' (position new), 'pu' (position update), 'pc' (position close)
SYMBOLstringPair (tBTCUSD, …).
STATUSstringStatus (ACTIVE, CLOSED).
±AMOUNTfloatSize of the position. Positive values means a long position, negative values means a short position. 0 means position closed.
BASE_PRICEfloatThe price at which you entered your position.
MARGIN_FUNDINGfloatThe amount of funding being used for this position.
MARGIN_FUNDING_TYPEint0 for daily, 1 for term.
PLfloatProfit & Loss
PL_PERCfloatProfit & Loss Percentage
PRICE_LIQfloatLiquidation price ('null' if the value is not updated yet (see notice below))
LEVERAGEfloatBeta value
POSITION_IDintPosition ID
MTS_CREATEintMillisecond timestamp of creation
MTS_UPDATEintMillisecond timestamp of update
TYPEintIdentifies the type of position, 0 = Margin position, 1 = Derivatives position
COLLATERALfloatThe amount of collateral applied to the open position
COLLATERAL_MINfloatThe minimum amount of collateral required for the position
METAjson stringAdditional meta information about the position

📘

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.