charton API / @chart-on/core / index / BarBuilder
Interface: BarBuilder<B>
Defined in: packages/core/src/data/aggregate.ts:127
Builds live bars from a trade stream; see createBarBuilder.
Type Parameters
B
Properties
bar
readonlybar:B|null
Defined in: packages/core/src/data/aggregate.ts:143
The bar being built, or null before the first trade.
Methods
apply()
apply(
trade):B[]
Defined in: packages/core/src/data/aggregate.ts:141
Add a trade and return every bar it changed, oldest first (copies). Empty when the trade is dropped. Only a large trade into volume bars changes more than one: it completes the bar being built and fills new ones.
Parameters
trade
Returns
B[]
push()
push(
trade):B|null
Defined in: packages/core/src/data/aggregate.ts:135
Add a trade. Returns the bar it changed (a copy, to pass to a data source's onBar), or null when the trade is dropped: outside the session, older than the bar being built, or with an invalid time or price. A volume bar trade that fills several bars returns the newest; apply returns them all.
Parameters
trade
Returns
B | null
reset()
reset():
void
Defined in: packages/core/src/data/aggregate.ts:145
Forget the bar being built, e.g. after a reconnect.
Returns
void