openalgo-charts 1.0.9 → 1.0.11
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 +192 -192
- package/dist/draw/index.d.ts +74 -1
- package/dist/index.d.ts +120 -1
- package/dist/openalgo-charts.draw.mjs +1 -1
- package/dist/openalgo-charts.draw.mjs.map +1 -1
- 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/profile/index.d.ts +253 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,192 +1,192 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
# OpenAlgo Charts
|
|
4
|
-
|
|
5
|
-
**A from-scratch, dependency-free HTML5-canvas charting engine for OpenAlgo.**
|
|
6
|
-
|
|
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
|
-
|
|
9
|
-
[](https://www.npmjs.com/package/openalgo-charts)
|
|
10
|
-
[](./LICENSE)
|
|
11
|
-
[](#size-budget)
|
|
12
|
-
[](#develop)
|
|
13
|
-
[](#principles)
|
|
14
|
-
|
|
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)
|
|
16
|
-
|
|
17
|
-
<img src="docs/architecture-diagram.png" alt="OpenAlgo Charts - layered architecture from public API down to feeds and data, with loadable bundle tiers" width="920" />
|
|
18
|
-
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Live OpenAlgo trading terminal
|
|
24
|
-
|
|
25
|
-
Right-click the chart to place market / limit / stop orders, drag the order and TP/SL bracket lines to modify, and watch live P&L on the position line - all on real OpenAlgo history + WebSocket tick data, with an analyzer (sandbox) mode so nothing goes live until you arm it.
|
|
26
|
-
|
|
27
|
-
<p align="center">
|
|
28
|
-
<img src="docs/trading.png" alt="OpenAlgo Charts live trading terminal: RELIANCE 5m candles with order lines, a right-click order menu, a long position with live P&L, and volume" width="920" />
|
|
29
|
-
</p>
|
|
30
|
-
|
|
31
|
-
## Examples gallery
|
|
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, place a drawing. What you see is the code that ran.
|
|
34
|
-
|
|
35
|
-
<p align="center">
|
|
36
|
-
<img src="docs/demo1.png" alt="Chart-type switcher, custom themes, data tooltips, and event markers" width="49%" />
|
|
37
|
-
<img src="docs/demo2.png" alt="Range switcher, legend, series compare, and indicators and markers" width="49%" />
|
|
38
|
-
</p>
|
|
39
|
-
<p align="center">
|
|
40
|
-
<img src="docs/demo3.png" alt="More live OpenAlgo Charts examples" width="49%" />
|
|
41
|
-
<img src="docs/demo4.png" alt="More live OpenAlgo Charts examples" width="49%" />
|
|
42
|
-
</p>
|
|
43
|
-
|
|
44
|
-
## Install
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
npm install openalgo-charts
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
```ts
|
|
51
|
-
import { createChart, generateBars } from 'openalgo-charts';
|
|
52
|
-
|
|
53
|
-
const chart = createChart(document.getElementById('chart'));
|
|
54
|
-
chart.addSeries('candlestick').setData(generateBars(1700000000, 200, 3600));
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Tiers
|
|
58
|
-
|
|
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` |
|
|
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**.
|
|
71
|
-
|
|
72
|
-
## What's built
|
|
73
|
-
|
|
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
|
-
|
|
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** |
|
|
132
|
-
|
|
133
|
-
## Documentation
|
|
134
|
-
|
|
135
|
-
Full docs, the interactive example gallery, and the generated API reference live at:
|
|
136
|
-
|
|
137
|
-
**https://marketcalls.github.io/openalgo-charts/**
|
|
138
|
-
|
|
139
|
-
The site is built with Nextra (in [`website/`](./website)) and statically exported to GitHub Pages on every push. Every code sample on a docs page is a *live* chart running the real library, so what you read is what runs. To run the site locally:
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
npm run build # build the library (dist/) the live demos import
|
|
143
|
-
cd website && npm install && npm run dev # http://localhost:3000/openalgo-charts
|
|
144
|
-
```
|
|
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
|
-
|
|
156
|
-
## Develop
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
npm install # install dev toolchain
|
|
160
|
-
npm run typecheck # strict TypeScript check
|
|
161
|
-
npm test # unit tests (vitest) - 468 across 47 files
|
|
162
|
-
npm run build # Rollup -> dist/ (minified ESM per tier + types)
|
|
163
|
-
npm run size # size-limit (Brotli) against the budget
|
|
164
|
-
npm run e2e # Playwright Chromium smoke tests
|
|
165
|
-
npm run verify # typecheck + test + build + size
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
## Principles
|
|
169
|
-
|
|
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.
|
|
174
|
-
- **Apache-2.0**, original code.
|
|
175
|
-
|
|
176
|
-
## Status & limitations
|
|
177
|
-
|
|
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.
|
|
189
|
-
|
|
190
|
-
## License
|
|
191
|
-
|
|
192
|
-
[Apache-2.0](./LICENSE). See [`NOTICE`](./NOTICE).
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# OpenAlgo Charts
|
|
4
|
+
|
|
5
|
+
**A from-scratch, dependency-free HTML5-canvas charting engine for OpenAlgo.**
|
|
6
|
+
|
|
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
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/openalgo-charts)
|
|
10
|
+
[](./LICENSE)
|
|
11
|
+
[](#size-budget)
|
|
12
|
+
[](#develop)
|
|
13
|
+
[](#principles)
|
|
14
|
+
|
|
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)
|
|
16
|
+
|
|
17
|
+
<img src="docs/architecture-diagram.png" alt="OpenAlgo Charts - layered architecture from public API down to feeds and data, with loadable bundle tiers" width="920" />
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Live OpenAlgo trading terminal
|
|
24
|
+
|
|
25
|
+
Right-click the chart to place market / limit / stop orders, drag the order and TP/SL bracket lines to modify, and watch live P&L on the position line - all on real OpenAlgo history + WebSocket tick data, with an analyzer (sandbox) mode so nothing goes live until you arm it.
|
|
26
|
+
|
|
27
|
+
<p align="center">
|
|
28
|
+
<img src="docs/trading.png" alt="OpenAlgo Charts live trading terminal: RELIANCE 5m candles with order lines, a right-click order menu, a long position with live P&L, and volume" width="920" />
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
## Examples gallery
|
|
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, place a drawing. What you see is the code that ran.
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<img src="docs/demo1.png" alt="Chart-type switcher, custom themes, data tooltips, and event markers" width="49%" />
|
|
37
|
+
<img src="docs/demo2.png" alt="Range switcher, legend, series compare, and indicators and markers" width="49%" />
|
|
38
|
+
</p>
|
|
39
|
+
<p align="center">
|
|
40
|
+
<img src="docs/demo3.png" alt="More live OpenAlgo Charts examples" width="49%" />
|
|
41
|
+
<img src="docs/demo4.png" alt="More live OpenAlgo Charts examples" width="49%" />
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install openalgo-charts
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { createChart, generateBars } from 'openalgo-charts';
|
|
52
|
+
|
|
53
|
+
const chart = createChart(document.getElementById('chart'));
|
|
54
|
+
chart.addSeries('candlestick').setData(generateBars(1700000000, 200, 3600));
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Tiers
|
|
58
|
+
|
|
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` | 34 drawing tools + a headless drawing controller | 8.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**.
|
|
71
|
+
|
|
72
|
+
## What's built
|
|
73
|
+
|
|
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
|
+
34 tools. Lines: trend line, ray, extended line, arrow, horizontal line/ray, vertical line, cross line. Shapes: rectangle, ellipse, circle, triangle. Paths: polyline, arc, curve. Channels: parallel channel, fib channel. Fibonacci: retracement, extension, time zone, speed fan. Gann: fan, box. Forecasting: long/short position (with R:R and risk-based sizing), forecast. Measurers: price range, date range, measure. Arrows: mark up, mark down. Annotation: text, brush, highlighter.
|
|
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** |
|
|
132
|
+
|
|
133
|
+
## Documentation
|
|
134
|
+
|
|
135
|
+
Full docs, the interactive example gallery, and the generated API reference live at:
|
|
136
|
+
|
|
137
|
+
**https://marketcalls.github.io/openalgo-charts/**
|
|
138
|
+
|
|
139
|
+
The site is built with Nextra (in [`website/`](./website)) and statically exported to GitHub Pages on every push. Every code sample on a docs page is a *live* chart running the real library, so what you read is what runs. To run the site locally:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npm run build # build the library (dist/) the live demos import
|
|
143
|
+
cd website && npm install && npm run dev # http://localhost:3000/openalgo-charts
|
|
144
|
+
```
|
|
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
|
+
|
|
156
|
+
## Develop
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npm install # install dev toolchain
|
|
160
|
+
npm run typecheck # strict TypeScript check
|
|
161
|
+
npm test # unit tests (vitest) - 468 across 47 files
|
|
162
|
+
npm run build # Rollup -> dist/ (minified ESM per tier + types)
|
|
163
|
+
npm run size # size-limit (Brotli) against the budget
|
|
164
|
+
npm run e2e # Playwright Chromium smoke tests
|
|
165
|
+
npm run verify # typecheck + test + build + size
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Principles
|
|
169
|
+
|
|
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.
|
|
174
|
+
- **Apache-2.0**, original code.
|
|
175
|
+
|
|
176
|
+
## Status & limitations
|
|
177
|
+
|
|
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.
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
[Apache-2.0](./LICENSE). See [`NOTICE`](./NOTICE).
|
package/dist/draw/index.d.ts
CHANGED
|
@@ -503,7 +503,6 @@ declare const LONG_POSITION: DrawingTool;
|
|
|
503
503
|
declare const SHORT_POSITION: DrawingTool;
|
|
504
504
|
declare const TEXT: DrawingTool;
|
|
505
505
|
declare const PATH: DrawingTool;
|
|
506
|
-
/** Every built-in, in toolbar order. */
|
|
507
506
|
declare const BUILTIN_DRAWING_TOOLS: readonly DrawingTool[];
|
|
508
507
|
/** Register every built-in tool. Idempotent; called on tier import. */
|
|
509
508
|
declare function registerBuiltinDrawingTools(): void;
|
|
@@ -828,6 +827,8 @@ declare class Pane {
|
|
|
828
827
|
/** Remove a series record if present; returns true if it was found. */
|
|
829
828
|
removeSeries(record: SeriesRecord): boolean;
|
|
830
829
|
series(): readonly SeriesRecord[];
|
|
830
|
+
/** Primitives attached to this pane, in draw order. */
|
|
831
|
+
primitives(): readonly IPrimitive[];
|
|
831
832
|
addPrimitive(primitive: IPrimitive, host: PrimitiveHost): void;
|
|
832
833
|
/** Remove a primitive if present; returns true if it was found. */
|
|
833
834
|
removePrimitive(primitive: IPrimitive): boolean;
|
|
@@ -1408,6 +1409,53 @@ declare class EventMarkers implements IPrimitive {
|
|
|
1408
1409
|
hitTest(x: number, y: number): PrimitiveHit | null;
|
|
1409
1410
|
}
|
|
1410
1411
|
|
|
1412
|
+
/**
|
|
1413
|
+
* Time navigator (ARCHITECTURE.md §8) — the hover-revealed zoom / step controls
|
|
1414
|
+
* that sit just above the time axis: `−` `+` to zoom, `‹` `›` to step one bar.
|
|
1415
|
+
*
|
|
1416
|
+
* Invisible until the pointer nears the bottom of the chart, so a clean chart
|
|
1417
|
+
* stays clean. It fades in and out rather than snapping, which is what keeps it
|
|
1418
|
+
* from reading as a glitch when the cursor crosses the reveal band.
|
|
1419
|
+
*
|
|
1420
|
+
* Reveal is driven by an explicit `setPointer` from the chart, **not** by
|
|
1421
|
+
* `rc.hoverId`. Hover ids come from `bestHit`, which picks the nearest primitive
|
|
1422
|
+
* — so a drawing or an order line near the bottom of the chart would win the
|
|
1423
|
+
* hit and silently hide the controls. Pointer position is the honest input here;
|
|
1424
|
+
* hit-testing still owns the buttons themselves.
|
|
1425
|
+
*/
|
|
1426
|
+
|
|
1427
|
+
/** Command each button runs. These are `Chart` shortcut command ids. */
|
|
1428
|
+
type TimeNavigatorAction = 'zoomOut' | 'zoomIn' | 'panLeftBar' | 'panRightBar';
|
|
1429
|
+
interface TimeNavigatorOptions {
|
|
1430
|
+
/** Prefix for hit ids. Lets a host run more than one. */
|
|
1431
|
+
id: string;
|
|
1432
|
+
/** Buttons, left to right. A `null` inserts a gap between groups. */
|
|
1433
|
+
buttons: readonly (TimeNavigatorAction | null)[];
|
|
1434
|
+
/** Button box size in media px. */
|
|
1435
|
+
size: number;
|
|
1436
|
+
/** Gap between buttons, and the wider gap a `null` produces. */
|
|
1437
|
+
gap: number;
|
|
1438
|
+
groupGap: number;
|
|
1439
|
+
/** Distance from the bottom of the plot to the bottom of the buttons. */
|
|
1440
|
+
bottomMargin: number;
|
|
1441
|
+
/**
|
|
1442
|
+
* Height of the reveal band above the plot bottom. The pointer anywhere in
|
|
1443
|
+
* this band brings the controls in.
|
|
1444
|
+
*/
|
|
1445
|
+
revealHeight: number;
|
|
1446
|
+
/** Seconds the fade takes. 0 disables the animation. */
|
|
1447
|
+
fadeSeconds: number;
|
|
1448
|
+
/** Tooltip label per action. */
|
|
1449
|
+
labels: Record<TimeNavigatorAction, string>;
|
|
1450
|
+
/** Optional keyboard hint shown next to the label, e.g. `"Ctrl + −"`. */
|
|
1451
|
+
hints: Partial<Record<TimeNavigatorAction, string>>;
|
|
1452
|
+
/** Show the tooltip above the hovered button. */
|
|
1453
|
+
showTooltip: boolean;
|
|
1454
|
+
font: number;
|
|
1455
|
+
radius: number;
|
|
1456
|
+
zOrder: ZOrder;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1411
1459
|
/**
|
|
1412
1460
|
* Top-level chart orchestrator (ARCHITECTURE.md §3.3). Owns the shared
|
|
1413
1461
|
* DataLayer + time scale, the panes, the invalidate mask, and the render loop.
|
|
@@ -1468,6 +1516,12 @@ interface ChartOptions {
|
|
|
1468
1516
|
* `(s) => new Date(s * 1000).toISOString().slice(11, 16)`.
|
|
1469
1517
|
*/
|
|
1470
1518
|
timeFormatter?: (utcSeconds: number, tickMark?: TickMarkType) => string;
|
|
1519
|
+
/**
|
|
1520
|
+
* Hover-revealed zoom / step controls above the time axis (TradingView-style).
|
|
1521
|
+
* `true` by default — they stay invisible until the pointer nears the bottom
|
|
1522
|
+
* of the chart. Pass `false` to drop them, or an options object to restyle.
|
|
1523
|
+
*/
|
|
1524
|
+
timeNavigator?: boolean | Partial<TimeNavigatorOptions>;
|
|
1471
1525
|
}
|
|
1472
1526
|
interface AddSeriesOptions {
|
|
1473
1527
|
/** Target pane index (0 = price). Higher panes are created on demand. */
|
|
@@ -1603,6 +1657,9 @@ declare class Chart {
|
|
|
1603
1657
|
private _priceScaleOptions;
|
|
1604
1658
|
private _timeFormatter;
|
|
1605
1659
|
private _leftAxisWidth;
|
|
1660
|
+
private _timeNav;
|
|
1661
|
+
/** Pane the navigator is currently attached to, so it can follow the bottom. */
|
|
1662
|
+
private _timeNavPane;
|
|
1606
1663
|
constructor(container: HTMLElement, options?: ChartOptions);
|
|
1607
1664
|
/** Register a callback fired when the user pans near the left (oldest) edge. */
|
|
1608
1665
|
setHistoryLoader(loader: () => void): void;
|
|
@@ -1875,6 +1932,22 @@ declare class Chart {
|
|
|
1875
1932
|
private _handleLegendAction;
|
|
1876
1933
|
/** Cumulative top + height of each pane, by weight (the source of truth for hit-testing). */
|
|
1877
1934
|
private _paneLayout;
|
|
1935
|
+
/**
|
|
1936
|
+
* Keyboard hints for the navigator tooltips, read from the live keymap so a
|
|
1937
|
+
* rebind shows up in the tooltip instead of a stale hardcoded string. The
|
|
1938
|
+
* one-bar step buttons have no default binding, so they get no hint.
|
|
1939
|
+
*/
|
|
1940
|
+
private _navHints;
|
|
1941
|
+
/**
|
|
1942
|
+
* Keep the navigator on the bottom pane — it belongs just above the time
|
|
1943
|
+
* axis, and adding or removing a pane moves which one that is.
|
|
1944
|
+
*/
|
|
1945
|
+
private _syncTimeNavPane;
|
|
1946
|
+
/**
|
|
1947
|
+
* Push the pointer to the navigator and keep painting while it fades, so the
|
|
1948
|
+
* animation runs even when nothing else on the chart is changing.
|
|
1949
|
+
*/
|
|
1950
|
+
private _feedTimeNav;
|
|
1878
1951
|
private _renderContext;
|
|
1879
1952
|
private _observeSize;
|
|
1880
1953
|
private _onFrame;
|