Overview
Instead of repeatedly calling the REST API to check for updates, you can open a Socket.IO connection and have PHS push data to you the moment it changes. This is the recommended way to build:- A live-updating priceboard
- Real-time order status tracking (placed / matched / cancelled / amended)
- Live buying power and portfolio updates
These two connections use different hosts, paths, and message formats. Mixing them up is the most common integration mistake — see Troubleshooting below.
Prerequisites
- A Socket.IO client library. The examples below use
socket.io-clientfor Node.js. - For the Order / Asset connection, an
access_tokenfrom the login endpoint. - Your trading sub-account number, for subscribing to your own order/asset updates.
Connection 1: Market Data
Connects to PHS’s market data gateway and streams live price ticks for any symbol you subscribe to. No authentication required.socket.emit("subscribe", ...) again with a different symbol in the topic string. To stop watching a symbol, use the same topic string with socket.emit("unsubscribe", ...).
Connection 2: Order / Asset
Connects to PHS’s account gateway and streams updates about your own orders, buying power, and portfolio. Requires youraccess_token.
Understanding account events
All account-related updates — order changes, buying power changes, and portfolio changes — arrive through the same account event. There is no separate OM, CI, or SE event name. Instead, look at the eventtype field inside the payload to know what kind of update you received:
Field reference
The tables below cover the most commonly used fields. Field names are intentionally short (legacy naming) — this is your lookup table.instrument fields (market data)
trade fields (matched trades)
account fields when eventtype = OM (underlying) or OO (derivatives)
Underlying (FLEX) and derivatives (FDS) accounts use slightly different field names for the same concept (e.g.
orderprice vs. order_price). Match the field names to your account type.Troubleshooting
Best practices
- Keep
access_tokenand any client secrets on your server, never in browser-side JavaScript. - Call
unsubscribefor symbols or accounts you no longer need to reduce unnecessary traffic. - Use a single connection per gateway and subscribe to multiple topics on it, rather than opening a new connection per symbol.
- Never commit real tokens into source control — treat a leaked token the same as a leaked password.
