Market Data streaming
Receive each change as the venue publishes it, over SignalR. The REST endpoints return a value as it stands when you ask; this hub pushes Level 1 quotes, trades and Level 2 depth as they happen.
At a glance
| Scope | marketdata-read |
| Staging | https://stage-stream.openmarkets.com.au/v1/market-data/hubs/marketdata |
| Production | https://stream.openmarkets.com.au/v1/market-data/hubs/marketdata |
| Protocol | SignalR JSON over WebSockets |
Connect to the stream host. It is built for streaming and holds a connection open for as long as your client wants it, up to the hour its token lasts.
The stream host is new. Hold its URL in configuration rather than in code, and confirm it with your integration contact before you go live. We will tell you ahead of any change.
The same hub also answers on the API host, as a fallback for a client that can only reach that one host:
| Environment | Fallback hub URL |
|---|---|
| Staging | https://stage-api.openmarkets.com.au/v1/market-data/hubs/marketdata |
| Production | https://api.openmarkets.com.au/v1/market-data/hubs/marketdata |
Both take the same token and the same subscriptions and carry the same data, but the network in front of the API host closes long-lived connections on its own schedule, so a client there reconnects far more often. Use the stream host unless you cannot reach it.
Connect with the negotiate step skipped. The hub runs on more than one server, and a negotiated connection relies on an affinity cookie to reach the server holding it. A client that drops that cookie reaches another server, which answers 404 No Connection with that ID. Safari, any browser on iPhone or iPad, private windows, browsers blocking third party cookies, and signalrcore for Python all drop it. Skipping negotiation makes the connection one request to one server, which starts reliably everywhere.
How it works
- Request a token with the
marketdata-readscope. - Build a hub connection against the URL above, supplying an access token provider and skipping negotiation.
- Register handlers for every event you care about, including
ReceiveMessage. - Start the connection.
- Invoke a subscribe method for each symbol or venue you want.
Register handlers before you start. A subscribe sends its snapshot before the invoke completes, so a handler registered afterwards misses it.
Establishing a connection
const connection = new signalR.HubConnectionBuilder()
.withUrl("https://stage-stream.openmarkets.com.au/v1/market-data/hubs/marketdata", {
accessTokenFactory: () => getAccessToken(),
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets,
})
.withAutomaticReconnect({
nextRetryDelayInMilliseconds: (ctx) => Math.min(30000, 1000 * 2 ** ctx.previousRetryCount),
})
.build();
var connection = new HubConnectionBuilder()
.WithUrl("https://stage-stream.openmarkets.com.au/v1/market-data/hubs/marketdata", options =>
{
options.AccessTokenProvider = async () => await GetAccessTokenAsync();
options.SkipNegotiation = true;
options.Transports = HttpTransportType.WebSockets;
})
.WithAutomaticReconnect(new RetryForever())
.Build();
// Retries for as long as the client runs, backing off to one attempt every 30 seconds.
sealed class RetryForever : IRetryPolicy
{
public TimeSpan? NextRetryDelay(RetryContext context) =>
TimeSpan.FromSeconds(Math.Min(30, Math.Pow(2, context.PreviousRetryCount)));
}
connection = (
HubConnectionBuilder()
.with_url(
"https://stage-stream.openmarkets.com.au/v1/market-data/hubs/marketdata",
options={"access_token_factory": get_access_token, "skip_negotiation": True},
)
.build()
)
signalrcore for Python reconnects with the token from the first start(), which lasts an hour. Run the reconnect loop yourself so each start() calls access_token_factory and sends a current token. The full loop is in the REST reference under Connecting.
Providing an access token
The hub takes the same bearer token as the REST endpoints, issued through the client credentials grant.
| Environment | Token endpoint |
|---|---|
| Staging | https://stage-identity.openmarkets.com.au/connect/token |
| Production | https://identity.openmarkets.com.au/connect/token |
With negotiation skipped the client sends the token on the WebSocket request itself: as the access_token query parameter from a browser, and as an Authorization header from the .NET, Node.js and Python clients. Pass it through your client's token option and it picks the right one per transport.
The hub closes a connection when the token it connected with expires, so a connection lasts an hour at most. Every reconnect presents a token afresh and the hub answers 401 to an expired one, so return a current token from your token factory rather than the one you started with: it runs on every connect.
Feeds
Four feeds share one connection.
| Feed | Subscribe with | Events |
|---|---|---|
| Level 1 quotes | SubscribeToSymbol for a symbol, SubscribeToAll for a venue | ReceiveMarketData, the full current quote on every update |
| Trades | SubscribeToTrades for a symbol, SubscribeToAllTrades for a venue | ReceiveTradesSnapshot once, then ReceiveTrade per print and per cancel |
| Level 2 by price | SubscribeToMarketByPrice | ReceiveL2Data once, then ReceiveL2Delta per changed level |
| Level 2 by order | SubscribeToMarketByOrders | ReceiveL2OrderBook on subscribe, then ReceiveL2Order per changed order |
Take market by price for a depth ladder, and market by order to see individual queue position. They are independent subscriptions and you can hold both.
Subscribing
SubscribeToSymbol(dataMode, symbol, mic)
SubscribeToAll(dataMode, mic)
SubscribeToTrades(dataMode, symbol, mic)
SubscribeToAllTrades(dataMode, mic)
SubscribeToMarketByPrice(symbol, mic)
SubscribeToMarketByOrders(symbol, mic)
Each has a matching UnsubscribeFrom... method. dataMode is LIVE or DELAYED, each entitled separately, and a message carries the same shape in either mode, so hold one mode per connection. symbol is the exchange ticker in any letter case, and mic is the venue.
Level 2 methods take the symbol and MIC alone, because Level 2 is live data.
SubscribeToAll sends one message per symbol on the venue, which on ASX is thousands of messages in the first second. Size your handler for it, or subscribe per symbol instead.
Venues
Every method takes the venue as its last argument, as an ISO 10383 MIC.
| MIC | Venue | Also accepted |
|---|---|---|
XASX | ASX | ASX, AXW |
CHIA | Cboe Australia | CXA |
AUS | ASX and Cboe Australia combined, the equivalent of V1's AUX |
Pass the MIC. The alternatives resolve to the same venue and the MIC is what comes back on every payload. AUS combines two venues, so a subscribe on it needs the permission on both XASX and CHIA, and it serves Level 1 only. Trades are stored per venue, so a trade subscribe on AUS replies on ReceiveMessage with the venues to request instead.
Indices and indicative values
Beside the listed securities, XASX serves three families of reference codes at Level 1. SubscribeToSymbol("LIVE", "XJO", "XASX") streams the S&P/ASX 200 level as it moves.
| Codes | What they are | Example |
|---|---|---|
X… | S&P/ASX index levels | XJO S&P/ASX 200, XAO All Ordinaries, XVI S&P/ASX 200 VIX |
Y… | Indicative values (iNAV) of ASX exchange-traded funds: the ETF code with a Y prefix | YSTW for STW |
OX… | Variants of index codes as FactSet publishes them | OXJO |
These carry their level in lastTradedPrice, with the bid and ask fields at 0, and index volume reads in shares. An indicative value is a reference level for the fund, not something you trade: trade the ETF under its own code.
Permissions
A valid token connects you. Each subscribe is then checked against a permission held per venue, and a subscribe beyond your permissions replies on ReceiveMessage while the stream stays quiet. Handle that event from the start.
| Subscribe method | Permission required |
|---|---|
SubscribeToSymbol / SubscribeToAll with LIVE | streaming-live |
SubscribeToSymbol / SubscribeToAll with DELAYED | streaming-delayed |
SubscribeToTrades / SubscribeToAllTrades with LIVE | streaming-live |
SubscribeToTrades / SubscribeToAllTrades with DELAYED | streaming-delayed |
SubscribeToMarketByPrice | streaming-live-l2 |
SubscribeToMarketByOrders | streaming-live-l2 |
Permissions are granted per client per venue, so a grant still to be added shows up as a quiet stream rather than an error.
The hub re-checks your permissions about once a minute while you stay subscribed, and reports the outcome on ReceiveMessage. Handle all three, since the middle one is recoverable and the first is not:
| Message | What happened | What to do |
|---|---|---|
Permission withdrawn: unsubscribed from ... | The permission is gone. Takes effect within about two minutes. | Subscribe again once it is granted again. |
Permission could not be confirmed: unsubscribed from ... | A check has been failing for five minutes, so the hub paused the subscription. | Nothing. The hub keeps checking. |
Permission confirmed again: resubscribed to ... | A paused subscription is streaming again, restored by the hub. | For Level 2, rebuild the book. |
You get one message per subscription, and your other subscriptions keep streaming throughout. A restored Level 2 subscription also receives ReceiveL2BookReset with reason subscription_restored, so take a fresh snapshot as you would for any reset. A paused subscription whose permission turns out to be withdrawn stays removed.
Treat a pause as recoverable: a client that tears down and rebuilds its connection on Permission could not be confirmed does more work than it needs to.
Events
Register every event before calling start(), so the snapshot that follows a subscribe has somewhere to land.
| Event | Sent when |
|---|---|
ReceiveMarketData | The current Level 1 quote for a symbol: once as the subscribe snapshot, then once per update |
ReceiveL2Data | The full price ladder, sent once on subscribe |
ReceiveL2Delta | A single price level changed |
ReceiveL2Order | A single order was added, changed or removed |
ReceiveL2OrderBook | The resting orders for a symbol, as a bounded run of chunks |
ReceiveL2BookReset | A symbol's book was rebuilt, so your copy of it is finished |
ReceiveTradesSnapshot | Today's stored prints for a symbol, sent once on SubscribeToTrades |
ReceiveTrade | One trade print, or one cancel of an earlier print, as it happens |
ReceiveMessage | A subscribe confirmation, a validation message, a permission refusal, or a removed subscription, as a string |
ReceiveMessage carries plain English text meant for a developer reading a log. Treat it as a diagnostic aid and drive your logic from the data events.
Keeping your copy correct
The two levels position themselves differently, and this is the part worth getting right.
Level 1 carries state. Every message holds the complete current quote, so the latest message you hold for a symbol is its full current state. Keep the newest message per symbol by comparing adapterTimestamp as a parsed time: a newer one replaces your copy, an equal one is the same update arriving twice and is harmless, an older one describes state you have already passed. A run of older stamps on one symbol means re-subscribing and telling us.
Level 2 is built from deltas, so a skipped frame leaves your book wrong. ReceiveL2Data and ReceiveL2Delta both carry epoch and seq. Compare epoch for equality and seq for contiguity:
- Buffer every
ReceiveL2Deltafrom the moment you invoke the subscribe. - On
ReceiveL2Data, take the ladder and record itsepochandseq. - Drop buffered deltas at or below the snapshot's
seq, and apply the rest in order. - From then on, apply a delta when its
seqis one past your last and itsepochmatches.
A skipped seq or a changed epoch means re-subscribing for a fresh snapshot. ReceiveL2BookReset says the same thing sooner: discard your copy of that symbol's book and take a fresh snapshot.
Market by order reports epoch: 0 and seq: 0, so gap detection is unavailable on that feed for now. Use market by price for a book you need to be certain of.
Key your local book the way the server does: price levels by price, and orders by orderId. Keying by rank or array position drifts, because removing one level shifts every level beneath it.
Publishing hours
A quiet stream is far more often the clock than a fault, so check the time before you check your client.
| Sydney time, weekdays | What the stream does |
|---|---|
| 07:00 to 20:00 | Level 1 publishes. Covers the pre-open, continuous trading 10:00 to 16:00, and the closing auction matching by about 16:12. |
| 20:00 to 07:00 | The connection stays open and the stream goes quiet. Each symbol holds its 20:00 state, and a subscribe returns that as its snapshot. |
The overnight quiet is expected, not a dropped feed. The feed rolls each record for the next session overnight, and the rolled record is the first message after 07:00: open, high, low, the bid and ask fields and the day's running totals read 0, close moves to the previous session's closing price, lastTradedPrice still holds it, and status reads market_closed. Take it as the day opening blank ahead of the pre-open.
Judge the connection by its transport state, and the feed by whether messages arrive across symbols. One quiet symbol inside continuous trading is ordinary. A venue quiet on every symbol inside continuous trading is worth a re-subscribe and a message to us.
Handling reconnects
Every connection closes from time to time, so build reconnecting in from the start. A deploy closes connections, so does a server leaving as load falls, and so does the expiry of the token the connection was made with.
How often depends on which host you are on. On the stream host those three are the closes to expect: across a 19-hour staging test, every close came from a token expiry or a server event. On the API host the network in front of the hub also closes long-lived connections on its own schedule, after anywhere from a few minutes to a few hours and about once an hour on average.
Often the connection simply ends before any close message reaches your client.
After every close:
- Reconnect, and keep retrying for as long as your client runs. The default
withAutomaticReconnect()schedule stops after four attempts in about forty seconds, so pass a policy that keeps going. - Connect with a current token.
- Re-subscribe everything. Subscriptions live on the connection, so a reconnect leaves you connected with nothing flowing until you do.
connection.onreconnected(() => {
for (const symbol of mySymbols) {
connection.invoke("SubscribeToSymbol", "LIVE", symbol, "XASX");
connection.invoke("SubscribeToMarketByPrice", symbol, "XASX");
}
});
For Level 1, take the re-subscribe snapshot as your new copy. For Level 2, discard your book and rebuild from it. For trades, the snapshot covers only the last 50 prints, so fill the stretch you missed from GET /pricing/trades/{live,delayed}/{security}/v2 starting at the last tradeDateTime you hold, merging by tradeId.
Full reference
Every hub method, every event and every payload field is documented in the REST reference, from Market data streaming onward. The same text is served as plain text at /v1/market-data/docs/streaming.md for reading outside the docs.
Build against staging first. It carries the same contract as production.

