@tony01/astroneum 0.4.1-beta.2 → 0.4.1-beta.24
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/CHANGELOG.md +280 -237
- package/LICENSE +21 -21
- package/README.md +250 -198
- package/dist/{Indicator-BBI3L_lx.d.ts → Indicator-BQQcVGGT.d.ts} +51 -227
- package/dist/astroneum.css +1 -1
- package/dist/chunk-47YGQEL5.js +399 -0
- package/dist/chunk-67XM5LOK.js +2 -0
- package/dist/{chunk-2YYGUSVX.js → chunk-DFJMDDL5.js} +1 -1
- package/dist/chunk-EFAS6F4C.js +59 -0
- package/dist/chunk-EHZN52CY.js +2 -0
- package/dist/chunk-HKLWNPMP.js +35 -0
- package/dist/chunk-ONPPQW65.js +2 -0
- package/dist/chunk-SCTHEM27.js +3 -0
- package/dist/chunk-UQXYMB6X.js +2 -0
- package/dist/chunk-WSIR5T2M.js +3 -0
- package/dist/entries/alerts.d.ts +36 -10
- package/dist/entries/alerts.js +1 -1
- package/dist/entries/datafeeds/crypto.d.ts +5 -1
- package/dist/entries/datafeeds/crypto.js +1 -1
- package/dist/entries/datafeeds/polygon.d.ts +3 -1
- package/dist/entries/datafeeds/polygon.js +1 -1
- package/dist/entries/headless.d.ts +78 -0
- package/dist/entries/headless.js +2 -0
- package/dist/entries/multichart.d.ts +12 -1
- package/dist/entries/multichart.js +1 -1
- package/dist/entries/replay.d.ts +3 -1
- package/dist/entries/script.d.ts +2 -68
- package/dist/entries/script.js +1 -1
- package/dist/entries/watchlist.d.ts +32 -2
- package/dist/entries/watchlist.js +1 -1
- package/dist/entries/workspace.d.ts +61 -0
- package/dist/entries/workspace.js +2 -0
- package/dist/index-BiXdqLA4.d.ts +45 -0
- package/dist/index-_JgHTy8X.d.ts +19 -0
- package/dist/index.d.ts +188 -27
- package/dist/index.js +1 -1
- package/dist/script-BU9StbN-.d.ts +120 -0
- package/dist/types-W6SIYQ9m.d.ts +232 -0
- package/dist/types-yETgeYsE.d.ts +28 -0
- package/dist/zh-CN-NDTUDZGZ.js +3 -0
- package/docs/MIRROR-PLAN-SYMBOL-SEARCH-WATCHLIST.md +255 -0
- package/docs/STRUCTURE.md +51 -37
- package/docs/TODO-DESIGN.md +111 -37
- package/docs/TODO.md +26 -16
- package/docs/WORKSTREAMS.md +55 -0
- package/docs/api.md +655 -528
- package/docs/datafeed-guide.md +329 -311
- package/docs/design-astroneum.md +204 -65
- package/docs/plugin-development.md +569 -565
- package/docs/tv-functions-skill.md +88 -64
- package/package.json +158 -147
- package/dist/chunk-4YOLQ5DC.js +0 -2
- package/dist/chunk-I4YQBP2M.js +0 -3
- package/dist/chunk-OOMZRONH.js +0 -35
- package/dist/chunk-PV2GAINM.js +0 -2
- package/dist/chunk-YW3STIPY.js +0 -653
- package/dist/zh-CN-Y2C6RSOI.js +0 -3
package/docs/api.md
CHANGED
|
@@ -1,528 +1,655 @@
|
|
|
1
|
-
# API Reference
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
-
|
|
254
|
-
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
---
|
|
302
|
-
|
|
303
|
-
## Exported
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
```typescript
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
## Strategy backtesting
|
|
4
|
+
|
|
5
|
+
`runBacktest(bars, signals, config)` is a deterministic, bar-close simulation
|
|
6
|
+
API. It returns `BacktestResult`, containing normalized trades, equity and
|
|
7
|
+
drawdown points, and summary metrics. It does not place orders, persist data,
|
|
8
|
+
or connect to brokers.
|
|
9
|
+
|
|
10
|
+
`ScriptEngine.compileStrategy(source)` is intentionally bounded: scripts define
|
|
11
|
+
`strategySignals({ open, high, low, close, volume, ta })` and return an array
|
|
12
|
+
of `{ index, action: 'enter' | 'exit', side?: 'long' | 'short' }`. Its runner
|
|
13
|
+
uses the same `runBacktest` core. It is not Pine-compatible `strategy.*`.
|
|
14
|
+
|
|
15
|
+
## Headless engine
|
|
16
|
+
|
|
17
|
+
The supported `@tony01/astroneum/headless` entry exposes the chart renderer
|
|
18
|
+
without React, native Astroneum UI, stylesheets, datafeeds, keyboard shortcuts,
|
|
19
|
+
or implicit network behavior.
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import {
|
|
23
|
+
asPrice,
|
|
24
|
+
asTimestamp,
|
|
25
|
+
createChart,
|
|
26
|
+
destroyChart,
|
|
27
|
+
registerBuiltInExtensions,
|
|
28
|
+
} from '@tony01/astroneum/headless'
|
|
29
|
+
|
|
30
|
+
registerBuiltInExtensions()
|
|
31
|
+
const chart = createChart(container, { timezone: 'UTC', styles: 'dark' })
|
|
32
|
+
|
|
33
|
+
chart.replaceBars([{
|
|
34
|
+
timestamp: asTimestamp(1_788_000_000_000),
|
|
35
|
+
open: asPrice(100),
|
|
36
|
+
high: asPrice(105),
|
|
37
|
+
low: asPrice(98),
|
|
38
|
+
close: asPrice(103),
|
|
39
|
+
}])
|
|
40
|
+
|
|
41
|
+
chart.updateBar({
|
|
42
|
+
timestamp: asTimestamp(1_788_000_060_000),
|
|
43
|
+
open: asPrice(103),
|
|
44
|
+
high: asPrice(106),
|
|
45
|
+
low: asPrice(102),
|
|
46
|
+
close: asPrice(104),
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
destroyChart(chart)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`createChart(container, options?)` owns one chart per supplied element. A second
|
|
53
|
+
call for the same element is idempotent and returns the existing instance;
|
|
54
|
+
options from the duplicate call are ignored. A container marked by another
|
|
55
|
+
Astroneum module instance fails visibly rather than mounting duplicate DOM.
|
|
56
|
+
`destroyChart(chartOrContainer)` is idempotent and releases all registry ownership.
|
|
57
|
+
|
|
58
|
+
`replaceBars(bars)` validates the full input before mutation and requires finite,
|
|
59
|
+
internally consistent OHLCV values with unique, strictly ascending safe-integer
|
|
60
|
+
UTC-millisecond timestamps. `updateBar(bar)` accepts only the current last
|
|
61
|
+
timestamp or a newer timestamp. Both methods copy accepted data, reject rather
|
|
62
|
+
than repair invalid input, and switch the chart to host-owned data by detaching
|
|
63
|
+
any explicitly configured engine loader. `getBars()` returns a copy.
|
|
64
|
+
|
|
65
|
+
`HeadlessChart` also exposes viewport, coordinate conversion, pane, indicator,
|
|
66
|
+
overlay, event, and resize primitives. `getViewportState()` returns the JSON-safe
|
|
67
|
+
version-1 shape `{ version, barSpace, rightOffsetBarCount }`.
|
|
68
|
+
`setViewportState()` accepts only version 1, finite bar spacing from 1 through 50,
|
|
69
|
+
and a finite right-offset bar count; the offset is clamped to the current bars and
|
|
70
|
+
container geometry. Apply recovery state after bars load. It is engine recovery
|
|
71
|
+
data, not semantic chart state.
|
|
72
|
+
|
|
73
|
+
Optional built-in indicators and drawings use process-wide registries and are
|
|
74
|
+
installed only after `registerBuiltInExtensions()` is called. The headless entry
|
|
75
|
+
also exports typed `registerIndicatorPlugin()` helpers plus raw
|
|
76
|
+
`registerIndicator()` and `registerOverlay()` primitives for host-owned outputs.
|
|
77
|
+
Browser coverage carries 16 study series and 16 overlay instances. Screenshot
|
|
78
|
+
export composites ordered Canvas2D and accelerated canvas layers; browser pixel
|
|
79
|
+
coverage verifies output dimensions and candle pixels from the accelerated layer.
|
|
80
|
+
|
|
81
|
+
`HEADLESS_CAPABILITIES` is the immutable version-1 runtime capability manifest.
|
|
82
|
+
The entry imports safely when browser globals are absent and does not require the
|
|
83
|
+
package stylesheet. Destroy cancels active chart animations, unsubscribes an
|
|
84
|
+
explicit loader, and rejects late loader callbacks before they mutate state.
|
|
85
|
+
|
|
86
|
+
## Constructor
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
<AstroneumChart ref={ref} {...options} />
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### `AstroneumOptions`
|
|
93
|
+
|
|
94
|
+
| Property | Type | Required | Default | Description |
|
|
95
|
+
|---|---|---|---|---|
|
|
96
|
+
| `symbol` | `SymbolInfo` | ✓ | — | Symbol to display on load |
|
|
97
|
+
| `period` | `Period` | ✓ | — | Initial timeframe |
|
|
98
|
+
| `datafeed` | `Datafeed` | ✓ | — | Data source implementation |
|
|
99
|
+
| `theme` | `'light' \| 'dark'` | | `getSystemTheme()` | UI theme. Omit to auto-detect OS color scheme. |
|
|
100
|
+
| `locale` | `string` | | `'en-US'` | UI locale key |
|
|
101
|
+
| `timezone` | `string` | | `'Asia/Shanghai'` | IANA timezone identifier for the X-axis |
|
|
102
|
+
| `watermark` | `string \| Node` | | Astroneum logo SVG | Watermark rendered in the chart center |
|
|
103
|
+
| `styles` | `DeepPartial<Styles>` | | `{}` | Deep-partial engine style override |
|
|
104
|
+
| `drawingBarVisible` | `boolean` | | `true` | Whether the left-side drawing toolbar is shown |
|
|
105
|
+
| `periods` | `Period[]` | | `[1m,5m,15m,1H,2H,4H,D,W,M,Y]` | Timeframes available in the period bar |
|
|
106
|
+
| `mainIndicators` | `IndicatorDef[]` | | `[{ name: 'EMA', calcParams: [7,25,99] }]` | Indicators overlaid on the main candle pane |
|
|
107
|
+
| `subIndicators` | `string[]` | | `['VOL']` | Indicator names rendered in sub-panes below the chart |
|
|
108
|
+
| `plugins` | `ChartPlugin[]` | | `[]` | Plugins mounted with chart lifecycle hooks (`onInit` / disposer) |
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Instance methods
|
|
113
|
+
|
|
114
|
+
### `setTheme(theme)`
|
|
115
|
+
```typescript
|
|
116
|
+
setTheme(theme: 'light' | 'dark'): void
|
|
117
|
+
```
|
|
118
|
+
Sets the UI theme. Updates both the `data-theme` attribute and the internal chart styles.
|
|
119
|
+
|
|
120
|
+
### `getTheme()`
|
|
121
|
+
```typescript
|
|
122
|
+
getTheme(): string
|
|
123
|
+
```
|
|
124
|
+
Returns the current theme name.
|
|
125
|
+
|
|
126
|
+
### `setStyles(styles)`
|
|
127
|
+
```typescript
|
|
128
|
+
setStyles(styles: DeepPartial<Styles>): void
|
|
129
|
+
```
|
|
130
|
+
Merges the given partial styles into the engine's current style tree.
|
|
131
|
+
|
|
132
|
+
### `getStyles()`
|
|
133
|
+
```typescript
|
|
134
|
+
getStyles(): Styles
|
|
135
|
+
```
|
|
136
|
+
Returns the full resolved engine style object.
|
|
137
|
+
|
|
138
|
+
### `setLocale(locale)`
|
|
139
|
+
```typescript
|
|
140
|
+
setLocale(locale: string): void
|
|
141
|
+
```
|
|
142
|
+
Switches the UI and engine locale. The locale key must have been registered with `loadLocales()` (for UI strings) and the engine's `registerLocale()` (for OHLC/indicator labels).
|
|
143
|
+
|
|
144
|
+
### `getLocale()`
|
|
145
|
+
```typescript
|
|
146
|
+
getLocale(): string
|
|
147
|
+
```
|
|
148
|
+
Returns the current locale key.
|
|
149
|
+
|
|
150
|
+
### `setTimezone(timezone)`
|
|
151
|
+
```typescript
|
|
152
|
+
setTimezone(timezone: string): void
|
|
153
|
+
```
|
|
154
|
+
Changes the IANA timezone used for the X-axis date labels.
|
|
155
|
+
|
|
156
|
+
### `getTimezone()`
|
|
157
|
+
```typescript
|
|
158
|
+
getTimezone(): string
|
|
159
|
+
```
|
|
160
|
+
Returns the current timezone.
|
|
161
|
+
|
|
162
|
+
### `setSymbol(symbol)`
|
|
163
|
+
```typescript
|
|
164
|
+
setSymbol(symbol: SymbolInfo): void
|
|
165
|
+
```
|
|
166
|
+
Loads a new symbol. Triggers a full data reload via the datafeed.
|
|
167
|
+
|
|
168
|
+
### `getSymbol()`
|
|
169
|
+
```typescript
|
|
170
|
+
getSymbol(): SymbolInfo
|
|
171
|
+
```
|
|
172
|
+
Returns the currently active `SymbolInfo`.
|
|
173
|
+
|
|
174
|
+
### `setPeriod(period)`
|
|
175
|
+
```typescript
|
|
176
|
+
setPeriod(period: Period): void
|
|
177
|
+
```
|
|
178
|
+
Switches the active timeframe. Triggers a full data reload.
|
|
179
|
+
|
|
180
|
+
### `getPeriod()`
|
|
181
|
+
```typescript
|
|
182
|
+
getPeriod(): Period
|
|
183
|
+
```
|
|
184
|
+
Returns the currently active `Period`.
|
|
185
|
+
|
|
186
|
+
### `serializeState()` / `loadState()`
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
serializeState(): SerializedChartState
|
|
190
|
+
loadState(state: SerializedChartState): void
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Capture and restore the chart's user-visible state — theme, locale,
|
|
194
|
+
timezone, symbol, period, styles, indicators, and drawing overlays —
|
|
195
|
+
as a JSON-safe object.
|
|
196
|
+
Indicator entries retain their calculation parameters, visibility, and styles.
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
// save
|
|
200
|
+
localStorage.setItem('chart-state', JSON.stringify(chartRef.current!.serializeState()))
|
|
201
|
+
|
|
202
|
+
// restore on mount
|
|
203
|
+
const saved = localStorage.getItem('chart-state')
|
|
204
|
+
if (saved) chartRef.current!.loadState(JSON.parse(saved))
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
`loadState()` is a best-effort restore: missing or unknown indicator /
|
|
208
|
+
overlay names are silently skipped (matching the engine's behaviour for
|
|
209
|
+
unregistered names). The `version` field lets the format evolve without
|
|
210
|
+
breaking older payloads; payloads from a newer format than the current
|
|
211
|
+
library understands are ignored.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Accessibility
|
|
216
|
+
|
|
217
|
+
`<AstroneumChart>` accepts an `accessible` prop (default `false`) that
|
|
218
|
+
opts the canvas into screen-reader and keyboard-focus support without
|
|
219
|
+
changing visuals:
|
|
220
|
+
|
|
221
|
+
- The container gets `tabindex=0`, `role="img"`, and an `aria-label`
|
|
222
|
+
(defaults to `"<ticker> <period text> chart"`; override via the
|
|
223
|
+
`ariaLabel` prop).
|
|
224
|
+
- A visually-hidden `aria-live="polite"` region announces OHLCV on
|
|
225
|
+
crosshair changes, throttled to ~10 updates / second to avoid
|
|
226
|
+
flooding screen-reader queues.
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
<AstroneumChart
|
|
230
|
+
symbol={{ ticker: 'BTC-USD' }}
|
|
231
|
+
period={{ multiplier: 1, timespan: 'minute', text: '1m' }}
|
|
232
|
+
datafeed={datafeed}
|
|
233
|
+
accessible
|
|
234
|
+
ariaLabel='Bitcoin / USD 1-minute candles'
|
|
235
|
+
/>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
For users who require a high-contrast UI, set `theme="high-contrast"`
|
|
239
|
+
(or call `setTheme('high-contrast')`). The bundled theme uses a
|
|
240
|
+
black background, white candles/grid, and yellow accents with strong
|
|
241
|
+
focus rings.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Lazy locales
|
|
246
|
+
|
|
247
|
+
Only `en-US` is bundled with the main entry. Load any other built-in
|
|
248
|
+
locale on demand:
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
import { loadLocale, BUILTIN_LOCALES } from '@tony01/astroneum'
|
|
252
|
+
|
|
253
|
+
await loadLocale('ja-JP')
|
|
254
|
+
chartRef.current?.setLocale('ja-JP')
|
|
255
|
+
|
|
256
|
+
console.log(BUILTIN_LOCALES) // ['en-US', 'zh-CN', 'ja-JP', ...]
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
`loadLocale(key)` resolves with the dictionary on success, or `null`
|
|
260
|
+
when `key` is not a built-in locale. Concurrent calls for the same
|
|
261
|
+
locale are de-duplicated. To register a fully custom locale,
|
|
262
|
+
keep using `loadLocales(key, dictionary)`.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Subpath entry points
|
|
267
|
+
|
|
268
|
+
Optional features are reachable through dedicated subpath imports so a
|
|
269
|
+
consumer can pull in just what they need.
|
|
270
|
+
|
|
271
|
+
| Subpath | Exports |
|
|
272
|
+
| --- | --- |
|
|
273
|
+
| `@tony01/astroneum/headless` | `createChart`, `destroyChart`, `registerBuiltInExtensions`, `HEADLESS_CAPABILITIES`, registration/query helpers, branded bar types, engine host types |
|
|
274
|
+
| `@tony01/astroneum/replay` | `BarReplay`, types `BarReplayOptions`, `BarReplayState` |
|
|
275
|
+
| `@tony01/astroneum/multichart` | `MultiChartLayout`, types `MultiChartCount`, `MultiChartSlot`, `MultiChartLayoutOptions` |
|
|
276
|
+
| `@tony01/astroneum/watchlist` | `WatchlistManager`, types `Watchlist`, `WatchSymbol`, `WatchlistColumn`, `WatchlistSort`, `WatchlistSortDirection` |
|
|
277
|
+
| `@tony01/astroneum/portfolio` | `PortfolioTracker`, types `Position`, `PositionSide`, `PnLResult` |
|
|
278
|
+
| `@tony01/astroneum/alerts` | `AlertManager`, full alert type surface |
|
|
279
|
+
| `@tony01/astroneum/script` | `ScriptEngine`, types `CompiledIndicator`, `StudyOptions`, `PlotOptions`, `InputOptions` |
|
|
280
|
+
| `@tony01/astroneum/datafeeds/polygon` | `DefaultDatafeed`, `WebSocketDatafeed`, `WebSocketDatafeedOptions` |
|
|
281
|
+
| `@tony01/astroneum/datafeeds/crypto` | `createStandardCryptoDatafeed`, `StandardCryptoDatafeed`, `STANDARD_CRYPTO_SYMBOLS`, `DATAFEED_ERROR_EVENT`, `BinanceAdapter`, `BitgetAdapter`, `OkxAdapter`, plus types |
|
|
282
|
+
|
|
283
|
+
All listed symbols also re-export from the root `@tony01/astroneum` entry today,
|
|
284
|
+
but the root re-exports for these modules will be removed in **v1.0**
|
|
285
|
+
(see the [Roadmap](../README.md#v10--stability)). Migrate to the subpath
|
|
286
|
+
import to be forward-compatible.
|
|
287
|
+
|
|
288
|
+
`MultiChartLayout` persists the grid, active pane, and complete serialized state
|
|
289
|
+
for each pane when given a `storageKey`; an explicit `count` takes precedence
|
|
290
|
+
over a stored grid size.
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
// recommended — forward-compatible with v1.0
|
|
294
|
+
import { BarReplay } from '@tony01/astroneum/replay'
|
|
295
|
+
import { createStandardCryptoDatafeed } from '@tony01/astroneum/datafeeds/crypto'
|
|
296
|
+
|
|
297
|
+
// legacy — works today, will be removed in v1.0
|
|
298
|
+
import { BarReplay, createStandardCryptoDatafeed } from '@tony01/astroneum'
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Exported utilities
|
|
304
|
+
|
|
305
|
+
### Brand cast helpers
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
import { asPrice, asVolume, asTimestamp } from '@tony01/astroneum'
|
|
309
|
+
|
|
310
|
+
const p: Price = asPrice(100.50)
|
|
311
|
+
const v: Volume = asVolume(1_250_000)
|
|
312
|
+
const t: Timestamp = asTimestamp(Date.now())
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
These are type-safe cast functions. They assert that a plain `number` belongs to a specific financial domain without any runtime overhead.
|
|
316
|
+
|
|
317
|
+
### `rafCoalesce`
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
import { rafCoalesce } from '@tony01/astroneum'
|
|
321
|
+
|
|
322
|
+
const dispatch = rafCoalesce((tick: CandleData) => chart.updateBar(tick))
|
|
323
|
+
webSocket.onmessage = e => dispatch(parse(e.data)) // safe to call 100×/s
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Returns a dispatcher that schedules `fn` on the next `requestAnimationFrame`, coalescing rapid calls so only the **last** value is delivered per frame. Use this when you only care about the latest state (e.g. price display). For financial accuracy across bursts, use `rafMergeTick` instead.
|
|
327
|
+
|
|
328
|
+
### `rafMergeTick`
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
import { rafMergeTick } from '@tony01/astroneum'
|
|
332
|
+
|
|
333
|
+
const cancel = rafMergeTick(incomingTick, (merged) => {
|
|
334
|
+
chart.updateBar(merged)
|
|
335
|
+
})
|
|
336
|
+
// Call cancel() to stop
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
OHLCV-aware frame coalescer for WebSocket burst handling. Merges all ticks arriving within the same `requestAnimationFrame` frame into one financially accurate bar:
|
|
340
|
+
- `open` = first tick
|
|
341
|
+
- `high` = max across ticks
|
|
342
|
+
- `low` = min across ticks
|
|
343
|
+
- `close` = last tick
|
|
344
|
+
- `volume` = sum across ticks
|
|
345
|
+
|
|
346
|
+
### `EventBus`
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
import { EventBus } from '@tony01/astroneum'
|
|
350
|
+
import type { ChartEventMap } from '@tony01/astroneum'
|
|
351
|
+
|
|
352
|
+
const bus = new EventBus<ChartEventMap>()
|
|
353
|
+
|
|
354
|
+
bus.on('tick', (candle) => console.log(candle.close))
|
|
355
|
+
bus.emit('tick', bar)
|
|
356
|
+
bus.off('tick', handler)
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
Zero-dependency, type-safe synchronous event bus.
|
|
360
|
+
|
|
361
|
+
### `TickAnimator`
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
import { TickAnimator } from '@tony01/astroneum'
|
|
365
|
+
import type { TickAnimatorOptions } from '@tony01/astroneum'
|
|
366
|
+
|
|
367
|
+
const opts: TickAnimatorOptions = { duration: 120 } // ms
|
|
368
|
+
const animator = new TickAnimator(opts, (frame) => {
|
|
369
|
+
chart.updateLastBar(frame)
|
|
370
|
+
})
|
|
371
|
+
|
|
372
|
+
animator.push(newTick)
|
|
373
|
+
animator.cancel()
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Smooth ease-out cubic interpolation of the last bar's `close`/`high`/`low` over `duration` ms (default 120 ms). Zero allocations in the rAF loop.
|
|
377
|
+
|
|
378
|
+
### `RingBuffer`
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
import { RingBuffer } from '@tony01/astroneum'
|
|
382
|
+
|
|
383
|
+
const buf = new RingBuffer<CandleData>(1000) // fixed capacity
|
|
384
|
+
buf.push(candle)
|
|
385
|
+
const arr = buf.toArray() // oldest → newest
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Fixed-capacity O(1) circular buffer designed for streaming time-series data.
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Exported types
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
import type {
|
|
396
|
+
// Core
|
|
397
|
+
AstroneumOptions,
|
|
398
|
+
AstroneumHandle,
|
|
399
|
+
SerializedChartState,
|
|
400
|
+
Datafeed,
|
|
401
|
+
SymbolInfo,
|
|
402
|
+
Period,
|
|
403
|
+
CandleData,
|
|
404
|
+
DatafeedSubscribeCallback,
|
|
405
|
+
QuoteSnapshot,
|
|
406
|
+
|
|
407
|
+
// Branded primitives
|
|
408
|
+
Price,
|
|
409
|
+
Volume,
|
|
410
|
+
Timestamp,
|
|
411
|
+
|
|
412
|
+
// Indicator
|
|
413
|
+
IndicatorDef,
|
|
414
|
+
IndicatorPlugin,
|
|
415
|
+
ChartPlugin,
|
|
416
|
+
ChartPluginContext,
|
|
417
|
+
|
|
418
|
+
// Events
|
|
419
|
+
ChartEventMap,
|
|
420
|
+
|
|
421
|
+
// Coordinate space
|
|
422
|
+
Viewport,
|
|
423
|
+
|
|
424
|
+
// Engine types
|
|
425
|
+
Styles,
|
|
426
|
+
DeepPartial,
|
|
427
|
+
Coordinate,
|
|
428
|
+
Bounding,
|
|
429
|
+
|
|
430
|
+
// Utility types
|
|
431
|
+
TickAnimatorOptions,
|
|
432
|
+
TimeframeText,
|
|
433
|
+
Timespan,
|
|
434
|
+
|
|
435
|
+
// MultiChartLayout
|
|
436
|
+
MultiChartCount,
|
|
437
|
+
MultiChartSlot,
|
|
438
|
+
MultiChartLayoutOptions,
|
|
439
|
+
|
|
440
|
+
// BarReplay
|
|
441
|
+
BarReplayOptions,
|
|
442
|
+
BarReplayState,
|
|
443
|
+
|
|
444
|
+
// Drawing templates
|
|
445
|
+
OverlayStylePreset,
|
|
446
|
+
DrawingStyleTemplate,
|
|
447
|
+
|
|
448
|
+
// AlertManager
|
|
449
|
+
Alert,
|
|
450
|
+
AlertCondition,
|
|
451
|
+
AlertStatus,
|
|
452
|
+
AlertFrequency,
|
|
453
|
+
AlertCreate,
|
|
454
|
+
AlertCheckInput,
|
|
455
|
+
AlertTriggeredCallback,
|
|
456
|
+
|
|
457
|
+
// Format helpers
|
|
458
|
+
FormatPriceOptions,
|
|
459
|
+
DateFormatStyle,
|
|
460
|
+
TimeFormatStyle,
|
|
461
|
+
|
|
462
|
+
// ScriptEngine
|
|
463
|
+
CompiledIndicator,
|
|
464
|
+
StudyOptions,
|
|
465
|
+
PlotOptions,
|
|
466
|
+
InputOptions,
|
|
467
|
+
|
|
468
|
+
// WatchlistManager
|
|
469
|
+
Watchlist,
|
|
470
|
+
WatchSymbol,
|
|
471
|
+
WatchlistColumn,
|
|
472
|
+
WatchlistSort,
|
|
473
|
+
WatchlistSortDirection,
|
|
474
|
+
|
|
475
|
+
// PortfolioTracker
|
|
476
|
+
Position,
|
|
477
|
+
PositionSide,
|
|
478
|
+
PnLResult,
|
|
479
|
+
|
|
480
|
+
// PerformanceMode
|
|
481
|
+
PerformanceBar,
|
|
482
|
+
} from '@tony01/astroneum'
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### `Datafeed.getQuotes` and `QuoteSnapshot`
|
|
486
|
+
|
|
487
|
+
`getQuotes` is optional. Watchlist consumers call it with resolved `SymbolInfo` records and keep displaying `—` when a datafeed does not provide snapshots.
|
|
488
|
+
|
|
489
|
+
```typescript
|
|
490
|
+
interface Datafeed {
|
|
491
|
+
getQuotes?(symbols: SymbolInfo[]): Promise<QuoteSnapshot[]>
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
interface QuoteSnapshot {
|
|
495
|
+
ticker: string
|
|
496
|
+
last: Price
|
|
497
|
+
change?: number
|
|
498
|
+
changePercent?: number
|
|
499
|
+
volume?: Volume
|
|
500
|
+
open?: Price
|
|
501
|
+
high?: Price
|
|
502
|
+
low?: Price
|
|
503
|
+
timestamp?: Timestamp
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
### `WatchlistManager`
|
|
508
|
+
|
|
509
|
+
List contents and configuration persist to `localStorage`. Quote fields are runtime-only and deliberately excluded from persistence.
|
|
510
|
+
|
|
511
|
+
```typescript
|
|
512
|
+
manager.addSymbolFromInfo(listId, symbol)
|
|
513
|
+
manager.moveSymbol(fromListId, toListId, ticker, toIndex?)
|
|
514
|
+
manager.setSort(listId, column, direction?)
|
|
515
|
+
manager.setColumns(listId, columns)
|
|
516
|
+
manager.setColor(listId, color)
|
|
517
|
+
manager.updateQuotes(snapshots)
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
### `IndicatorDef`
|
|
521
|
+
|
|
522
|
+
```typescript
|
|
523
|
+
interface IndicatorDef {
|
|
524
|
+
/** Registered indicator name, e.g. 'EMA', 'MA', 'RSI' */
|
|
525
|
+
name: string
|
|
526
|
+
/** Calculation parameters passed to the indicator engine */
|
|
527
|
+
calcParams?: number[]
|
|
528
|
+
}
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### `IndicatorPlugin<TOutput>`
|
|
532
|
+
|
|
533
|
+
```typescript
|
|
534
|
+
interface IndicatorPlugin<TOutput> {
|
|
535
|
+
name: string
|
|
536
|
+
shortName?: string
|
|
537
|
+
calcParams?: number[]
|
|
538
|
+
calc(data: CandleData[], params: number[]): TOutput[]
|
|
539
|
+
render2D?(ctx: CanvasRenderingContext2D, output: TOutput[], viewport: Viewport): void
|
|
540
|
+
renderGL?(gl: WebGL2RenderingContext, output: TOutput[], viewport: Viewport, vbo: WebGLBuffer): void
|
|
541
|
+
}
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
Implement this interface to register a custom typed indicator.
|
|
545
|
+
Use `render2D` for lightweight overlays (< 10k points) and `renderGL` for high-density or GPU-accelerated rendering.
|
|
546
|
+
When `renderGL` is present, Astroneum executes it on a dedicated WebGL2 layer and reuses a per-indicator `vbo`.
|
|
547
|
+
If WebGL2 is unavailable, `render2D` is used as fallback when available.
|
|
548
|
+
|
|
549
|
+
### `registerIndicatorPlugin(plugin)`
|
|
550
|
+
|
|
551
|
+
```typescript
|
|
552
|
+
registerIndicatorPlugin<TOutput>(plugin: IndicatorPlugin<TOutput>): void
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
Adapts `IndicatorPlugin` to the engine `IndicatorTemplate` format and registers it.
|
|
556
|
+
|
|
557
|
+
### `registerIndicatorPlugins(plugins)`
|
|
558
|
+
|
|
559
|
+
```typescript
|
|
560
|
+
registerIndicatorPlugins(plugins: IndicatorPlugin<unknown>[]): void
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
Batch helper for registering multiple indicator plugins.
|
|
564
|
+
|
|
565
|
+
### `createIndicatorTemplateFromPlugin(plugin)`
|
|
566
|
+
|
|
567
|
+
```typescript
|
|
568
|
+
createIndicatorTemplateFromPlugin<TOutput>(plugin: IndicatorPlugin<TOutput>): IndicatorTemplate
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
Returns the converted engine template without registering it. Useful when you want manual control over registration.
|
|
572
|
+
|
|
573
|
+
### `ChartPlugin`
|
|
574
|
+
|
|
575
|
+
```typescript
|
|
576
|
+
interface ChartPlugin {
|
|
577
|
+
name?: string
|
|
578
|
+
indicators?: IndicatorPlugin<unknown>[]
|
|
579
|
+
onInit?: (context: ChartPluginContext) => void | (() => void)
|
|
580
|
+
}
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
`indicators` are registered before chart indicator creation begins. `onInit` runs once after chart initialization and may return a disposer called during chart teardown.
|
|
584
|
+
|
|
585
|
+
### `ChartPluginContext`
|
|
586
|
+
|
|
587
|
+
```typescript
|
|
588
|
+
interface ChartPluginContext {
|
|
589
|
+
chart: Chart
|
|
590
|
+
registerIndicatorPlugin: (plugin: IndicatorPlugin<unknown>) => void
|
|
591
|
+
registerIndicatorPlugins: (plugins: IndicatorPlugin<unknown>[]) => void
|
|
592
|
+
}
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
### `ChartEventMap`
|
|
596
|
+
|
|
597
|
+
```typescript
|
|
598
|
+
interface ChartEventMap {
|
|
599
|
+
'symbol-change': SymbolInfo
|
|
600
|
+
'period-change': Period
|
|
601
|
+
'crosshair-move': Coordinate | null
|
|
602
|
+
'zoom': { scale: number; anchor: ZoomAnchor }
|
|
603
|
+
'data-load': { type: 'init' | 'forward' | 'backward'; count: number }
|
|
604
|
+
'tick': CandleData
|
|
605
|
+
'drawing-start': string
|
|
606
|
+
'drawing-end': string
|
|
607
|
+
'theme-change': string
|
|
608
|
+
}
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
### `Viewport`
|
|
612
|
+
|
|
613
|
+
```typescript
|
|
614
|
+
interface Viewport {
|
|
615
|
+
priceMin: Price
|
|
616
|
+
priceMax: Price
|
|
617
|
+
timeMin: Timestamp
|
|
618
|
+
timeMax: Timestamp
|
|
619
|
+
resolution: readonly [width: number, height: number]
|
|
620
|
+
}
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
Represents the currently visible region of the chart canvas. Used for coordinate-space transforms in custom `IndicatorPlugin` renderers.
|
|
624
|
+
|
|
625
|
+
---
|
|
626
|
+
|
|
627
|
+
## Additional exports
|
|
628
|
+
|
|
629
|
+
| Export | Description |
|
|
630
|
+
|---|---|
|
|
631
|
+
| `DefaultDatafeed` | Polygon.io REST + WebSocket datafeed |
|
|
632
|
+
| `MultiChartLayout` | Multi-chart layout manager |
|
|
633
|
+
| `BarReplay` | Historical bar replay engine |
|
|
634
|
+
| `DrawingTemplates` | Save/load drawing style templates |
|
|
635
|
+
| `AlertManager` | Price alert creation and monitoring |
|
|
636
|
+
| `ScriptEngine` | Pine-like indicator scripting sandbox (`compile()` auto-registers indicators) |
|
|
637
|
+
| `registerIndicator` | Register a raw engine `IndicatorTemplate` |
|
|
638
|
+
| `getSupportedIndicators` | List all registered indicator names |
|
|
639
|
+
| `registerOverlay` | Register a raw engine `OverlayTemplate` |
|
|
640
|
+
| `getSupportedOverlays` | List all registered overlay names |
|
|
641
|
+
| `registerXAxis` / `registerYAxis` | Register custom axis templates |
|
|
642
|
+
| `registerIndicatorPlugin` | Register a typed `IndicatorPlugin` via adapter |
|
|
643
|
+
| `registerIndicatorPlugins` | Batch register typed indicator plugins |
|
|
644
|
+
| `createIndicatorTemplateFromPlugin` | Convert `IndicatorPlugin` to engine template |
|
|
645
|
+
| `WatchlistManager` | Symbol watchlist with live prices |
|
|
646
|
+
| `PortfolioTracker` | Position tracking and P&L calculation |
|
|
647
|
+
| `PerformanceMode` | Reduced-render performance optimization |
|
|
648
|
+
| `loadLocales` | Register UI locale strings |
|
|
649
|
+
| `formatPrice` | Format a price number using symbol precision |
|
|
650
|
+
| `formatVolume` | Format a volume number |
|
|
651
|
+
| `formatPercent` | Format a percentage value |
|
|
652
|
+
| `formatDate` / `formatTime` / `formatDateTime` | Date/time formatting helpers |
|
|
653
|
+
| `formatDuration` | Format a duration in milliseconds as human-readable text |
|
|
654
|
+
| `formatPeriod` | Format a `Period` as a human-readable string (e.g. `'1H'`) |
|
|
655
|
+
| `detectPricePrecision` | Auto-detect decimal precision from price data |
|