openalgo-charts 1.0.7 → 1.0.9
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 +101 -21
- package/dist/draw/index.d.ts +2075 -0
- package/dist/index.d.ts +710 -70
- package/dist/indicators/index.d.ts +139 -0
- package/dist/openalgo-charts.draw.mjs +2 -0
- package/dist/openalgo-charts.draw.mjs.map +1 -0
- package/dist/openalgo-charts.indicators.mjs +2 -0
- package/dist/openalgo-charts.indicators.mjs.map +1 -0
- package/dist/openalgo-charts.mjs +1 -1
- package/dist/openalgo-charts.mjs.map +1 -1
- package/dist/openalgo-charts.profile.mjs +1 -1
- package/dist/openalgo-charts.profile.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.transform.mjs +1 -1
- package/dist/openalgo-charts.transform.mjs.map +1 -1
- package/dist/profile/index.d.ts +161 -16
- package/dist/trade/index.d.ts +33 -0
- package/dist/transform/index.d.ts +62 -9
- package/package.json +101 -72
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
|
|
7
|
+
Professional interactive charts, indicators, drawing tools, order flow, and on-chart trading — six lazy-loaded tiers, zero runtime dependencies, ~33 KB Brotli for the base engine.
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/openalgo-charts)
|
|
10
10
|
[](./LICENSE)
|
|
11
|
-
[](#size-budget)
|
|
12
|
+
[](#develop)
|
|
13
13
|
[](#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) · [**Architecture**](./ARCHITECTURE.md)
|
|
@@ -30,7 +30,7 @@ Right-click the chart to place market / limit / stop orders, drag the order and
|
|
|
30
30
|
|
|
31
31
|
## Examples gallery
|
|
32
32
|
|
|
33
|
-
Every chart in the [live gallery](https://marketcalls.github.io/openalgo-charts/examples) is the real library running in your browser - switch tabs, hover the crosshair, drag the order lines. What you see is the code that ran.
|
|
33
|
+
Every chart in the [live gallery](https://marketcalls.github.io/openalgo-charts/examples) is the real library running in your browser - switch tabs, hover the crosshair, drag the order lines, place a drawing. What you see is the code that ran.
|
|
34
34
|
|
|
35
35
|
<p align="center">
|
|
36
36
|
<img src="docs/demo1.png" alt="Chart-type switcher, custom themes, data tooltips, and event markers" width="49%" />
|
|
@@ -54,22 +54,81 @@ const chart = createChart(document.getElementById('chart'));
|
|
|
54
54
|
chart.addSeries('candlestick').setData(generateBars(1700000000, 200, 3600));
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
## Tiers
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
|
62
|
-
|
|
63
|
-
| `openalgo-charts
|
|
64
|
-
| `openalgo-charts/
|
|
59
|
+
Import only what you use. Each tier is a separate bundle that registers into the base engine's registries, so the cost of a feature you don't load is zero.
|
|
60
|
+
|
|
61
|
+
| Import | Contents | Brotli |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `openalgo-charts` | Engine, 13 chart types, panes & scales, primitives, registries, chart state, trading overlay, OpenAlgo feeds | 32.7 KB |
|
|
64
|
+
| `openalgo-charts/indicators` | 18 built-in indicators + the Tier-2 (external-data) contract | 4.5 KB |
|
|
65
|
+
| `openalgo-charts/draw` | 18 drawing tools + a headless drawing controller | 6.3 KB |
|
|
66
|
+
| `openalgo-charts/transform` | Heikin Ashi, Renko, Range bars, Line Break, Point & Figure, Kagi | 2.7 KB |
|
|
67
|
+
| `openalgo-charts/profile` | Volume Profile, Market Profile (TPO), Footprint, order flow | 5.5 KB |
|
|
68
|
+
| `openalgo-charts/trade` | Order / position / bracket tools + DOM ladder | 6.6 KB |
|
|
69
|
+
|
|
70
|
+
Everything together is **58 KB Brotli**.
|
|
65
71
|
|
|
66
72
|
## What's built
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
### Chart types & transforms
|
|
75
|
+
Candles, hollow and volume candles, OHLC bars, high-low, line, line+markers, step, area, HLC-area, baseline, columns, histogram — plus Heikin Ashi, Renko, Range bars, Line Break, **Point & Figure** (fixed / percent / ATR box sizing, high-low or close construction), and Kagi.
|
|
76
|
+
|
|
77
|
+
### Indicators
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import 'openalgo-charts/indicators';
|
|
81
|
+
|
|
82
|
+
chart.addIndicator('bollinger'); // overlays the price pane
|
|
83
|
+
const macd = chart.addIndicator('macd', { fastPeriod: 8 }); // gets its own pane
|
|
84
|
+
macd.setSettings({ 'macd:width': 2, 'macd:lineStyle': 'dashed' });
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
18 built-ins: SMA, EMA, WMA, VWAP, Bollinger Bands, Supertrend, Parabolic SAR, Ichimoku Cloud, RSI, MACD, Stochastic, ADX/DMI, CCI, MFI, ATR, Volume, OBV, A/D.
|
|
88
|
+
|
|
89
|
+
The chart owns the whole lifecycle — series, pane placement, reference levels, fixed ranges (RSI 0..100), recompute on data change, teardown. Every plot gets colour, opacity, thickness, and line style for free, generated from the descriptor. Write your own with `registerIndicator`, or use the **Tier-2 contract** for indicators whose data isn't derived from OHLCV (open interest, CVD, any external feed).
|
|
90
|
+
|
|
91
|
+
### Drawing tools
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { DrawingController } from 'openalgo-charts/draw';
|
|
95
|
+
|
|
96
|
+
const draw = new DrawingController(chart, { magnet: true });
|
|
97
|
+
draw.setTool('trend-line'); // the next two clicks place it
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
18 tools: trend line, ray, extended line, arrow, horizontal line/ray, vertical line, cross line, rectangle, ellipse, parallel channel, fib retracement/extension, long/short position (with R:R and risk-based sizing), measure, text, path.
|
|
101
|
+
|
|
102
|
+
Headless by design — no toolbar, no dialogs. Placement with live preview, selection, whole-shape and per-anchor dragging, magnet snap to O/H/L/C, undo/redo (a drag is one step), and persistence. Anchors are `{ time, price }`, never pixels, so they survive zoom and resolve inside collapsed session gaps and past the last bar.
|
|
103
|
+
|
|
104
|
+
### Panes & legends
|
|
105
|
+
Draggable pane dividers, move / maximize / remove, and TradingView-style pane legends showing one reading per plot in that plot's own colour, with inline show-hide / settings / move / delete controls revealed on hover.
|
|
106
|
+
|
|
107
|
+
### Trading
|
|
108
|
+
Order, position, and bracket lines with live P&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).
|
|
109
|
+
|
|
110
|
+
### Profiles & order flow
|
|
111
|
+
Volume Profile, Market Profile (TPO), Footprint, and cumulative delta.
|
|
112
|
+
|
|
113
|
+
### State
|
|
114
|
+
`chart.getState()` / `chart.restoreState()` capture the viewport, grid, panes, price scales, indicator instances, and drawings as one JSON payload — saved layouts and templates with no extra storage plumbing.
|
|
115
|
+
|
|
116
|
+
### Data
|
|
117
|
+
OpenAlgo REST history + WebSocket ticks with auto-reconnect and resubscribe, live candle aggregation, tick/volume bars, a unified `chart.on(...)` event bus, markers and signals, earnings/dividend/expiry event markers, and custom price/time formatters.
|
|
118
|
+
|
|
119
|
+
## Size budget
|
|
120
|
+
|
|
121
|
+
Enforced in CI by [`size-limit`](./.size-limit.json) — nothing is excluded, because there are no runtime dependencies to exclude.
|
|
122
|
+
|
|
123
|
+
| Bundle | Limit | Actual |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| Base engine | 34 KB | 32.72 KB |
|
|
126
|
+
| Base + trade | 40.5 KB | 39.31 KB |
|
|
127
|
+
| Indicators tier | 9 KB | 4.47 KB |
|
|
128
|
+
| Draw tier | 14 KB | 6.25 KB |
|
|
129
|
+
| Transform tier | 5 KB | 2.66 KB |
|
|
130
|
+
| Profile tier | 8 KB | 5.53 KB |
|
|
131
|
+
| **Everything** | **72 KB** | **58.22 KB** |
|
|
73
132
|
|
|
74
133
|
## Documentation
|
|
75
134
|
|
|
@@ -84,12 +143,22 @@ npm run build # build the library (dist/) the live
|
|
|
84
143
|
cd website && npm install && npm run dev # http://localhost:3000/openalgo-charts
|
|
85
144
|
```
|
|
86
145
|
|
|
146
|
+
## Examples
|
|
147
|
+
|
|
148
|
+
Runnable demos in [`examples/`](./examples), including a full **yfinance terminal** ([`examples/yfinance`](./examples/yfinance)) with a TradingView-style shell: symbol search, interval pills, chart-type picker, indicator menu, a vertical drawing rail, a floating properties bar, generated indicator settings, and layout persistence.
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
npm run build
|
|
152
|
+
cd examples/yfinance && pip install -r requirements.txt && python server.py
|
|
153
|
+
# → http://127.0.0.1:8000/examples/yfinance/index.html
|
|
154
|
+
```
|
|
155
|
+
|
|
87
156
|
## Develop
|
|
88
157
|
|
|
89
158
|
```bash
|
|
90
159
|
npm install # install dev toolchain
|
|
91
160
|
npm run typecheck # strict TypeScript check
|
|
92
|
-
npm test # unit tests (vitest) -
|
|
161
|
+
npm test # unit tests (vitest) - 468 across 47 files
|
|
93
162
|
npm run build # Rollup -> dist/ (minified ESM per tier + types)
|
|
94
163
|
npm run size # size-limit (Brotli) against the budget
|
|
95
164
|
npm run e2e # Playwright Chromium smoke tests
|
|
@@ -98,14 +167,25 @@ npm run verify # typecheck + test + build + size
|
|
|
98
167
|
|
|
99
168
|
## Principles
|
|
100
169
|
|
|
101
|
-
- **Single canvas pipeline** (no SVG, no DOM-per-bar)
|
|
102
|
-
- **Gapless time axis by default**
|
|
103
|
-
- **
|
|
170
|
+
- **Single canvas pipeline** (no SVG, no DOM-per-bar) — small and fast.
|
|
171
|
+
- **Gapless time axis by default** — weekends, holidays, and session breaks collapse.
|
|
172
|
+
- **Registries, not switches** — chart types, indicators, and drawing tools are all descriptors. Adding one is a registration, never a core change.
|
|
173
|
+
- **Zero runtime dependencies** — nothing is excluded from the size budget.
|
|
104
174
|
- **Apache-2.0**, original code.
|
|
105
175
|
|
|
106
176
|
## Status & limitations
|
|
107
177
|
|
|
108
|
-
Version **1.0.
|
|
178
|
+
Version **1.0.8 (published)**. All engine build phases are implemented with 468 unit tests across 47 files.
|
|
179
|
+
|
|
180
|
+
Known gaps, stated plainly:
|
|
181
|
+
|
|
182
|
+
- The **Footprint / order-flow renderer** works but has not had its visual pass — hardcoded colours (not theme-aware), a single display mode, no `setOptions`, and `stackedImbalances` is computed but not drawn.
|
|
183
|
+
- **Footprint and order flow need trade-by-trade data classified bid/ask.** OpenAlgo does not store this by default, so it is live-session-only unless you add a tick recorder. See [`ARCHITECTURE.md`](./ARCHITECTURE.md) §6A.
|
|
184
|
+
- The OpenAlgo **WS/trade adapter wire schemas** ship with injectable transports and offline tests, but the exact field names should be verified against your running OpenAlgo build.
|
|
185
|
+
- Price-scale **`percentage`** and **`indexed-to-100`** modes, and overlay scales on a shared axis, are not implemented.
|
|
186
|
+
- An optional **DOM chrome package** (toolbar, dialogs, command palette, objects panel) is the next planned piece; today that UI lives in the examples.
|
|
187
|
+
|
|
188
|
+
See [`ARCHITECTURE.md`](./ARCHITECTURE.md) §13a for the full deferred list.
|
|
109
189
|
|
|
110
190
|
## License
|
|
111
191
|
|