Skip to main content
GET
TypeScript

Authorizations

Authorization
string
header
required

The Trading API key (trdrs_sk_…), for market data, orders and account state on the accounts its owner holds. Use it server-to-server, and keep it on your server. Its scope is named trading in the API.

Query Parameters

provider
string

The provider the account is at. Omit it to use your default provider.

account
string

The account number at that provider. It must be one of your own accounts.

after
string

The execId of the last execution report you received, so the stream sends the account's report events after it. An EventSource sends the same id as Last-Event-ID when it reconnects on its own, and that header wins when you send both.

watch
enum<string>
default:engine

Who follows changes made to the account outside trdrs, at the provider. engine (the default): trdrs reads the provider and sends a frame for each change it sees. client: you follow the provider yourself, as a provider whose publicAccountState is true lets you do, and the stream sends the frame it opens with and a frame for each change trdrs makes or reads, such as after an order you place through trdrs.

Available options:
engine,
client

Response

An open event stream. Each event's name is its event: line, and its data: line is the body.

  • account: the whole account at one revision. There is no separate snapshot event, because the first frame is simply the first. A row missing from a frame is closed or cancelled. A frame that skips revisions is still complete, so there is nothing to recover. Never work out a revision of your own. Protection is part of the account, so brackets comes in the same frame, at the same revision.
  • lock: whether the account is locked, why, and when it unlocks (the RiskLock model).
  • trading: what the account can trade (the AccountTrading model): whose markets it trades, its gates, and the match of every market in view, which is each market it holds or has a working order on and each one you asked about through GET /api/trading/match in the last half hour. It comes after the first account frame and again whenever any of it changes, with version one higher each time, so keep the one with the highest version. It is its own event because it changes while the account doesn't, such as when a venue halts new entries or a continuous future rolls. When its fingerprint changes, read GET /api/account/markets again. The markets you asked about on the account are kept for a week, and a stream that opens asks them again for you, so its first trading event carries the market you last looked at.
  • execution { accountId, execution }: one fill the ledger just recorded on this account, as GET /api/account/executions lists it. Read the route once for the fills before the stream, and add each event's fill by its id.
  • report: the account's execution reports, in the account's order (the ExecutionReportEvent model). { kind: "report", accountId, sequence, report } is one report, and its execId, the report's identity, is the event's id: line unless it is an order_status report. { kind: "status", accountId, sequence, reports } is the order_status report of every order that may still fill: replace what you hold of the account's orders with it. A stream that opens with the execId of your last report, as Last-Event-ID or after, sends every report after it; one that opens without one, or with one the account no longer keeps, sends a status first, and an open stream is sent a status whenever its reports could not be carried whole. An account sends report events once its execution reports are on, and none until then.
  • strategy: your live strategy instances, as GET /api/strategy-instances lists them. { kind: "list", instances } is the whole set, sent once after the first account frame; { kind: "instance", instance } is one instance whole after a change; { kind: "removed", id } names one that no longer exists. Instances are yours rather than one account's, so every stream of yours carries every instance.
  • error { code, message }: the stream is ending. provider_disconnected means the account couldn't be read when the stream opened, risk_resync_required that the risk state changed faster than the stream could send it or couldn't be followed, and session_expired that the session or key that opened the stream ended. Reconnect for the current account, after signing in again for session_expired.

The stream also carries alert and copier events for the trdrs app's own alerts and Trader Copier. Skip any event you don't use.

The stream may end with a reconnect event, { code, afterMs }: the engine serving it is restarting for a release, or the trader it serves moved to another engine, and the stream closes right after the event. code is engine_draining. Open the stream again after afterMs milliseconds, which is never more than 1,000: another engine serves it, and it opens as any connection does. It is not an error, so keep what you show until the new stream's first events arrive. The event sets the stream's retry: to afterMs too, so an EventSource that reconnects on its own follows it.

The response is of type string.