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.
1wbuckets start on Monday 00:00 UTC, and1Mbuckets 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.
- 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.
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:
Token whose USD price the candle tracks: your
token, or the pool’s base token in pool-only mode.v is the USD volume of the bucket so far.
Example
0.0102.
Pair with REST history
Load history from REST with the same period, then apply live events:GET /token/ohlcvfortokenmodeGET /market/ohlcvforpoolmode
t, o, h, l, c and v, oldest first.