openalgo-charts 2.4.8 → 2.5.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 +15 -15
- package/dist/index.d.ts +68 -4
- package/dist/openalgo-charts.mjs +1 -1
- package/dist/openalgo-charts.mjs.map +1 -1
- package/dist/openalgo-charts.standalone.js +1 -1
- package/dist/openalgo-charts.standalone.js.map +1 -1
- package/dist/openalgo-charts.widget.mjs +1 -1
- package/dist/openalgo-charts.widget.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ with no runtime dependencies.
|
|
|
12
12
|
[](https://www.npmjs.com/package/openalgo-charts)
|
|
13
13
|
[](./LICENSE)
|
|
14
14
|
[](https://www.npmjs.com/package/openalgo-charts)
|
|
15
|
-
[](#develop)
|
|
16
16
|
[](#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.
|
|
28
|
+
Current version: **2.5.1**. Hosts can hide finished alert lines while keeping their saved history.
|
|
29
29
|
See the [changelog](./CHANGELOG.md) for release notes.
|
|
30
30
|
|
|
31
31
|
## Quick start
|
|
@@ -56,7 +56,7 @@ for live data, or [the widget example](#the-whole-terminal-in-one-call) for char
|
|
|
56
56
|
|
|
57
57
|
## Architecture
|
|
58
58
|
|
|
59
|
-
<a href="docs/architecture-diagram.svg"><img src="docs/architecture-diagram.svg" alt="OpenAlgo Charts 2.
|
|
59
|
+
<a href="docs/architecture-diagram.svg"><img src="docs/architecture-diagram.svg" alt="OpenAlgo Charts 2.5.1 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>
|
|
60
60
|
|
|
61
61
|
How data reaches the chart, what your app owns, and which features you can import.
|
|
62
62
|
[Open the full-size diagram](docs/architecture-diagram.svg).
|
|
@@ -107,7 +107,7 @@ You can also load the library from a CDN in a plain HTML page:
|
|
|
107
107
|
```html
|
|
108
108
|
<div id="chart" style="width:100vw;height:100vh"></div>
|
|
109
109
|
<script type="module">
|
|
110
|
-
import { createChart, generateBars } from 'https://unpkg.com/openalgo-charts@2.
|
|
110
|
+
import { createChart, generateBars } from 'https://unpkg.com/openalgo-charts@2.5.1/dist/openalgo-charts.mjs';
|
|
111
111
|
const chart = createChart(document.getElementById('chart'), { timezone: 'Asia/Kolkata' });
|
|
112
112
|
chart.addSeries('candlestick').setData(generateBars(1700000000, 200, 3600));
|
|
113
113
|
chart.fitContent();
|
|
@@ -157,17 +157,17 @@ Unused optional tiers stay out of the base chart download.
|
|
|
157
157
|
|
|
158
158
|
| Import | Contents | Brotli |
|
|
159
159
|
|---|---|---|
|
|
160
|
-
| `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 |
|
|
160
|
+
| `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 | 93.60 kB |
|
|
161
161
|
| `openalgo-charts/indicators` | 105 built-in indicators, calculation helpers and helpers for studies that use external data | 29.84 kB |
|
|
162
162
|
| `openalgo-charts/draw` | 85 drawing tools + a headless drawing controller, clipboard, settings schema, level palette, freehand geometry and SVG icons | 35.43 kB |
|
|
163
163
|
| `openalgo-charts/transform` | Heikin Ashi, Renko, Range bars, Line Break, Point & Figure, Kagi, and symbol arithmetic (`AAPL/MSFT`) | 4.50 kB |
|
|
164
164
|
| `openalgo-charts/profile` | Volume Profile, Market Profile (TPO) with compact pixel letters, Footprint, order flow | 14.96 kB |
|
|
165
165
|
| `openalgo-charts/trade` | Order, position and bracket tools, plus a depth-of-market ladder | 8.01 kB |
|
|
166
166
|
| `openalgo-charts/webgl` | GPU drawing for supported series, with Canvas 2D fallback | 6.39 kB |
|
|
167
|
-
| `openalgo-charts/widget` | `createWidget`: toolbar, drawing controls, dialogs, mobile controls, status line, shortcuts and optional layout persistence | 49.
|
|
167
|
+
| `openalgo-charts/widget` | `createWidget`: toolbar, drawing controls, dialogs, mobile controls, status line, shortcuts and optional layout persistence | 49.06 kB |
|
|
168
168
|
| `openalgo-charts/workspace` | Validated workspace and indicator-template documents, named catalogs with revision checks, asynchronous storage and an IndexedDB adapter; no DOM | 5.52 kB |
|
|
169
169
|
|
|
170
|
-
Everything together is **
|
|
170
|
+
Everything together is **247.32 kB Brotli**; a widget terminal with built-in indicators (base + draw + indicators + widget) is 207.93 kB. Figures are measured from the 2.5.1 release build. The trade tier is 8.01 kB on its own; base + trade costs 101.60 kB. Sizes use decimal kB.
|
|
171
171
|
|
|
172
172
|
## What's built
|
|
173
173
|
|
|
@@ -489,17 +489,17 @@ Enforced in CI by [`size-limit`](./.size-limit.json). Nothing is excluded, becau
|
|
|
489
489
|
|
|
490
490
|
| Bundle | Limit | Actual |
|
|
491
491
|
|---|---|---|
|
|
492
|
-
| Base engine | 93.
|
|
493
|
-
| Base + trade | 101.
|
|
492
|
+
| Base engine | 93.75 kB | 93.60 kB |
|
|
493
|
+
| Base + trade | 101.75 kB | 101.60 kB |
|
|
494
494
|
| Indicators tier | 30 kB | 29.84 kB |
|
|
495
495
|
| Draw tier | 36 kB | 35.43 kB |
|
|
496
496
|
| Transform tier | 6 kB | 4.50 kB |
|
|
497
497
|
| Profile tier | 15 kB | 14.96 kB |
|
|
498
498
|
| WebGL2 tier | 7 kB | 6.39 kB |
|
|
499
|
-
| Widget tier | 49.25 kB | 49.
|
|
500
|
-
| Widget terminal (base + draw + indicators + widget) |
|
|
499
|
+
| Widget tier | 49.25 kB | 49.06 kB |
|
|
500
|
+
| Widget terminal (base + draw + indicators + widget) | 208.25 kB | 207.93 kB |
|
|
501
501
|
| Workspace tier | 6 kB | 5.52 kB |
|
|
502
|
-
| **Everything** | 247.
|
|
502
|
+
| **Everything** | 247.75 kB | 247.32 kB |
|
|
503
503
|
|
|
504
504
|
## Documentation
|
|
505
505
|
|
|
@@ -544,8 +544,8 @@ See [Contributing](./CONTRIBUTING.md) for setup, targeted checks, documentation
|
|
|
544
544
|
```bash
|
|
545
545
|
npm install # install dev toolchain
|
|
546
546
|
npm run typecheck # strict TypeScript check
|
|
547
|
-
npm test # engine unit tests (Vitest):
|
|
548
|
-
npm run test:demo # reference-host tests:
|
|
547
|
+
npm test # engine unit tests (Vitest): 5918 across 249 files
|
|
548
|
+
npm run test:demo # reference-host tests: 415 across 32 files
|
|
549
549
|
npm run test:endurance # node endurance-harness tests: 7 cases
|
|
550
550
|
npm run build # Rollup -> dist/ (minified ESM per tier + types)
|
|
551
551
|
npm run size # size-limit (Brotli) against the budget
|
|
@@ -563,7 +563,7 @@ npm run verify # lint + types + unit + endurance harness + build + demo + dt
|
|
|
563
563
|
|
|
564
564
|
## Status & limitations
|
|
565
565
|
|
|
566
|
-
Version **2.
|
|
566
|
+
Version **2.5.1**. All engine build phases are implemented. Upgrading a 1.9.x host: [Migrating to 2.0](./docs/migrating-to-2.md).
|
|
567
567
|
|
|
568
568
|
Known gaps, stated plainly:
|
|
569
569
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TradingCapabilitySource as TradingCapabilitySource$1 } from 'openalgo-charts';
|
|
2
2
|
|
|
3
3
|
/** Library version string. Matches package.json (including locally prepared releases). */
|
|
4
|
-
declare const VERSION = "2.
|
|
4
|
+
declare const VERSION = "2.5.1";
|
|
5
5
|
/** Returns the current library version. */
|
|
6
6
|
declare function version(): string;
|
|
7
7
|
|
|
@@ -1908,8 +1908,16 @@ interface ChartTableOptions {
|
|
|
1908
1908
|
position: TablePosition;
|
|
1909
1909
|
/** Gap from the pane edge, media px. */
|
|
1910
1910
|
margin: number;
|
|
1911
|
-
/**
|
|
1912
|
-
|
|
1911
|
+
/**
|
|
1912
|
+
* Column width in media px. A per-column array sizes each one separately.
|
|
1913
|
+
*
|
|
1914
|
+
* `'auto'` measures instead: every column takes the width of its own widest
|
|
1915
|
+
* cell at the size that cell will be drawn at. A grid whose cells are
|
|
1916
|
+
* sentences rather than numbers cannot be sized by a caller who has not
|
|
1917
|
+
* measured the text, and a fixed width there is a column of readings running
|
|
1918
|
+
* into the column beside it.
|
|
1919
|
+
*/
|
|
1920
|
+
cellWidth: number | readonly number[] | 'auto';
|
|
1913
1921
|
cellHeight: number;
|
|
1914
1922
|
/**
|
|
1915
1923
|
* Type size in media px, or `'auto'` to fit each cell: as large as its row
|
|
@@ -2226,6 +2234,8 @@ interface ChartDataUpdate {
|
|
|
2226
2234
|
/** Minimum headless chart surface needed to evaluate alerts. */
|
|
2227
2235
|
interface AlertChartHost {
|
|
2228
2236
|
primaryBars(): readonly Bar[];
|
|
2237
|
+
/** Owning price scale for primary-price drag snapping, including a left axis. */
|
|
2238
|
+
primarySeries?(): Pick<SeriesApi, 'priceScale'> | null;
|
|
2229
2239
|
getDataContext(): Readonly<ChartDataContext> | undefined;
|
|
2230
2240
|
on(event: string, callback: (payload: unknown) => void): () => void;
|
|
2231
2241
|
emit(event: string, payload: unknown): void;
|
|
@@ -2235,6 +2245,13 @@ interface AlertChartHost {
|
|
|
2235
2245
|
removePrimitive?(primitive: IPrimitive): void;
|
|
2236
2246
|
alertState?(): AlertsDocument | undefined;
|
|
2237
2247
|
setAlertState?(document: AlertsDocument | undefined): void;
|
|
2248
|
+
/**
|
|
2249
|
+
* A price rounded to the tick the pane's scale is written in.
|
|
2250
|
+
*
|
|
2251
|
+
* Optional, and unrounded is the fallback: a host that declares no tick has
|
|
2252
|
+
* nothing to round to, and inventing one would move a price somebody chose.
|
|
2253
|
+
*/
|
|
2254
|
+
snapPrice?(paneIndex: number, price: number): number;
|
|
2238
2255
|
}
|
|
2239
2256
|
type AlertCondition = 'crossing' | 'crossingUp' | 'crossingDown' | 'greaterThan' | 'lessThan' | 'enteringRange' | 'leavingRange' | 'matches';
|
|
2240
2257
|
type AlertPolicy = 'onBarClose' | 'onTouch';
|
|
@@ -2304,7 +2321,11 @@ interface BarCondition {
|
|
|
2304
2321
|
/** Runs at the alert's chosen policy, never for loaded history. */
|
|
2305
2322
|
when(context: BarConditionContext): boolean;
|
|
2306
2323
|
}
|
|
2307
|
-
/**
|
|
2324
|
+
/**
|
|
2325
|
+
* Evaluation belongs to the instrument and interval present when the alert was armed.
|
|
2326
|
+
* Fixed price levels remain visible on other intervals of the same instrument,
|
|
2327
|
+
* labelled with their original timeframe and paused until it is displayed again.
|
|
2328
|
+
*/
|
|
2308
2329
|
interface AlertScope {
|
|
2309
2330
|
symbol?: string;
|
|
2310
2331
|
exchange?: string;
|
|
@@ -2368,6 +2389,23 @@ interface AlertControllerOptions {
|
|
|
2368
2389
|
drawings?: AlertDrawingProvider;
|
|
2369
2390
|
/** PriceLine visuals are enabled on chart hosts; disable for a model-only consumer. */
|
|
2370
2391
|
visuals?: boolean;
|
|
2392
|
+
/**
|
|
2393
|
+
* Whether a spent alert keeps its line. Defaults to `'show'`.
|
|
2394
|
+
*
|
|
2395
|
+
* A triggered or expired alert is no longer watching anything, and the two
|
|
2396
|
+
* defensible things to do with its line are opposites. Keeping it is this
|
|
2397
|
+
* library's default and is why each lifecycle state has its own badge and
|
|
2398
|
+
* colour: the line says what became of the level, which is worth knowing on a
|
|
2399
|
+
* chart somebody has just come back to.
|
|
2400
|
+
*
|
|
2401
|
+
* `'hide'` is for the host where that reading does not pay. A terminal left
|
|
2402
|
+
* open through a session accumulates levels that will never fire again, and
|
|
2403
|
+
* past a certain number the ones still watching are the hardest to pick out
|
|
2404
|
+
* of them. The alert itself is untouched either way: it stays in `list()`,
|
|
2405
|
+
* keeps its lifecycle state, still refuses to fire twice, and gets its line
|
|
2406
|
+
* back if a host re-arms it. Only the drawing goes.
|
|
2407
|
+
*/
|
|
2408
|
+
spentLines?: 'show' | 'hide';
|
|
2371
2409
|
}
|
|
2372
2410
|
|
|
2373
2411
|
/**
|
|
@@ -5284,6 +5322,20 @@ declare class Chart {
|
|
|
5284
5322
|
*/
|
|
5285
5323
|
drawingState(): unknown;
|
|
5286
5324
|
setDrawingState(value: unknown): void;
|
|
5325
|
+
/**
|
|
5326
|
+
* A price rounded to the tick the pane's own axis is written with.
|
|
5327
|
+
*
|
|
5328
|
+
* A dragged alert's price comes from a pointer, and a pixel maps to a price
|
|
5329
|
+
* with a dozen decimals behind it: dropped where the axis reads 1255.90 it
|
|
5330
|
+
* was stored as 1255.8706204379562, a price the instrument cannot trade at
|
|
5331
|
+
* and a number nothing in the interface could show. The scale already knows
|
|
5332
|
+
* the tick, because it is the one the axis is written with, so this is the
|
|
5333
|
+
* chart's answer rather than something every host works out again.
|
|
5334
|
+
*
|
|
5335
|
+
* A scale with no declared tick rounds nothing: there is no tick to round to
|
|
5336
|
+
* and inventing one would move a price somebody chose.
|
|
5337
|
+
*/
|
|
5338
|
+
snapPrice(paneIndex: number, price: number): number;
|
|
5287
5339
|
/** Detached JSON state, also available when no alert controller is attached. */
|
|
5288
5340
|
alertState(): AlertsDocument | undefined;
|
|
5289
5341
|
/** Runtime snapshot. JSON safety of opaque payloads is checked when state is read. */
|
|
@@ -9573,9 +9625,13 @@ declare function roundToTick(value: number, step: number): number;
|
|
|
9573
9625
|
declare class AlertController {
|
|
9574
9626
|
private readonly _chart;
|
|
9575
9627
|
private readonly _records;
|
|
9628
|
+
/** The alert whose line the pointer is over, for a key that acts on it. */
|
|
9629
|
+
private _hovered;
|
|
9576
9630
|
private readonly _off;
|
|
9577
9631
|
private readonly _now;
|
|
9578
9632
|
private readonly _drawings;
|
|
9633
|
+
/** Whether a spent alert keeps its line; the host's choice, default 'show'. */
|
|
9634
|
+
private readonly _spentLines;
|
|
9579
9635
|
private readonly _visuals;
|
|
9580
9636
|
private _timer;
|
|
9581
9637
|
private _timerAt;
|
|
@@ -9587,6 +9643,14 @@ declare class AlertController {
|
|
|
9587
9643
|
private _drag;
|
|
9588
9644
|
constructor(_chart: AlertChartHost, options?: AlertControllerOptions);
|
|
9589
9645
|
private _dragAvailability;
|
|
9646
|
+
/**
|
|
9647
|
+
* The alert the pointer is over, or none.
|
|
9648
|
+
*
|
|
9649
|
+
* Offered so a host can bind a key to it. The controller does not bind keys
|
|
9650
|
+
* itself: it owns no input and a chart embedded without the widget shell has
|
|
9651
|
+
* its own idea of what a keystroke means.
|
|
9652
|
+
*/
|
|
9653
|
+
hovered(): string | undefined;
|
|
9590
9654
|
private _dragPrice;
|
|
9591
9655
|
private _startDrag;
|
|
9592
9656
|
private _cancelDrag;
|