@tony01/astroneum 0.4.1-beta.2

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +237 -0
  2. package/LICENSE +21 -0
  3. package/README.md +198 -0
  4. package/dist/Indicator-BBI3L_lx.d.ts +1181 -0
  5. package/dist/ar-SA-AEPUSRMF.js +2 -0
  6. package/dist/astroneum.css +1 -0
  7. package/dist/chunk-2SN3RH42.js +2 -0
  8. package/dist/chunk-2YYGUSVX.js +3 -0
  9. package/dist/chunk-3GJSZFLM.js +2 -0
  10. package/dist/chunk-4YOLQ5DC.js +2 -0
  11. package/dist/chunk-I4YQBP2M.js +3 -0
  12. package/dist/chunk-OOMZRONH.js +35 -0
  13. package/dist/chunk-PV2GAINM.js +2 -0
  14. package/dist/chunk-SDXH2WAI.js +3 -0
  15. package/dist/chunk-YFPXTHZX.js +2 -0
  16. package/dist/chunk-YW3STIPY.js +653 -0
  17. package/dist/de-DE-4PR3NRQ7.js +2 -0
  18. package/dist/entries/alerts.d.ts +93 -0
  19. package/dist/entries/alerts.js +2 -0
  20. package/dist/entries/datafeeds/crypto.d.ts +65 -0
  21. package/dist/entries/datafeeds/crypto.js +2 -0
  22. package/dist/entries/datafeeds/polygon.d.ts +113 -0
  23. package/dist/entries/datafeeds/polygon.js +2 -0
  24. package/dist/entries/multichart.d.ts +96 -0
  25. package/dist/entries/multichart.js +2 -0
  26. package/dist/entries/portfolio.d.ts +55 -0
  27. package/dist/entries/portfolio.js +2 -0
  28. package/dist/entries/replay.d.ts +141 -0
  29. package/dist/entries/replay.js +2 -0
  30. package/dist/entries/script.d.ts +68 -0
  31. package/dist/entries/script.js +2 -0
  32. package/dist/entries/watchlist.d.ts +43 -0
  33. package/dist/entries/watchlist.js +2 -0
  34. package/dist/es-ES-HNDVPSLW.js +2 -0
  35. package/dist/fr-FR-Y7XWRGF2.js +2 -0
  36. package/dist/hi-IN-KEGIKIMV.js +2 -0
  37. package/dist/id-ID-QXDIUQUZ.js +2 -0
  38. package/dist/index.d.ts +1434 -0
  39. package/dist/index.js +2 -0
  40. package/dist/it-IT-UDTDFSRB.js +2 -0
  41. package/dist/ja-JP-NIODTBW3.js +2 -0
  42. package/dist/ko-KR-DQHPXKBA.js +2 -0
  43. package/dist/nl-NL-BB3ZHCXS.js +2 -0
  44. package/dist/pl-PL-I5MZDLFD.js +2 -0
  45. package/dist/pt-BR-MAMRTOYR.js +2 -0
  46. package/dist/ru-RU-F43D6B7G.js +2 -0
  47. package/dist/th-TH-KTFIUAD6.js +2 -0
  48. package/dist/tr-TR-WFTKJ22Y.js +2 -0
  49. package/dist/vi-VN-CD3WI2FQ.js +2 -0
  50. package/dist/zh-CN-Y2C6RSOI.js +3 -0
  51. package/docs/STRUCTURE.md +231 -0
  52. package/docs/TODO-DESIGN.md +261 -0
  53. package/docs/TODO.md +222 -0
  54. package/docs/api.md +528 -0
  55. package/docs/datafeed-guide.md +311 -0
  56. package/docs/design-astroneum.md +479 -0
  57. package/docs/plugin-development.md +565 -0
  58. package/docs/tv-functions-skill.md +706 -0
  59. package/package.json +147 -0
@@ -0,0 +1,1181 @@
1
+ import react__default from 'react';
2
+
3
+ type Nullable<T> = T | null;
4
+
5
+ interface NeighborData<D> {
6
+ prev: D;
7
+ current: D;
8
+ next: D;
9
+ }
10
+ type Timestamp$1 = number;
11
+ interface CandleData {
12
+ timestamp: Timestamp$1;
13
+ open: number;
14
+ high: number;
15
+ low: number;
16
+ close: number;
17
+ volume?: number;
18
+ turnover?: number;
19
+ [key: string]: unknown;
20
+ }
21
+
22
+ interface Margin {
23
+ marginLeft: number;
24
+ marginTop: number;
25
+ marginRight: number;
26
+ marginBottom: number;
27
+ }
28
+ interface Padding {
29
+ paddingLeft: number;
30
+ paddingTop: number;
31
+ paddingRight: number;
32
+ paddingBottom: number;
33
+ }
34
+ interface Offset {
35
+ offsetLeft: number;
36
+ offsetTop: number;
37
+ offsetRight: number;
38
+ offsetBottom: number;
39
+ }
40
+ /**
41
+ * line type
42
+ */
43
+ type LineType = 'dashed' | 'solid';
44
+ interface LineStyle {
45
+ style: LineType;
46
+ size: number;
47
+ color: string;
48
+ dashedValue: number[];
49
+ }
50
+ interface SmoothLineStyle extends LineStyle {
51
+ smooth: boolean | number;
52
+ show?: boolean;
53
+ }
54
+ interface StateLineStyle extends LineStyle {
55
+ show: boolean;
56
+ }
57
+ type PathType = 'stroke' | 'fill';
58
+ interface PathStyle {
59
+ style: PathType;
60
+ color: string;
61
+ lineWidth: number;
62
+ }
63
+ type PolygonType = PathType | 'stroke_fill';
64
+ interface PolygonStyle {
65
+ style: PolygonType;
66
+ color: string | CanvasGradient;
67
+ borderColor: string;
68
+ borderSize: number;
69
+ borderStyle: LineType;
70
+ borderDashedValue: number[];
71
+ }
72
+ interface RectStyle extends PolygonStyle {
73
+ borderRadius: number | number[];
74
+ }
75
+ interface TextStyle extends Padding {
76
+ style: PolygonType;
77
+ color: string;
78
+ size: number;
79
+ family: string;
80
+ weight: number | string;
81
+ borderStyle: LineType;
82
+ borderDashedValue: number[];
83
+ borderSize: number;
84
+ borderColor: string;
85
+ borderRadius: number | number[];
86
+ backgroundColor: string | CanvasGradient;
87
+ }
88
+ interface StateTextStyle extends TextStyle {
89
+ show: boolean;
90
+ }
91
+ type LastValueMarkTextStyle = Omit<StateTextStyle, 'backgroundColor'>;
92
+ type TooltipShowRule = 'always' | 'follow_cross' | 'none';
93
+ type TooltipShowType = 'standard' | 'rect';
94
+ interface ChangeColor {
95
+ upColor: string;
96
+ downColor: string;
97
+ noChangeColor: string;
98
+ }
99
+ interface GradientColor {
100
+ offset: number;
101
+ color: string;
102
+ }
103
+ type FeatureType = 'path' | 'icon_font';
104
+ interface FeaturePathStyle extends Omit<PathStyle, 'color'> {
105
+ path: string;
106
+ }
107
+ interface FeatureIconFontStyle {
108
+ family: string;
109
+ code: string;
110
+ }
111
+ interface FeatureStyle extends Padding, Margin {
112
+ id: string;
113
+ backgroundColor: string;
114
+ activeBackgroundColor: string;
115
+ size: number;
116
+ color: string;
117
+ activeColor: string;
118
+ borderRadius: number | number[];
119
+ type: FeatureType;
120
+ content: FeaturePathStyle | FeatureIconFontStyle;
121
+ }
122
+ interface GridStyle {
123
+ show: boolean;
124
+ horizontal: StateLineStyle;
125
+ vertical: StateLineStyle;
126
+ }
127
+ type TooltipTextStyle = Pick<TextStyle, 'color' | 'size' | 'family' | 'weight'> & Margin;
128
+ type TooltipTitleStyle = TooltipTextStyle & {
129
+ show: boolean;
130
+ };
131
+ type TooltipLegendStyle = TooltipTextStyle & {
132
+ defaultValue: string;
133
+ };
134
+ interface TooltipLegendChild {
135
+ text: string;
136
+ color: string;
137
+ }
138
+ interface TooltipLegend {
139
+ title: string | TooltipLegendChild;
140
+ value: string | TooltipLegendChild;
141
+ }
142
+ type TooltipFeaturePosition = 'left' | 'middle' | 'right';
143
+ interface TooltipFeatureStyle extends FeatureStyle {
144
+ position: TooltipFeaturePosition;
145
+ }
146
+ interface TooltipStyle extends Offset {
147
+ showRule: TooltipShowRule;
148
+ showType: TooltipShowType;
149
+ features: TooltipFeatureStyle[];
150
+ }
151
+ interface CandleAreaPointStyle {
152
+ show: boolean;
153
+ color: string;
154
+ radius: number;
155
+ rippleColor: string;
156
+ rippleRadius: number;
157
+ animation: boolean;
158
+ animationDuration: number;
159
+ }
160
+ interface CandleAreaStyle {
161
+ lineSize: number;
162
+ lineColor: string;
163
+ value: string;
164
+ smooth: boolean;
165
+ backgroundColor: string | GradientColor[];
166
+ point: CandleAreaPointStyle;
167
+ }
168
+ interface CandleHighLowPriceMarkStyle {
169
+ show: boolean;
170
+ color: string;
171
+ textOffset: number;
172
+ textSize: number;
173
+ textFamily: string;
174
+ textWeight: string;
175
+ }
176
+ type CandleLastPriceMarkLineStyle = Omit<StateLineStyle, 'color'>;
177
+ type CandleLastPriceMarkExtendTextPosition = 'above_price' | 'below_price';
178
+ type CandleLastPriceMarkExtendTextStyle = LastValueMarkTextStyle & {
179
+ position: CandleLastPriceMarkExtendTextPosition;
180
+ updateInterval: number;
181
+ };
182
+ interface CandleLastPriceMarkStyle extends ChangeColor {
183
+ show: boolean;
184
+ compareRule: CandleColorCompareRule;
185
+ line: CandleLastPriceMarkLineStyle;
186
+ text: LastValueMarkTextStyle;
187
+ extendTexts: CandleLastPriceMarkExtendTextStyle[];
188
+ }
189
+ interface CandlePriceMarkStyle {
190
+ show: boolean;
191
+ high: CandleHighLowPriceMarkStyle;
192
+ low: CandleHighLowPriceMarkStyle;
193
+ last: CandleLastPriceMarkStyle;
194
+ }
195
+ type CandleTooltipRectPosition = 'fixed' | 'pointer';
196
+ interface CandleTooltipRectStyle extends Omit<RectStyle, 'style' | 'borderDashedValue' | 'borderStyle'>, Padding, Offset {
197
+ position: CandleTooltipRectPosition;
198
+ }
199
+ type CandleTooltipLegendsCustomCallback = (data: NeighborData<Nullable<CandleData>>, styles: CandleStyle) => TooltipLegend[];
200
+ interface CandleTooltipStyle extends TooltipStyle {
201
+ title: TooltipTitleStyle & {
202
+ template: string;
203
+ };
204
+ legend: TooltipLegendStyle & {
205
+ template: CandleTooltipLegendsCustomCallback | TooltipLegend[];
206
+ };
207
+ rect: CandleTooltipRectStyle;
208
+ }
209
+ type CandleType = 'candle_solid' | 'candle_stroke' | 'candle_up_stroke' | 'candle_down_stroke' | 'ohlc' | 'area';
210
+ type CandleColorCompareRule = 'current_open' | 'previous_close';
211
+ interface CandleBarColor extends ChangeColor {
212
+ compareRule: CandleColorCompareRule;
213
+ upBorderColor: string;
214
+ downBorderColor: string;
215
+ noChangeBorderColor: string;
216
+ upWickColor: string;
217
+ downWickColor: string;
218
+ noChangeWickColor: string;
219
+ }
220
+ interface CandleStyle {
221
+ type: CandleType;
222
+ bar: CandleBarColor;
223
+ area: CandleAreaStyle;
224
+ priceMark: CandlePriceMarkStyle;
225
+ tooltip: CandleTooltipStyle;
226
+ }
227
+ type IndicatorPolygonStyle = Omit<PolygonStyle, 'color' | 'borderColor'> & ChangeColor;
228
+ interface IndicatorLastValueMarkStyle {
229
+ show: boolean;
230
+ text: LastValueMarkTextStyle;
231
+ }
232
+ interface IndicatorTooltipStyle extends TooltipStyle {
233
+ title: TooltipTitleStyle & {
234
+ showName: boolean;
235
+ showParams: boolean;
236
+ };
237
+ legend: TooltipLegendStyle;
238
+ }
239
+ interface IndicatorStyle {
240
+ ohlc: Pick<CandleBarColor, 'compareRule' | 'upColor' | 'downColor' | 'noChangeColor'>;
241
+ bars: IndicatorPolygonStyle[];
242
+ lines: SmoothLineStyle[];
243
+ circles: IndicatorPolygonStyle[];
244
+ lastValueMark: IndicatorLastValueMarkStyle;
245
+ tooltip: IndicatorTooltipStyle;
246
+ [key: string]: unknown;
247
+ }
248
+ type AxisLineStyle = Omit<StateLineStyle, 'style' | 'dashedValue'>;
249
+ interface AxisTickLineStyle extends AxisLineStyle {
250
+ length: number;
251
+ }
252
+ interface AxisTickTextStyle extends Pick<StateTextStyle, 'show' | 'color' | 'weight' | 'family' | 'size'> {
253
+ marginStart: number;
254
+ marginEnd: number;
255
+ }
256
+ interface AxisStyle {
257
+ show: boolean;
258
+ size: number | 'auto';
259
+ axisLine: AxisLineStyle;
260
+ tickLine: AxisTickLineStyle;
261
+ tickText: AxisTickTextStyle;
262
+ }
263
+ interface CrosshairDirectionStyle {
264
+ show: boolean;
265
+ line: StateLineStyle;
266
+ text: StateTextStyle;
267
+ }
268
+ interface CrosshairStyle {
269
+ show: boolean;
270
+ horizontal: CrosshairDirectionStyle & {
271
+ features: TooltipFeatureStyle[];
272
+ };
273
+ vertical: CrosshairDirectionStyle;
274
+ }
275
+ interface OverlayPointStyle {
276
+ color: string;
277
+ borderColor: string;
278
+ borderSize: number;
279
+ radius: number;
280
+ activeColor: string;
281
+ activeBorderColor: string;
282
+ activeBorderSize: number;
283
+ activeRadius: number;
284
+ }
285
+ interface OverlayStyle {
286
+ point: OverlayPointStyle;
287
+ line: SmoothLineStyle;
288
+ rect: RectStyle;
289
+ polygon: PolygonStyle;
290
+ circle: PolygonStyle;
291
+ arc: LineStyle;
292
+ text: TextStyle;
293
+ [key: string]: unknown;
294
+ }
295
+ interface SeparatorStyle {
296
+ size: number;
297
+ color: string;
298
+ fill: boolean;
299
+ activeBackgroundColor: string;
300
+ }
301
+ interface Styles {
302
+ grid: GridStyle;
303
+ candle: CandleStyle;
304
+ indicator: IndicatorStyle;
305
+ xAxis: AxisStyle;
306
+ yAxis: AxisStyle;
307
+ separator: SeparatorStyle;
308
+ crosshair: CrosshairStyle;
309
+ overlay: OverlayStyle;
310
+ }
311
+
312
+ type Price = number & {
313
+ readonly _brand: 'Price';
314
+ };
315
+ type Volume = number & {
316
+ readonly _brand: 'Volume';
317
+ };
318
+ type Timestamp = number & {
319
+ readonly _brand: 'Timestamp';
320
+ };
321
+ interface IndicatorDef {
322
+ name: string;
323
+ calcParams?: number[];
324
+ }
325
+ /** Canonical timespan identifiers — aligned with engine PeriodType */
326
+ type Timespan = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
327
+ interface SymbolInfo {
328
+ ticker: string;
329
+ name?: string;
330
+ shortName?: string;
331
+ exchange?: string;
332
+ market?: string;
333
+ pricePrecision?: number;
334
+ volumePrecision?: number;
335
+ priceCurrency?: string;
336
+ type?: string;
337
+ logo?: string;
338
+ [key: string]: unknown;
339
+ }
340
+ interface Period {
341
+ multiplier: number;
342
+ /** Canonical timespan — maps directly to engine PeriodType */
343
+ timespan: Timespan;
344
+ text: string;
345
+ }
346
+ type DatafeedSubscribeCallback = (data: CandleData) => void;
347
+ interface Datafeed {
348
+ searchSymbols(search?: string): Promise<SymbolInfo[]>;
349
+ getHistoryData(symbol: SymbolInfo, period: Period, from: number, to: number): Promise<CandleData[]>;
350
+ subscribe(symbol: SymbolInfo, period: Period, callback: DatafeedSubscribeCallback): void;
351
+ unsubscribe(symbol: SymbolInfo, period: Period): void;
352
+ }
353
+ interface AstroneumOptions {
354
+ styles?: DeepPartial<Styles>;
355
+ watermark?: string | Node;
356
+ theme?: string;
357
+ locale?: string;
358
+ drawingBarVisible?: boolean;
359
+ symbol: SymbolInfo;
360
+ period: Period;
361
+ periods?: Period[];
362
+ timezone?: string;
363
+ mainIndicators?: IndicatorDef[];
364
+ subIndicators?: string[];
365
+ plugins?: ChartPlugin[];
366
+ datafeed: Datafeed;
367
+ /** Inline styles applied to the root `.astroneum` container element. */
368
+ style?: react__default.CSSProperties;
369
+ /** Additional class names applied to the root `.astroneum` container element. */
370
+ className?: string;
371
+ /**
372
+ * Make the chart canvas focusable + emit an `aria-live` summary of the
373
+ * crosshair OHLCV. Off by default to avoid surprising existing apps.
374
+ * When `true`, the chart container gets `tabindex=0`, `role="img"`,
375
+ * and an `aria-label` describing the current symbol. Cursor moves
376
+ * announce OHLCV through a visually-hidden polite live region.
377
+ */
378
+ accessible?: boolean;
379
+ /**
380
+ * Optional ARIA label override for the chart canvas. Only used when
381
+ * `accessible` is true. Defaults to a string built from the symbol
382
+ * ticker and current period.
383
+ */
384
+ ariaLabel?: string;
385
+ /**
386
+ * Bar rendering style. Defaults to 'candle' (standard candlesticks).
387
+ * 'heikin_ashi' transforms OHLC data with the Heikin-Ashi formula
388
+ * before rendering — no datafeed changes required.
389
+ */
390
+ barStyle?: 'candle' | 'heikin_ashi';
391
+ /**
392
+ * Price axis scale mode. Defaults to 'linear' (absolute price).
393
+ * 'log' uses logarithmic scale (useful for long-term charts).
394
+ * 'percent' shows percentage change from the first visible bar.
395
+ */
396
+ priceScale?: 'linear' | 'log' | 'percent';
397
+ initialHistory?: 'all' | 'none';
398
+ }
399
+ /**
400
+ * Serialised chart state — drawings, indicators, and the user-facing
401
+ * surface settings (theme, locale, timezone, symbol, period, styles).
402
+ *
403
+ * The shape is intentionally simple JSON so it can be persisted to
404
+ * `localStorage`, a URL, or a backend. The `version` field lets the
405
+ * library evolve the format without breaking older payloads.
406
+ */
407
+ interface SerializedChartState {
408
+ version: 1;
409
+ theme: string;
410
+ locale: string;
411
+ timezone: string;
412
+ symbol: SymbolInfo;
413
+ period: Period;
414
+ styles: DeepPartial<Styles>;
415
+ mainIndicators: IndicatorDef[];
416
+ subIndicators: string[];
417
+ overlays: Array<{
418
+ name: string;
419
+ points?: ReadonlyArray<{
420
+ timestamp?: number;
421
+ value?: number;
422
+ dataIndex?: number;
423
+ }>;
424
+ styles?: unknown;
425
+ lock?: boolean;
426
+ visible?: boolean;
427
+ }>;
428
+ }
429
+ interface AstroneumHandle {
430
+ setTheme(theme: string): void;
431
+ getTheme(): string;
432
+ setStyles(styles: DeepPartial<Styles>): void;
433
+ getStyles(): Styles;
434
+ setLocale(locale: string): void;
435
+ getLocale(): string;
436
+ setTimezone(timezone: string): void;
437
+ getTimezone(): string;
438
+ setSymbol(symbol: SymbolInfo): void;
439
+ getSymbol(): SymbolInfo;
440
+ setPeriod(period: Period): void;
441
+ getPeriod(): Period;
442
+ getDataListLength(): number;
443
+ getLastDataTimestamp(): number | null;
444
+ /**
445
+ * Capture the chart's current user-visible state as a JSON-safe object.
446
+ * Includes theme, locale, timezone, symbol, period, styles, indicators,
447
+ * and drawing overlays. Pair with `loadState()` to restore.
448
+ */
449
+ serializeState(): SerializedChartState;
450
+ /**
451
+ * Restore a previously-captured state. Best-effort: missing or unknown
452
+ * indicator / overlay names are silently skipped, matching the engine's
453
+ * behaviour for unregistered names.
454
+ */
455
+ loadState(state: SerializedChartState): void;
456
+ /**
457
+ * Subscribe to crosshair moves. Returns an unsubscribe function.
458
+ * Callback receives the crosshair data (or null when it leaves the chart).
459
+ * Returns a Coordinate-like object with the timestamp + price at cursor.
460
+ */
461
+ onCrosshairMove(callback: (data: unknown) => void): () => void;
462
+ /**
463
+ * Programmatically set the crosshair position on this chart.
464
+ * Used internally by MultiChartLayout for crosshair sync.
465
+ */
466
+ setCrosshair(data: unknown): void;
467
+ /** Lock or unlock ALL drawing overlays at once. */
468
+ lockAllDrawings(locked: boolean): void;
469
+ createIndicator(value: string | IndicatorCreate, isStack?: boolean, paneOptions?: PaneOptions): Nullable<string>;
470
+ removeIndicator(filter?: IndicatorFilter): boolean;
471
+ createOverlay(value: string | OverlayCreate | Array<string | OverlayCreate>): Nullable<string> | Array<Nullable<string>>;
472
+ removeOverlay(filter?: OverlayFilter): boolean;
473
+ getDataList(): CandleData[];
474
+ resetData(): void;
475
+ resize(): void;
476
+ }
477
+ interface Viewport {
478
+ /** Minimum (bottom) visible price in canvas coordinates. */
479
+ priceMin: Price;
480
+ /** Maximum (top) visible price in canvas coordinates. */
481
+ priceMax: Price;
482
+ /** Earliest visible candle timestamp (ms). */
483
+ timeMin: Timestamp;
484
+ /** Latest visible candle timestamp (ms). */
485
+ timeMax: Timestamp;
486
+ /** Physical canvas resolution [width, height] in device pixels. */
487
+ resolution: readonly [width: number, height: number];
488
+ }
489
+ interface IndicatorPlugin<TOutput> {
490
+ /** Unique registry name — used as the indicator identifier in the engine. */
491
+ name: string;
492
+ /** Short display name shown in the chart legend. */
493
+ shortName?: string;
494
+ /** Default calculation parameters (can be overridden by the user). */
495
+ calcParams?: number[];
496
+ /**
497
+ * Pure calculation function. Must NOT mutate `data`.
498
+ * Called on every data update; keep it fast (O(n) or better).
499
+ */
500
+ calc(data: CandleData[], params: number[]): TOutput[];
501
+ /** Canvas 2D renderer — for lightweight overlays and small datasets. */
502
+ render2D?(ctx: CanvasRenderingContext2D, output: TOutput[], viewport: Viewport): void;
503
+ /**
504
+ * WebGL2 renderer — for high-density or GPU-accelerated rendering.
505
+ * Astroneum reuses a stable per-indicator vbo and falls back to render2D when WebGL2 is unavailable.
506
+ */
507
+ renderGL?(gl: WebGL2RenderingContext, output: TOutput[], viewport: Viewport, vbo: WebGLBuffer): void;
508
+ }
509
+ interface ChartPluginContext {
510
+ /** The chart instance mounted by Astroneum. */
511
+ chart: Chart;
512
+ /** Register a typed indicator plugin at runtime. */
513
+ registerIndicatorPlugin: (plugin: IndicatorPlugin<unknown>) => void;
514
+ /** Batch register typed indicator plugins at runtime. */
515
+ registerIndicatorPlugins: (plugins: ReadonlyArray<IndicatorPlugin<unknown>>) => void;
516
+ }
517
+ interface ChartPlugin {
518
+ /** Optional plugin label for diagnostics and debugging. */
519
+ name?: string;
520
+ /** Indicator plugins to register before this chart starts creating indicators. */
521
+ indicators?: ReadonlyArray<IndicatorPlugin<unknown>>;
522
+ /** Optional lifecycle hook called once after the chart is initialized. */
523
+ onInit?: (context: ChartPluginContext) => void | (() => void);
524
+ }
525
+ interface ChartEventMap {
526
+ /** Fired when the active symbol changes. */
527
+ 'symbol-change': SymbolInfo;
528
+ /** Fired when the active period / timeframe changes. */
529
+ 'period-change': Period;
530
+ /** Fired on every crosshair move; null when the crosshair leaves the chart. */
531
+ 'crosshair-move': Coordinate | null;
532
+ /** Fired when the user zooms the chart. */
533
+ 'zoom': {
534
+ scale: number;
535
+ anchor: ZoomAnchor;
536
+ };
537
+ /** Fired when a historical data batch is loaded. */
538
+ 'data-load': {
539
+ type: 'init' | 'forward' | 'backward';
540
+ count: number;
541
+ };
542
+ /** Fired when a real-time tick arrives from the datafeed subscription. */
543
+ 'tick': CandleData;
544
+ /** Fired when the user starts drawing an overlay (value = overlay type name). */
545
+ 'drawing-start': string;
546
+ /** Fired when the user finishes drawing (value = overlay id). */
547
+ 'drawing-end': string;
548
+ /** Fired when the active theme changes (value = theme name). */
549
+ 'theme-change': string;
550
+ }
551
+
552
+ type DataLoadType = 'init' | 'forward' | 'backward' | 'update';
553
+ type DataLoadMore = boolean | {
554
+ backward?: boolean;
555
+ forward?: boolean;
556
+ };
557
+ interface DataLoaderGetBarsParams {
558
+ type: DataLoadType;
559
+ timestamp: Nullable<number>;
560
+ symbol: SymbolInfo;
561
+ period: Period;
562
+ callback: (data: CandleData[], more?: DataLoadMore) => void;
563
+ }
564
+ interface DataLoaderSubscribeBarParams {
565
+ symbol: SymbolInfo;
566
+ period: Period;
567
+ callback: (data: CandleData) => void;
568
+ }
569
+ type DataLoaderUnsubscribeBarParams = Omit<DataLoaderSubscribeBarParams, 'callback'>;
570
+ interface DataLoader {
571
+ getBars: (params: DataLoaderGetBarsParams) => void | Promise<void>;
572
+ subscribeBar?: (params: DataLoaderSubscribeBarParams) => void;
573
+ unsubscribeBar?: (params: DataLoaderUnsubscribeBarParams) => void;
574
+ }
575
+
576
+ type DeepPartial<T> = {
577
+ [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer X> ? ReadonlyArray<DeepPartial<X>> : T[P] extends object ? DeepPartial<T[P]> : T[P];
578
+ };
579
+
580
+ interface Coordinate {
581
+ x: number;
582
+ y: number;
583
+ }
584
+
585
+ interface Bounding {
586
+ width: number;
587
+ height: number;
588
+ left: number;
589
+ right: number;
590
+ top: number;
591
+ bottom: number;
592
+ }
593
+
594
+ type ActionCallback = (data?: unknown) => void;
595
+ type ActionType = 'onZoom' | 'onScroll' | 'onVisibleRangeChange' | 'onCandleTooltipFeatureClick' | 'onIndicatorTooltipFeatureClick' | 'onCrosshairFeatureClick' | 'onCrosshairChange' | 'onCandleBarClick' | 'onPaneDrag';
596
+
597
+ type PickRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
598
+
599
+ type ExcludePickPartial<T, K extends keyof T> = PickRequired<Partial<T>, K>;
600
+
601
+ interface BarSpace {
602
+ bar: number;
603
+ halfBar: number;
604
+ gapBar: number;
605
+ halfGapBar: number;
606
+ }
607
+
608
+ interface Crosshair extends Partial<Coordinate> {
609
+ paneId?: string;
610
+ realX?: number;
611
+ timestamp?: number;
612
+ candleData?: CandleData;
613
+ dataIndex?: number;
614
+ realDataIndex?: number;
615
+ }
616
+
617
+ interface VisibleRange {
618
+ readonly from: number;
619
+ readonly to: number;
620
+ readonly realFrom: number;
621
+ readonly realTo: number;
622
+ }
623
+
624
+ /**
625
+ * This file uses most of the logic of lightweight-charts/mouse-event-handler.ts(https://github.com/tradingview/lightweight-charts) for reference.
626
+ * Makes some modifications to add some events.
627
+ * The use of the source code of this file is also subject to the terms
628
+ * and consitions of the license of "lightweight-charts" (Apache License V2, see
629
+ * </licenses/LICENSE-lightweight-charts>).
630
+ */
631
+
632
+ interface MouseTouchEvent extends Coordinate {
633
+ pageX: number;
634
+ pageY: number;
635
+ isTouch?: boolean;
636
+ preventDefault?: () => void;
637
+ }
638
+
639
+ type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
640
+
641
+ interface Point {
642
+ dataIndex: number;
643
+ timestamp: number;
644
+ value: number;
645
+ }
646
+
647
+ type PaneState = 'normal' | 'maximize' | 'minimize';
648
+ interface PaneOptions {
649
+ id?: string;
650
+ height?: number;
651
+ minHeight?: number;
652
+ dragEnabled?: boolean;
653
+ order?: number;
654
+ state?: PaneState;
655
+ axis?: Partial<AxisCreate>;
656
+ }
657
+
658
+ type FormatDateType = 'tooltip' | 'crosshair' | 'xAxis';
659
+ interface FormatDateParams {
660
+ dateTimeFormat: Intl.DateTimeFormat;
661
+ timestamp: number;
662
+ template: string;
663
+ type: FormatDateType;
664
+ }
665
+ type FormatDate = (params: FormatDateParams) => string;
666
+ type FormatBigNumber = (value: string | number) => string;
667
+ type ExtendTextType = 'last_price';
668
+ interface FormatExtendTextParams {
669
+ type: ExtendTextType;
670
+ data: CandleData;
671
+ index: number;
672
+ }
673
+ type FormatExtendText = (params: FormatExtendTextParams) => string;
674
+ interface Formatter {
675
+ formatDate: FormatDate;
676
+ formatBigNumber: FormatBigNumber;
677
+ formatExtendText: FormatExtendText;
678
+ }
679
+ interface DecimalFold {
680
+ threshold: number;
681
+ format: (value: string | number) => string;
682
+ }
683
+ interface ThousandsSeparator {
684
+ sign: string;
685
+ format: (value: string | number) => string;
686
+ }
687
+ type ZoomAnchorType = 'cursor' | 'last_bar';
688
+ interface ZoomAnchor {
689
+ main: ZoomAnchorType;
690
+ xAxis: ZoomAnchorType;
691
+ }
692
+
693
+ interface YAxisTemplate extends AxisTemplate {
694
+ /**
695
+ * Y-axis scale smoothing time in seconds.
696
+ * Larger value = longer/softer scaling, smaller value = shorter/tighter scaling.
697
+ */
698
+ scaleSmoothTime?: number;
699
+ /**
700
+ * MT4-style scale stabilization deadband in pixels.
701
+ * Tiny auto-range shifts under this threshold are ignored.
702
+ */
703
+ scaleDeadbandPx?: number;
704
+ /**
705
+ * Portion of under-deadband movement that still passes through.
706
+ * 0 = fully hold (step-like), 1 = no hold.
707
+ */
708
+ scaleDeadbandLeak?: number;
709
+ }
710
+ interface YAxis extends Axis, Required<YAxisTemplate> {
711
+ isFromZero: () => boolean;
712
+ isInCandle: () => boolean;
713
+ convertToNicePixel: (value: number) => number;
714
+ getDisplayRange: () => {
715
+ realFrom: number;
716
+ realTo: number;
717
+ };
718
+ }
719
+
720
+ type OverlayMode = 'normal' | 'weak_magnet' | 'strong_magnet';
721
+ interface OverlayPerformEventParams {
722
+ currentStep: number;
723
+ mode: OverlayMode;
724
+ points: Array<Partial<Point>>;
725
+ performPointIndex: number;
726
+ performPoint: Partial<Point>;
727
+ }
728
+ interface OverlayEventCollection<E> {
729
+ onDrawStart: Nullable<OverlayEventCallback<E>>;
730
+ onDrawing: Nullable<OverlayEventCallback<E>>;
731
+ onDrawEnd: Nullable<OverlayEventCallback<E>>;
732
+ onRemoved: Nullable<OverlayEventCallback<E>>;
733
+ onClick: Nullable<OverlayEventCallback<E>>;
734
+ onDoubleClick: Nullable<OverlayEventCallback<E>>;
735
+ onRightClick: Nullable<OverlayEventCallback<E>>;
736
+ onPressedMoveStart: Nullable<OverlayEventCallback<E>>;
737
+ onPressedMoving: Nullable<OverlayEventCallback<E>>;
738
+ onPressedMoveEnd: Nullable<OverlayEventCallback<E>>;
739
+ onMouseMove: Nullable<OverlayEventCallback<E>>;
740
+ onMouseEnter: Nullable<OverlayEventCallback<E>>;
741
+ onMouseLeave: Nullable<OverlayEventCallback<E>>;
742
+ onSelected: Nullable<OverlayEventCallback<E>>;
743
+ onDeselected: Nullable<OverlayEventCallback<E>>;
744
+ }
745
+ interface OverlayFigure {
746
+ key?: string;
747
+ type: string;
748
+ attrs: unknown;
749
+ styles?: unknown;
750
+ ignoreEvent?: boolean | Array<keyof Omit<OverlayEventCollection<unknown>, 'onDrawStart' | 'onDrawing' | 'onDrawEnd' | 'onRemoved'>>;
751
+ }
752
+ interface OverlayCreateFiguresCallbackParams<E> {
753
+ chart: Chart;
754
+ overlay: Overlay<E>;
755
+ coordinates: Coordinate[];
756
+ bounding: Bounding;
757
+ xAxis: Nullable<XAxis>;
758
+ yAxis: Nullable<YAxis>;
759
+ }
760
+ interface OverlayEvent<E> extends Partial<MouseTouchEvent> {
761
+ figure?: OverlayFigure;
762
+ overlay: Overlay<E>;
763
+ chart: Chart;
764
+ }
765
+ type OverlayEventCallback<E> = (event: OverlayEvent<E>) => void;
766
+ type OverlayCreateFiguresCallback<E> = (params: OverlayCreateFiguresCallbackParams<E>) => OverlayFigure | OverlayFigure[];
767
+ interface Overlay<E = unknown> extends OverlayEventCollection<E> {
768
+ /**
769
+ * Unique identification
770
+ */
771
+ id: string;
772
+ /**
773
+ * Group id
774
+ */
775
+ groupId: string;
776
+ /**
777
+ * Pane id
778
+ */
779
+ paneId: string;
780
+ /**
781
+ * Name
782
+ */
783
+ name: string;
784
+ /**
785
+ * Total number of steps required to complete mouse operation
786
+ */
787
+ totalStep: number;
788
+ /**
789
+ * Current step
790
+ */
791
+ currentStep: number;
792
+ /**
793
+ * Whether it is locked. When it is true, it will not respond to events
794
+ */
795
+ lock: boolean;
796
+ /**
797
+ * Whether the overlay is visible
798
+ */
799
+ visible: boolean;
800
+ /**
801
+ * Draw level
802
+ */
803
+ zLevel: number;
804
+ /**
805
+ * Whether the default figure corresponding to the point is required
806
+ */
807
+ needDefaultPointFigure: boolean;
808
+ /**
809
+ * Whether the default figure on the Y axis is required
810
+ */
811
+ needDefaultXAxisFigure: boolean;
812
+ /**
813
+ * Whether the default figure on the X axis is required
814
+ */
815
+ needDefaultYAxisFigure: boolean;
816
+ /**
817
+ * Mode
818
+ */
819
+ mode: OverlayMode;
820
+ /**
821
+ * When mode is weak_magnet is the response distance
822
+ */
823
+ modeSensitivity: number;
824
+ /**
825
+ * Time and value information
826
+ */
827
+ points: Array<Partial<Point>>;
828
+ /**
829
+ * Extended Data
830
+ */
831
+ extendData: E;
832
+ /**
833
+ * The style information and format are consistent with the overlay in the unified configuration
834
+ */
835
+ styles: Nullable<DeepPartial<OverlayStyle>>;
836
+ /**
837
+ * Create figures corresponding to points
838
+ */
839
+ createPointFigures: Nullable<OverlayCreateFiguresCallback<E>>;
840
+ /**
841
+ * Create figures on the Y axis
842
+ */
843
+ createXAxisFigures: Nullable<OverlayCreateFiguresCallback<E>>;
844
+ /**
845
+ * Create figures on the X axis
846
+ */
847
+ createYAxisFigures: Nullable<OverlayCreateFiguresCallback<E>>;
848
+ /**
849
+ * Special handling callbacks when pressing events
850
+ */
851
+ performEventPressedMove: Nullable<(params: OverlayPerformEventParams) => void>;
852
+ /**
853
+ * In drawing, special handling callback when moving events
854
+ */
855
+ performEventMoveForDrawing: Nullable<(params: OverlayPerformEventParams) => void>;
856
+ }
857
+ type OverlayTemplate<E = unknown> = ExcludePickPartial<Omit<Overlay<E>, 'id' | 'groupId' | 'paneId' | 'points' | 'currentStep'>, 'name'>;
858
+ type OverlayCreate<E = unknown> = ExcludePickPartial<Omit<Overlay<E>, 'currentStep' | 'totalStep' | 'createPointFigures' | 'createXAxisFigures' | 'createYAxisFigures' | 'performEventPressedMove' | 'performEventMoveForDrawing'>, 'name'>;
859
+ type OverlayFilter<E = unknown> = Partial<Pick<Overlay<E>, 'id' | 'groupId' | 'name' | 'paneId'>>;
860
+
861
+ interface Store {
862
+ setStyles: (value: string | DeepPartial<Styles>) => void;
863
+ getStyles: () => Styles;
864
+ setFormatter: (formatter: Partial<Formatter>) => void;
865
+ getFormatter: () => Formatter;
866
+ setLocale: (locale: string) => void;
867
+ getLocale: () => string;
868
+ setTimezone: (timezone: string) => void;
869
+ getTimezone: () => string;
870
+ setThousandsSeparator: (thousandsSeparator: Partial<ThousandsSeparator>) => void;
871
+ getThousandsSeparator: () => ThousandsSeparator;
872
+ setDecimalFold: (decimalFold: Partial<DecimalFold>) => void;
873
+ getDecimalFold: () => DecimalFold;
874
+ setSymbol: (symbol: PickPartial<SymbolInfo, 'pricePrecision' | 'volumePrecision'>) => void;
875
+ getSymbol: () => Nullable<SymbolInfo>;
876
+ setPeriod: (period: Period) => void;
877
+ getPeriod: () => Nullable<Period>;
878
+ getDataList: () => CandleData[];
879
+ setOffsetRightDistance: (distance: number) => void;
880
+ getOffsetRightDistance: () => number;
881
+ setMaxOffsetLeftDistance: (distance: number) => void;
882
+ setMaxOffsetRightDistance: (distance: number) => void;
883
+ setLeftMinVisibleBarCount: (barCount: number) => void;
884
+ setRightMinVisibleBarCount: (barCount: number) => void;
885
+ setBarSpace: (space: number) => void;
886
+ getBarSpace: () => BarSpace;
887
+ getVisibleRange: () => VisibleRange;
888
+ setDataLoader: (dataLoader: DataLoader) => void;
889
+ overrideIndicator: (override: IndicatorCreate) => boolean;
890
+ removeIndicator: (filter?: IndicatorFilter) => boolean;
891
+ overrideOverlay: (override: Partial<OverlayCreate>) => boolean;
892
+ removeOverlay: (filter?: OverlayFilter) => boolean;
893
+ setZoomEnabled: (enabled: boolean) => void;
894
+ isZoomEnabled: () => boolean;
895
+ setZoomAnchor: (behavior: ZoomAnchor) => void;
896
+ getZoomAnchor: () => ZoomAnchor;
897
+ setScrollEnabled: (enabled: boolean) => void;
898
+ isScrollEnabled: () => boolean;
899
+ resetData: () => void;
900
+ }
901
+
902
+ type DomPosition = 'root' | 'main' | 'yAxis';
903
+ interface ConvertFilter {
904
+ paneId?: string;
905
+ absolute?: boolean;
906
+ }
907
+ interface Chart extends Store {
908
+ id: string;
909
+ getDom: (paneId?: string, position?: DomPosition) => Nullable<HTMLElement>;
910
+ getSize: (paneId?: string, position?: DomPosition) => Nullable<Bounding>;
911
+ createIndicator: (value: string | IndicatorCreate, isStack?: boolean, paneOptions?: PaneOptions) => Nullable<string>;
912
+ getIndicators: (filter?: IndicatorFilter) => Indicator[];
913
+ createOverlay: (value: string | OverlayCreate | Array<string | OverlayCreate>) => Nullable<string> | Array<Nullable<string>>;
914
+ getOverlays: (filter?: OverlayFilter) => Overlay[];
915
+ setPaneOptions: (options: PaneOptions) => void;
916
+ getPaneOptions: (id?: string) => Nullable<PaneOptions> | PaneOptions[];
917
+ scrollByDistance: (distance: number, animationDuration?: number) => void;
918
+ scrollToRealTime: (animationDuration?: number) => void;
919
+ scrollToDataIndex: (dataIndex: number, animationDuration?: number) => void;
920
+ scrollToTimestamp: (timestamp: number, animationDuration?: number) => void;
921
+ zoomAtCoordinate: (scale: number, coordinate?: Coordinate, animationDuration?: number) => void;
922
+ zoomAtDataIndex: (scale: number, dataIndex: number, animationDuration?: number) => void;
923
+ zoomAtTimestamp: (scale: number, timestamp: number, animationDuration?: number) => void;
924
+ convertToPixel: (points: Partial<Point> | Array<Partial<Point>>, filter?: ConvertFilter) => Partial<Coordinate> | Array<Partial<Coordinate>>;
925
+ convertFromPixel: (coordinates: Array<Partial<Coordinate>>, filter?: ConvertFilter) => Partial<Point> | Array<Partial<Point>>;
926
+ executeAction: (type: ActionType, data: Crosshair) => void;
927
+ subscribeAction: (type: ActionType, callback: ActionCallback) => void;
928
+ unsubscribeAction: (type: ActionType, callback?: ActionCallback) => void;
929
+ getConvertPictureUrl: (includeOverlay?: boolean, type?: 'png' | 'jpeg' | 'bmp', backgroundColor?: string) => string;
930
+ resize: () => void;
931
+ }
932
+
933
+ interface AxisTick {
934
+ coord: number;
935
+ value: number | string;
936
+ text: string;
937
+ }
938
+ interface AxisRange extends VisibleRange {
939
+ readonly range: number;
940
+ readonly realRange: number;
941
+ readonly displayFrom: number;
942
+ readonly displayTo: number;
943
+ readonly displayRange: number;
944
+ }
945
+ interface AxisGap {
946
+ top?: number;
947
+ bottom?: number;
948
+ }
949
+ type AxisPosition = 'left' | 'right';
950
+ interface AxisValueToValueParams {
951
+ range: AxisRange;
952
+ }
953
+ type AxisValueToValueCallback = (value: number, params: AxisValueToValueParams) => number;
954
+ interface AxisCreateRangeParams {
955
+ chart: Chart;
956
+ paneId: string;
957
+ defaultRange: AxisRange;
958
+ }
959
+ type AxisCreateRangeCallback = (params: AxisCreateRangeParams) => AxisRange;
960
+ interface AxisCreateTicksParams {
961
+ range: AxisRange;
962
+ bounding: Bounding;
963
+ defaultTicks: AxisTick[];
964
+ }
965
+ type AxisCreateTicksCallback = (params: AxisCreateTicksParams) => AxisTick[];
966
+ type AxisMinSpanCallback = (value: number) => number;
967
+ interface AxisTemplate {
968
+ name: string;
969
+ reverse?: boolean;
970
+ inside?: boolean;
971
+ position?: AxisPosition;
972
+ scrollZoomEnabled?: boolean;
973
+ gap?: AxisGap;
974
+ valueToRealValue?: AxisValueToValueCallback;
975
+ realValueToDisplayValue?: AxisValueToValueCallback;
976
+ displayValueToRealValue?: AxisValueToValueCallback;
977
+ realValueToValue?: AxisValueToValueCallback;
978
+ displayValueToText?: (value: number, precision: number) => string;
979
+ minSpan?: AxisMinSpanCallback;
980
+ createRange?: AxisCreateRangeCallback;
981
+ createTicks?: AxisCreateTicksCallback;
982
+ }
983
+ interface Axis {
984
+ override: (axis: AxisTemplate) => void;
985
+ getTicks: () => AxisTick[];
986
+ getRange: () => AxisRange;
987
+ getAutoSize: () => number;
988
+ convertToPixel: (value: number) => number;
989
+ convertFromPixel: (px: number) => number;
990
+ }
991
+ type AxisCreate = Omit<AxisTemplate, 'displayValueToText' | 'valueToRealValue' | 'realValueToDisplayValue' | 'displayValueToRealValue' | 'realValueToValue'>;
992
+
993
+ type XAxisTemplate = Pick<AxisTemplate, 'name' | 'scrollZoomEnabled' | 'createTicks'>;
994
+ interface XAxis extends Axis, Required<XAxisTemplate> {
995
+ convertTimestampFromPixel: (pixel: number) => Nullable<number>;
996
+ convertTimestampToPixel: (timestamp: number) => number;
997
+ }
998
+
999
+ interface CircleAttrs {
1000
+ x: number;
1001
+ y: number;
1002
+ r: number;
1003
+ }
1004
+
1005
+ interface ArcAttrs extends CircleAttrs {
1006
+ startAngle: number;
1007
+ endAngle: number;
1008
+ }
1009
+
1010
+ interface RectAttrs {
1011
+ x: number;
1012
+ y: number;
1013
+ width: number;
1014
+ height: number;
1015
+ }
1016
+
1017
+ interface TextAttrs {
1018
+ x: number;
1019
+ y: number;
1020
+ text: string;
1021
+ width?: number;
1022
+ height?: number;
1023
+ align?: CanvasTextAlign;
1024
+ baseline?: CanvasTextBaseline;
1025
+ }
1026
+
1027
+ type IndicatorSeries = 'normal' | 'price' | 'volume';
1028
+ type IndicatorFigureStyle = Partial<Omit<SmoothLineStyle, 'style'>> & Partial<Omit<RectStyle, 'style'>> & Partial<TextStyle> & Partial<{
1029
+ style: LineType[keyof LineType];
1030
+ }> & Record<string, unknown>;
1031
+ type IndicatorFigureAttrs = Partial<ArcAttrs> & Partial<LineStyle> & Partial<RectAttrs> & Partial<TextAttrs> & Record<string, unknown>;
1032
+ interface IndicatorFigureAttrsCallbackParams<D> {
1033
+ data: NeighborData<Nullable<D>>;
1034
+ coordinate: NeighborData<Record<keyof D, number> & {
1035
+ x: number;
1036
+ }>;
1037
+ bounding: Bounding;
1038
+ barSpace: BarSpace;
1039
+ xAxis: XAxis;
1040
+ yAxis: YAxis;
1041
+ }
1042
+ interface IndicatorFigureStylesCallbackParams<D> {
1043
+ data: NeighborData<Nullable<D>>;
1044
+ indicator: Indicator<D>;
1045
+ defaultStyles?: IndicatorStyle;
1046
+ }
1047
+ type IndicatorFigureAttrsCallback<D> = (params: IndicatorFigureAttrsCallbackParams<D>) => IndicatorFigureAttrs;
1048
+ type IndicatorFigureStylesCallback<D> = (params: IndicatorFigureStylesCallbackParams<D>) => IndicatorFigureStyle;
1049
+ interface IndicatorFigure<D = unknown> {
1050
+ key: string;
1051
+ title?: string;
1052
+ type?: string;
1053
+ baseValue?: number;
1054
+ attrs?: IndicatorFigureAttrsCallback<D>;
1055
+ styles?: IndicatorFigureStylesCallback<D>;
1056
+ }
1057
+ type IndicatorRegenerateFiguresCallback<D, C> = (calcParams: C[]) => Array<IndicatorFigure<D>>;
1058
+ interface IndicatorTooltipData {
1059
+ name: string;
1060
+ calcParamsText: string;
1061
+ features: TooltipFeatureStyle[];
1062
+ legends: TooltipLegend[];
1063
+ }
1064
+ interface IndicatorCreateTooltipDataSourceParams<D> {
1065
+ chart: Chart;
1066
+ indicator: Indicator<D>;
1067
+ bounding: Bounding;
1068
+ crosshair: Crosshair;
1069
+ xAxis: XAxis;
1070
+ yAxis: YAxis;
1071
+ }
1072
+ type IndicatorCreateTooltipDataSourceCallback<D> = (params: IndicatorCreateTooltipDataSourceParams<D>) => Partial<IndicatorTooltipData>;
1073
+ interface IndicatorDrawParams<D, C, E> {
1074
+ ctx: CanvasRenderingContext2D;
1075
+ chart: Chart;
1076
+ indicator: Indicator<D, C, E>;
1077
+ bounding: Bounding;
1078
+ xAxis: XAxis;
1079
+ yAxis: YAxis;
1080
+ }
1081
+ type IndicatorDrawCallback<D, C, E> = (params: IndicatorDrawParams<D, C, E>) => boolean;
1082
+ type IndicatorCalcCallback<D, C, E> = (dataList: CandleData[], indicator: Indicator<D, C, E>) => Promise<D[]> | D[];
1083
+ type IndicatorShouldUpdateCallback<D, C, E> = (prev: Indicator<D, C, E>, current: Indicator<D, C, E>) => (boolean | {
1084
+ calc: boolean;
1085
+ draw: boolean;
1086
+ });
1087
+ interface Indicator<D = unknown, C = unknown, E = unknown> {
1088
+ /**
1089
+ * Unique id
1090
+ */
1091
+ id: string;
1092
+ /**
1093
+ * Pane id
1094
+ */
1095
+ paneId: string;
1096
+ /**
1097
+ * Indicator name
1098
+ */
1099
+ name: string;
1100
+ /**
1101
+ * Short name, for display
1102
+ */
1103
+ shortName: string;
1104
+ /**
1105
+ * Precision
1106
+ */
1107
+ precision: number;
1108
+ /**
1109
+ * Calculation parameters
1110
+ */
1111
+ calcParams: C[];
1112
+ /**
1113
+ * Whether ohlc column is required
1114
+ */
1115
+ shouldOhlc: boolean;
1116
+ /**
1117
+ * Whether large data values need to be formatted, starting from 1000, for example, whether 100000 needs to be formatted with 100K
1118
+ */
1119
+ shouldFormatBigNumber: boolean;
1120
+ /**
1121
+ * Whether the indicator is visible
1122
+ */
1123
+ visible: boolean;
1124
+ /**
1125
+ * Z index
1126
+ */
1127
+ zLevel: number;
1128
+ /**
1129
+ * Extend data
1130
+ */
1131
+ extendData: E;
1132
+ /**
1133
+ * Indicator series
1134
+ */
1135
+ series: IndicatorSeries;
1136
+ /**
1137
+ * Figure configuration information
1138
+ */
1139
+ figures: Array<IndicatorFigure<D>>;
1140
+ /**
1141
+ * Specified minimum value
1142
+ */
1143
+ minValue: Nullable<number>;
1144
+ /**
1145
+ * Specified maximum value
1146
+ */
1147
+ maxValue: Nullable<number>;
1148
+ /**
1149
+ * Style configuration
1150
+ */
1151
+ styles: Nullable<DeepPartial<IndicatorStyle>>;
1152
+ /**
1153
+ * Should update, should calc or draw
1154
+ */
1155
+ shouldUpdate: Nullable<IndicatorShouldUpdateCallback<D, C, E>>;
1156
+ /**
1157
+ * Indicator calculation
1158
+ */
1159
+ calc: IndicatorCalcCallback<D, C, E>;
1160
+ /**
1161
+ * Regenerate figure configuration
1162
+ */
1163
+ regenerateFigures: Nullable<IndicatorRegenerateFiguresCallback<D, C>>;
1164
+ /**
1165
+ * Create custom tooltip text
1166
+ */
1167
+ createTooltipDataSource: Nullable<IndicatorCreateTooltipDataSourceCallback<D>>;
1168
+ /**
1169
+ * Custom draw
1170
+ */
1171
+ draw: Nullable<IndicatorDrawCallback<D, C, E>>;
1172
+ /**
1173
+ * Calculation result
1174
+ */
1175
+ result: D[];
1176
+ }
1177
+ type IndicatorTemplate<D = unknown, C = unknown, E = unknown> = ExcludePickPartial<Omit<Indicator<D, C, E>, 'result' | 'paneId'>, 'name' | 'calc'>;
1178
+ type IndicatorCreate<D = unknown, C = unknown, E = unknown> = ExcludePickPartial<Omit<Indicator<D, C, E>, 'result'>, 'name'>;
1179
+ type IndicatorFilter = Partial<Pick<Indicator, 'id' | 'paneId' | 'name'>>;
1180
+
1181
+ export type { AstroneumOptions as A, CandleData as C, Datafeed as D, IndicatorTemplate as I, Nullable as N, OverlayTemplate as O, Price as P, SerializedChartState as S, Timestamp as T, Volume as V, XAxisTemplate as X, YAxisTemplate as Y, AstroneumHandle as a, IndicatorPlugin as b, Chart as c, Period as d, SymbolInfo as e, ChartEventMap as f, ChartPlugin as g, ChartPluginContext as h, DatafeedSubscribeCallback as i, Viewport as j };