openalgo-charts 2.1.0 → 2.1.1

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/README.md CHANGED
@@ -4,12 +4,12 @@
4
4
 
5
5
  **A from-scratch, dependency-free HTML5-canvas charting engine for OpenAlgo.**
6
6
 
7
- Professional interactive charts, 102 built-in indicators plus your own custom ones, 51 drawing tools, order flow, market replay, linked chart grids, on-chart trading, vector SVG export and an optional WebGL2 backend. Eight lazy-loaded tiers, zero runtime dependencies, 66.51 KB Brotli for the base engine, and a one-call widget tier that adds the toolbar, drawing rail, dialogs and shortcuts.
7
+ Professional interactive charts, 102 built-in indicators plus your own custom ones, 51 drawing tools, order flow, market replay, linked chart grids, on-chart trading, vector SVG export and an optional WebGL2 backend. Eight lazy-loaded tiers, zero runtime dependencies, 66.49 KB Brotli for the base engine, and a one-call widget tier that adds the toolbar, drawing rail, dialogs and shortcuts.
8
8
 
9
9
  [![npm version](https://img.shields.io/npm/v/openalgo-charts.svg?color=cb3837&label=npm)](https://www.npmjs.com/package/openalgo-charts)
10
10
  [![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
11
11
  [![bundle](https://img.shields.io/badge/brotli-66%20KB%20base%20%C2%B7%20183%20KB%20all%20tiers-brightgreen.svg)](#size-budget)
12
- [![tests](https://img.shields.io/badge/tests-4026%20passing-brightgreen.svg)](#develop)
12
+ [![tests](https://img.shields.io/badge/tests-4139%20passing-brightgreen.svg)](#develop)
13
13
  [![dependencies](https://img.shields.io/badge/runtime%20deps-0-brightgreen.svg)](#principles)
14
14
 
15
15
  [**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)
@@ -43,6 +43,8 @@ Every chart in the [live gallery](https://marketcalls.github.io/openalgo-charts/
43
43
 
44
44
  ## Install
45
45
 
46
+ Current version: **2.1.1**.
47
+
46
48
  ```bash
47
49
  npm install openalgo-charts
48
50
  ```
@@ -62,7 +64,7 @@ in front of npm rather than being places you upload to. A chart is one HTML file
62
64
  ```html
63
65
  <div id="chart" style="width:100vw;height:100vh"></div>
64
66
  <script type="module">
65
- import { createChart } from 'https://unpkg.com/openalgo-charts@2.1.0/dist/openalgo-charts.mjs';
67
+ import { createChart } from 'https://unpkg.com/openalgo-charts@2.1.1/dist/openalgo-charts.mjs';
66
68
  const chart = createChart(document.getElementById('chart'), { timezone: 'Asia/Kolkata' });
67
69
  chart.addSeries('candlestick').setData(bars);
68
70
  </script>
@@ -101,16 +103,16 @@ Import only what you use. Each tier is a separate bundle that registers into the
101
103
 
102
104
  | Import | Contents | Brotli |
103
105
  |---|---|---|
104
- | `openalgo-charts` | Engine, 13 chart types, panes &amp; scales, primitives, registries, chart state, chart linking, bar cache, interval registry, trading overlay, SVG export, render backend port, OpenAlgo feeds | 66.51 KB |
106
+ | `openalgo-charts` | Engine, 13 chart types, panes &amp; scales, primitives, registries, chart state, chart linking, bar cache, interval registry, trading overlay, SVG export, render backend port, OpenAlgo feeds | 66.49 KB |
105
107
  | `openalgo-charts/indicators` | 102 built-in indicators, the `registerIndicator` contract for your own, and the Tier-2 (external-data) contract | 27.27 KB |
106
108
  | `openalgo-charts/draw` | 51 drawing tools + a headless drawing controller, clipboard, settings schema, level palette, freehand geometry and SVG icons | 25.82 KB |
107
109
  | `openalgo-charts/transform` | Heikin Ashi, Renko, Range bars, Line Break, Point &amp; Figure, Kagi | 2.66 KB |
108
- | `openalgo-charts/profile` | Volume Profile, Market Profile (TPO) with compact pixel letters, Footprint, order flow | 11.95 KB |
110
+ | `openalgo-charts/profile` | Volume Profile, Market Profile (TPO) with compact pixel letters, Footprint, order flow | 14.96 KB |
109
111
  | `openalgo-charts/trade` | Order / position / bracket tools + DOM ladder | 7.61 KB |
110
112
  | `openalgo-charts/webgl` | WebGL2 series backend: batched, analytically anti-aliased GPU rendering of the standard chart types behind `renderer: 'auto'`, with a session-long fallback to the 2D path | 6.38 KB |
111
113
  | `openalgo-charts/widget` | The chart with its chrome in one call: `createWidget` adds a top bar, the drawing rail, a status line, the settings and indicator dialogs, drawing properties, a right-click menu, a keymap with a `?` panel and optional layout persistence. The only tier that ships DOM | 35.56 KB |
112
114
 
113
- Everything together is **183.74 KB Brotli**; a widget terminal (base + draw + indicators + widget, what one `createWidget` call loads) is 155.15 KB. Figures are the measured `size-limit` output. The trade tier is listed as its delta over the base, so loading base + trade costs 74.11 KB.
115
+ Everything together is **186.74 KB Brotli**; a widget terminal (base + draw + indicators + widget, what one `createWidget` call loads) is 155.13 KB. Figures are the measured `size-limit` output. The trade tier is listed as its delta over the base, so loading base + trade costs 74.10 KB.
114
116
 
115
117
  ## What's built
116
118
 
@@ -245,6 +247,72 @@ Headless like the rest, and the engine has no instrument concept, so symbol sync
245
247
  ### Trading
246
248
  Order, position, and bracket lines with live P&amp;L, one-click and drag-to-modify, OCO, validation, an order state machine, analyzer (sandbox) mode, and a depth-of-market ladder (5 to 200 levels).
247
249
 
250
+ ### Depth of market: simulated live example
251
+
252
+ [Try the depth ladder](https://marketcalls.github.io/openalgo-charts/docs/depth-of-market/)
253
+ with continuously simulated bids and asks, pause/resume, 5/20/200 depth levels,
254
+ and configurable price grouping independent of the candlestick chart's scale.
255
+ Try option candles with an option ladder, or spot candles with a separate ATM
256
+ call ladder. The
257
+ [drawing playground](https://marketcalls.github.io/openalgo-charts/docs/drawing-tools/)
258
+ also lets you place, select, move, delete, undo and redo drawings.
259
+
260
+ ```html
261
+ <div id="depth-chart" style="height: 440px"></div>
262
+ <div style="max-height: 440px; overflow: auto">
263
+ <table>
264
+ <thead><tr><th>Bid qty</th><th>Price</th><th>Ask qty</th></tr></thead>
265
+ <tbody id="depth-rows"></tbody>
266
+ </table>
267
+ </div>
268
+ ```
269
+
270
+ ```ts
271
+ import { createChart, darkTheme, generateBars } from 'openalgo-charts';
272
+ import { buildRows, FakeBroker } from 'openalgo-charts/trade';
273
+
274
+ const chart = createChart(document.getElementById('depth-chart')!, { theme: darkTheme });
275
+ const bars = generateBars(1700000000, 120, 60);
276
+ chart.addSeries('candlestick').setData(bars);
277
+ chart.timeScale.fitContent(bars.length);
278
+ const mid = Math.round(bars.at(-1)!.close / 0.05) * 0.05;
279
+ const bookRows = document.getElementById('depth-rows')!;
280
+ let groupBy = 20; // Change this to regroup the ladder; the chart keeps its own scale.
281
+
282
+ let step = 0;
283
+ function updateDepth() {
284
+ const price = mid + Math.round(Math.sin(step++ / 8) * 4) * 0.05;
285
+ const depth = FakeBroker.makeDepth(price, 200, 0.05);
286
+ bookRows.replaceChildren(...buildRows(depth, 0.05, groupBy).map(row => {
287
+ const tr = document.createElement('tr');
288
+ for (const text of [String(row.bidQty), row.price.toFixed(2), String(row.askQty)]) {
289
+ const td = document.createElement('td');
290
+ td.textContent = text;
291
+ td.style.height = '28px';
292
+ tr.append(td);
293
+ }
294
+ return tr;
295
+ }));
296
+ }
297
+ updateDepth();
298
+ const timer = setInterval(updateDepth, 750);
299
+
300
+ // Call this when removing the demo from your application.
301
+ function dispose() {
302
+ clearInterval(timer);
303
+ chart.destroy();
304
+ }
305
+ ```
306
+
307
+ `tickSize` is the instrument's minimum tick; `groupBy` is the number of ticks
308
+ per display row. Here, 20 × 0.05 creates 1.00-point rows. Quantities are summed
309
+ into the nearest price bucket, with bids and asks kept separate. Grouping changes
310
+ the display; it does not change the instrument's valid order prices. With a real
311
+ feed, pass each supplied order-book snapshot to `buildRows`. Chart candles and
312
+ ladder depth can come from separate instrument subscriptions. `DomLadder` remains
313
+ available for an attached ladder that aligns to the chart's own price scale;
314
+ see the guide for both integration patterns.
315
+
248
316
  ### Profiles &amp; order flow
249
317
  Volume Profile, Market Profile (TPO), Footprint, and cumulative delta.
250
318
 
@@ -258,10 +326,37 @@ newest-session `#` price markers, and Dark, Blue, Graphite, Emerald and Ivory th
258
326
 
259
327
  The [website profile guide](./website/pages/docs/market-profile-examples.mdx) includes
260
328
  the interactive demo, all five theme screenshots and packed/split close-ups.
261
- See the [2.1.0 changelog](./CHANGELOG.md#210).
262
-
263
- <a href="website/public/screenshots/market-profile/blue.png"><img src="website/public/screenshots/market-profile/blue.png" alt="Blue compact TPO theme, with the newest session split" width="49%" /></a>
264
- <a href="website/public/screenshots/market-profile/ivory.png"><img src="website/public/screenshots/market-profile/ivory.png" alt="Ivory compact TPO theme using the same synthetic sessions" width="49%" /></a>
329
+ See the [2.1.1 changelog](./CHANGELOG.md#211).
330
+
331
+ <a href="website/public/screenshots/market-profile-v2.1.1/blue.png"><img src="website/public/screenshots/market-profile-v2.1.1/blue.png" alt="Blue TPO close-up with readable letters and the newest session split" width="400" /></a>
332
+ <a href="website/public/screenshots/market-profile-v2.1.1/ivory.png"><img src="website/public/screenshots/market-profile-v2.1.1/ivory.png" alt="Ivory TPO close-up using the same synthetic session" width="400" /></a>
333
+
334
+ ### Footprint charts in 2.1.1
335
+
336
+ `Footprint` supports volume-profile rows, cluster ladders and heatmaps through
337
+ `cellStyle: 'profile' | 'ladder' | 'heatmap'`. Background display and text coloring
338
+ are independent: `textColorMode` selects neutral contrast, bid/ask side, row delta,
339
+ same-row dominance, diagonal imbalance or volume intensity. Separate
340
+ `buyTextColor` and `sellTextColor` palettes keep the numbers readable on light,
341
+ dark and bright fills. Candle context, POC/value-area markers and per-bar
342
+ volume, delta, cumulative delta and actual trade-count summaries complete the view.
343
+
344
+ The optional bottom table is disabled by default. Set `tableRows` to any ordered
345
+ subset of `['delta', 'minDelta', 'maxDelta', 'cvd', 'askVolume', 'bidVolume', 'volume']`.
346
+ Columns follow their footprint bars; the fixed left column names each metric.
347
+ Min/Max Delta measure the running delta within the bar, including initial zero.
348
+ The demo simulates NIFTY near 23,800 with 2-point rows and provides a Table switch
349
+ and row checkboxes, independent of the per-bar cards.
350
+ Switch Quantity/Lots and edit the lot size (initially 65) to change display units.
351
+ The library option `volumeDivisor: 65` scales volume and delta labels; its default
352
+ is 1. Raw statistics, delta percentages and actual trade counts remain unchanged.
353
+
354
+ Try the [order-flow example](./examples/orderflow/index.html) and follow the
355
+ [footprint guide](./website/pages/docs/profiles-and-orderflow.mdx). The example uses
356
+ synthetic classified trades; production footprints require actual bid/ask trade
357
+ classification. The 2.1.1 data fixes preserve detached live snapshots, respect
358
+ missing ladder rows during imbalance comparisons, and retain real OHLC and
359
+ trade-count metadata.
265
360
 
266
361
  ### Warm-load cache &amp; interval registry
267
362
 
@@ -309,16 +404,16 @@ Enforced in CI by [`size-limit`](./.size-limit.json). Nothing is excluded, becau
309
404
 
310
405
  | Bundle | Limit | Actual |
311
406
  |---|---|---|
312
- | Base engine | 67 KB | 66.51 KB |
313
- | Base + trade | 75 KB | 74.11 KB |
407
+ | Base engine | 67 KB | 66.49 KB |
408
+ | Base + trade | 75 KB | 74.10 KB |
314
409
  | Indicators tier | 30 KB | 27.27 KB |
315
410
  | Draw tier | 26 KB | 25.82 KB |
316
411
  | Transform tier | 5 KB | 2.66 KB |
317
- | Profile tier | 12 KB | 11.95 KB |
412
+ | Profile tier | 15 KB | 14.96 KB |
318
413
  | WebGL2 tier | 7 KB | 6.38 KB |
319
414
  | Widget tier | 36 KB | 35.56 KB |
320
- | Widget terminal (base + draw + indicators + widget) | 156 KB | 155.15 KB |
321
- | **Everything** | **184 KB** | **183.74 KB** |
415
+ | Widget terminal (base + draw + indicators + widget) | 156 KB | 155.13 KB |
416
+ | **Everything** | **187 KB** | **186.74 KB** |
322
417
 
323
418
  ## Documentation
324
419
 
@@ -361,7 +456,7 @@ python server.py --fixture # no yfinance, no network: deterministic synthetic
361
456
  ```bash
362
457
  npm install # install dev toolchain
363
458
  npm run typecheck # strict TypeScript check
364
- npm test # unit tests (vitest) - 4026 across 172 files
459
+ npm test # unit tests (vitest) - 4139 across 176 files
365
460
  npm run build # Rollup -> dist/ (minified ESM per tier + types)
366
461
  npm run size # size-limit (Brotli) against the budget
367
462
  npm run e2e # Playwright Chromium smoke tests
@@ -378,7 +473,7 @@ npm run verify # lint + typecheck + test + build + demo tests + dts + size +
378
473
 
379
474
  ## Status &amp; limitations
380
475
 
381
- Version **2.1.0**. All engine build phases are implemented with 4026 unit tests across 172 files. Upgrading a 1.9.x host: [Migrating to 2.0](./docs/migrating-to-2.md).
476
+ Version **2.1.1**. All engine build phases are implemented. Upgrading a 1.9.x host: [Migrating to 2.0](./docs/migrating-to-2.md).
382
477
 
383
478
  Known gaps, stated plainly:
384
479
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- /** Library version string. Matches package.json (published npm release). */
2
- declare const VERSION = "2.1.0";
1
+ /** Library version string. Matches package.json (including locally prepared releases). */
2
+ declare const VERSION = "2.1.1";
3
3
  /** Returns the current library version. */
4
4
  declare function version(): string;
5
5
 
@@ -3350,6 +3350,8 @@ interface ChartOptions {
3350
3350
  theme?: ChartTheme;
3351
3351
  priceAxisWidth?: number;
3352
3352
  timeAxisHeight?: number;
3353
+ /** Initial horizontal scale configuration, including spacing limits for wide profiles. */
3354
+ timeScale?: Partial<TimeScaleOptions>;
3353
3355
  /**
3354
3356
  * Where indicator legend rows start inside **one** pane, in media px. A host
3355
3357
  * that draws its own overlay in a pane's top-left corner — an OHLC readout, a