@reincharts/datafeed
Datafeed adapters, realtime updates, aggregation and replay.
npm install @reincharts/datafeedEverything here is also re-exported by the umbrella package reincharts.
Hooks
| Name | Description |
|---|---|
| useBarReplay | Bar replay: hides bars after a start index and reveals them one by one (play, pause, step, step back, speed). |
| useDatafeed | Connects a Datafeed to a chart: loads history, merges realtime bars, paginates backwards, resets on symbol / resolution change and ignores stale responses. |
Functions
| Name | Description |
|---|---|
| aggregateBars | Builds higher timeframe bars (e.g. |
| alignSeries | Aligns a second series (compare symbol) to base by time: each base item gets [key] set to the other bar with the same time. |
| alignTime | Start time of the bar containing time (ms epoch). |
| applyTick | Realtime tick merge (pure): folds tick into the last bar or appends a new bar. |
| compareResolutions | Compares resolutions by duration (for sorting). |
| createMemoryDatafeed | A datafeed serving in-memory bars, e.g. |
| createRandomDatafeed | A browser-only demo / test feed: deterministic random-walk prices for any symbol and resolution (open / close consistent across resolutions and pages) plus a realtime ticker that updates the last bar and rolls new ones. |
| formatResolution | Human label: "1s", "5m", "1h", "4h", "1D", "1W", "1M", "1Y" (style: "short", default) or "5 minutes", "1 hour" (style: "long"). |
| isResolution | Returns true when the string is a valid resolution. |
| mergeBar | Realtime merge (pure): replaces the last bar when bar.time equals it, appends when newer, and ignores older bars (returns data unchanged). |
| mergeBars | Merges two sorted series (e.g. |
| nextBarTime | Start time of the bar following the one that starts at (or contains) time. |
| normalizeResolution | Canonical resolution string: "1h" → "60", "1d" → "1D", "1y" → "12M", "1s" → "1S". |
| parseCsv | Parses CSV / TSV OHLC text (with a header row) into bars sorted by time. |
| parseResolution | Parses a resolution string. |
| parseTimeValue | Default time cell parser (see ParseCsvOptions.parseTime). |
| resolutionToMs | Nominal bar duration in milliseconds (months count as 30 days). |
| sliceBars | Returns bars with time < to: the last countBack ones, or those >= from when countBack is 0. |
| sortBars | Sorts by time and removes duplicates (the last occurrence wins). |
| ticksToBars | Builds bars from trades (seconds or minute bars from ticks). |
| tickToBar | Updates (or starts) the bar for tick. |
| timeZoneOffset | Offset (ms) of timeZone from UTC at time: local wall-clock = time + offset. |
| toChartBar | Adds date so the bar can be passed straight to <ChartCanvas data>. |
Constants
| Name | Description |
|---|---|
| DAY | One day in milliseconds. |
| HOUR | One hour in milliseconds. |
| MINUTE | One minute in milliseconds. |
| RESOLUTIONS | Common resolutions, in increasing order (handy for interval pickers). |
| SECOND | One second in milliseconds. |
| WEEK | One week in milliseconds. |
Types
| Name | Description |
|---|---|
| AlignOptions | Options for calendar alignment of bars. |
| AlignSeriesOptions | Options of alignSeries. |
| Bar | One OHLCV bar. |
| ChartBar | A bar ready for <ChartCanvas data>: date makes the chart detect a time axis automatically. |
| CsvBar | A parsed CSV / TSV row: OHLCV plus any extra column (numbers when numeric, strings otherwise). |
| Datafeed | The adapter between your backend and the chart: history requests, realtime updates and symbol search. |
| GetBarsRequest | History request: bars with from <= time < to, at least the countBack most recent ones before to. |
| GetBarsResult | History response. |
| MemoryDatafeed | A Datafeed over in-memory arrays, with pushBar to simulate realtime updates. |
| MemoryDatafeedOptions | Options of createMemoryDatafeed. |
| ParseCsvOptions | Options of parseCsv. |
| ParsedResolution | A parsed resolution: count × unit (hours are expressed as minutes, years as months). |
| RandomDatafeed | A demo Datafeed with deterministic history and a simulated realtime ticker. |
| RandomDatafeedOptions | Options of createRandomDatafeed. |
| Resolution | Bar interval in the common charting notation: "1S"/"5S" seconds, "1"/"5"/"15"/"60"/"240" minutes, "1D" days, "1W" weeks, "1M" months. |
| ResolutionUnit | |
| SymbolInfo | Instrument metadata . |
| Tick | A single trade / price update. |
| UseBarReplayOptions | Options of useBarReplay. |
| UseBarReplayResult | State and controls returned by useBarReplay. |
| UseDatafeedOptions | Options of useDatafeed. |
| UseDatafeedResult | State returned by useDatafeed. |