Tick Charts
Using Tick Charts
Requesting Tick Charts
To get Tick Chart data, you can use the same process described in the Market Data section. Just like with Market Data, you need to open and authorize a WebSocket first. If you’re following the comprehensive JavaScript tutorial, you can find tick chart examples here.
Just like requesting regular chart data, you must construct a request body with the symbol, chartDescription, and timeRange fields. However, you need to lock elementSize to 1 and set underlyingType to Tick. For example:
You call the standard md/getChart endpoint and pass the request to it. The server responds with the standard JSON object schema for chart data. Because an unsubscription request requires the real-time subscription ID sent with this response, store the ID of each subscription you create so you can properly unsubscribe later.
Data Stream Messages
A typical data stream message has the following structure:
Because tick prices and timestamps are sent as deltas from the packet’s base values, you reconstruct them with actual price = (bp + tick.p) * ts and actual time = bt + tick.t. For example, with a base price bp of 11917, a contract tick size ts of 0.25, and a tick with p of 4, the actual price is (11917 + 4) * 0.25 = 2980.25. The deltas stay small because most ticks trade near the same price level, which keeps the payload compact compared to repeating full prices on every tick.
Using the Tick Stream
The following code snippet is an example of how to process tick chart data stream messages and calculate actual ticks for client consumption.
The function takes a data stream message and converts its packets into a list of actual ticks. Usage of this function assumes that you’ll be passing it the message data retrieved from the WebSocket. Because tick stream data can arrive out of chronological order, it is the client’s responsibility to store and sort pertinent portions of this data.
Ordering Ticks Before Rendering
processTickChartMessage decodes each packet into actual ticks, but it doesn’t sort them, and tick data can arrive out of chronological order for a few reasons:
- A single WebSocket message can carry multiple packets, each with its own base timestamp (
bt), and the packets aren’t guaranteed to be in order. - Historical and real-time ticks can interleave around the end-of-history boundary. The
eohflag marks the transition, but the boundary isn’t always clean. - Network batching can deliver several packets in one burst, where the order within the burst depends on how the server assembled it.
If you plot ticks as they arrive, your chart can show gaps and false price spikes. Buffer incoming ticks, sort by timestamp with the tick ID as a tiebreaker, and only then render or aggregate them. Sort the historical batch when eoh arrives, then keep a small sort window for real-time ticks, which can also arrive slightly out of order within a burst.
This snippet re-sorts the whole buffer for clarity. A production implementation would bound the real-time sort window rather than re-sorting every tick.
To build N-tick or time-based bars from raw ticks, aggregate them after sorting. For the full charting pipeline (connection sharding, candle warehousing, and overlaying live data), see Charting Best Practices.