Subscribing to the position updates provides real-time data on changes and status of the positions held by the account.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "portfolio.position_updates.subscribe",
  "params":{}
}

Parameters:

  • with_snapshot: Whether to include the snapshot in the response. It may incur additional API credit spending.
  • from_block_id: Specifies the block from which to start sending the events. See more information about this in the Managing Data Integrity section.

Snapshots

The snapshot format is the same as v1/portfolio/positions endpoint response. Upon subscription, the list of the positions is provided:

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "portfolio.position_updates.snapshot",
  "params": {
    "data": {
      "positions": [
        {
          "average_entry_price": "5000.00",
          "contract": "BTC-24MAR24",
          "deleverage_rank": "0.55",
          "liquidation_price": "4590",
          "net_value": "120000",
          "quantity_contracts": "10",
          "quantity_assets": "0.01",
          "quantity_steps": "1000",
          "quantity_quote": "6000",
          "unrealized_profit": "20000"
        }
      ]
    }
  }
}

Events

The events format is the same as v1/portfolio/history/positions endpoint response.

{
    "jsonrpc": "2.0",
    "method": "portfolio.position_updates.event",
    "params": {
        "data": {
            "average_entry_price": "2250",
            "contract_id": 6,
            "contract_info": {
                "contract_id": 6,
                "delivery_date": "2024-09-17T00:00:00Z",
                "lot_decimals": -2,
                "name": "ETH",
                "symbol": "ETH-17SEP24"
            },
            "entry_price": "2255",
            "exit_price": "0",
            "fees": "0",
            "new_size": "1.98",
            "quantity": "2",
            "quantity_contracts": "2",
            "quantity_assets": "2",
            "quantity_steps": "200",
            "realised_profit": "0",
            "side": "sell",
            "total_fee": "0",
            "tx_info": {
                "block_timestamp": "2024-09-06T15:41:15Z",
                "event_id": "699091-4",
                "transaction_hash": "0x4d5126ddcafd63b04bb447f9931844d2c8d04c267f7381c2893a56dd293ac47d"
            },
            "type": "position_increased"
        }
    }
}