Positions Channel
Topic: positions:{user_id}
Delivers your positions as they change. Money arrives as dollar strings and contract counts as quantity strings; see Wire format.
Position object
Section titled “Position object”Identity
Section titled “Identity”id: The unique id of the position record.account_id: The id of the account the position belongs to.market_id: The id of the market the position is on.event_id: The id of the event the market is attached to.
Exposure
Section titled “Exposure”position: The account’s net position in the market: positive if long (bought), negative if short (sold). A quantity string.premium: The total premium paid or received for the open portion of the position.average_open_premium: The average premium per contract for the open portion.buy_order_liability: The liability from the account’s open buy orders on this market.sell_order_liability: The liability from the account’s open sell orders on this market.position_premium_liability: The liability from the position’s premium that counts against available balance. Routinely negative.
Risk and potential
Section titled “Risk and potential”max_risk: The account-level risk on the position, netting in already settled profit and loss.open_risk: The risk on the position’s currently open (unsettled) contracts; this is what’s shown as “Risk” in the app.max_potential_profit: The total possible profit for the position if everything settles favorably.open_potential_profit: The possible profit on the position’s open contracts.max_potential_fee: The total potential fee across the position’s settlements.open_potential_fee: The potential fee on the position’s open contracts when they settle.
Realized
Section titled “Realized”total_settlement_pnl: The profit or loss the account has realized from settlements so far.gross_pnl:total_settlement_pnlplus any pending-close profit or loss that hasn’t settled yet.total_fee: The total fees paid across the position’s settlements.contracts_settled: The number of contracts settled in the position so far. A quantity string.
Combination
Section titled “Combination”multiplier: For a combination position, what it pays per dollar risked: the max price over the buy-side average fill, floored to two places. A JSON number, not a string, because it is a ratio, not money.nullfor any market that is not a combination.
Use Cases
Section titled “Use Cases”| Use case | Message to send |
|---|---|
| Join and receive your open positions | ["3","3","positions:<user_id>","phx_join",{}] |
| Join filtered to one market (see filtering) | ["3","3","positions:<user_id>","phx_join",{"market_ids":["<uuid>"]}] |
| Change the market filter without rejoining | ["3","4","positions:<user_id>","select_market_ids",{"market_ids":null}] |
| Check the connection is alive | ["3","5","positions:<user_id>","ping",{}] |
Joining
Section titled “Joining”["3","3","positions:<user_id>","phx_join",{}]{"status":"ok","response":{"selected_market_ids":null}}Initial response after joining
Section titled “Initial response after joining”[null, null, "positions:e6528824-b4e0-4ff8-bd70-36e5904738d1", "all_positions", { "positions": [Position]}]positions is a list of Position objects, described above, ordered by position
descending, empty if you have none open, and also empty when a market_ids filter
matches nothing.
[ null, null, "positions:e6528824-b4e0-4ff8-bd70-36e5904738d1", "all_positions", { "positions": [ { "id": "e00651a3-10cb-4bc1-9e1f-c5ea1796c83b", "account_id": "28417940-ecef-40a9-8816-cc055d7d846f", "market_id": "e00651a3-10cb-4bc1-9e1f-c5ea1796c83b", "event_id": "24636b3d-f566-4dd3-8c8b-c1a6c2747789", "position": "40.00", "premium": "-23.2000", "average_open_premium": "-0.5800", "buy_order_liability": "34.8000", "sell_order_liability": "0.0000", "position_premium_liability": "-23.2000", "max_risk": "23.2000", "open_risk": "23.2000", "max_potential_profit": "16.8000", "open_potential_profit": "16.8000", "max_potential_fee": "0.9800", "open_potential_fee": "0.0000", "total_settlement_pnl": "0.0000", "gross_pnl": "0.0000", "total_fee": "0.9800", "contracts_settled": "0.00", "multiplier": null } ] }]Pushed when the account’s positions change
Section titled “Pushed when the account’s positions change”[null, null, "positions:e6528824-b4e0-4ff8-bd70-36e5904738d1", "updated_positions", { "positions": [Position]}]This event is a delta: it carries only the positions that changed, not your
whole book. When a market_ids filter is active and none of the changed positions
match it, no frame is sent at all rather than one carrying an empty list.
[ null, null, "positions:e6528824-b4e0-4ff8-bd70-36e5904738d1", "updated_positions", { "positions": [ { "id": "e00651a3-10cb-4bc1-9e1f-c5ea1796c83b", "account_id": "28417940-ecef-40a9-8816-cc055d7d846f", "market_id": "e00651a3-10cb-4bc1-9e1f-c5ea1796c83b", "event_id": "24636b3d-f566-4dd3-8c8b-c1a6c2747789", "position": "70.00", "premium": "-40.6000", "average_open_premium": "-0.5800", "buy_order_liability": "17.4000", "sell_order_liability": "0.0000", "position_premium_liability": "-40.6000", "max_risk": "40.6000", "open_risk": "40.6000", "max_potential_profit": "29.4000", "open_potential_profit": "29.4000", "max_potential_fee": "1.7100", "open_potential_fee": "0.0000", "total_settlement_pnl": "0.0000", "gross_pnl": "0.0000", "total_fee": "1.7100", "contracts_settled": "0.00", "multiplier": null } ] }]Docs version v1.10.5

