Streaming Data
Details on streaming market and account data
Tradier offers access to an HTTP and WebSocket streaming API. These streaming APIs allow you to receive updated market data and account information as these events occur. We process market data and account events as soon as they happen and send them downstream to anyone listening.
Streaming sessions
In order to initiate streaming, you’ll need to create an authenticated streaming session. Once this session has been created, you can request the streaming API endpoints using the returned session identifier. Streaming session identifiers are short-lived identifiers that have short expiry times – so they should be used immediately after the request.
HTTP Streaming
HTTP Streaming involves the process of opening an HTTP connection that does not close. Instead, data is continually transmitted to the HTTP client in “chunks” which can be parsed and processed. The value of an HTTP stream (as opposed to a raw TCP or binary stream) is the inherent convenience of using a well-established protocol, built-in encryption, and battle-tested clients that are readily available.
As long as data is flowing across the HTTP connection, the HTTP request will stay open. If you’re streaming very inactive symbols and don’t receive data for 15 minutes, the session will close automatically.
It is critical to implement reconnection logic into your streaming interface. There are many things that might cause an HTTP connection to close, and solid reconnect logic will ensure you continue to receive data.
WebSocket streaming
We offer a secure WebSocket connection that can be natively connected to directly via a browser using modern WebSocket APIs or through backend client libraries. An additional advantage of leveraging the WebSocket streaming APIs is that it does not require reconnection to modify the streamed securities.
WebSocket streaming offers a much more resilient and feature-rich streaming interface. Once a WebSocket connection is opened, you will send a request payload to our servers, and we’ll process your request and begin sending back data right away. WebSockets offer many different client implementations, support encrypted connections, and have very fast throughput.
Once connected and streaming data, to make modifications to your current streaming connection, simply resend your request payload. You can change the parameters, and we’ll adjust your stream accordingly. Note: if your session ID has expired, you will need to get a new one and send it with your adjusted payload.
In the event of validation issues with your WebSocket request, you should expect an error payload with details about the validation.
{"error":"1234 is not a valid symbol"}
WebSocket Endpoint
wss://ws.tradier.com/v1/
Limits
While we do not publish the symbol limits for these APIs, we do monitor for abuse to make sure people aren’t doing anything egregious (like asking for an entire exchange's worth of symbols). Essentially, ask for what you need. Don’t abuse the APIs, and you should be fine. It is not permitted to open more than one session at a time, meaning you can have one market data stream and one account stream open at a time, not multiples of either type.
Market Data Streaming
When streaming market data, you can stream as few as a single symbol or in excess of several hundred symbols, with the limiting factor being your system's ability to receive updates promptly. For example, a few high-activity symbols will take up more bandwidth than many lower-activity symbols. You are also able to send updated payloads to add or remove symbols from your stream without the need for closing a stream and obtaining a new sessionID. Filters for market data include: "trade", "quote", "summary", "timesale", or "tradex". You are able to include one or more of these filters when you create the stream initially, but once the stream is started, you can not update the filter.
Account Streaming
Account streaming can include one or more of your Tradier accounts but is limited to live or sandbox, not both together. For example, if you have an individual cash, an IRA, and a separate margi,n account, you can have a running stream to check for orders from 1 or more of those accounts in a single stream. Currently, trades are the only data point sent via streaming.
Updated 22 days ago