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
Index | Field | Type | Description |
---|---|---|---|
[0] | CHANNEL_ID | Int | Identification number assigned to the channel for the duration of this connection. |
[1] | MSG_TYPE | String | 'ps' (position snapshot) |
[2] | POSITION_SNAPSHOT | Array | Array with an array of active positions (Indices [0...n] will be positions) |
[2][0...n] | POSITION_ARRAY | Array | Position array |
Position update data
Index | Field | Type | Description |
---|---|---|---|
[0] | CHANNEL_ID | Int | Identification number assigned to the channel for the duration of this connection. |
[1] | MSG_TYPE | String | 'pn' (position new), 'pu' (position update), 'pc' (position close). |
[2] | POSITION_ARRAY | Array | Position array |
Position arrays
Index | Field | Type | Description |
---|---|---|---|
[0] | SYMBOL | String | Pair (tBTCUSD, …). |
[1] | STATUS | String | Status (ACTIVE, CLOSED). |
[2] | AMOUNT | Float | Size of the position. Positive values means a long position, negative values means a short position. 0 means position closed. |
[3] | BASE_PRICE | Float | The price at which you entered your position. |
[4] | MARGIN_FUNDING | Float | The amount of funding being used for this position. |
[5] | MARGIN_FUNDING_TYPE | Int | 0 for daily, 1 for term. |
[6] | PL | Float | Profit & Loss |
[7] | PL_PERC | Float | Profit & Loss Percentage |
[8] | PRICE_LIQ | Float | Liquidation price ('null' if the value is not updated yet (see notice below)) |
[9] | LEVERAGE | Float | For derivative positions |
[10] | FLAGS | Int | Special flags for position |
[11] | POSITION_ID | Int | Position ID |
[12] | MTS_CREATE | Int | Millisecond timestamp of creation |
[13] | MTS_UPDATE | Int | Millisecond timestamp of update |
[ . . . ] | |||
[15] | TYPE | Int | Identifies the type of position, 0 = Margin position, 1 = Derivatives position |
[16] | COLLATERAL | Float | The amount of collateral applied to the open position |
[17] | COLLATERAL_MIN | Float | The minimum amount of collateral required for the position |
[18] | META | Json string | Additional 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.