Skip to main content
Keep a chart and an account panel live without asking for them again and again. Use this page once your chart has its history and your screen has read the account. Both streams are plain Server-Sent Events, so curl -N is a working client and so is any Server-Sent Events library. Both follow one rule: every time you connect, and every time you reconnect, the stream starts with the whole current picture and then sends changes. A dropped connection costs nothing but a reconnect. By the end you can follow one chart, many charts on one connection, and the account with its risk lock.

Before you start

The examples use TRDRS_API_BASE_URL, TRDRS_TRADING_API_KEY, PROVIDER and ACCOUNT from the programmatic quickstart. They stream HYPERLIQUID:BTC, the Bitcoin perpetual, whose prices come from a provider’s public data, so they run in the sandbox with no other login. The TypeScript SDK isn’t published, so call the routes over HTTP, as the curl examples do. The TypeScript examples show the same calls through the SDK’s client, which turns a stream into an async iterator. A futures contract, such as ESZ6, streams the same way. So does a continuous symbol, ES1! or ES2!, which streams the contract its position names when you connect, so reconnect after the product’s roll to follow the next contract. Futures prices are licensed to each user and come from their own login at a provider that carries them (Providers lists which), so futures stream in a trader’s own signed-in session at trdrs. A Trading API key streams crypto, and a futures stream it opens is refused with 503 and feed_requires_connection.
1

Stream one chart

Stream live bars takes an instrument and a timeframe.
Events arrive by name:The error codes are unknown_instrument, not_entitled, feed_down, session_displaced (another application signed in with the same login and took its market data session) and session_expired (your own sign-in or key stopped being valid; sign in again, or check the key, before you reconnect). A heartbeat event keeps a quiet connection open, and you can ignore it. A plain dropped connection carries no event, and a browser’s EventSource reconnects on its own.
2

Stream many charts on one connection

A layout with several charts should share one connection, because browsers limit how many connections a page can hold open to one site. Stream multiplexed live bars takes up to 24 subscriptions in subs, each written INSTRUMENT~tf and separated by commas.
The events are the same, and each one also names its instrument and tf, so you can route it to the right chart. A subscription you send twice counts once, and a malformed one is dropped. When one subscription fails, you get an error event for it and the others carry on. To change the set, reconnect with new subs: each subscription starts again with its own snapshot.
3

Follow the account

Stream account updates follows one account: its balance, positions, working orders, brackets and risk lock.
Every change arrives as one account event carrying the whole account, the same body Get the account snapshot returns. The first frame on each connection is simply the first account event. Apply frames by revision and nothing else: keep the newest frame you hold, ignore one at or behind it, and replace your whole picture with one ahead of it. A row missing from a frame has closed or been cancelled.On an account a venue issues, the frame’s rules state where the venue’s rules stand: each loss floor whose breach fails the account, and the stage’s profit target where passing it advances the account. To show the price at which an open position reaches a floor, solve for the mark at which the account’s equity would equal the floor, holding its other positions where they are.The risk lock arrives as its own lock event, first on connect while the account is locked and then whenever it changes, so one connection drives the positions, the orders and the lock banner. An account that isn’t locked sends none until a lock takes hold.An error event ends the account stream. Its code is provider_disconnected when the account couldn’t be read, risk_resync_required when the lock fell behind, or session_expired when your sign-in or key stopped being valid. Reconnect, and the first frame gives you the whole account again.

Reconnect without bookkeeping

Because every connection starts with the whole picture, a client never has to work out what it missed:
  • When you connect, replace your state with the first snapshot or frame.
  • After that, apply events as they arrive.
  • When the connection drops, reconnect and replace your state again.
An order that filled while you were away is simply absent from the next frame, and that absence is the truth. Streaming states the rule in full.

When a stream is refused

Next steps

Backfill history

Load the bars before the stream’s window, and scroll back through older ones.

Track fills and P&L

Read the history behind the account frames.

Build a front end

Put streams, charts and orders together on your own site.