Realtime updates
The websocket at /v1/events: the handshake, the subscribe and unsubscribe messages, the topics, the events on each, and what to do after a reconnect.
A client that wants to follow a run, a download or a plan change as it happens opens one websocket to the engine and subscribes to the things it cares about. This page lists the messages in both directions, the topics you can subscribe to and the events each one carries.
The connection is a feed, not a control channel. You start, stop and read things over HTTP; the websocket tells you when something changed.
Connection
| Address | ws://127.0.0.1:8080/v1/events |
| Subprotocol | neurotrader.v1 |
| Token | auth.bearer.<token> as a second subprotocol value, or an Authorization: Bearer <token> header |
| Messages | JSON text frames |
| Refused handshake | HTTP 401 before the upgrade (403 for a browser origin that is not allowed) |
const socket = new WebSocket("ws://127.0.0.1:8080/v1/events", [
"neurotrader.v1",
`auth.bearer.${accessToken}`,
])The token is checked once, at the handshake. The connection is not closed when the token expires. See Authentication.
Right after the upgrade, before anything else, the engine sends a welcome
message:
{
"type": "welcome",
"connection_id": "9f3b2a10-4c1e-4d7a-8b52-6e0f3a9c7d14",
"heartbeat_interval_ms": 240000
}connection_id names this connection, for example in a problem report.
heartbeat_interval_ms is how often the engine expects to hear from you.
Client messages
Every message you send is a JSON object with an action.
action | Fields | Answer |
|---|---|---|
subscribe | topics: a list of topic ids | subscribed with the topics accepted, and one error with code unknown_topic for each topic that names nothing |
unsubscribe | topics: a list of topic ids | unsubscribed with every topic you sent, whether or not you were subscribed |
ping | None | pong |
{ "action": "subscribe", "topics": ["0d6c3f0e-5a55-4b0e-9a57-3f2a1b7c9e11"] }{ "action": "unsubscribe", "topics": ["0d6c3f0e-5a55-4b0e-9a57-3f2a1b7c9e11"] }{ "action": "ping" }A subscription is judged topic by topic: the topics that exist are subscribed even when others in the same message do not. A topic that is not a UUID at all makes the whole message invalid.
Send a ping at the interval the welcome message gave. A connection that
stays silent for longer than twice that interval may be closed.
Server messages
Every message you receive is a JSON object with a type. There are six, and
the set is closed: new kinds of update arrive as new event payloads, never
as new message types.
type | Fields | Meaning |
|---|---|---|
welcome | connection_id, heartbeat_interval_ms | Sent once, first. |
subscribed | topics | The topics a subscribe accepted. |
unsubscribed | topics | The topics an unsubscribe named. |
pong | None | The answer to ping. |
event | topic, timestamp, payload | Something happened on a topic you subscribed to. |
error | code, message, retryable | A message of yours was refused, or events were lost. |
Event message
{
"type": "event",
"topic": "0d6c3f0e-5a55-4b0e-9a57-3f2a1b7c9e11",
"timestamp": "2026-03-02T09:17:05.412Z",
"payload": {
"kind": "progress",
"run_id": "e2a9f6b4-0c3d-4e7a-9f15-8b6d2a4c7e90",
"value": 50.5
}
}timestamp is an ISO 8601 instant in UTC. What the event means is in
payload, and payload.kind names it. Ignore a kind you do not know:
that is how new events are added without breaking your client.
Error codes
code | retryable | Meaning |
|---|---|---|
invalid_message | false | The message is not valid JSON, names an unknown action, or carries a topic that is not a UUID. |
unknown_topic | false | The topic is a UUID that names nothing that exists. |
lagged | true | Your connection fell behind and some events were dropped. The feed continues. Read the current state over HTTP. |
Topics
A topic is the id of the thing you want to hear about. There is no list of topics to fetch: you already hold the id, because an HTTP response gave it to you.
| Topic | Id source | Content |
|---|---|---|
| A runner | The runner's id | The life of its runs: status, progress, messages |
| A live run | details.context of the start, or run_id of GET /v1/live/{id} | One step event per candle boundary |
| A download job | details.topic of POST /v1/repository | The download's progress |
| A plan change | details.topic of POST /v1/billing/session | The plan change's progress |
| The plugin catalog | The fixed id 6e757472-6164-6572-706c-7567696e7301 | Plugins added, loaded, built, removed |
A topic exists while the thing it names exists. A live run's topic exists only while the run is in progress, and a backtest has none: follow a backtest on its runner's topic.
Runner topic
Every event names the run it concerns as run_id.
kind | Fields | Meaning |
|---|---|---|
state_change | run_id, state | The runner's status changed. state is ready, running, paused or error. run_id is null when no run is concerned, as after a reset. |
progress | run_id, value | A backtest's progress, from 0 to 100. |
pulse | run_id, steps | A live run is alive and has taken this many steps. A live run has no end, so it has no percentage. |
update | run_id, message | A line of text for a status area, such as "Initializing data sources". A null message clears it. |
margin | run_id, algorithm, event, margin_level, equity, liabilities, amount | On a margin account: event is margin_call, margin_call_cleared, liquidation or bankruptcy. |
prelude | run_id, from, boundaries | A live run has loaded the recent candles it opens on, and GET /v1/live/{id}/data now serves them. |
stopped | run_id, disposition, cancelled, flattened, failed, left | A live run acted on its stop. The lists name the orders cancelled, closed, failed to close and left standing. |
condition | run_id, condition, at, message | Something a live run is up against. See the list below. |
When a run has to download market data before it starts, the download's
progress arrives on the runner's topic too: as update messages, and as the
download events listed under Download job topic.
The condition values:
condition | Meaning |
|---|---|
feed_disconnected, feed_reconnected | The market data connection dropped, or came back. |
feed_gap | The feed skipped candles. |
lag, lag_cleared | A boundary passed with no candle delivered, or the delay ended. |
disconnected, reconnected | The connection to the venue's trading interface dropped, or came back. |
venue_refusal | The venue refused a request. |
maintenance | The venue announced maintenance. |
rate_limited | The venue is limiting the engine's requests. |
discrepancy | What the venue reports differs from what the engine recorded. |
A condition that lasts produces one event when it begins and one when it
ends. A backtest never sends prelude, stopped or condition.
Live run topic
A live run publishes one step event per candle boundary on its own topic,
the run's id.
{
"kind": "step",
"run_id": "e2a9f6b4-0c3d-4e7a-9f15-8b6d2a4c7e90",
"timestamp": 1772443080000,
"candles": {
"1f8b39a6-6ed8-4557-babe-6fa3b2372e07": {
"open": 64210.5, "high": 64260.0, "low": 64188.1, "close": 64251.3,
"volume": 12.84
}
},
"algorithms": {
"5c1d9a7e-2b64-4f03-b8a9-71e0d3c6f482": {
"indicators": { "fast": 64190.2, "slow": null },
"account": {
"free": 10000.0, "frozen": 0.0, "total": 10000.0, "percent": 0.0,
"liabilities": 0.0, "margin_level": null
},
"decisions": [],
"orders": [],
"account_events": []
}
}
}candles is keyed by instrument id and algorithms by algorithm instance
id. An indicator that has not seen enough candles yet is null. candles
can be empty: a boundary passes even when no candle arrived in time.
A client that joins late reads what it missed from GET /v1/live/{id} and
the routes under it, then continues from the stream. See
Live simulations.
Download job topic
Every event carries a message ready to show, and the counters it was built
from.
kind | Fields besides message | Meaning |
|---|---|---|
requested | objects, present, ingesting | The download was accepted: how many months it covers, how many are ready, how many must be fetched. |
acquiring | completed, total | Months are being prepared by the data service. |
object_ready | series, month | One month is ready. |
object_unavailable | series, month, reason | One month does not exist at the provider. |
object_failed | series, month, retryable, reason | One month could not be prepared. |
downloaded | completed, total | Months stored on your computer so far. |
indexing | None | The engine is reading its local store. |
complete | objects, ready, unavailable, failed | The download ended. Read GET /v1/repository for what is stored now. |
failed | reason | The download could not run. |
complete and failed are the last event of a job.
Plan change topic
kind | Meaning |
|---|---|
session_opened | The payment page is ready to open. |
watching | The engine is waiting for the plan to change. |
changed | The plan changed, from one plan to another. |
plan_applied | The new plan is in effect on this device. |
licence_not_refreshed | The plan changed, but the new lease could not be obtained yet. |
timed_out | No change was seen in the time the engine waits. A change that lands later still takes effect. |
Plugin catalog topic
Every event carries plugin_id, name and a message.
kind | Meaning |
|---|---|
changed | A plugin was added, replaced or removed. Read GET /v1/plugin again. |
loaded | A plugin was loaded. |
unloaded | A plugin was unloaded. |
failed | A plugin could not be loaded. reason says why. |
build_started | The build of a linked project started. |
build_finished | The build ended. ok says whether it succeeded, and log_tail holds the end of the build log. |
End of a run
What you receive on the runner's topic when a run ends:
| The run | Events, in order |
|---|---|
| Reaches the end of its data | A last progress, an update while the results are saved, an update with a null message, then state_change to ready |
| Is stopped | The same, ending in state_change to ready. A live run sends stopped first. |
| Is paused | state_change to paused |
| Fails | state_change to error |
The state_change is the signal to read the result over HTTP. It does not
carry the result itself:
GET /v1/runner/{id}/run/{run_id}gives the run'soutcome:completed,cancelled,failedwith amessage, orinterrupted.readyalone does not tell a finished run from a stopped one. Theoutcomedoes.- A failed run leaves the runner in
error. Send"reset"toPOST /v1/runner/{simulation_id}/operateto return it toready.
Until the state_change arrives, the run routes answer 404 for that run.
Reconnection
The engine keeps nothing for a connection that has closed. After you reconnect:
- Open a new connection with a valid token. The token that opened the old connection may have expired since.
- Subscribe again. Subscriptions belong to the connection and are gone with it.
- Read the current state over HTTP. Events sent while you were away are not replayed.
| Subject | Read after reconnecting |
|---|---|
| A runner | GET /v1/runner/{id} for its status, GET /v1/runner/{id}/run for its runs |
| A live run | GET /v1/live/{id} and the routes under it |
| A download | GET /v1/repository/job/{id}, or GET /v1/repository/job for all of them |
| A plan change | GET /v1/billing/session/{session_id} |
| The plugin catalog | GET /v1/plugin |
Treat the websocket as a hint and the HTTP routes as the state. A client
built that way also handles the lagged error correctly: it reads the state
again and carries on.
A topic can stop existing while you are away. A finished live run's topic
answers unknown_topic on the new subscription, which tells you the run has
ended.
Related
- Authentication: the token and the handshake
- Errors: the HTTP error envelope and reason codes
- Run control
- Runs and statuses
eventsin the API reference
Authentication
The access token every request carries, the header and websocket forms, device enrolment, the entitlement lease, and the status codes of a refused request.
Errors
The error envelope of the HTTP API, the status codes in use, and the stable reason codes a client can branch on, grouped by area.