Skip to main content
Two WebSocket streams push an account’s activity as it happens, so you do not have to poll. Both work the same way for real and paper accounts. A stream sends only what happens after you connect. It has no snapshot and does not replay events you missed, so a correct client always pairs it with a REST read. The reconciliation pattern below shows how.

Check the host first

Read the account’s host from List hosts and check its capabilities before you connect. A stream the host does not support is refused with 422 NotSupported. See Host capabilities for how to read these entries.

Connect

Send the same X-API-KEY and X-API-SECRET headers you use for HTTP on the upgrade request. There is nothing to send after connecting: the account is in the path, and the server ignores any frames you send. With websocat:
With the Python websockets library, version 14 or later:
If the upgrade fails, for example because the credentials are wrong, the account does not exist or the host does not support the stream, you get an ordinary HTTP error response with the error envelope, before any WebSocket is opened. Treat it like the same error from an HTTP operation: fix the request rather than reconnecting in a loop. WebSocket ping and pong frames keep the connection alive; most client libraries answer pings for you.
Browser authentication is not supported. Browsers cannot set custom headers on a WebSocket upgrade, so connect from a server or a native client.

Messages

Every message is one JSON text frame with the same envelope: timestamp is when Plurex sent the event, and data is the payload.

Order events

Each order event carries the change that happened and the complete order, exactly as Get an order returns it:
Because every event carries the whole order, you do not need to rebuild state from the change. Store the latest order you receive for each order ID and use change to decide what to react to. New change types can be added, so handle an unrecognised type the same way as Unknown.

Transaction events

Each transaction event is one balance posting, with the same id that List account transactions returns for it:
amount is signed from your side: positive increases the balance, negative decreases it. Transaction events are ordered among themselves but not relative to order events, so a fee can arrive before or after the fill it belongs to. See Balances, positions and settings for posting types and links.

Keep a correct local copy

The streams promise no snapshot, no replay, no sequence numbers and no resume point. The pattern that stays correct anyway:
1

Connect first

Open the stream before reading anything. Events that arrive from now on are buffered by your client.
2

Read the current state

Page through List open orders (or recent transactions) until nextCursor is null. This is your starting copy.
3

Apply events on top

Apply buffered events, then live ones, in the order they arrive. For orders the newest event for an order ID replaces what you hold; drop an order from your open set once its state is Filled, Cancelled or Rejected. For transactions, add any posting whose id you do not have.
4

After any disconnect, do both again

Events sent while you were disconnected are gone. Reconnect, then read the REST state again and replace your copy.
Connecting before you read is what closes the gap: anything that changes after your REST read also arrives as an event, and because each event carries the complete order, applying an event on top of slightly newer REST data still ends on the latest state. This sketch keeps the set of open orders correct across reconnects. It uses websockets 14 or later and httpx:
The websockets client holds messages that arrive while you read the REST state, so they are applied after it, in order. The loop backs off on network failures and on 429 and 5xx responses, and stops on errors that need a fix. For transactions, the same loop works with ListTransactions in place of ListOpenOrders. Keep posting IDs you have seen, and after reconnecting re-read history a little further back than the newest posting you hold, so a posting that reached the host’s history late is not missed. The listTransactions capability’s defaultOrdering says whether history comes newest or oldest first.

Close codes

Any other disconnect, such as a network failure, is handled the same way: reconnect, then reconcile.

What a stream does not promise

  • No snapshot on connect, and no replay of missed events.
  • No sequence numbers or resume tokens. A gap is detected only by a disconnect.
  • No ordering between the order stream and the transaction stream.
  • No individual executions when includesFillDetails is false.
  • No browser authentication.