Everything a transport bar and a clock need, in one object.

interface ReplayState {
    bar: null | Bar;
    index: number;
    playing: boolean;
    simulated: boolean;
    speed: number;
    subIndex: number;
    subSteps: number;
    total: number;
}

Properties

bar: null | Bar

The bar at index, the replay clock's "now". Null when there is no data.

Under intra-bar replay this is the partial bar as it stands this step, not the completed one, which is what makes it the right thing to drive a host's own forming volume bar or an OHLC readout from.

index: number

0-based newest bar; -1 before the first observation in timed replay.

playing: boolean
simulated: boolean

True while the newest bar forms along a simulated path (simulate), because no finer bar covers it. Its forming prices were never traded, so a host shows that plainly; the bar closes on the real bar either way.

speed: number

Multiplier over barMs: 2 plays two bars per barMs.

subIndex: number

Which step of the forming bar this is, 0-based, and how many it takes. Both are 0 and 1 without subBars, so a transport that shows them needs no special case for the plain mode.

subSteps: number
total: number

Bars in the replay set (the scrub bar's maximum is total - 1).