Skip to main content

Shards and bars

What you send: bars​

A bar is one interval of your series:

[open_time, close_time, open, high, low, close]

Times are epoch milliseconds, UTC. The rules:

RuleWhy
In time order, not overlappingA series has one past
low <= open, close <= highThe four values describe the interval
Every value above zeroA contract constraint. If your measure crosses zero, add a fixed offset before sending and remove it when you draw
Leave gaps; never send a flat filler barAn interval where nothing happened, too few readings, nothing moved, or nothing flowed (an inverter at night), is absent, not zero. Irregular spacing is expected and read well

You can send samples, [time, value], instead, and the service makes bars. Sending bars keeps the choice of width with you, and is the better default. examples/python/bars.py builds them.

A shard is a fragment of a time series that keeps its shape at any scale. Each segment Delve returns is one shard.

What you get: segment boxes​

{ "id": "h2@1730246400000", "parent": "h3@1730246400000", "height": 2, "order": 0, "bars": 14,
"open_time": 1730246400000, "open": 412.0, "high_time": 1730271600000, "high": 455.2,
"low_time": 1730250000000, "low": 401.7, "close_time": 1730296799000, "close": 448.3,
"provisional": false }
FieldMeaning
heightThe level. 1 is the finest segments above your bars; higher is coarser. The top is the whole series
idh<height>@<open_time>. Stable: the same segment has the same id in a segmentation and in every extension
parentThe segment one level up that contains it
barsHow many of your bars it covers
open, high, low, close with timesThe four vertices of its shape
provisionalThe open right edge at its level: it may still grow and its close may move. Every other segment is final

Drawing​

  • A chart of width W pixels over a time window shows the coarsest level whose segments are still wide enough to read in that window, and switches to finer levels as the viewer zooms in. Store all levels; pick per chart.
  • Draw a segment as a box from open_time to close_time between low and high, and its line from open through high and low, in time order, to close.
  • A trend is the same series at a coarser level, drawn faintly behind.
  • The open segment at levels 1, 2 and 3 gives a reading at three timescales: rising if its close is above its open, falling if below, steady if close.

Finished and forming​

FinishedForming
You haveThe whole series, or a window of itOne more bar at a time
You callPOST /v1/segmentations (or a job from your storage)POST /v1/segmentations/extend, with the edge
You getEvery segmentThe segments the bars closed, the right edge, and a new edge to store
Same resultYes: appending every bar gives the same segments as sending them all at once