Skip to main content
ohlcv keeps one live candle for a pool or token at a period you choose. After each trade that changes the candle, it sends the whole current candle. Use it to keep a chart up to date after loading its history from REST. Weight: 1 per subscription. See Subscription weight.

Parameters

Sending neither pool nor token fails with INVALID_PARAMETERS, message pool or token is required.

Existence checks

ohlcv is the only channel that checks that what you follow exists. The subscribe fails with:

Which pool and price the candle tracks

In token mode, the best pool is the one with the highest 24-hour volume among the token’s pools. It is re-checked at most every 60 seconds, so the subscription can move to a new pool when volume shifts. Trades in the token’s other pools are ignored. This is the same pool choice as REST GET /token/ohlcv. The quote-token rule of the trade channels does not apply here.

How candles are updated

  • Buckets are aligned in UTC. 1w buckets start on Monday 00:00 UTC, and 1M buckets are calendar months.
  • The first time the server needs a candle, it seeds it from stored trades, so the first event already includes the trades earlier in the bucket.
  • After each trade in the tracked pool, the server updates the candle and sends it in full. Several events in a row can have the same t. Replace your current candle with the newest one.
  • When a trade falls in a new bucket, the new candle opens at the previous candle’s close (o = h = l = c = previous close, v = 0) before the trade is applied. Consecutive candles therefore connect, as in REST OHLCV.
  • Only priced trades move the price: the USD price must be above 0 and below 1e9, and the trade must be worth at least $0.10. Every trade, priced or not, adds its USD value to v.
Events are not guaranteed for every trade. No event is sent:
  • until the candle has an opening price, for example for a brand-new pool whose first trades are too small to be priced;
  • for a trade that is older than, or the same as, one the server already applied to this candle;
  • when building the candle takes longer than 2 seconds. The subscription’s cursor still moves past that trade.
Because each event carries the full candle, a skipped event is corrected by the next one in the same bucket. The last update of a bucket can still be missed, so reload candles from REST after a reconnect.
With maxUpdatesPerMinute, the interval is used up by the first matching trade even when that trade produces no event. In token mode, a trade of the token in one of its other pools matches the subscription but is not part of the candle. So a sampled token-mode subscription can go longer than the interval without an update. Use pool mode (with token if needed) when you sample.
Resuming with since works, but trades the server has already counted into its live candle are not sent again. If you were disconnected across a bucket boundary, you may not receive the final state of the bucket that closed. After any reconnect, reload the most recent candles from REST and then apply live events.

Event data

data is the current candle:
string
Pool the candle comes from. In token mode this is the current best pool.
string
Token whose USD price the candle tracks: your token, or the pool’s base token in pool-only mode.
string
The period you subscribed with.
number
Bucket start time in Unix epoch milliseconds (UTC).
number
Open price in USD.
number
High price in USD.
number
Low price in USD.
number
Close price in USD.
number
Volume in USD. 0 when the bucket has no volume.
v is the USD volume of the bucket so far.

Example

The third event opens a new bucket at the previous close, 0.0102.

Pair with REST history

Load history from REST with the same period, then apply live events: REST returns the same candle shape, t, o, h, l, c and v, oldest first.
See the live price chart guide for a complete walkthrough.