openalgo-charts 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Library version string. Matches package.json (including locally prepared releases). */
2
- declare const VERSION = "2.3.1";
2
+ declare const VERSION = "2.4.0";
3
3
  /** Returns the current library version. */
4
4
  declare function version(): string;
5
5
 
@@ -441,6 +441,15 @@ interface Bar {
441
441
  * two. Neither is expressible with one colour for the whole series.
442
442
  */
443
443
  color?: string;
444
+ /**
445
+ * Wick colour for this bar alone, over `color`. A study that paints candles
446
+ * with a translucent body and a solid wick cannot say so with one colour,
447
+ * and without this a per-bar override always set the two together. Read by
448
+ * the candle renderers only; absent means the wick follows `color`.
449
+ */
450
+ wickColor?: string;
451
+ /** Border colour for this bar alone, on the same terms as `wickColor`. */
452
+ borderColor?: string;
444
453
  }
445
454
  /** A single value point (for line/area/baseline series). */
446
455
  interface LinePoint {
@@ -600,6 +609,14 @@ interface SeriesStyle {
600
609
  * so whoever builds those readings owns their formatting.
601
610
  */
602
611
  precision?: number;
612
+ /**
613
+ * Draw every point this many bars to the right of the bar it belongs to
614
+ * (negative: left). The data is untouched and keeps its own times; only the
615
+ * painted position moves, so the last `barOffset` points of a series land in
616
+ * the right margin, past the newest bar. Autoscale follows what is drawn in
617
+ * view. Default 0.
618
+ */
619
+ barOffset?: number;
603
620
  color?: string;
604
621
  lineWidth?: number;
605
622
  /** Line dash style for line/step/area/HLC series. Default 'solid'. */
@@ -824,8 +841,13 @@ declare function bestHit(hits: readonly (PrimitiveHit | null)[]): PrimitiveHit |
824
841
  * body sits clear of it: `labelUp`'s tail points up so its body hangs below the
825
842
  * anchor, `labelDown` is the mirror. Both require `text`.
826
843
  */
827
- type MarkerShape = 'arrowUp' | 'arrowDown' | 'circle' | 'square' | 'triangleUp' | 'triangleDown' | 'diamond' | 'flag' | 'text' | 'labelUp' | 'labelDown';
828
- type MarkerPosition = 'aboveBar' | 'belowBar' | 'inBar' | 'atPrice';
844
+ type MarkerShape = 'arrowUp' | 'arrowDown' | 'circle' | 'square' | 'triangleUp' | 'triangleDown' | 'diamond' | 'flag' | 'text' | 'labelUp' | 'labelDown' | 'cross' | 'xcross';
845
+ /**
846
+ * `paneTop` and `paneBottom` pin the glyph to the edge of the plot rather than
847
+ * to a price, so a squeeze dot or a session flag sits in a fixed row whatever
848
+ * the scale does. They need no bar under them and no `price`.
849
+ */
850
+ type MarkerPosition = 'aboveBar' | 'belowBar' | 'inBar' | 'atPrice' | 'paneTop' | 'paneBottom';
829
851
  type MarkerSize = 'tiny' | 'small' | 'medium' | 'big';
830
852
  interface SeriesMarker {
831
853
  time: number;
@@ -1554,7 +1576,13 @@ interface ChartTableOptions {
1554
1576
  /** Column width in media px. A per-column array sizes each one separately. */
1555
1577
  cellWidth: number | readonly number[];
1556
1578
  cellHeight: number;
1557
- fontSize: number;
1579
+ /**
1580
+ * Type size in media px, or `'auto'` to fit each cell: as large as its row
1581
+ * allows, shrunk until its text also fits its column. A stretched grid with
1582
+ * one long label would otherwise either clip that cell or be sized down as a
1583
+ * whole to suit it.
1584
+ */
1585
+ fontSize: number | 'auto';
1558
1586
  /** Grid line colour. Omit to draw no grid. */
1559
1587
  borderColor?: string;
1560
1588
  borderWidth: number;
@@ -1678,6 +1706,36 @@ type IndicatorInput = {
1678
1706
  default: IndicatorSource;
1679
1707
  group?: string;
1680
1708
  tooltip?: string;
1709
+ }
1710
+ /**
1711
+ * A timeframe code (`'5m'`, `'1d'`), for a study that folds the chart's bars
1712
+ * up to a coarser interval. A settings UI renders it as a select over the
1713
+ * registered intervals, so the value is always one the engine can bucket by;
1714
+ * a free text box would accept `'5min'` and leave the study computing on a
1715
+ * code it cannot resolve. An empty default means "the chart's own interval".
1716
+ */
1717
+ | {
1718
+ key: string;
1719
+ type: 'interval';
1720
+ label: string;
1721
+ default: string;
1722
+ group?: string;
1723
+ tooltip?: string;
1724
+ }
1725
+ /**
1726
+ * A wall-clock instant in the chart's zone, written `YYYY-MM-DD HH:MM` (the
1727
+ * time part optional), for an anchor a user picks by date: the start of an
1728
+ * anchored VWAP, an event to measure from. It is carried as that string, not
1729
+ * as UTC seconds, so a layout saved in one zone restores to the same wall
1730
+ * clock in another, and `zonedStringToUtcSeconds` turns it into a bar time.
1731
+ */
1732
+ | {
1733
+ key: string;
1734
+ type: 'time';
1735
+ label: string;
1736
+ default: string;
1737
+ group?: string;
1738
+ tooltip?: string;
1681
1739
  };
1682
1740
  /** Dash pattern for a level, a drawing, or a plot. */
1683
1741
  type IndicatorLineStyle = 'solid' | 'dashed' | 'dotted';
@@ -1734,7 +1792,26 @@ interface IndicatorFillSpec {
1734
1792
  colorDownKey?: string;
1735
1793
  /** 0..1. Defaults to 0.12. */
1736
1794
  opacity?: number;
1795
+ /**
1796
+ * Draw the band on the price pane even though the indicator owns a pane of
1797
+ * its own. The pair with `IndicatorPlot.overlay`: a study can already send
1798
+ * one plot to the candles, and a band between two such plots belongs beside
1799
+ * them rather than in the study pane the fill would otherwise land in.
1800
+ * Ignored for an `'onchart'` descriptor, which is on the price pane already.
1801
+ */
1802
+ overlay?: boolean;
1737
1803
  }
1804
+ /**
1805
+ * What `colorParts` answers: a candle plot's colour split three ways, which is
1806
+ * how a study paints a wick in full colour over a translucent body. `body` is
1807
+ * the bar's colour (and the only part a line, histogram or column reads); a
1808
+ * part left undefined falls back to `colorBy`, then to the plot's own colour.
1809
+ */
1810
+ type PlotBarColor = {
1811
+ body?: string;
1812
+ wick?: string;
1813
+ border?: string;
1814
+ };
1738
1815
  interface IndicatorPlot {
1739
1816
  /** Key into the `calc` result. */
1740
1817
  key: string;
@@ -1772,6 +1849,16 @@ interface IndicatorPlot {
1772
1849
  * Ignored for an `'onchart'` descriptor, which is already on the price pane.
1773
1850
  */
1774
1851
  overlay?: boolean;
1852
+ /**
1853
+ * Draw the column shifted this many bars to the right (negative: left). The
1854
+ * column itself stays one value per bar and `calc` returns exactly what it
1855
+ * always did; only where each value is painted moves. Positive is what a
1856
+ * displaced cloud or a projected channel wants: the last `offset` values land
1857
+ * in the right margin, past the newest candle, where no bar exists to hold
1858
+ * them. It shifts the drawn series only. A fill between two plots with the
1859
+ * same offset follows; the legend reads the value drawn under the cursor.
1860
+ */
1861
+ offset?: number;
1775
1862
  /**
1776
1863
  * Settings key holding this plot's color, so a settings change restyles the
1777
1864
  * series without a full rebuild.
@@ -1812,6 +1899,19 @@ interface IndicatorPlot {
1812
1899
  values: IndicatorValues;
1813
1900
  settings: IndicatorSettings;
1814
1901
  }): string | undefined;
1902
+ /**
1903
+ * Per-bar colour split three ways, for a candle plot whose wick or border
1904
+ * should not follow its body: a solid wick over a translucent body, a
1905
+ * border in the trend colour. Takes precedence over `colorBy` for the parts
1906
+ * it names; a part it leaves undefined falls back to `colorBy`, then to the
1907
+ * plot's own colour. A value plot (line, histogram, column) reads `body` only.
1908
+ */
1909
+ colorParts?(ctx: {
1910
+ value: number;
1911
+ index: number;
1912
+ values: IndicatorValues;
1913
+ settings: IndicatorSettings;
1914
+ }): PlotBarColor | undefined;
1815
1915
  }
1816
1916
  /** A horizontal reference level (RSI 70/30, Stochastic 80/20, a zero line). */
1817
1917
  interface IndicatorLevel {
@@ -1861,6 +1961,17 @@ type IndicatorDrawing = {
1861
1961
  /** Caption drawn on a plate at the centre of the box; `\n` splits lines. */
1862
1962
  text?: string;
1863
1963
  textColor?: string;
1964
+ /**
1965
+ * Detail shown on a plate while the pointer rests on the box, and gone
1966
+ * when it leaves; `\n` splits lines. A zone that carries its size, its
1967
+ * age and what formed it cannot print all of that on the box without
1968
+ * hiding the candles under it, so the caption names it and this explains
1969
+ * it. The box becomes hit-testable, and `id` (or the tooltip text) is
1970
+ * what `subscribeClick` reports for it.
1971
+ */
1972
+ tooltip?: string;
1973
+ /** Hit id, for `subscribeClick`. Defaults to the tooltip text. */
1974
+ id?: string;
1864
1975
  } | {
1865
1976
  kind: 'label';
1866
1977
  at: DrawAnchor;
@@ -1871,6 +1982,10 @@ type IndicatorDrawing = {
1871
1982
  textColor?: string;
1872
1983
  /** Which edge of the plate sits on the anchor. Defaults to 'center'. */
1873
1984
  align?: 'left' | 'center' | 'right';
1985
+ /** Hover detail, as on a box. */
1986
+ tooltip?: string;
1987
+ /** Hit id, for `subscribeClick`. Defaults to the tooltip text. */
1988
+ id?: string;
1874
1989
  } | {
1875
1990
  kind: 'polyline';
1876
1991
  points: readonly DrawAnchor[];
@@ -1952,10 +2067,48 @@ interface IndicatorAlertSpec {
1952
2067
  id: string;
1953
2068
  /** Short human label, e.g. `'MACD crossed up'`. */
1954
2069
  title: string;
1955
- /** Longer text for a notification; defaults to `title`. */
1956
- message?: string;
2070
+ /**
2071
+ * Longer text for a notification; defaults to `title`. A function is handed
2072
+ * the same context `when` judged, so the message can carry the bar's own
2073
+ * numbers: the price it crossed at, the histogram reading, a JSON body for a
2074
+ * webhook. It runs only for a bar `when` accepted.
2075
+ */
2076
+ message?: string | ((ctx: IndicatorAlertContext) => string);
1957
2077
  when(ctx: IndicatorAlertContext): boolean;
1958
2078
  }
2079
+ /**
2080
+ * Thrown by a `calc` (or any hook) to say its inputs cannot produce a study,
2081
+ * the way a script language's runtime error does: a period at or below zero, a
2082
+ * fast length above the slow one, a benchmark the provider cannot serve.
2083
+ *
2084
+ * Any error out of a recompute is caught by the runtime and published on the
2085
+ * instance's data status as `{ state: 'error' }`, so the chart keeps drawing
2086
+ * every other indicator and a host can show the reason beside this one. This
2087
+ * class exists so a descriptor can throw a **named** condition and a host can
2088
+ * tell a bad input, which the user can fix, from a bug, which they cannot.
2089
+ */
2090
+ declare class IndicatorInputError extends Error {
2091
+ constructor(message: string);
2092
+ }
2093
+ /**
2094
+ * Bars of another instrument or interval, supplied by the host on request.
2095
+ *
2096
+ * The engine is handed one symbol's bars and owns no transport, so a study
2097
+ * that compares against a benchmark, or a Tier-2 provider that needs a second
2098
+ * series, asks the host through this and the host answers from wherever it
2099
+ * keeps history. `from` and `to` are UTC seconds; `signal` is aborted when the
2100
+ * instance is removed or its settings change, so a provider can drop the
2101
+ * request rather than answer into the void.
2102
+ */
2103
+ interface IndicatorBarsRequest {
2104
+ symbol: string;
2105
+ exchange?: string;
2106
+ interval: string;
2107
+ from: number;
2108
+ to: number;
2109
+ signal?: AbortSignal;
2110
+ }
2111
+ type IndicatorBarsProvider = (request: IndicatorBarsRequest) => Promise<readonly Bar[]>;
1959
2112
  /** Payload of the `'indicator:alert'` event on the chart's own bus. */
1960
2113
  interface IndicatorAlertPayload {
1961
2114
  /** Descriptor id, e.g. `'macd'`. */
@@ -2017,6 +2170,13 @@ interface IndicatorAttachContext {
2017
2170
  timezone?(): string;
2018
2171
  /** Chart wall clock in UTC seconds, the same clock the countdown row uses. */
2019
2172
  now?(): number;
2173
+ /**
2174
+ * Ask the host for another instrument's (or interval's) bars. Always present
2175
+ * under `chart.addIndicator`; it rejects when the host has registered no
2176
+ * provider (`chart.setBarsProvider`), so a study can treat the rejection as
2177
+ * "unsupported here" and say so through `setDataStatus`.
2178
+ */
2179
+ requestBars?(request: IndicatorBarsRequest): Promise<readonly Bar[]>;
2020
2180
  /** The pane this instance drew into. Moves when panes are reordered. */
2021
2181
  paneIndex?(): number;
2022
2182
  /** Attach a primitive to this indicator's pane, and detach it again. */
@@ -2656,6 +2816,12 @@ interface IndicatorHost {
2656
2816
  setBarColors?(colors: readonly (string | null)[] | null, owner: string): void;
2657
2817
  /** Emit on the chart's event bus (indicator alerts, and `attach`'s own events). */
2658
2818
  emit?(event: string, payload: unknown): void;
2819
+ /**
2820
+ * Bars of another instrument or interval, from wherever the host keeps its
2821
+ * history. Optional: without it the attach context's `requestBars` rejects,
2822
+ * which a study reads as "not available on this chart".
2823
+ */
2824
+ requestBars?(request: IndicatorBarsRequest): Promise<readonly Bar[]>;
2659
2825
  /**
2660
2826
  * Tick size of the named pane's price scale, or undefined when none is set.
2661
2827
  * Optional so a host predating it still satisfies this interface.
@@ -3775,6 +3941,15 @@ interface ChartOptions {
3775
3941
  * Tune a single pane later via `chart.panes()[n].priceScale.setOptions(...)`.
3776
3942
  */
3777
3943
  priceScale?: Partial<PriceScaleOptions>;
3944
+ /**
3945
+ * Where an indicator gets another instrument's bars. The engine is handed
3946
+ * one symbol's history and owns no transport, so a study that compares
3947
+ * against a benchmark asks through this and the host answers from wherever
3948
+ * it keeps candles. Change it later with `setBarsProvider`. Without one an
3949
+ * indicator's `requestBars` rejects, and the study reports itself
3950
+ * unsupported rather than drawing something invented.
3951
+ */
3952
+ barsProvider?: IndicatorBarsProvider;
3778
3953
  /**
3779
3954
  * Custom time-axis and crosshair label formatter (receives UTC seconds). When
3780
3955
  * omitted, labels use IST (Indian market default). e.g. for UTC:
@@ -4144,6 +4319,7 @@ declare class Chart {
4144
4319
  private _primary;
4145
4320
  private readonly _indicators;
4146
4321
  private _dataContext;
4322
+ private _barsProvider;
4147
4323
  /** Guards indicator recompute against re-entry via its own `series.setData`. */
4148
4324
  private _recomputing;
4149
4325
  private _indicatorsDirty;
@@ -4362,6 +4538,14 @@ declare class Chart {
4362
4538
  getDataContext(): Readonly<ChartDataContext> | undefined;
4363
4539
  /** Clear the previous source bars before changing context, then load the new source. */
4364
4540
  setDataContext(context: ChartDataContext | undefined): void;
4541
+ /**
4542
+ * Register, replace or remove (`null`) the provider indicators reach through
4543
+ * `requestBars`. Read at request time, so an indicator added before the
4544
+ * provider was set is served once one exists.
4545
+ */
4546
+ setBarsProvider(provider: IndicatorBarsProvider | null): void;
4547
+ /** Whether a bars provider is registered, so a host can grey what needs one. */
4548
+ hasBarsProvider(): boolean;
4365
4549
  /** Replace chart-owned branding. Manually attached primitives are independent. */
4366
4550
  setBranding(options: boolean | LogoWatermarkOptions): void;
4367
4551
  /** Host branding options, excluded from saved chart state. */
@@ -6468,6 +6652,16 @@ interface CandleUpdate {
6468
6652
  bar: Bar;
6469
6653
  /** True when this tick started a new interval bar (append vs mutate-in-place). */
6470
6654
  isNew: boolean;
6655
+ /**
6656
+ * True while the bar's open, high, low and volume cover only the ticks this
6657
+ * builder has seen. A bar is provisional when it was opened from a tick
6658
+ * without the builder having streamed the bar before it: a cold start, or a
6659
+ * seed from an older bucket, both of which mean the trades between the
6660
+ * bucket's true open and the first tick seen were missed. The close is still
6661
+ * the latest price. An authoritative bar for the same bucket, from history,
6662
+ * corrects the rest through `reconcile`.
6663
+ */
6664
+ provisional?: boolean;
6471
6665
  }
6472
6666
  declare class CandleBuilder {
6473
6667
  private readonly _opts;
@@ -6475,10 +6669,30 @@ declare class CandleBuilder {
6475
6669
  private _cumAtBarStart;
6476
6670
  private _lastCum;
6477
6671
  private _hasCum;
6672
+ /** The current bar has received at least one tick, so a rollover from it sees the true open. */
6673
+ private _streamed;
6674
+ private _provisional;
6478
6675
  constructor(options?: Partial<CandleBuilderOptions>);
6479
6676
  /** Seed with the last historical bar so the first live tick continues it. */
6480
6677
  seed(lastBar: Bar, cumDayVolumeSoFar?: number): void;
6481
6678
  current(): Bar | null;
6679
+ /** Whether the current bar is provisional; see `CandleUpdate.provisional`. */
6680
+ isProvisional(): boolean;
6681
+ /**
6682
+ * Adopt an authoritative bar for the current bucket, typically the broker's
6683
+ * history for the bar that is still forming.
6684
+ *
6685
+ * A provisional bar takes the authoritative open, because its own is the
6686
+ * first tick this builder happened to see. Every bar takes the union of the
6687
+ * extremes, since both sides observed real prices, and the larger volume,
6688
+ * since volume inside a bar only grows. The close stays with the ticks: a
6689
+ * history snapshot was taken before the request went out, and a price that
6690
+ * jumps backwards on every repair is the one thing a live chart must not do.
6691
+ *
6692
+ * Returns the reconciled bar, or null when the builder holds no bar for that
6693
+ * bucket, in which case the caller decides whether to `seed` instead.
6694
+ */
6695
+ reconcile(authoritative: Bar): Bar | null;
6482
6696
  /** Bucket-start (bar-open) time for a tick, aligned to the session anchor. */
6483
6697
  bucketStart(time: UTCSeconds): UTCSeconds;
6484
6698
  /**
@@ -6509,6 +6723,13 @@ declare class IndicatorDrawings implements IPrimitive {
6509
6723
  private _items;
6510
6724
  private _host;
6511
6725
  private _visible;
6726
+ /**
6727
+ * The labels and boxes that carry an id or a tooltip, where the last frame
6728
+ * put them. Only those are hit-testable: a bare trendline stays under the
6729
+ * pointer as pure ink, so hovering a busy study does not light up a cursor
6730
+ * on every ray it drew.
6731
+ */
6732
+ private _hits;
6512
6733
  attached(host: PrimitiveHost): void;
6513
6734
  detached(): void;
6514
6735
  /** Over the series, under the crosshair: these are annotations on the data. */
@@ -6522,6 +6743,16 @@ declare class IndicatorDrawings implements IPrimitive {
6522
6743
  setItems(items: readonly IndicatorDrawing[]): void;
6523
6744
  setVisible(on: boolean): void;
6524
6745
  draw(ctx: CanvasRenderingContext2D, rc: PrimitiveRenderContext): void;
6746
+ /** Keep a label's or box's rect when it has something to say on hover or click. */
6747
+ private _recordHit;
6748
+ /**
6749
+ * The hovered shape's tooltip, as a plate clear of the shape: above it when
6750
+ * there is room, below it otherwise. Drawn last so it sits over everything
6751
+ * else in the layer, and only while the chart reports the pointer on it, so
6752
+ * it costs nothing on a frame with nothing hovered.
6753
+ */
6754
+ private _drawTooltip;
6755
+ hitTest(x: number, y: number): PrimitiveHit | null;
6525
6756
  }
6526
6757
 
6527
6758
  /**
@@ -6964,6 +7195,17 @@ interface BarSubscriptionOptions {
6964
7195
  */
6965
7196
  onResync?: () => void;
6966
7197
  }
7198
+ /** What a live push knows about the bar beyond its values. */
7199
+ interface LiveBarMeta {
7200
+ /**
7201
+ * The bar's open, high, low and volume cover only the ticks its builder saw:
7202
+ * it opened the bucket from a tick without having streamed the bar before
7203
+ * it. See `CandleUpdate.provisional`. A consumer holding history for the
7204
+ * same bucket keeps that open and widens the extremes rather than replacing
7205
+ * them.
7206
+ */
7207
+ provisional?: boolean;
7208
+ }
6967
7209
  /**
6968
7210
  * Broker-agnostic market-data source. The chart depends only on this.
6969
7211
  * `subscribeBars` is optional: a history-only feed (e.g. `OpenAlgoDataFeed`) omits
@@ -6974,7 +7216,7 @@ interface DataFeed {
6974
7216
  getBarsPage?(req: BarsPageRequest): Promise<BarsPage>;
6975
7217
  /** Read a closed-bar snapshot without initiating a network request. */
6976
7218
  getCachedBars?(req: BarsRequest): Promise<Bar[] | undefined>;
6977
- subscribeBars?(req: BarsRequest, onBar: (bar: Bar) => void, opts?: BarSubscriptionOptions): UnsubscribeFn;
7219
+ subscribeBars?(req: BarsRequest, onBar: (bar: Bar, meta?: LiveBarMeta) => void, opts?: BarSubscriptionOptions): UnsubscribeFn;
6978
7220
  /**
6979
7221
  * `opts.depthLevel` requests a book depth (broker-dependent: 5/20/30/50).
6980
7222
  * Named on the interface so a caller holding a `DataFeed` can ask for one;
@@ -7081,6 +7323,35 @@ interface DataLoadingOptions {
7081
7323
  maxBars?: number;
7082
7324
  /** Optional history repair cadence. Zero disables polling. */
7083
7325
  pollIntervalMs?: number;
7326
+ /**
7327
+ * Repair the tail when a bar closes, driven by the stream rather than the
7328
+ * clock. A pushed bar that opens a new bucket means the bar before it has
7329
+ * just closed, so one refresh runs `delayMs` later (default 2500 ms), long
7330
+ * enough for a broker's history to have published the close. Nothing fires
7331
+ * while the stream is quiet, so a closed market costs no requests. When the
7332
+ * reply still stops short of the bar that closed, the repair retries
7333
+ * `retries` times (default 2), `retryDelayMs` apart (default 5000 ms).
7334
+ * Off by default.
7335
+ */
7336
+ refreshOnBarClose?: boolean | {
7337
+ delayMs?: number;
7338
+ retries?: number;
7339
+ retryDelayMs?: number;
7340
+ };
7341
+ /**
7342
+ * Refresh at once when a pushed bar skips one or more whole buckets, which
7343
+ * is what a stream leaves behind after a dropped socket, a hidden tab or a
7344
+ * sleeping machine. Needs a fixed-length interval. Off by default.
7345
+ */
7346
+ refreshOnGap?: boolean;
7347
+ /**
7348
+ * How many bars back from the tail a refresh re-fetches. Unset re-fetches
7349
+ * the whole load window on every refresh, which is what polling always did;
7350
+ * a small number turns each repair into a tail request. A gap repair widens
7351
+ * the window to cover the gap. Needs a fixed-length interval; any other
7352
+ * interval keeps the whole window.
7353
+ */
7354
+ refreshWindowBars?: number;
7084
7355
  /** UTC seconds. */
7085
7356
  now?: () => number;
7086
7357
  }
@@ -7109,6 +7380,14 @@ declare class DataLoadingController {
7109
7380
  private _poll;
7110
7381
  private _visible;
7111
7382
  private _destroyed;
7383
+ /** Seconds per bar of the current request, null when the interval is not fixed-length. */
7384
+ private _seconds;
7385
+ /** Bucket whose open is only the first tick a builder saw, until history covers it. */
7386
+ private _provisionalTime;
7387
+ private _repairTimer;
7388
+ private _repairRetries;
7389
+ private _pendingRepair;
7390
+ private readonly _barClose;
7112
7391
  constructor(feed: DataFeed, options?: DataLoadingOptions);
7113
7392
  getState(): DataLoadingSnapshot;
7114
7393
  bars(): readonly Bar[];
@@ -7116,8 +7395,23 @@ declare class DataLoadingController {
7116
7395
  load(req: BarsRequest): Promise<readonly Bar[]>;
7117
7396
  private _load;
7118
7397
  refresh(): Promise<readonly Bar[]>;
7119
- /** Supply bars from an existing host subscription instead of subscribing twice. */
7120
- pushBar(value: Bar): void;
7398
+ private _refresh;
7399
+ /**
7400
+ * Supply bars from an existing host subscription instead of subscribing twice.
7401
+ *
7402
+ * `meta.provisional` marks a bar whose open is only the first tick a builder
7403
+ * saw, see `CandleUpdate.provisional`. Pushed onto a bar history already
7404
+ * holds for that bucket, it keeps that bar's open and widens the extremes
7405
+ * instead of replacing them, so a repair that found the true open is not
7406
+ * undone by the next tick.
7407
+ */
7408
+ pushBar(value: Bar, meta?: LiveBarMeta): void;
7409
+ /** The stream opened a bucket: the one before it closed, and any between were skipped. */
7410
+ private _onNewBucket;
7411
+ private _scheduleRepair;
7412
+ /** Run a repair now, or queue one behind the refresh already in flight rather than aborting it. */
7413
+ private _requestRepair;
7414
+ private _clearRepairTimer;
7121
7415
  loadMore(): Promise<readonly Bar[]>;
7122
7416
  private _loadMore;
7123
7417
  setPaused(paused: boolean): void;
@@ -8030,7 +8324,7 @@ declare class OpenAlgoLiveDataFeed implements DataFeed {
8030
8324
  * a `day-delta` builder diffs against the right baseline. Seeding applies to
8031
8325
  * time-bucketed intervals: a count-driven bar cannot resume a historical one.
8032
8326
  */
8033
- subscribeBars(req: BarsRequest, onBar: (bar: Bar) => void, opts?: BarSubscriptionOptions): UnsubscribeFn;
8327
+ subscribeBars(req: BarsRequest, onBar: (bar: Bar, meta?: LiveBarMeta) => void, opts?: BarSubscriptionOptions): UnsubscribeFn;
8034
8328
  /** A broker may omit the tick timestamp; never bucket at the epoch, use now. */
8035
8329
  private static _tickTime;
8036
8330
  private _candleReader;
@@ -8429,7 +8723,7 @@ declare class BarCache implements DataFeed {
8429
8723
  private _misses;
8430
8724
  private _evictions;
8431
8725
  constructor(feed: DataFeed, options?: BarCacheOptions);
8432
- subscribeBars?: (req: BarsRequest, onBar: (bar: Bar) => void, ...rest: unknown[]) => UnsubscribeFn;
8726
+ subscribeBars?: (req: BarsRequest, onBar: (bar: Bar, meta?: LiveBarMeta) => void, ...rest: unknown[]) => UnsubscribeFn;
8433
8727
  subscribeDepth?: (req: BarsRequest, onDepth: (depth: MarketDepth) => void, ...rest: unknown[]) => UnsubscribeFn;
8434
8728
  getBarsPage?: (req: BarsPageRequest) => Promise<BarsPage>;
8435
8729
  getBars(req: CachedBarsRequest): Promise<Bar[]>;
@@ -8663,4 +8957,4 @@ declare function lerp(a: number, b: number, t: number): number;
8663
8957
  */
8664
8958
  declare function roundToTick(value: number, step: number): number;
8665
8959
 
8666
- export { ALT_PRESET, type AddSeriesOptions, type AggTick, type AxisChromeOptions, type AxisStyle, BAR_CACHE_VERSION, BUILTIN_COMMANDS, type Bar, BarCache, type BarCacheOptions, type BarCacheStats, type BarCacheStore, type BarSubscriptionOptions, type BarUpdate, type BarsPage, type BarsPageRequest, type BarsRequest, type BrandingChangedEvent, type Bucketing, BuySellButtons, type BuySellButtonsOptions, CHART_STATE_VERSION, type CachedBars, type CachedBarsRequest, type CalendarBucketing, type CalendarUnit, CandleBuilder, type CandleBuilderOptions, type CandleGeometry, type CandleStyle, type CandleTier, type CandleUpdate, Canvas2dBackend, type CanvasLineStyle, type CanvasOptions, Chart, type ChartClickEvent, type ChartDataContext, type ChartDragEndEvent, type ChartDragEvent, type ChartEvent, type ChartEventOptions, type ChartNavigationOptions, type ChartObjectCapabilities, type ChartObjectDefinition, type ChartObjectDrawing, type ChartObjectDrawingSource, type ChartObjectKind, type ChartObjectProvider, type ChartObjectSnapshot, ChartObjects, type ChartObjectsOptions, type ChartOptions, type ChartSettingsColorPairInput, type ChartSettingsInput, type ChartSettingsState, type ChartSettingsTab, type ChartSettingsTabId, type ChartSettingsValue, type ChartSettingsValues, type ChartState, ChartTable, type ChartTableOptions, type ChartTheme, type ChartWatermarkOptions, type ComparisonAlignment, type ComparisonChartHost, ComparisonController, type ComparisonControllerOptions, type ComparisonHandle, type ComparisonMode, type ComparisonOptions, type ComparisonPane, type ContextMenuEvent, type ContextMenuTarget, type ContextMenuTargetKind, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairStyle, type CustomShortcut, DEFAULT_CANDLE_BUILDER_OPTIONS, DEFAULT_CANDLE_STYLE, DEFAULT_CHART_TABLE_OPTIONS, DEFAULT_HISTOGRAM_STYLE, DEFAULT_KEYMAP, DEFAULT_PRICE_SCALE_OPTIONS, DEFAULT_THEME, DEFAULT_TIMEZONE, DEFAULT_TIME_NAVIGATOR_OPTIONS, DEFAULT_TIME_SCALE_OPTIONS, DEFAULT_TRADING_COLORS, DEFAULT_ZOOM_GLIDE_OPTIONS, type DataFeed, DataLayer, DataLoadingController, type DataLoadingOptions, type DataLoadingSnapshot, type DataLoadingStatus, type DataUpdateReason, type DecodedOrder, type DepthLevel, type DoubleClickAction, type DoubleClickEvent, type DrawAnchor, type DrawItem, EventMarkers, type ExportSvgOptions, FakeDataFeed, type FeedScheduler, type FillGradient, type FillPoint, type GridAxisStyle, type GridOptions, type GridStyle, type HistogramStyle, type HistoryLoadingStatus, HistoryRequestPool, type HistoryRequestPoolOptions, INDICATOR_LINE_STYLES, INDICATOR_PLOT_STYLES, INDICATOR_SOURCES, type IPrimitive, type IRenderBackend, IST_OFFSET_SECONDS, type IndexedBar, type IndicatorAlertContext, type IndicatorAlertPayload, type IndicatorAlertSpec, type IndicatorApi, type IndicatorAttachContext, IndicatorBackground, type IndicatorCalcContext, type IndicatorDataChange, type IndicatorDataStatus, type IndicatorDescriptor, type IndicatorDrawing, IndicatorDrawings, IndicatorFill, type IndicatorFillOptions, type IndicatorFillSpec, type IndicatorHost, type IndicatorInput, type IndicatorLevel, type IndicatorLevelContext, type IndicatorLineStyle, type IndicatorPlot, type IndicatorSettings, type IndicatorSource, type IndicatorState, type IndicatorStore, type IndicatorValues, type IntervalBucketing, type IntervalDescriptor, type IntervalParts, InvalidationLevel, type IstParts, type KeymapEntry, LINK_CROSSHAIR_ALPHA, type LateTickPolicy, type LegendField, type LegendStatusData, type LegendStatusLineOptions, type LegendStatusSource, type LegendTitleMode, type LegendValue, type LinePoint, type LinkChart, LinkCrosshair, type LinkDataLayer, LinkGroup, type LinkMemberOptions, type LinkMissingPolicy, type LinkOptions, type LogicalRange, LogoWatermark, type LogoWatermarkOptions, type LtpEvent, type MarkerPosition, type MarkerShape, type MarkerSize, type MarketDepth, type MarketPhase, type MarketPhaseFn, type MaybePromise, type ModeCheck, type OpenAlgoConfig, OpenAlgoDataFeed, type OpenAlgoLiveConfig, OpenAlgoLiveDataFeed, type OpenAlgoTradeConfig, OpenAlgoTradeFeed, type OpenAlgoWsConfig, OpenAlgoWsFeed, type OrderBookSnapshot, type OrderDecodeCode, type OrderDecodeIssue, type OrderDecodeResult, type OrderSide$1 as OrderSide, type OrderType$1 as OrderType, type OrderUpdateEvent, type OriginalTime, PRICE_LEVEL_KINDS, PRICE_SCALE_MODES, Pane, type PaneInvalidation, PaneLegend, type PaneLegendAction, type PaneLegendOptions, type PaneState, type PickHost, type PickKind, type PlaceOrder, type PlotMarginOptions, type PointerInfo, type PointerKind, type PointerModifiers, type PointerSample, type PositionSide, type PriceAxisState, type PriceFormat, type PriceLevelInput, type PriceLevelKind, type PriceLevelQuote, type PriceLevelStyle, type PriceLevelValues, PriceLevels, type PriceLevelsOptions, PriceLine, type PriceLineOptions, type PriceRange, PriceScale, type PriceScaleId, type PriceScaleMode, type PriceScaleOptions, type PriceScaleState, type PrimitiveAnchor, type PrimitiveHit, type PrimitiveHost, type PrimitivePlacement, type PrimitiveRenderContext, type QuarantinedRow, type RawOrder, type RenderBackendFactory, type RenderBackendKind, type RenderDevice, type RendererChoice, type RendererEntry, type RendererFallbackEvent, type RendererFallbackReason, type ReplayChartHost, ReplayController, type ReplayOptions, type ReplayScheduler, ReplayShade, type ReplayShadeOptions, type ReplayState, type ReplayViewport, type ResolvedLinkOptions, type RestoreReport, SCALE_FONT_MAX, SCALE_FONT_MIN, type ScaleCanvasOptions, type SeriesApi, type SeriesDataItem, type SeriesId, type SeriesMarker, SeriesMarkers, type SeriesRenderContext, type SeriesState, type SeriesStyle, type SeriesType, type SessionSpec, type ShortcutListItem, ShortcutManager, type ShortcutManagerOptions, type ShortcutPreset, type ShortcutScope, type ShortcutTriggerEvent, type Size, type SocketFactory, type SocketLike, type SupertrendPoint, SvgContext, type SvgContextOptions, SvgLinearGradient, type TableCell, type TablePosition, TextWatermark, type TextWatermarkOptions, type Tick, TickBarAggregator, type TickBarOptions, type TickCountBucketing, type TickMarkType, type TickTimeframe, TimeNavigator, type TimeNavigatorAction, type TimeNavigatorOptions, TimeScale, type TimeScaleOp, type TimeScaleOptions, type TradeFeed, type TradeMarkerVariant, TradeMarkersPrimitive, type TradingColors, TradingController, type TradingHost, type TradingLineStyle, type TradingLineVariant, type TradingOrder, type TradingOrderSide, type TradingOrderType, type TradingPosition, type TradingSettings, type TradingSyncPayload, type TradingTrade, type UTCSeconds, UnknownIntervalError, type UnsubscribeFn, VERSION, type VolumeBucketing, type VolumeMode, type WatermarkPosition, type Whitespace, type WsClientWarning, type WsControlMessage, type WsMode, type WsState, type ZOrder, type ZonedParts, type ZonedPeriod, type ZoomAnchor, ZoomGlide, type ZoomGlideOptions, addComparison, alignToPrimary, applyChartSettings, atr, autoscaleRange, backendDegradation, backoffDelayMs, barCacheKey, barCloseSec, beginPick, bestHit, bitmapSize, bucketStartOf, calendarPeriodFlags, candleGeometry, candleTier, chartSettingsSchema, clamp, classifyAuthAck, compactVolume, comparisonController, computePriceLevels, conflateBars, conflateItems, conflationGroupSize, createChart, createLinkGroup, createRenderBackend, darkTheme, dashPattern, decodeOrder, drawLabel, drawShape, effectiveMarkerPx, ema, emaSeries, epochMsToUtcSeconds, eventToCombo, followerIndex, followerRange, formatCombo, formatIstCrosshairLabel, formatIstDate, formatIstTime, formatIstTimeSeconds, formatSubscribe, formatUnsubscribe, formatZonedCrosshairLabel, formatZonedDate, formatZonedTime, formatZonedTimeSeconds, fromGradient, generateBars, getChartType, getIndicator, hasIndicator, inSessionAt, indicatorDefaults, indicatorStyleInputs, intervalParts, intervalToSeconds, isDailyInterval, isIntradayInterval, isKnownInterval, isNewIstDay, isNewZonedDay, isNewZonedMonth, isNewZonedPeriod, isNewZonedQuarter, isNewZonedWeek, isNewZonedYear, isRebasing, isReservedCombo, isSecondsInterval, isTickInterval, isTimeBucketed, isValidCombo, isValidTimezone, isWhitespace, istStringToUtcSeconds, lastPriceLevelFromSeriesStyle, lerp, lightTheme, mapHistoryResponse, mapOrder, mapOrderStatus, mapPosition, markerSizePx, mergeBars, nextBucketStart, niceTicks, normalizeCombo, optimalBarWidth, parseCombo, parseMessage, parseSessionSpec, parseTopic, plotStyleKeys, precisionForStep, readChartSettings, readSequence, registerChartType, registerIndicator, registerInterval, registerRenderBackend, registeredChartTypes, registeredIndicators, registeredIntervals, registeredRenderBackends, resolveCrosshairStyle, resolveGridStyle, resolveInterval, resolvePlotMargins, resolveRenderBackend, resolveScaleStyle, roundToTick, rowTimeToUtcSeconds, rsi, rsiSeries, seriesStyleForLastPriceLevel, sessionFlags, sessionStartFlags, sessionStartIndices, sharedHistoryRequests, snapToDevicePixel, sourceValue, sourceValues, startOfZonedDay, startOfZonedMonth, startOfZonedWeek, supertrend, supertrendSeries, tableOrigin, toBar, trueRange, tryResolveInterval, unregisterInterval, unregisterRenderBackend, utcSecondsToIstDateString, utcSecondsToIstParts, utcSecondsToZonedDateString, utcSecondsToZonedParts, version, verticalGradient, watermarkRect, withAlpha, withBarCache, zoneOffsetSeconds, zonedDayIndex, zonedStringToUtcSeconds, zonedWallClockToUtcSeconds, zonedWeekIndex };
8960
+ export { ALT_PRESET, type AddSeriesOptions, type AggTick, type AxisChromeOptions, type AxisStyle, BAR_CACHE_VERSION, BUILTIN_COMMANDS, type Bar, BarCache, type BarCacheOptions, type BarCacheStats, type BarCacheStore, type BarSubscriptionOptions, type BarUpdate, type BarsPage, type BarsPageRequest, type BarsRequest, type BrandingChangedEvent, type Bucketing, BuySellButtons, type BuySellButtonsOptions, CHART_STATE_VERSION, type CachedBars, type CachedBarsRequest, type CalendarBucketing, type CalendarUnit, CandleBuilder, type CandleBuilderOptions, type CandleGeometry, type CandleStyle, type CandleTier, type CandleUpdate, Canvas2dBackend, type CanvasLineStyle, type CanvasOptions, Chart, type ChartClickEvent, type ChartDataContext, type ChartDragEndEvent, type ChartDragEvent, type ChartEvent, type ChartEventOptions, type ChartNavigationOptions, type ChartObjectCapabilities, type ChartObjectDefinition, type ChartObjectDrawing, type ChartObjectDrawingSource, type ChartObjectKind, type ChartObjectProvider, type ChartObjectSnapshot, ChartObjects, type ChartObjectsOptions, type ChartOptions, type ChartSettingsColorPairInput, type ChartSettingsInput, type ChartSettingsState, type ChartSettingsTab, type ChartSettingsTabId, type ChartSettingsValue, type ChartSettingsValues, type ChartState, ChartTable, type ChartTableOptions, type ChartTheme, type ChartWatermarkOptions, type ComparisonAlignment, type ComparisonChartHost, ComparisonController, type ComparisonControllerOptions, type ComparisonHandle, type ComparisonMode, type ComparisonOptions, type ComparisonPane, type ContextMenuEvent, type ContextMenuTarget, type ContextMenuTargetKind, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairStyle, type CustomShortcut, DEFAULT_CANDLE_BUILDER_OPTIONS, DEFAULT_CANDLE_STYLE, DEFAULT_CHART_TABLE_OPTIONS, DEFAULT_HISTOGRAM_STYLE, DEFAULT_KEYMAP, DEFAULT_PRICE_SCALE_OPTIONS, DEFAULT_THEME, DEFAULT_TIMEZONE, DEFAULT_TIME_NAVIGATOR_OPTIONS, DEFAULT_TIME_SCALE_OPTIONS, DEFAULT_TRADING_COLORS, DEFAULT_ZOOM_GLIDE_OPTIONS, type DataFeed, DataLayer, DataLoadingController, type DataLoadingOptions, type DataLoadingSnapshot, type DataLoadingStatus, type DataUpdateReason, type DecodedOrder, type DepthLevel, type DoubleClickAction, type DoubleClickEvent, type DrawAnchor, type DrawItem, EventMarkers, type ExportSvgOptions, FakeDataFeed, type FeedScheduler, type FillGradient, type FillPoint, type GridAxisStyle, type GridOptions, type GridStyle, type HistogramStyle, type HistoryLoadingStatus, HistoryRequestPool, type HistoryRequestPoolOptions, INDICATOR_LINE_STYLES, INDICATOR_PLOT_STYLES, INDICATOR_SOURCES, type IPrimitive, type IRenderBackend, IST_OFFSET_SECONDS, type IndexedBar, type IndicatorAlertContext, type IndicatorAlertPayload, type IndicatorAlertSpec, type IndicatorApi, type IndicatorAttachContext, IndicatorBackground, type IndicatorBarsProvider, type IndicatorBarsRequest, type IndicatorCalcContext, type IndicatorDataChange, type IndicatorDataStatus, type IndicatorDescriptor, type IndicatorDrawing, IndicatorDrawings, IndicatorFill, type IndicatorFillOptions, type IndicatorFillSpec, type IndicatorHost, type IndicatorInput, IndicatorInputError, type IndicatorLevel, type IndicatorLevelContext, type IndicatorLineStyle, type IndicatorPlot, type IndicatorSettings, type IndicatorSource, type IndicatorState, type IndicatorStore, type IndicatorValues, type IntervalBucketing, type IntervalDescriptor, type IntervalParts, InvalidationLevel, type IstParts, type KeymapEntry, LINK_CROSSHAIR_ALPHA, type LateTickPolicy, type LegendField, type LegendStatusData, type LegendStatusLineOptions, type LegendStatusSource, type LegendTitleMode, type LegendValue, type LinePoint, type LinkChart, LinkCrosshair, type LinkDataLayer, LinkGroup, type LinkMemberOptions, type LinkMissingPolicy, type LinkOptions, type LiveBarMeta, type LogicalRange, LogoWatermark, type LogoWatermarkOptions, type LtpEvent, type MarkerPosition, type MarkerShape, type MarkerSize, type MarketDepth, type MarketPhase, type MarketPhaseFn, type MaybePromise, type ModeCheck, type OpenAlgoConfig, OpenAlgoDataFeed, type OpenAlgoLiveConfig, OpenAlgoLiveDataFeed, type OpenAlgoTradeConfig, OpenAlgoTradeFeed, type OpenAlgoWsConfig, OpenAlgoWsFeed, type OrderBookSnapshot, type OrderDecodeCode, type OrderDecodeIssue, type OrderDecodeResult, type OrderSide$1 as OrderSide, type OrderType$1 as OrderType, type OrderUpdateEvent, type OriginalTime, PRICE_LEVEL_KINDS, PRICE_SCALE_MODES, Pane, type PaneInvalidation, PaneLegend, type PaneLegendAction, type PaneLegendOptions, type PaneState, type PickHost, type PickKind, type PlaceOrder, type PlotBarColor, type PlotMarginOptions, type PointerInfo, type PointerKind, type PointerModifiers, type PointerSample, type PositionSide, type PriceAxisState, type PriceFormat, type PriceLevelInput, type PriceLevelKind, type PriceLevelQuote, type PriceLevelStyle, type PriceLevelValues, PriceLevels, type PriceLevelsOptions, PriceLine, type PriceLineOptions, type PriceRange, PriceScale, type PriceScaleId, type PriceScaleMode, type PriceScaleOptions, type PriceScaleState, type PrimitiveAnchor, type PrimitiveHit, type PrimitiveHost, type PrimitivePlacement, type PrimitiveRenderContext, type QuarantinedRow, type RawOrder, type RenderBackendFactory, type RenderBackendKind, type RenderDevice, type RendererChoice, type RendererEntry, type RendererFallbackEvent, type RendererFallbackReason, type ReplayChartHost, ReplayController, type ReplayOptions, type ReplayScheduler, ReplayShade, type ReplayShadeOptions, type ReplayState, type ReplayViewport, type ResolvedLinkOptions, type RestoreReport, SCALE_FONT_MAX, SCALE_FONT_MIN, type ScaleCanvasOptions, type SeriesApi, type SeriesDataItem, type SeriesId, type SeriesMarker, SeriesMarkers, type SeriesRenderContext, type SeriesState, type SeriesStyle, type SeriesType, type SessionSpec, type ShortcutListItem, ShortcutManager, type ShortcutManagerOptions, type ShortcutPreset, type ShortcutScope, type ShortcutTriggerEvent, type Size, type SocketFactory, type SocketLike, type SupertrendPoint, SvgContext, type SvgContextOptions, SvgLinearGradient, type TableCell, type TablePosition, TextWatermark, type TextWatermarkOptions, type Tick, TickBarAggregator, type TickBarOptions, type TickCountBucketing, type TickMarkType, type TickTimeframe, TimeNavigator, type TimeNavigatorAction, type TimeNavigatorOptions, TimeScale, type TimeScaleOp, type TimeScaleOptions, type TradeFeed, type TradeMarkerVariant, TradeMarkersPrimitive, type TradingColors, TradingController, type TradingHost, type TradingLineStyle, type TradingLineVariant, type TradingOrder, type TradingOrderSide, type TradingOrderType, type TradingPosition, type TradingSettings, type TradingSyncPayload, type TradingTrade, type UTCSeconds, UnknownIntervalError, type UnsubscribeFn, VERSION, type VolumeBucketing, type VolumeMode, type WatermarkPosition, type Whitespace, type WsClientWarning, type WsControlMessage, type WsMode, type WsState, type ZOrder, type ZonedParts, type ZonedPeriod, type ZoomAnchor, ZoomGlide, type ZoomGlideOptions, addComparison, alignToPrimary, applyChartSettings, atr, autoscaleRange, backendDegradation, backoffDelayMs, barCacheKey, barCloseSec, beginPick, bestHit, bitmapSize, bucketStartOf, calendarPeriodFlags, candleGeometry, candleTier, chartSettingsSchema, clamp, classifyAuthAck, compactVolume, comparisonController, computePriceLevels, conflateBars, conflateItems, conflationGroupSize, createChart, createLinkGroup, createRenderBackend, darkTheme, dashPattern, decodeOrder, drawLabel, drawShape, effectiveMarkerPx, ema, emaSeries, epochMsToUtcSeconds, eventToCombo, followerIndex, followerRange, formatCombo, formatIstCrosshairLabel, formatIstDate, formatIstTime, formatIstTimeSeconds, formatSubscribe, formatUnsubscribe, formatZonedCrosshairLabel, formatZonedDate, formatZonedTime, formatZonedTimeSeconds, fromGradient, generateBars, getChartType, getIndicator, hasIndicator, inSessionAt, indicatorDefaults, indicatorStyleInputs, intervalParts, intervalToSeconds, isDailyInterval, isIntradayInterval, isKnownInterval, isNewIstDay, isNewZonedDay, isNewZonedMonth, isNewZonedPeriod, isNewZonedQuarter, isNewZonedWeek, isNewZonedYear, isRebasing, isReservedCombo, isSecondsInterval, isTickInterval, isTimeBucketed, isValidCombo, isValidTimezone, isWhitespace, istStringToUtcSeconds, lastPriceLevelFromSeriesStyle, lerp, lightTheme, mapHistoryResponse, mapOrder, mapOrderStatus, mapPosition, markerSizePx, mergeBars, nextBucketStart, niceTicks, normalizeCombo, optimalBarWidth, parseCombo, parseMessage, parseSessionSpec, parseTopic, plotStyleKeys, precisionForStep, readChartSettings, readSequence, registerChartType, registerIndicator, registerInterval, registerRenderBackend, registeredChartTypes, registeredIndicators, registeredIntervals, registeredRenderBackends, resolveCrosshairStyle, resolveGridStyle, resolveInterval, resolvePlotMargins, resolveRenderBackend, resolveScaleStyle, roundToTick, rowTimeToUtcSeconds, rsi, rsiSeries, seriesStyleForLastPriceLevel, sessionFlags, sessionStartFlags, sessionStartIndices, sharedHistoryRequests, snapToDevicePixel, sourceValue, sourceValues, startOfZonedDay, startOfZonedMonth, startOfZonedWeek, supertrend, supertrendSeries, tableOrigin, toBar, trueRange, tryResolveInterval, unregisterInterval, unregisterRenderBackend, utcSecondsToIstDateString, utcSecondsToIstParts, utcSecondsToZonedDateString, utcSecondsToZonedParts, version, verticalGradient, watermarkRect, withAlpha, withBarCache, zoneOffsetSeconds, zonedDayIndex, zonedStringToUtcSeconds, zonedWallClockToUtcSeconds, zonedWeekIndex };
@@ -1,4 +1,4 @@
1
- import { IndicatorDescriptor, ChartDataContext, IndicatorSettings, Bar, IndicatorInput, IndicatorPlot, IndicatorLevel } from 'openalgo-charts';
1
+ import { IndicatorDescriptor, ChartDataContext, IndicatorSettings, Bar, IndicatorBarsRequest, IndicatorInput, IndicatorPlot, IndicatorValues, IndicatorStore, IndicatorCalcContext, IndicatorLevel } from 'openalgo-charts';
2
2
 
3
3
  declare const SMA: IndicatorDescriptor;
4
4
  declare const WMA: IndicatorDescriptor;
@@ -1106,6 +1106,12 @@ interface Tier2Context {
1106
1106
  /** UTC seconds of the first and last source bar (0 when there are none). */
1107
1107
  from: number;
1108
1108
  to: number;
1109
+ /**
1110
+ * The host's bar provider, when the runtime supplies one, so a `fetch` that
1111
+ * needs another instrument's candles asks the host rather than carrying its
1112
+ * own transport and credentials. Rejects when the host registered none.
1113
+ */
1114
+ requestBars?(request: IndicatorBarsRequest): Promise<readonly Bar[]>;
1109
1115
  }
1110
1116
  interface Tier2Descriptor {
1111
1117
  id: string;
@@ -1114,6 +1120,22 @@ interface Tier2Descriptor {
1114
1120
  placement: 'onchart' | 'pane';
1115
1121
  inputs: readonly IndicatorInput[];
1116
1122
  plots: readonly IndicatorPlot[];
1123
+ /**
1124
+ * External columns to align besides the plots, by key. A point may carry
1125
+ * more than what is drawn: a benchmark close that `calc` divides by, an
1126
+ * open-interest figure a ratio is built from. Anything not named here or in
1127
+ * `plots` is dropped at alignment.
1128
+ */
1129
+ series?: readonly string[];
1130
+ /**
1131
+ * Combine the aligned external columns with the chart's own bars. Without
1132
+ * it the aligned columns are the result, one per plot, exactly as before.
1133
+ * With it, `external` holds every plot and `series` key aligned onto the
1134
+ * bars (last-known-value, `null` before the first point), and the return is
1135
+ * what the plots draw: a relative strength, a beta, a spread. Pure in its
1136
+ * arguments, like any `calc`.
1137
+ */
1138
+ calc?(bars: readonly Bar[], external: IndicatorValues, settings: Readonly<IndicatorSettings>, store: IndicatorStore, ctx?: IndicatorCalcContext): IndicatorValues;
1117
1139
  /** A host/provider can explicitly decline data it cannot supply. */
1118
1140
  supports?(ctx: Tier2Context): boolean;
1119
1141
  /** Load the series for the current window. */
@@ -1150,6 +1172,61 @@ interface Tier2Descriptor {
1150
1172
  */
1151
1173
  declare function createTier2Indicator(d: Tier2Descriptor): IndicatorDescriptor;
1152
1174
 
1175
+ /**
1176
+ * A higher-timeframe view of the chart's own bars, one value per source bar.
1177
+ *
1178
+ * A study written for a script language asks for the daily high on a 5-minute
1179
+ * chart and gets a column the same length as the chart. The engine has no
1180
+ * such call, and every port that needed one folded the bars by hand, each a
1181
+ * little differently: some anchored an hourly bucket to midnight and some to
1182
+ * the session open, some read the bucket as it stood and some read its final
1183
+ * values. This is the one fold, with the three readings named:
1184
+ *
1185
+ * - `offset: 0` (the default) reads the bucket **as it stood at that bar**:
1186
+ * its open so far, high and low so far, the bar's own close, volume so far.
1187
+ * It is what the live bar sees and it never uses a later bar.
1188
+ * - `offset: k` reads the bucket that completed `k` buckets before, held
1189
+ * constant across the current one. The classic non-repainting reference,
1190
+ * `close[1]` on the higher timeframe.
1191
+ * - `lookahead: true` reads the current bucket's **final** values on every one
1192
+ * of its bars. It uses bars that had not happened yet, which is what the
1193
+ * source it is porting did; it is here so that can be reproduced, not
1194
+ * recommended.
1195
+ *
1196
+ * Buckets follow the chart's calendar: a day is a day in `timezone`, a week
1197
+ * starts on Monday there, and a sub-day interval is anchored to the epoch, or
1198
+ * to the session open when `session` is given, which is how an exchange cuts
1199
+ * its hourly bars.
1200
+ */
1201
+
1202
+ interface SecurityOptions {
1203
+ /** The calendar the buckets are cut in. Defaults to the shipped default zone. */
1204
+ timezone?: string;
1205
+ /** Read each bucket's final values on all of its bars. Default false. */
1206
+ lookahead?: boolean;
1207
+ /** Read the bucket completed this many buckets ago. Default 0, the current one. */
1208
+ offset?: number;
1209
+ /**
1210
+ * A session window, `'0915-1530'`, that anchors sub-day buckets to the
1211
+ * session open instead of the epoch. Without it a 30-minute bucket on a
1212
+ * 09:15 open runs 09:00 to 09:30; with it, 09:15 to 09:45.
1213
+ */
1214
+ session?: string;
1215
+ }
1216
+ interface SecuritySeries {
1217
+ open: (number | null)[];
1218
+ high: (number | null)[];
1219
+ low: (number | null)[];
1220
+ close: (number | null)[];
1221
+ /** Null on a bucket none of whose bars carried volume. */
1222
+ volume: (number | null)[];
1223
+ /** Time of the first source bar in the bucket being read, UTC seconds. */
1224
+ bucketStart: (number | null)[];
1225
+ /** True on the first source bar of each bucket. */
1226
+ isNew: boolean[];
1227
+ }
1228
+ declare function securitySeries(bars: readonly Bar[], interval: string, options?: SecurityOptions): SecuritySeries;
1229
+
1153
1230
  declare const INDICATORS_TIER: "indicators";
1154
1231
  /** Every built-in descriptor, in picker order. */
1155
1232
  declare const BUILTIN_INDICATORS: readonly IndicatorDescriptor[];
@@ -1160,4 +1237,4 @@ declare const BUILTIN_INDICATORS: readonly IndicatorDescriptor[];
1160
1237
  */
1161
1238
  declare function registerBuiltinIndicators(): void;
1162
1239
 
1163
- export { ADAPTIVE_INDICATORS, ADL, ADX, ALLIGATOR, ALMA, ALPHATREND, AROON, AROON_OSCILLATOR, ATR, AVERAGE_DAILY_RANGE, AVERAGE_INDICATORS, AWESOME_OSCILLATOR, BALANCE_OF_POWER, BB_TREND, BOLLINGER, BOLLINGER_BANDWIDTH, BOLLINGER_PERCENT_B, BUILTIN_INDICATORS, CCI, CHAIKIN_MONEY_FLOW, CHAIKIN_OSCILLATOR, CHAIKIN_VOLATILITY, CHANDELIER_EXIT, CHANDE_KROLL_STOP, CHANDE_MOMENTUM, CHOPPINESS_INDEX, CHOP_ZONE, CONNORS_RSI, CONSOLIDATION_BREAKOUT, COPPOCK_CURVE, CPR, DEMA, DONCHIAN, DPO, EASE_OF_MOVEMENT, ELDER_FORCE_INDEX, EMA, ENVELOPE, FISHER_TRANSFORM, FLOW_INDICATORS, HALFTREND, HISTORICAL_VOLATILITY, HMA, HULL_SUITE, ICHIMOKU, INDEX_INDICATORS, INDICATORS_TIER, KAMA, KELTNER_CHANNEL, KLINGER_OSCILLATOR, KNOW_SURE_THING, LINREG_SLOPE, LSMA, MACD, MASS_INDEX, MA_CHANNEL, MA_CROSS, MA_RIBBON, MCGINLEY_DYNAMIC, MEDIAN, MFI, MOMENTUM, NET_VOLUME, NVI, OBV, OSCILLATOR_INDICATORS, OVERLAY_INDICATORS, PARABOLIC_SAR, PPO, PVI, PVO, PVT, RANGE_ANALYSIS, RANGE_INDICATORS, RELATIVE_VIGOR_INDEX, RELATIVE_VOLATILITY_INDEX, ROC, RSI, RSI_DIVERGENCE, SEASONALITY, SEASONALITY_INDICATORS, SIGNAL_INDICATORS, SMA, SMI, SMI_ERGODIC_INDICATOR, SMI_ERGODIC_OSCILLATOR, SMMA, SPECIAL_K, STANDARD_DEVIATION, STANDARD_ERROR, STANDARD_ERROR_BANDS, STOCHASTIC, STOCHASTIC_RSI, STRENGTH_INDICATORS, STUDY_INDICATORS, SUPERTREND, T3, TEMA, TREND_STRENGTH_INDEX, TRIX, TSI, TWAP, type Tier2Context, type Tier2Descriptor, type Tier2Point, ULCER_INDEX, ULTIMATE_OSCILLATOR, VOLATILITY_INDICATORS, VOLATILITY_STOP, VOLUME, VORTEX, VWAP, VWMA, WAVETREND, WAVETREND_INDICATORS, WILLIAMS_FRACTALS, WILLIAMS_PERCENT_R, WILLIAMS_VIX_FIX, WMA, WOODIES_CCI, alma, barsSince, cci, change, connorsStreak, correlation, createTier2Indicator, cumulative, dev, highest, highestBars, linreg, lowest, lowestBars, nulls, percentRank, percentileNearestRank, pivotHigh, pivotLow, registerBuiltinIndicators, rma, roc, rollingSum, sma, smaSeededEma, stdev, stoch, swma, valueWhen, vwma, wma };
1240
+ export { ADAPTIVE_INDICATORS, ADL, ADX, ALLIGATOR, ALMA, ALPHATREND, AROON, AROON_OSCILLATOR, ATR, AVERAGE_DAILY_RANGE, AVERAGE_INDICATORS, AWESOME_OSCILLATOR, BALANCE_OF_POWER, BB_TREND, BOLLINGER, BOLLINGER_BANDWIDTH, BOLLINGER_PERCENT_B, BUILTIN_INDICATORS, CCI, CHAIKIN_MONEY_FLOW, CHAIKIN_OSCILLATOR, CHAIKIN_VOLATILITY, CHANDELIER_EXIT, CHANDE_KROLL_STOP, CHANDE_MOMENTUM, CHOPPINESS_INDEX, CHOP_ZONE, CONNORS_RSI, CONSOLIDATION_BREAKOUT, COPPOCK_CURVE, CPR, DEMA, DONCHIAN, DPO, EASE_OF_MOVEMENT, ELDER_FORCE_INDEX, EMA, ENVELOPE, FISHER_TRANSFORM, FLOW_INDICATORS, HALFTREND, HISTORICAL_VOLATILITY, HMA, HULL_SUITE, ICHIMOKU, INDEX_INDICATORS, INDICATORS_TIER, KAMA, KELTNER_CHANNEL, KLINGER_OSCILLATOR, KNOW_SURE_THING, LINREG_SLOPE, LSMA, MACD, MASS_INDEX, MA_CHANNEL, MA_CROSS, MA_RIBBON, MCGINLEY_DYNAMIC, MEDIAN, MFI, MOMENTUM, NET_VOLUME, NVI, OBV, OSCILLATOR_INDICATORS, OVERLAY_INDICATORS, PARABOLIC_SAR, PPO, PVI, PVO, PVT, RANGE_ANALYSIS, RANGE_INDICATORS, RELATIVE_VIGOR_INDEX, RELATIVE_VOLATILITY_INDEX, ROC, RSI, RSI_DIVERGENCE, SEASONALITY, SEASONALITY_INDICATORS, SIGNAL_INDICATORS, SMA, SMI, SMI_ERGODIC_INDICATOR, SMI_ERGODIC_OSCILLATOR, SMMA, SPECIAL_K, STANDARD_DEVIATION, STANDARD_ERROR, STANDARD_ERROR_BANDS, STOCHASTIC, STOCHASTIC_RSI, STRENGTH_INDICATORS, STUDY_INDICATORS, SUPERTREND, type SecurityOptions, type SecuritySeries, T3, TEMA, TREND_STRENGTH_INDEX, TRIX, TSI, TWAP, type Tier2Context, type Tier2Descriptor, type Tier2Point, ULCER_INDEX, ULTIMATE_OSCILLATOR, VOLATILITY_INDICATORS, VOLATILITY_STOP, VOLUME, VORTEX, VWAP, VWMA, WAVETREND, WAVETREND_INDICATORS, WILLIAMS_FRACTALS, WILLIAMS_PERCENT_R, WILLIAMS_VIX_FIX, WMA, WOODIES_CCI, alma, barsSince, cci, change, connorsStreak, correlation, createTier2Indicator, cumulative, dev, highest, highestBars, linreg, lowest, lowestBars, nulls, percentRank, percentileNearestRank, pivotHigh, pivotLow, registerBuiltinIndicators, rma, roc, rollingSum, securitySeries, sma, smaSeededEma, stdev, stoch, swma, valueWhen, vwma, wma };