Skip to Content
NeurotraderDocs
Reference

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

Addressws://127.0.0.1:8080/v1/events
Subprotocolneurotrader.v1
Tokenauth.bearer.<token> as a second subprotocol value, or an Authorization: Bearer <token> header
MessagesJSON text frames
Refused handshakeHTTP 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.

actionFieldsAnswer
subscribetopics: a list of topic idssubscribed with the topics accepted, and one error with code unknown_topic for each topic that names nothing
unsubscribetopics: a list of topic idsunsubscribed with every topic you sent, whether or not you were subscribed
pingNonepong
{ "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.

typeFieldsMeaning
welcomeconnection_id, heartbeat_interval_msSent once, first.
subscribedtopicsThe topics a subscribe accepted.
unsubscribedtopicsThe topics an unsubscribe named.
pongNoneThe answer to ping.
eventtopic, timestamp, payloadSomething happened on a topic you subscribed to.
errorcode, message, retryableA 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

coderetryableMeaning
invalid_messagefalseThe message is not valid JSON, names an unknown action, or carries a topic that is not a UUID.
unknown_topicfalseThe topic is a UUID that names nothing that exists.
laggedtrueYour 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.

TopicId sourceContent
A runnerThe runner's idThe life of its runs: status, progress, messages
A live rundetails.context of the start, or run_id of GET /v1/live/{id}One step event per candle boundary
A download jobdetails.topic of POST /v1/repositoryThe download's progress
A plan changedetails.topic of POST /v1/billing/sessionThe plan change's progress
The plugin catalogThe fixed id 6e757472-6164-6572-706c-7567696e7301Plugins 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.

kindFieldsMeaning
state_changerun_id, stateThe runner's status changed. state is ready, running, paused or error. run_id is null when no run is concerned, as after a reset.
progressrun_id, valueA backtest's progress, from 0 to 100.
pulserun_id, stepsA live run is alive and has taken this many steps. A live run has no end, so it has no percentage.
updaterun_id, messageA line of text for a status area, such as "Initializing data sources". A null message clears it.
marginrun_id, algorithm, event, margin_level, equity, liabilities, amountOn a margin account: event is margin_call, margin_call_cleared, liquidation or bankruptcy.
preluderun_id, from, boundariesA live run has loaded the recent candles it opens on, and GET /v1/live/{id}/data now serves them.
stoppedrun_id, disposition, cancelled, flattened, failed, leftA live run acted on its stop. The lists name the orders cancelled, closed, failed to close and left standing.
conditionrun_id, condition, at, messageSomething 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:

conditionMeaning
feed_disconnected, feed_reconnectedThe market data connection dropped, or came back.
feed_gapThe feed skipped candles.
lag, lag_clearedA boundary passed with no candle delivered, or the delay ended.
disconnected, reconnectedThe connection to the venue's trading interface dropped, or came back.
venue_refusalThe venue refused a request.
maintenanceThe venue announced maintenance.
rate_limitedThe venue is limiting the engine's requests.
discrepancyWhat 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.

kindFields besides messageMeaning
requestedobjects, present, ingestingThe download was accepted: how many months it covers, how many are ready, how many must be fetched.
acquiringcompleted, totalMonths are being prepared by the data service.
object_readyseries, monthOne month is ready.
object_unavailableseries, month, reasonOne month does not exist at the provider.
object_failedseries, month, retryable, reasonOne month could not be prepared.
downloadedcompleted, totalMonths stored on your computer so far.
indexingNoneThe engine is reading its local store.
completeobjects, ready, unavailable, failedThe download ended. Read GET /v1/repository for what is stored now.
failedreasonThe download could not run.

complete and failed are the last event of a job.

Plan change topic

kindMeaning
session_openedThe payment page is ready to open.
watchingThe engine is waiting for the plan to change.
changedThe plan changed, from one plan to another.
plan_appliedThe new plan is in effect on this device.
licence_not_refreshedThe plan changed, but the new lease could not be obtained yet.
timed_outNo 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.

kindMeaning
changedA plugin was added, replaced or removed. Read GET /v1/plugin again.
loadedA plugin was loaded.
unloadedA plugin was unloaded.
failedA plugin could not be loaded. reason says why.
build_startedThe build of a linked project started.
build_finishedThe 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 runEvents, in order
Reaches the end of its dataA last progress, an update while the results are saved, an update with a null message, then state_change to ready
Is stoppedThe same, ending in state_change to ready. A live run sends stopped first.
Is pausedstate_change to paused
Failsstate_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's outcome: completed, cancelled, failed with a message, or interrupted.
  • ready alone does not tell a finished run from a stopped one. The outcome does.
  • A failed run leaves the runner in error. Send "reset" to POST /v1/runner/{simulation_id}/operate to return it to ready.

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:

  1. Open a new connection with a valid token. The token that opened the old connection may have expired since.
  2. Subscribe again. Subscriptions belong to the connection and are gone with it.
  3. Read the current state over HTTP. Events sent while you were away are not replayed.
SubjectRead after reconnecting
A runnerGET /v1/runner/{id} for its status, GET /v1/runner/{id}/run for its runs
A live runGET /v1/live/{id} and the routes under it
A downloadGET /v1/repository/job/{id}, or GET /v1/repository/job for all of them
A plan changeGET /v1/billing/session/{session_id}
The plugin catalogGET /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.

On this page