Active positions
The Active Positions Channel delivers information to the subscriber on a position an account holds in an active market.
[TOC]
ActivePosition JSON Schema
Section titled “ActivePosition JSON Schema”{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://bet_stack.com/active_trade_schema", "title": "ActivePosition", "type": "object", "description": "Information on a position in the active positions channel", "properties": { "market_id": { "description": "The unique id of the market the trade that was settled was on.", "type": "string", "format": "uuid" }, "position": { "description": "The position of the user which will be positive if long and negative if short.", "type": "number", "format": "integer" }, "premium": { "description": "The premium paid to acquire the position.", "type": "number", "format": "integer", "minimum": 1 }, "buy_order_liability": { "description": "The liability of all outstanding buy orders.", "type": "number", "format": "integer", "minimum": 0 }, "sell_order_liability": { "description": "The liability of all outstanding sell orders.", "type": "number", "format": "integer", "minimum": 0 }, "position_premium_liability": { "description": "The liability resulting from the position's premium.", "type": "number", "format": "integer", "minimum": 0 } }}Joining
Section titled “Joining”["3","3","active_positions:{{UID}}","phx_join", ""]
Initial Response After Joining
Section titled “Initial Response After Joining”[ null, null, "active_positions:fbNZHhLfj8Ts2jxDczSQrOEBSdg1", "all_positions", { "positions": [ActivePosition] }]Example:
[ null, null, "active_positions:fbNZHhLfj8Ts2jxDczSQrOEBSdg1", "all_positions", { "positions": [ { "market_id": "687e9cdb-a391-4118-aa80-1122bb14779f", "position": -70, "premium": 3500, "buy_order_liability": 0, "sell_order_liability": 0, "position_liability": 2100, "position_premium_liability": -3500, "market_value": -4900, "unrealized_pnl": -1400 } ] }]Push updates with new data
Section titled “Push updates with new data”[ null, null, "active_positions:fbNZHhLfj8Ts2jxDczSQrOEBSdg1", "updated_positions", { "positions": [Activeposition] }]Example:
[ null, null, "active_positions:cW7UI52lToTDbIEYaXAFtqYYaZB2", "new_positions", { "positions": [ { "market_id": "687e9cdb-a391-4118-aa80-1122bb14779f", "position": -70, "premium": 3500, "buy_order_liability": 0, "sell_order_liability": 0, "position_liability": 2100, "position_premium_liability": -3500, "market_value": -4900, "unrealized_pnl": -1400 } ] }]
