openalgo-charts 2.7.1 → 2.7.3

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.
Files changed (51) hide show
  1. package/README.md +27 -27
  2. package/dist/draw/index.d.ts +117 -8
  3. package/dist/index.d.ts +122 -10
  4. package/dist/indicators/index.d.ts +8 -1
  5. package/dist/openalgo-charts.draw.mjs +1 -1
  6. package/dist/openalgo-charts.draw.mjs.map +1 -1
  7. package/dist/openalgo-charts.draw.standalone.js +1 -1
  8. package/dist/openalgo-charts.indicators.mjs +1 -1
  9. package/dist/openalgo-charts.indicators.mjs.map +1 -1
  10. package/dist/openalgo-charts.indicators.standalone.js +1 -1
  11. package/dist/openalgo-charts.mjs +1 -1
  12. package/dist/openalgo-charts.mjs.map +1 -1
  13. package/dist/openalgo-charts.profile.mjs +1 -1
  14. package/dist/openalgo-charts.profile.mjs.map +1 -1
  15. package/dist/openalgo-charts.profile.standalone.js +1 -1
  16. package/dist/openalgo-charts.standalone.js +1 -1
  17. package/dist/openalgo-charts.standalone.js.map +1 -1
  18. package/dist/openalgo-charts.trade.mjs +1 -1
  19. package/dist/openalgo-charts.trade.mjs.map +1 -1
  20. package/dist/openalgo-charts.trade.standalone.js +1 -1
  21. package/dist/openalgo-charts.transform.mjs +1 -1
  22. package/dist/openalgo-charts.transform.mjs.map +1 -1
  23. package/dist/openalgo-charts.transform.standalone.js +1 -1
  24. package/dist/{openalgo-charts.widget.chart-data-export-dialog-CX6h5-cp.mjs → openalgo-charts.widget.chart-data-export-dialog-we0VDywF.mjs} +2 -2
  25. package/dist/{openalgo-charts.widget.chart-data-export-dialog-CX6h5-cp.mjs.map → openalgo-charts.widget.chart-data-export-dialog-we0VDywF.mjs.map} +1 -1
  26. package/dist/{openalgo-charts.widget.chart-type-settings-Bu7g-LFB.mjs → openalgo-charts.widget.chart-type-settings-DYCCD4Ax.mjs} +2 -2
  27. package/dist/{openalgo-charts.widget.chart-type-settings-Bu7g-LFB.mjs.map → openalgo-charts.widget.chart-type-settings-DYCCD4Ax.mjs.map} +1 -1
  28. package/dist/openalgo-charts.widget.grid-bar-CWfujvFQ.mjs +2 -0
  29. package/dist/openalgo-charts.widget.grid-bar-CWfujvFQ.mjs.map +1 -0
  30. package/dist/{openalgo-charts.widget.grid-menus-CPZWEiD3.mjs → openalgo-charts.widget.grid-menus-Ujc8dpxO.mjs} +2 -2
  31. package/dist/{openalgo-charts.widget.grid-menus-CPZWEiD3.mjs.map → openalgo-charts.widget.grid-menus-Ujc8dpxO.mjs.map} +1 -1
  32. package/dist/{openalgo-charts.widget.layouts-templates-menu-CFf0bR9J.mjs → openalgo-charts.widget.layouts-templates-menu-DPPa9Cn1.mjs} +2 -2
  33. package/dist/{openalgo-charts.widget.layouts-templates-menu-CFf0bR9J.mjs.map → openalgo-charts.widget.layouts-templates-menu-DPPa9Cn1.mjs.map} +1 -1
  34. package/dist/openalgo-charts.widget.mjs +1 -1
  35. package/dist/openalgo-charts.widget.mjs.map +1 -1
  36. package/dist/openalgo-charts.widget.standalone.js +1 -1
  37. package/dist/openalgo-charts.widget.storage-idb-JzCQh1Se.mjs +2 -0
  38. package/dist/openalgo-charts.widget.storage-idb-JzCQh1Se.mjs.map +1 -0
  39. package/dist/openalgo-charts.workspace.mjs +1 -1
  40. package/dist/openalgo-charts.workspace.mjs.map +1 -1
  41. package/dist/openalgo-charts.workspace.standalone.js +1 -1
  42. package/dist/profile/index.d.ts +63 -59
  43. package/dist/trade/index.d.ts +69 -9
  44. package/dist/transform/index.d.ts +20 -4
  45. package/dist/widget/index.d.ts +112 -5
  46. package/dist/workspace/index.d.ts +22 -5
  47. package/package.json +1 -1
  48. package/dist/openalgo-charts.widget.grid-bar-Cm_CyA2j.mjs +0 -2
  49. package/dist/openalgo-charts.widget.grid-bar-Cm_CyA2j.mjs.map +0 -1
  50. package/dist/openalgo-charts.widget.storage-idb-WH_o01Wj.mjs +0 -2
  51. package/dist/openalgo-charts.widget.storage-idb-WH_o01Wj.mjs.map +0 -1
package/README.md CHANGED
@@ -12,7 +12,7 @@ with no runtime dependencies.
12
12
  [![npm version](https://img.shields.io/npm/v/openalgo-charts.svg?color=cb3837&label=npm)](https://www.npmjs.com/package/openalgo-charts)
13
13
  [![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
14
14
  [![npm downloads](https://img.shields.io/npm/dm/openalgo-charts.svg?color=0ea5e9&label=npm%20downloads)](https://www.npmjs.com/package/openalgo-charts)
15
- [![tests](https://img.shields.io/badge/engine%20tests-12108%20passing-brightgreen.svg)](#develop)
15
+ [![tests](https://img.shields.io/badge/engine%20tests-12488%20passing-brightgreen.svg)](#develop)
16
16
  [![dependencies](https://img.shields.io/badge/runtime%20deps-0-brightgreen.svg)](#principles)
17
17
 
18
18
  [**Documentation**](https://marketcalls.github.io/openalgo-charts/)  ·  [**Live examples**](https://marketcalls.github.io/openalgo-charts/examples)  ·  [**Getting started**](./docs/getting-started.md)  ·  [**Migrating to 2.0**](./docs/migrating-to-2.md)  ·  [**Architecture**](./ARCHITECTURE.md)
@@ -25,7 +25,7 @@ with no runtime dependencies.
25
25
  npm install openalgo-charts
26
26
  ```
27
27
 
28
- Current version: **2.7.1**. Five Elliott wave counts, each drawn from its origin and labelled by degree: the impulse and the correction gain the origin they lacked, and a triangle, a double combination and a triple combination join them, for 90 drawing tools. A degree from Grand Supercycle to Subminuette sets the numerals and whether labels are circled, in parentheses or plain, and a count saved by 2.7.0 loads as it was drawn. 2.7.0 redrew the drawing tool icons around their anchors: every point you place is an open ring and a line stops at its edge.
28
+ Current version: **2.7.3**. A correctness release: saved drawings and layouts survive reloads, a second tab and a reopened layout; alerts fire across history refreshes; live candles follow the history they continue; the price axis labels only tradable prices; and orders and positions keep the exchange and product that identify them. 2.7.2 numbered Elliott wave counts from the point after their origin, as a count is read, with each label centred on its point, and 2.7.1 added the five Elliott wave counts, each drawn from its origin and labelled by degree, for 90 drawing tools.
29
29
 
30
30
  2.6.4 was an order flow release: a footprint finds the imbalances beside a row that never traded, prints volume shaded by delta, alerts once when price comes back to a zone, extends only the zone kinds you pick, and takes a colour for each of its parts or one of six named themes; the website gains an Order flow page of live footprint and market profile examples. 2.6.3 was a finish release: finer glyphs at one line weight, a drawing rail that folds away, a smoother wheel and trackpad zoom, a widget whose drag keeps the price scale fitting, and a log scale that fills the pane. 2.6.2 was a fix for the bottom bar's ranges and Go to, which reported missing history across a weekend or another gap no session trades in. 2.6.1 was order flow analytics for the footprint (trade classification, a trade size filter, imbalance and delta views, zones, unfinished auctions, delta flips and session statistics), rows aligned on the even boundary, Renko and point and figure sizing from price or the ATR, and settings dialogs for both chart types in the widget and the reference host. 2.6.0 was analysis depth and a stricter API: the chart applies Heikin Ashi, Renko, range bars, line break, point and figure and Kagi to the bars you feed, live, with each study on the elements or the underlying bars; seven new built-ins and a timeframe input on 29 of them; symbol search through the OpenAlgo feed; rich event details with host actions; a typed event map for `chart.on`; a classic-script build of every tier and `require()` of the ESM files; and declarations that hold for a host compiling with both strict flags. 2.5.10 was the persistence, saved layouts and chart grid release.
31
31
  See the [changelog](./CHANGELOG.md) for release notes.
@@ -68,7 +68,7 @@ Firefox and WebKit. In Vue, hold the chart in a `shallowRef`, never in `ref()` o
68
68
 
69
69
  ## Architecture
70
70
 
71
- <a href="docs/architecture-diagram.svg"><img src="docs/architecture-diagram.svg" alt="OpenAlgo Charts 2.6.7 architecture: host responsibilities, the base data-to-rendering pipeline with alerts and shared replay, and eight optional tiers including workspace storage, trading tools and the widget" width="920" /></a>
71
+ <a href="docs/architecture-diagram.svg"><img src="docs/architecture-diagram.svg" alt="OpenAlgo Charts architecture: host responsibilities, the base data-to-rendering pipeline with alerts and shared replay, and eight optional tiers including workspace storage, trading tools and the widget" width="920" /></a>
72
72
 
73
73
  How data reaches the chart, what your app owns, and which features you can import.
74
74
  [Open the full-size diagram](docs/architecture-diagram.svg).
@@ -119,7 +119,7 @@ You can also load the library from a CDN in a plain HTML page:
119
119
  ```html
120
120
  <div id="chart" style="width:100vw;height:100vh"></div>
121
121
  <script type="module">
122
- import { createChart, generateBars } from 'https://unpkg.com/openalgo-charts@2.7.1/dist/openalgo-charts.mjs';
122
+ import { createChart, generateBars } from 'https://unpkg.com/openalgo-charts@2.7.3/dist/openalgo-charts.mjs';
123
123
  const chart = createChart(document.getElementById('chart'), { timezone: 'Asia/Kolkata' });
124
124
  chart.addSeries('candlestick').setData(generateBars(1700000000, 200, 3600));
125
125
  chart.fitContent();
@@ -181,17 +181,17 @@ Unused optional tiers stay out of the base chart download.
181
181
 
182
182
  | Import | Contents | Brotli |
183
183
  |---|---|---|
184
- | `openalgo-charts` | Engine, 13 chart types, panes and scales, custom indicator registry, primitives, alerts, replay, comparisons, chart linking, state, feeds, bar cache, trading overlays, CSV and SVG export | 140.06 kB |
185
- | `openalgo-charts/indicators` | 112 built-in indicators, calculation helpers and helpers for studies that use external data | 44.85 kB |
186
- | `openalgo-charts/draw` | 90 drawing tools + a headless drawing controller, clipboard, settings schema, level palette, freehand geometry and SVG icons | 60.44 kB |
187
- | `openalgo-charts/transform` | Heikin Ashi, Renko, Range bars, Line Break, Point &amp; Figure, Kagi, and symbol arithmetic (`AAPL/MSFT`) | 6.38 kB |
188
- | `openalgo-charts/profile` | Volume Profile, Market Profile (TPO) with compact pixel letters, Footprint, order flow | 20.83 kB |
189
- | `openalgo-charts/trade` | Order, position and bracket tools, account state, order preview and position commands, plus a depth-of-market ladder | 16.88 kB |
184
+ | `openalgo-charts` | Engine, 13 chart types, panes and scales, custom indicator registry, primitives, alerts, replay, comparisons, chart linking, state, feeds, bar cache, trading overlays, CSV and SVG export | 141.88 kB |
185
+ | `openalgo-charts/indicators` | 112 built-in indicators, calculation helpers and helpers for studies that use external data | 45.10 kB |
186
+ | `openalgo-charts/draw` | 90 drawing tools + a headless drawing controller, clipboard, settings schema, level palette, freehand geometry and SVG icons | 61.86 kB |
187
+ | `openalgo-charts/transform` | Heikin Ashi, Renko, Range bars, Line Break, Point &amp; Figure, Kagi, and symbol arithmetic (`AAPL/MSFT`) | 6.55 kB |
188
+ | `openalgo-charts/profile` | Volume Profile, Market Profile (TPO) with compact pixel letters, Footprint, order flow | 20.96 kB |
189
+ | `openalgo-charts/trade` | Order, position and bracket tools, account state, order preview and position commands, plus a depth-of-market ladder | 17.29 kB |
190
190
  | `openalgo-charts/webgl` | GPU drawing for supported series, with Canvas 2D fallback | 6.99 kB |
191
- | `openalgo-charts/widget` | `createWidget`: toolbar, bottom bar, Data, Objects, Watchlist and News dock, account summary, symbol search, dialogs, mobile controls, a shortcuts editor, saved layouts, the chart grid (`createChartGrid`) and optional persistence in IndexedDB | 129.58 kB |
192
- | `openalgo-charts/workspace` | Validated workspace and indicator-template documents, named watchlists, named catalogs with revision checks, asynchronous storage and an IndexedDB adapter; no DOM | 11.73 kB |
191
+ | `openalgo-charts/widget` | `createWidget`: toolbar, bottom bar, Data, Objects, Watchlist and News dock, account summary, symbol search, dialogs, mobile controls, a shortcuts editor, saved layouts, the chart grid (`createChartGrid`) and optional persistence in IndexedDB | 131.55 kB |
192
+ | `openalgo-charts/workspace` | Validated workspace and indicator-template documents, named watchlists, named catalogs with revision checks, asynchronous storage and an IndexedDB adapter; no DOM | 11.89 kB |
193
193
 
194
- Everything together is **437.73 kB Brotli**; a widget terminal with built-in indicators (base + draw + indicators + widget) is 374.92 kB. The widget's eight first-use parts (the shortcuts editor, the Layouts menu, the templates list, the chart data dialog, the chart type settings dialog, the grid bar and its menus, and the IndexedDB store) add 21.00 kB in files of their own, fetched only when a widget first uses one. The nine classic-script files together are 451.45 kB. Figures are measured from the 2.7.1 release build. The trade tier is 16.88 kB on its own; base + trade costs 156.93 kB. Sizes use decimal kB.
194
+ Everything together is **444.07 kB Brotli**; a widget terminal with built-in indicators (base + draw + indicators + widget) is 380.39 kB. The widget's eight first-use parts (the shortcuts editor, the Layouts menu, the templates list, the chart data dialog, the chart type settings dialog, the grid bar and its menus, and the IndexedDB store) add 21.04 kB in files of their own, fetched only when a widget first uses one. The nine classic-script files together are 457.61 kB. Figures are measured from the 2.7.3 release build. The trade tier is 17.29 kB on its own; base + trade costs 159.17 kB. Sizes use decimal kB.
195
195
 
196
196
  ## What's built
197
197
 
@@ -517,19 +517,19 @@ Enforced in CI by [`size-limit`](./.size-limit.json). Nothing is excluded, becau
517
517
 
518
518
  | Bundle | Limit | Actual |
519
519
  |---|---|---|
520
- | Base engine | 140.14 kB | 140.06 kB |
521
- | Base + trade | 157.02 kB | 156.93 kB |
522
- | Indicators tier | 44.86 kB | 44.85 kB |
523
- | Draw tier | 60.45 kB | 60.44 kB |
524
- | Transform tier | 6.39 kB | 6.38 kB |
525
- | Profile tier | 20.83 kB | 20.83 kB |
520
+ | Base engine | 141.89 kB | 141.88 kB |
521
+ | Base + trade | 159.18 kB | 159.17 kB |
522
+ | Indicators tier | 45.10 kB | 45.10 kB |
523
+ | Draw tier | 61.86 kB | 61.86 kB |
524
+ | Transform tier | 6.56 kB | 6.55 kB |
525
+ | Profile tier | 20.97 kB | 20.96 kB |
526
526
  | WebGL2 tier | 6.99 kB | 6.99 kB |
527
- | Widget tier | 129.58 kB | 129.58 kB |
528
- | Widget first-use parts (eight files beside the widget tier) | 21.00 kB | 21.00 kB |
529
- | Widget terminal (base + draw + indicators + widget) | 374.93 kB | 374.92 kB |
530
- | Workspace tier | 11.73 kB | 11.73 kB |
531
- | Script tags (the nine classic-script files) | 451.46 kB | 451.45 kB |
532
- | **Everything** | 437.73 kB | 437.73 kB |
527
+ | Widget tier | 131.55 kB | 131.55 kB |
528
+ | Widget first-use parts (eight files beside the widget tier) | 21.05 kB | 21.04 kB |
529
+ | Widget terminal (base + draw + indicators + widget) | 380.40 kB | 380.39 kB |
530
+ | Workspace tier | 11.89 kB | 11.89 kB |
531
+ | Script tags (the nine classic-script files) | 457.62 kB | 457.61 kB |
532
+ | **Everything** | 444.08 kB | 444.07 kB |
533
533
 
534
534
  ## Documentation
535
535
 
@@ -580,7 +580,7 @@ See [Contributing](./CONTRIBUTING.md) for setup, targeted checks, documentation
580
580
  ```bash
581
581
  npm install # install dev toolchain
582
582
  npm run typecheck # TypeScript: src with the stricter flags, then the tests
583
- npm test # engine unit tests (Vitest): 12108 across 528 files
583
+ npm test # engine unit tests (Vitest): 12488 across 561 files
584
584
  npm run test:demo # reference-host tests: 740 across 69 files
585
585
  npm run test:endurance # node endurance-harness tests: 7 cases
586
586
  npm run build # Rollup -> dist/ (minified ESM per tier + types)
@@ -601,7 +601,7 @@ npm run verify # lint + types + cycles + unused exports + unit + endurance h
601
601
 
602
602
  ## Status &amp; limitations
603
603
 
604
- Version **2.7.1**. All engine build phases are implemented. Upgrading a 1.9.x host: [Migrating to 2.0](./docs/migrating-to-2.md).
604
+ Version **2.7.3**. All engine build phases are implemented. Upgrading a 1.9.x host: [Migrating to 2.0](./docs/migrating-to-2.md).
605
605
 
606
606
  Known gaps, stated plainly:
607
607
 
@@ -433,6 +433,14 @@ interface DrawingTool {
433
433
  * polyline behaviour and never terminates on its own.
434
434
  */
435
435
  freehand?: boolean;
436
+ /**
437
+ * Paint the tool itself while it is placed, from its second anchor on, in
438
+ * place of the dashed guide every other multi-anchor tool shows. Declare it
439
+ * only when `draw` paints whatever anchors it is given, from two up to
440
+ * `points`: a wave count does, so each click shows the wave it ends and that
441
+ * wave's label, and the first click reads as the origin it is.
442
+ */
443
+ progressive?: boolean;
436
444
  /**
437
445
  * Hold Shift to snap the free end of a two-anchor tool to 45 degree steps
438
446
  * on screen, while placing and while dragging a handle. The line family
@@ -1707,6 +1715,26 @@ declare function createDrawingLinkGroup(options?: DrawingLinkOptions): DrawingLi
1707
1715
  * document actually changed, so a reload loses nothing and a stream of
1708
1716
  * updates to transient drawings writes nothing. An instrument left with no
1709
1717
  * drawings has its entry removed rather than an empty one kept.
1718
+ * - **A write keeps what another writer stored.** Two pages on one store and
1719
+ * one instrument each hold the document they last read. Before writing,
1720
+ * the stored document is read again: what this chart added, changed or
1721
+ * deleted since it last read or wrote it goes in as it has it, and every
1722
+ * other drawing stays as the store has it, so the later writer erases
1723
+ * neither the other's drawings nor its deletions. A store whose writes
1724
+ * land later does the same once more as each write lands
1725
+ * (`InstrumentDrawings.merge`), since two writes can be made before either
1726
+ * has landed.
1727
+ * - **A drawing stays on its pane.** Panes are slots, and a study removed or
1728
+ * moved while an instrument is off screen shifts them under its document.
1729
+ * Each document is written with the panes it was drawn on (`panes`: the
1730
+ * price pane as null, any other by its studies, each by id and kind), and
1731
+ * is put back on those panes wherever they stand now when it is read,
1732
+ * which a chart that reports its panes and studies allows. A pane whose
1733
+ * studies have all gone takes its drawings with it, unless a pane of the
1734
+ * same kinds of study stands where it was (the same template applied
1735
+ * again): another study put in its place is not given them. A layout
1736
+ * restored over drawings that carry their panes, as `document` returns
1737
+ * them, puts them on the panes their studies hold once it has landed.
1710
1738
  * - **A store that fails loses nothing for the session.** A refused write is
1711
1739
  * reported through `onError` and the document is held in memory, read back
1712
1740
  * from there, and written again with the next change.
@@ -1754,6 +1782,20 @@ interface InstrumentDrawingsChart {
1754
1782
  readonly isDestroyed?: boolean;
1755
1783
  on(event: string, handler: (payload: unknown) => void): () => void;
1756
1784
  getDataContext?(): Readonly<DrawingInstrument> | undefined;
1785
+ /**
1786
+ * Optional, the first two together: the panes, the studies on them and
1787
+ * the slot of the price pane. With them each document is saved with the
1788
+ * panes its drawings are on, and read back onto those panes where they
1789
+ * stand now; without them a drawing keeps its slot.
1790
+ */
1791
+ panes?(): readonly unknown[];
1792
+ /** `indicatorId`, the kind of study, lets a pane rebuilt with new ids (a template applied again) keep its drawings. */
1793
+ indicators?(): readonly {
1794
+ readonly id: string;
1795
+ readonly paneIndex: number;
1796
+ readonly indicatorId?: string;
1797
+ }[];
1798
+ primaryPaneIndex?(): number;
1757
1799
  }
1758
1800
  /** A store operation that failed, as `InstrumentDrawingsOptions.onError` receives it. */
1759
1801
  interface InstrumentDrawingsError {
@@ -1822,13 +1864,26 @@ declare function migrateUnscopedDrawings(store: DrawingDocumentStore, key: strin
1822
1864
  * ```
1823
1865
  */
1824
1866
  declare class InstrumentDrawings {
1867
+ private readonly _chart;
1825
1868
  private readonly _draw;
1826
1869
  private readonly _store;
1827
1870
  private readonly _keyOf;
1828
1871
  private readonly _onError;
1829
1872
  private _key;
1830
- /** The current instrument's document as last written or loaded, to skip a write that changes nothing. */
1873
+ /**
1874
+ * The current instrument's document as this chart last read or wrote it:
1875
+ * a write that changes nothing is skipped, and what another writer stored
1876
+ * since is told apart from this chart's own changes against it.
1877
+ */
1831
1878
  private _text;
1879
+ /**
1880
+ * The panes the drawings on the chart were read with, while the chart may
1881
+ * not have them yet: a document read as a widget starts, before its layout
1882
+ * lands. `text` is the document as read, `stamp` its panes as stored, and
1883
+ * `panes` those after every pane moved or removed since. Null once the
1884
+ * drawings are on the panes standing now.
1885
+ */
1886
+ private _pending;
1832
1887
  /** Documents whose write failed, by key: what the store should hold, kept for the session. */
1833
1888
  private readonly _held;
1834
1889
  private _swapping;
@@ -1847,17 +1902,30 @@ declare class InstrumentDrawings {
1847
1902
  setInstrument(instrument: DrawingInstrument | null): void;
1848
1903
  /**
1849
1904
  * The saved document of an instrument: the drawings on the chart for the
1850
- * current one, the stored document for any other, or null when it has
1851
- * none (or no key). A copy either way.
1905
+ * current one, the stored document for any other, on the panes standing
1906
+ * now, or null when it has none (or no key). A copy either way. The
1907
+ * current one's names the panes it is drawn on (`panes`), as it is stored,
1908
+ * so a layout restored with it puts each drawing on its study's pane.
1852
1909
  */
1853
1910
  document(instrument: DrawingInstrument): DrawingsDocument | null;
1854
1911
  /**
1855
- * Replace one instrument's drawings. On the current instrument that is the
1856
- * controller's `fromJSON`, which clears its undo history; on any other, the
1857
- * stored document, shown when the chart next moves there. For a layout
1858
- * that brings the drawings of an instrument the chart is about to show.
1912
+ * Replace one instrument's drawings, drawn on the panes standing now, or
1913
+ * on those it names (`panes`, as stored). On the current instrument that
1914
+ * is the controller's `fromJSON`, which clears its undo history; on any
1915
+ * other, the stored document, shown when the chart next moves there. For a
1916
+ * layout that brings the drawings of an instrument the chart is about to show.
1859
1917
  */
1860
1918
  setDocument(instrument: DrawingInstrument, document: unknown): void;
1919
+ /**
1920
+ * The document to store when another writer may have stored one since
1921
+ * `base`, the stored document `ours` was made from: each drawing `ours`
1922
+ * added, changed or deleted since `base` as `ours` has it, every other as
1923
+ * `theirs` (what the store holds now) has it, on the panes `ours` names.
1924
+ * For a store whose writes land later than they are made, so that two
1925
+ * writes made before either landed keep both: the widget's own store
1926
+ * merges each write as it lands. Since 2.7.3.
1927
+ */
1928
+ static merge(base: unknown, ours: unknown, theirs: unknown): DrawingsDocument;
1861
1929
  /** Write the current instrument's document now, and any the store refused before. False while one is still refused. */
1862
1930
  save(): boolean;
1863
1931
  /** Stop following the chart. The documents stay where they are. */
@@ -1865,6 +1933,17 @@ declare class InstrumentDrawings {
1865
1933
  private _keyFor;
1866
1934
  /** The drawings the controller would save, as text. */
1867
1935
  private _live;
1936
+ /**
1937
+ * The panes standing now: null for the price pane, its studies by id and
1938
+ * kind for any other. Null for a chart that does not report them.
1939
+ */
1940
+ private _panes;
1941
+ /**
1942
+ * `document` as it is stored: with the panes it is drawn on, when they are
1943
+ * known and there is more than the price pane. A document stored without
1944
+ * them keeps its slots when read, which on one pane is all there is.
1945
+ */
1946
+ private _stamped;
1868
1947
  /** Take `key` as the current instrument, with the drawings `prefer` picks. */
1869
1948
  private _start;
1870
1949
  private _follow;
@@ -1872,10 +1951,40 @@ declare class InstrumentDrawings {
1872
1951
  /** Put `document` on the controller without the change it announces being written back. */
1873
1952
  private _load;
1874
1953
  private _changed;
1954
+ /**
1955
+ * The whole document was replaced. When it is the one read (a layout
1956
+ * restored over it), it is still on the panes it was read with; anything
1957
+ * else is drawn on the panes standing now.
1958
+ */
1959
+ private _restored;
1960
+ /**
1961
+ * A layout restored with drawings that name their panes (`document`'s, as
1962
+ * the widget restores a state over the drawings on the chart): they are
1963
+ * on those panes, and go onto the panes their studies hold once the layout
1964
+ * has landed (`_settle`), wherever it puts them.
1965
+ */
1966
+ private _restoredOnPanes;
1967
+ /** A layout has landed: drawings read before it go onto its panes. */
1968
+ private _settle;
1875
1969
  /** Write the current document when it changed, or always when `force`. */
1876
1970
  private _saveCurrent;
1971
+ /**
1972
+ * What the current instrument's entry is to hold: the drawings on the
1973
+ * chart, with whatever another writer stored since this chart last read or
1974
+ * wrote it (see the module notes), and the panes they are drawn on. A store
1975
+ * that cannot say what it holds, or that refused this chart's last write
1976
+ * and so does not hold what it was read against, is written as this chart
1977
+ * has it.
1978
+ */
1979
+ private _outgoing;
1980
+ /** Store `document` under `key`; true when it landed. */
1877
1981
  private _write;
1878
- /** The stored document for `key`, migrated to the current shape, or null. A held one comes first. */
1982
+ /** What the store holds for `key`, a held write first, or null. */
1983
+ private _raw;
1984
+ /**
1985
+ * The stored document for `key` (or the stored `value` given), migrated to
1986
+ * the current shape and put on the panes `onto` when given, or null.
1987
+ */
1879
1988
  private _read;
1880
1989
  private _report;
1881
1990
  }
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.7.1";
2
+ declare const VERSION = "2.7.3";
3
3
  /** Returns the current library version. */
4
4
  declare function version(): string;
5
5
 
@@ -317,6 +317,10 @@ declare class PriceScale {
317
317
  * Manually scale the visible range around its centre. `factor` > 1 widens the
318
318
  * range (compress / zoom out), < 1 narrows it (expand / zoom in). Switches the
319
319
  * scale to manual mode so autoscale stops overriding it.
320
+ *
321
+ * Scaled in the space the axis draws in, as `scaleAtY` is. In price units,
322
+ * widening a log axis over 100 to 1000 by a fifth dropped its floor under 1,
323
+ * two empty decades beneath the data, and a little more took it past zero.
320
324
  */
321
325
  scaleAroundCenter(factor: number): void;
322
326
  /** Scale around a screen coordinate, retaining its price in every scale mode. */
@@ -378,12 +382,18 @@ declare class PriceScale {
378
382
  * they care about. `minPrecision` is the floor for that case, and it is the
379
383
  * same two decimals the percent branch above already settles on for the same
380
384
  * reason.
385
+ *
386
+ * A log axis gives the bottom of the pane the most pixels per price, so the
387
+ * span is read there: a hundredth of the pane at its foot. Read off the
388
+ * linear span, a log chart from 2 to 3000 printed a crosshair at 2.35 as "2".
381
389
  */
382
390
  precision(): number;
383
391
  /**
384
- * Tick prices for the axis ladder, at most `maxTicks` of them. Linear and log
385
- * get the nice ladder over the price range, exactly what the axis renderer
386
- * used to build for itself.
392
+ * Tick prices for the axis ladder, at most `maxTicks` of them. Linear gets
393
+ * the nice ladder over the price range, exactly what the axis renderer used
394
+ * to build for itself, and log a ladder whose rungs keep their spacing down
395
+ * every decade (`logTicks`). Both keep to `minMove` when one is declared, so
396
+ * no rung falls between two prices the instrument trades at.
387
397
  *
388
398
  * The rebasing modes need it built in *label* space: a nice price is an ugly
389
399
  * percentage, and a ladder of "+3.47%, +6.94%" is not a ladder. So the nice
@@ -2487,6 +2497,8 @@ interface FillPoint {
2487
2497
  }
2488
2498
  declare class IndicatorFill implements IPrimitive {
2489
2499
  private _points;
2500
+ /** The band's lowest and highest value, for a gradient that names no prices; measured once per set of points. */
2501
+ private _extent;
2490
2502
  private _opts;
2491
2503
  private _host;
2492
2504
  private _visible;
@@ -2497,6 +2509,7 @@ declare class IndicatorFill implements IPrimitive {
2497
2509
  zOrder(): ZOrder;
2498
2510
  /** The plots it spans already drive the scale; the fill must not widen it. */
2499
2511
  autoscaleInfo(): null;
2512
+ /** Points in index order, one per bar, as a study's plots are. */
2500
2513
  setPoints(points: readonly FillPoint[]): void;
2501
2514
  setOptions(patch: Partial<IndicatorFillOptions>): void;
2502
2515
  setVisible(on: boolean): void;
@@ -8737,6 +8750,22 @@ declare class ComparisonController {
8737
8750
  destroy(): void;
8738
8751
  private _dispose;
8739
8752
  private _needsAlignment;
8753
+ /**
8754
+ * Keep every comparison on the primary's bars. A live bar appended at the
8755
+ * right edge is the change a session brings, and aligning that bar alone is
8756
+ * what spares a long history a full alignment and rewrite per bar. Anything
8757
+ * else (history paged in or replaced, a replay step) aligns in full.
8758
+ */
8759
+ private _follow;
8760
+ /** One primary bar appended at `time`: its item, as `alignToPrimary` would have made it. Counts 1 for a print there. */
8761
+ private _append;
8762
+ /**
8763
+ * The instrument's prints later than `after`, read from where they can
8764
+ * start: past the last of the prints in time order at the front of its array
8765
+ * that is not later. A history in time order, the usual kind, then costs an
8766
+ * append its new prints rather than a read of every one.
8767
+ */
8768
+ private _later;
8740
8769
  private _rememberAlignment;
8741
8770
  /**
8742
8771
  * Preserve the first comparison's legacy placement when the scale is free.
@@ -8773,6 +8802,14 @@ declare class ComparisonController {
8773
8802
  * independently scaled overlay instead of freezing on a stale range.
8774
8803
  */
8775
8804
  private _mirror;
8805
+ /**
8806
+ * Widen the primary's range to hold each shown comparison's relative moves
8807
+ * over `bars`, the primary's bars in view. The primary autoscales on its own
8808
+ * series alone, and every overlay is that band times its baseline ratio, so
8809
+ * a comparison that moved further than the primary was drawn off the pane
8810
+ * whichever baseline it was measured from.
8811
+ */
8812
+ private _fit;
8776
8813
  private _primaryBars;
8777
8814
  private _record;
8778
8815
  private _visible;
@@ -9264,8 +9301,13 @@ declare function snapToDevicePixel(mediaCoord: number, dpr: number): number;
9264
9301
  * Generate up to ~`maxTicks` nicely-rounded tick values spanning [min, max].
9265
9302
  * Returns ascending values aligned to the chosen step (may sit slightly inside
9266
9303
  * the range). Returns a single midpoint when the range is degenerate.
9304
+ *
9305
+ * `tick` is the instrument's price increment. Given one, the step is a whole
9306
+ * number of ticks and never finer than one, so a tight range thins its rungs
9307
+ * (to none, on a range narrower than a tick) rather than print prices the
9308
+ * instrument cannot trade at. 0 leaves the step to the span alone.
9267
9309
  */
9268
- declare function niceTicks(min: number, max: number, maxTicks?: number): number[];
9310
+ declare function niceTicks(min: number, max: number, maxTicks?: number, tick?: number): number[];
9269
9311
  /** Decimal places implied by a price step / tick size (for label formatting). */
9270
9312
  declare function precisionForStep(step: number): number;
9271
9313
 
@@ -9940,10 +9982,11 @@ declare class LinkCrosshair implements IPrimitive {
9940
9982
 
9941
9983
  /**
9942
9984
  * Live candle aggregation (ARCHITECTURE.md §10.2). The WS feed does not deliver
9943
- * interval candles: LTP mode gives a tick price (+ last-traded-qty), Quote mode
9944
- * gives a *cumulative day* volume. This builder buckets ticks into interval OHLC
9945
- * with explicit volume, session-reset, and late-tick policies. Pure and
9946
- * deterministic (no Date/rAF) so it is fully unit-testable.
9985
+ * interval candles: LTP mode gives a tick price (+ last-traded-qty where the
9986
+ * broker sends one), Quote mode gives a *cumulative day* volume. This builder
9987
+ * buckets ticks into interval OHLC with explicit volume, session-reset, and
9988
+ * late-tick policies. Pure and deterministic (no Date/rAF) so it is fully
9989
+ * unit-testable.
9947
9990
  */
9948
9991
 
9949
9992
  type VolumeMode = 'ltq-sum' | 'day-delta';
@@ -10031,6 +10074,14 @@ declare class CandleBuilder {
10031
10074
  */
10032
10075
  onTick(tick: Tick): CandleUpdate | null;
10033
10076
  private _foldInto;
10077
+ /**
10078
+ * A tick's own quantity counts in 'ltq-sum'; otherwise its cumulative day
10079
+ * total gives the bar's volume. The total is tracked whenever a tick carries
10080
+ * one, so a stream that drops the quantity on some frames falls back to it
10081
+ * without counting a trade twice. A tick with neither adds nothing, as it
10082
+ * always has: a host on such a stream fills the volume from history, and a
10083
+ * host that wants it reported unknown says so itself (OpenAlgoLiveDataFeed).
10084
+ */
10034
10085
  private _volumeForNewBar;
10035
10086
  private _volumeForSameBar;
10036
10087
  }
@@ -10927,6 +10978,14 @@ declare class DataLoadingController {
10927
10978
  private _seconds;
10928
10979
  /** Bucket whose open is only the first tick a builder saw, until history covers it. */
10929
10980
  private _provisionalTime;
10981
+ /** Bucket the stream last delivered, whose close is newer than a history snapshot of it. */
10982
+ private _liveTime;
10983
+ /**
10984
+ * The last refresh failed, so what the stream delivered since is newer than
10985
+ * any history this controller holds. Through 2.7.2 those ticks waited in the
10986
+ * buffer and a retry kept them; the buffer is shown now, and this keeps the retry's answer.
10987
+ */
10988
+ private _ahead;
10930
10989
  private _repairTimer;
10931
10990
  private _repairRetries;
10932
10991
  private _pendingRepair;
@@ -10937,8 +10996,25 @@ declare class DataLoadingController {
10937
10996
  subscribe(listener: (snapshot: DataLoadingSnapshot) => void): UnsubscribeFn;
10938
10997
  load(req: BarsRequest): Promise<readonly Bar[]>;
10939
10998
  private _load;
10999
+ /**
11000
+ * Refresh the window from history. A refresh asked for here is
11001
+ * authoritative for the forming bar's close too: a host asks after its
11002
+ * stream reconnected or its page came back, when the stream's last close is
11003
+ * the stale one. The controller's own poll and bar-close repair run while
11004
+ * the stream is live, so they keep the close the stream delivered, and so
11005
+ * does a retry after a failed refresh.
11006
+ */
10940
11007
  refresh(): Promise<readonly Bar[]>;
10941
11008
  private _refresh;
11009
+ /**
11010
+ * Show what the stream delivered while a refresh held the display, one bar
11011
+ * at a time and in order, before the refresh's answer replaces it. A reader
11012
+ * of the display (an alert, a study) then meets each as the live update it
11013
+ * was. Folded into the replacement it reads as history: an alert armed
11014
+ * since the last update seeds on it, and a touch that came back inside the
11015
+ * bar is gone. Returns false when a listener moved the controller on.
11016
+ */
11017
+ private _showBuffered;
10942
11018
  /** The span a refresh asks history for: the request's own width ending now, or a tail window. */
10943
11019
  private _refreshWindow;
10944
11020
  /**
@@ -11398,6 +11474,13 @@ type OrderRole = 'entry' | 'sl' | 'tp';
11398
11474
  interface Order {
11399
11475
  id: string;
11400
11476
  symbol: string;
11477
+ /**
11478
+ * The venue, when the provider says. Symbol and exchange together name a
11479
+ * contract: one symbol on two exchanges is two instruments.
11480
+ */
11481
+ exchange?: string | undefined;
11482
+ /** The product (`CNC`, `MIS`, `NRML` on OpenAlgo), when the provider says. */
11483
+ product?: string | undefined;
11401
11484
  side: OrderSide;
11402
11485
  type: OrderType;
11403
11486
  qty: number;
@@ -11411,6 +11494,9 @@ interface Order {
11411
11494
  }
11412
11495
  interface Position {
11413
11496
  symbol: string;
11497
+ /** As on `Order`. A book holds one row per symbol, exchange and product, and each is its own position. */
11498
+ exchange?: string | undefined;
11499
+ product?: string | undefined;
11414
11500
  /** Net signed quantity: positive = long, negative = short, 0 = flat. */
11415
11501
  netQty: number;
11416
11502
  avgPrice: number;
@@ -11837,7 +11923,11 @@ declare class OpenAlgoTradeFeed implements OrderFeed {
11837
11923
  getOrderBook(): Promise<OrderBookSnapshot>;
11838
11924
  /** Fetch the order book for reconciliation (maps to broker-agnostic orders). */
11839
11925
  getOrders(): Promise<DecodedOrder[]>;
11840
- /** Fetch the position book for reconciliation. */
11926
+ /**
11927
+ * Fetch the position book for reconciliation. One row per symbol, exchange
11928
+ * and product. Throws rather than answer when the book or any row in it
11929
+ * cannot be read: a failed position read is unknown, not flat.
11930
+ */
11841
11931
  getPositions(): Promise<Position[]>;
11842
11932
  }
11843
11933
  interface RawOrder {
@@ -11855,6 +11945,8 @@ interface RawOrder {
11855
11945
  }
11856
11946
  interface RawPosition {
11857
11947
  symbol?: string;
11948
+ exchange?: string;
11949
+ product?: string;
11858
11950
  quantity?: number | string;
11859
11951
  average_price?: number | string;
11860
11952
  }
@@ -11948,6 +12040,15 @@ declare function decodeOrder(r: RawOrder, path?: string): OrderDecodeResult;
11948
12040
  * `quarantined`.
11949
12041
  */
11950
12042
  declare function mapOrder(r: RawOrder): DecodedOrder;
12043
+ /**
12044
+ * Map one position book row, keeping its exchange and product.
12045
+ *
12046
+ * Throws on a row with no symbol, an unreadable quantity, or an open quantity
12047
+ * with an unreadable average price. A position has no inert form the way an
12048
+ * order has `status: 'unknown'`: an unreadable quantity used to read 0, which
12049
+ * says flat, and a trader told flat may open the same position again. A flat
12050
+ * row's average price may be blank, and reads 0.
12051
+ */
11951
12052
  declare function mapPosition(r: RawPosition): Position;
11952
12053
 
11953
12054
  /**
@@ -12746,6 +12847,17 @@ declare class AlertController {
12746
12847
  private _onObjects;
12747
12848
  private _syncVisual;
12748
12849
  private _onData;
12850
+ /**
12851
+ * Where a replacement of the primary bars resumes a record: after the element
12852
+ * it last judged, or at that element when the replacement revised it.
12853
+ * Undefined seeds the record instead. A replacement without that element is
12854
+ * another series. One that only extends it is judged once the record has
12855
+ * watched the series grow: until then the bars it brings closed before
12856
+ * anyone looked, as when a warm load extends its cached bars. A front trimmed
12857
+ * at a retention cap is judged regardless, since every new bar arrives that
12858
+ * way there.
12859
+ */
12860
+ private _resumeAt;
12749
12861
  /**
12750
12862
  * The first element of this update a record has not judged. An update that
12751
12863
  * still has the record's tail at its index, at its time or later (a forming
@@ -29,7 +29,9 @@ declare function createTimeframeProvider(feed: TimeframeFeed, options: Timeframe
29
29
  *
30
30
  * Sub-day buckets start at the session open, the way an exchange cuts its own
31
31
  * hourly bars, and the open is read from the bars in the chart's zone (see
32
- * `sessionOpen`). A timeframe no coarser than the chart's is the chart's own.
32
+ * `sessionOpen`). A timeframe no coarser than the chart's is the chart's own,
33
+ * and one the chart's bars do not divide into (5m on a 3m chart) is refused
34
+ * rather than folded into buckets of the wrong length.
33
35
  *
34
36
  * Only a calculation from the chart's bars alone folds, and only a causal one:
35
37
  * a value at a bar reads no later bar. Which built-ins opt in, and why the
@@ -491,6 +493,11 @@ declare const FLOW_INDICATORS: readonly IndicatorDescriptor[];
491
493
  * this follows Kaufman's published definition. It first prints at `erLength`, the
492
494
  * earliest bar where both legs of the ratio exist, seeded there on the source
493
495
  * itself, because there is no prior average to carry forward.
496
+ *
497
+ * A bar with no value is read as if it were not there, the way Parabolic SAR
498
+ * reads an incomplete bar: it prints nothing, the ratio window counts the
499
+ * values either side of it, and the average carries on from the last one. One
500
+ * missing close otherwise entered the recursion as NaN and ended the line.
494
501
  */
495
502
  declare const KAMA: IndicatorDescriptor;
496
503
  /**