@livefolio/sdk / collectBars
Function: collectBars()
collectBars(
it):Promise<Bar[]>
Defined in: features/series-utils.ts:32
Drains an AsyncIterable<Bar> into a plain Bar[] array.
Used internally by FeatureRuntime to materialise the stream returned by DataFeed.bars before passing it to indicator functions that expect a fully-in-memory array. The resulting array is in the same order as the iterable yields (typically chronological).
Parameters
| Parameter | Type | Description |
|---|---|---|
it | AsyncIterable<Bar> | Any AsyncIterable<Bar>, such as the return value of DataFeed.bars. |
Returns
Promise<Bar[]>
A promise that resolves to a Bar[] containing every bar yielded by the iterable, in iteration order.
Example
ts
import { collectBars } from '@livefolio/sdk';
const bars = await collectBars(dataFeed.bars(asset, range, '1d'));
// bars is now a Bar[] — safe to index, slice, and pass to barsToSeries