@tradecanvas/commons 1.4.0 → 1.7.0

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 (61) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +67 -67
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.js +617 -122
  6. package/dist/index.js.map +1 -1
  7. package/dist/types/a11y.d.ts +18 -0
  8. package/dist/types/a11y.d.ts.map +1 -0
  9. package/dist/types/chart.d.ts +103 -2
  10. package/dist/types/chart.d.ts.map +1 -1
  11. package/dist/types/drawing.d.ts +85 -1
  12. package/dist/types/drawing.d.ts.map +1 -1
  13. package/dist/types/events.d.ts +139 -1
  14. package/dist/types/events.d.ts.map +1 -1
  15. package/dist/types/execution.d.ts +20 -1
  16. package/dist/types/execution.d.ts.map +1 -1
  17. package/dist/types/index.d.ts +4 -0
  18. package/dist/types/index.d.ts.map +1 -1
  19. package/dist/types/indicator.d.ts +81 -0
  20. package/dist/types/indicator.d.ts.map +1 -1
  21. package/dist/types/layout.d.ts +8 -0
  22. package/dist/types/layout.d.ts.map +1 -1
  23. package/dist/types/news.d.ts +18 -0
  24. package/dist/types/news.d.ts.map +1 -0
  25. package/dist/types/ohlc.d.ts +11 -1
  26. package/dist/types/ohlc.d.ts.map +1 -1
  27. package/dist/types/quote.d.ts +40 -0
  28. package/dist/types/quote.d.ts.map +1 -0
  29. package/dist/types/realtime.d.ts +50 -0
  30. package/dist/types/realtime.d.ts.map +1 -1
  31. package/dist/types/rendering.d.ts +11 -0
  32. package/dist/types/rendering.d.ts.map +1 -1
  33. package/dist/types/symbol.d.ts +42 -0
  34. package/dist/types/symbol.d.ts.map +1 -0
  35. package/dist/types/theme.d.ts +6 -0
  36. package/dist/types/theme.d.ts.map +1 -1
  37. package/dist/types/trading.d.ts +33 -2
  38. package/dist/types/trading.d.ts.map +1 -1
  39. package/dist/utils/chartTypeOptions.d.ts +9 -0
  40. package/dist/utils/chartTypeOptions.d.ts.map +1 -0
  41. package/dist/utils/drawingOptions.d.ts +8 -0
  42. package/dist/utils/drawingOptions.d.ts.map +1 -0
  43. package/dist/utils/drawingStyle.d.ts +9 -0
  44. package/dist/utils/drawingStyle.d.ts.map +1 -0
  45. package/dist/utils/index.d.ts +8 -0
  46. package/dist/utils/index.d.ts.map +1 -1
  47. package/dist/utils/marketStatus.d.ts +16 -0
  48. package/dist/utils/marketStatus.d.ts.map +1 -0
  49. package/dist/utils/precision.d.ts +18 -0
  50. package/dist/utils/precision.d.ts.map +1 -1
  51. package/dist/utils/priceSource.d.ts +15 -0
  52. package/dist/utils/priceSource.d.ts.map +1 -0
  53. package/dist/utils/resample.d.ts +13 -0
  54. package/dist/utils/resample.d.ts.map +1 -0
  55. package/dist/utils/symbols.d.ts +13 -0
  56. package/dist/utils/symbols.d.ts.map +1 -0
  57. package/dist/utils/time.d.ts +17 -6
  58. package/dist/utils/time.d.ts.map +1 -1
  59. package/dist/utils/timezone.d.ts +28 -0
  60. package/dist/utils/timezone.d.ts.map +1 -0
  61. package/package.json +1 -1
@@ -1,11 +1,72 @@
1
1
  import { DataSeries } from './ohlc.js';
2
2
  import { ViewportState } from './rendering.js';
3
3
  export type IndicatorPlacement = 'overlay' | 'panel';
4
+ /** How a plot is drawn. */
5
+ export type IndicatorPlotKind = 'line' | 'histogram' | 'dots' | 'step';
6
+ /**
7
+ * One series an indicator draws from a field of its output: a line, a
8
+ * histogram, dots. Fields of the output that no plot names are not drawn
9
+ * (flags, running state) and are left out of scales, legends and labels.
10
+ */
11
+ export interface IndicatorPlot {
12
+ /** The output field (`IndicatorValue` key) it is drawn from. */
13
+ key: string;
14
+ /** Short name: "Signal", "%K", "Upper". */
15
+ title: string;
16
+ /** Index into `style.colors` it is drawn in (its up colour when two-tone). */
17
+ color: number;
18
+ /** Default `'line'`. */
19
+ kind?: IndicatorPlotKind;
20
+ /**
21
+ * Two-tone: drawn bar by bar in `color` or `downColor`, by the value's
22
+ * sign (`'sign'`, zero counts as up) or by another output field that is
23
+ * 1 for up (`{ field }`).
24
+ */
25
+ tone?: 'sign' | {
26
+ field: string;
27
+ };
28
+ /** Index into `style.colors` of the down colour of a two-tone plot. */
29
+ downColor?: number;
30
+ }
31
+ /** The value scale of an indicator's pane. */
32
+ export interface IndicatorScale {
33
+ /** Fixed lower bound (RSI: 0); unset follows the visible values. */
34
+ min?: number;
35
+ /** Fixed upper bound (RSI: 100); unset follows the visible values. */
36
+ max?: number;
37
+ /** Keep zero in view (oscillators around zero, histograms). */
38
+ zero?: boolean;
39
+ }
40
+ /** How a parameter is edited. Types not described here are inferred from the default value. */
41
+ export interface IndicatorInputSpec {
42
+ /** Label in settings; defaults to the parameter name in words. */
43
+ label?: string;
44
+ min?: number;
45
+ max?: number;
46
+ step?: number;
47
+ /** A choice among these values. */
48
+ options?: readonly (string | number)[];
49
+ /**
50
+ * A price source: `'close'`, `'hl2'`… or another indicator's line
51
+ * (`'ind:<instanceId>:<key>'`). The indicator then reads it as `close`.
52
+ */
53
+ source?: boolean;
54
+ }
4
55
  export interface IndicatorDescriptor {
5
56
  id: string;
6
57
  name: string;
7
58
  placement: IndicatorPlacement;
8
59
  defaultConfig: Record<string, unknown>;
60
+ /** Short name for legends ("RSI"); defaults to the id in capitals. */
61
+ shortName?: string;
62
+ /** What it draws, in drawing order. Without it every output field counts as drawn. */
63
+ plots?: readonly IndicatorPlot[];
64
+ /** Its pane's value scale (panel indicators). */
65
+ scale?: IndicatorScale;
66
+ /** Default horizontal reference levels (RSI 30 / 70), drawn by the chart and editable per instance. */
67
+ levels?: readonly number[];
68
+ /** How its parameters are edited, by parameter name. */
69
+ inputs?: Readonly<Record<string, IndicatorInputSpec>>;
9
70
  }
10
71
  export interface IndicatorConfig {
11
72
  id: string;
@@ -13,7 +74,21 @@ export interface IndicatorConfig {
13
74
  params: Record<string, number | string | boolean>;
14
75
  style?: IndicatorStyleConfig;
15
76
  visible?: boolean;
77
+ /** Reference levels for this instance; unset uses the descriptor's `levels`. */
78
+ levels?: number[];
79
+ /**
80
+ * Draw in another instance's pane, on its scale (a moving average applied
81
+ * to RSI). Unset: the price pane for overlays, a pane of its own for panels.
82
+ */
83
+ pane?: string;
84
+ /**
85
+ * `'left'`: an overlay drawn on a price scale of its own on the left, fit
86
+ * to its values (volume-like lines over price). Unset: the price scale.
87
+ */
88
+ scale?: 'left';
16
89
  }
90
+ /** Which price scale an overlay is drawn on. */
91
+ export type OverlayScale = 'right' | 'left';
17
92
  export interface IndicatorStyleConfig {
18
93
  colors?: string[];
19
94
  lineWidths?: number[];
@@ -47,6 +122,12 @@ export interface IndicatorPlugin {
47
122
  * Return `null` to fall back to a full `calculate`.
48
123
  */
49
124
  update?(data: DataSeries, config: IndicatorConfig, prev: IndicatorOutput, from: number): IndicatorOutput | null;
125
+ /**
126
+ * How many bars before `from` an `update` may rewrite (a fractal is decided
127
+ * by the bars after it). Default 0: only bars from `from` on change.
128
+ * Indicators read from this one recompute from that far back.
129
+ */
130
+ revisesBefore?(config: IndicatorConfig): number;
50
131
  render(ctx: CanvasRenderingContext2D, output: IndicatorOutput, viewport: ViewportState, style: ResolvedIndicatorStyle): void;
51
132
  }
52
133
  //# sourceMappingURL=indicator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"indicator.d.ts","sourceRoot":"","sources":["../../src/types/indicator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,OAAO,CAAC;AAErD,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,kBAAkB,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,eAAe;I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M,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACpC,qFAAqF;IACrF,MAAM,CAAC,EAAE,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,mBAAmB,CAAC;IAChC,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,GAAG,eAAe,CAAC;IACtE;;;;;;;;;OASG;IACH,MAAM,CAAC,CACL,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,MAAM,GACX,eAAe,GAAG,IAAI,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAAC;IAChD,MAAM,CACJ,GAAG,EAAE,wBAAwB,EAC7B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,sBAAsB,GAC5B,IAAI,CAAC;CACT"}
@@ -6,6 +6,14 @@ export interface PanelConfig {
6
6
  size: number;
7
7
  minSize: number;
8
8
  content: PanelContentConfig;
9
+ /** Folded to its header (a top or bottom pane); `size` is kept for when it opens again. */
10
+ collapsed?: boolean;
11
+ /** Its value scale is logarithmic (only while all its values are above 0). */
12
+ logScale?: boolean;
13
+ /** Its value scale runs upside down. */
14
+ invertScale?: boolean;
15
+ /** Its value scale reads in percent of its first value on screen. */
16
+ percentScale?: boolean;
9
17
  }
10
18
  export interface PanelContentConfig {
11
19
  type: 'indicator' | 'custom';
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/types/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhE,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,IAAI,CAAC;IACpB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,QAAQ,EAAE,WAAW,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,IAAI,CAAC;IACX,WAAW,EAAE,YAAY,GAAG,UAAU,CAAC;CACxC"}
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/types/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhE,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,2FAA2F;IAC3F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wCAAwC;IACxC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qEAAqE;IACrE,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,IAAI,CAAC;IACpB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,QAAQ,EAAE,WAAW,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,IAAI,CAAC;IACX,WAAW,EAAE,YAAY,GAAG,UAAU,CAAC;CACxC"}
@@ -0,0 +1,18 @@
1
+ /** A news headline about a symbol. */
2
+ export interface NewsItem {
3
+ title: string;
4
+ /** When it was published, in ms since the epoch. */
5
+ time: number;
6
+ /** The article; only http(s) links are kept. */
7
+ url?: string;
8
+ source?: string;
9
+ summary?: string;
10
+ id?: string;
11
+ }
12
+ /**
13
+ * Headlines from untrusted input (a feed, a host): each needs a title and a
14
+ * time; links that aren't web pages are dropped. Newest first, at most
15
+ * `limit`.
16
+ */
17
+ export declare function readNews(raw: unknown, limit?: number): NewsItem[];
18
+ //# sourceMappingURL=news.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"news.d.ts","sourceRoot":"","sources":["../../src/types/news.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAqBD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,SAAK,GAAG,QAAQ,EAAE,CAoB7D"}
@@ -12,6 +12,16 @@ export interface TickData {
12
12
  price: number;
13
13
  volume?: number;
14
14
  }
15
- export type TimeFrame = '1s' | '5s' | '15s' | '30s' | '1m' | '3m' | '5m' | '15m' | '30m' | '45m' | '1h' | '2h' | '3h' | '4h' | '6h' | '8h' | '12h' | '1d' | '2d' | '3d' | '1w' | '2w' | '1M' | '3M' | '6M' | '12M';
15
+ /** Seconds, minutes, hours, days, weeks, months (`m` is minutes, `M` months). */
16
+ export type TimeFrameUnit = 's' | 'm' | 'h' | 'd' | 'w' | 'M';
17
+ /** The timeframes most feeds offer, listed for editor completion. */
18
+ export type KnownTimeFrame = '1s' | '5s' | '15s' | '30s' | '1m' | '3m' | '5m' | '15m' | '30m' | '45m' | '1h' | '2h' | '3h' | '4h' | '6h' | '8h' | '12h' | '1d' | '2d' | '3d' | '1w' | '2w' | '1M' | '3M' | '6M' | '12M';
19
+ /**
20
+ * A bar interval: a whole count and a unit, e.g. `'5m'`, `'7m'`, `'90m'`,
21
+ * `'2d'`. Any count works; `parseTimeframe` / `isTimeFrame` check a string at
22
+ * runtime.
23
+ */
24
+ /** A time timeframe, or a tick one (`'100T'`: bars of 100 trades, from a feed with trades). */
25
+ export type TimeFrame = KnownTimeFrame | (`${number}${TimeFrameUnit}` & {}) | (`${number}T` & {});
16
26
  export type DataSeries = OHLCBar[];
17
27
  //# sourceMappingURL=ohlc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ohlc.d.ts","sourceRoot":"","sources":["../../src/types/ohlc.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,SAAS,GACjB,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAC3B,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAC1C,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAC/C,IAAI,GAAG,IAAI,GAAG,IAAI,GAClB,IAAI,GAAG,IAAI,GACX,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAE/B,MAAM,MAAM,UAAU,GAAG,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"ohlc.d.ts","sourceRoot":"","sources":["../../src/types/ohlc.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,iFAAiF;AACjF,MAAM,MAAM,aAAa,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAE9D,qEAAqE;AACrE,MAAM,MAAM,cAAc,GACtB,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAC3B,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAC1C,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAC/C,IAAI,GAAG,IAAI,GAAG,IAAI,GAClB,IAAI,GAAG,IAAI,GACX,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAE/B;;;;GAIG;AACH,+FAA+F;AAC/F,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,CAAC,GAAG,MAAM,GAAG,aAAa,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC;AAElG,MAAM,MAAM,UAAU,GAAG,OAAO,EAAE,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * A symbol's latest quote: its price and the day's move, for a watchlist row
3
+ * or a symbol's details. Prices are in the symbol's quote currency.
4
+ */
5
+ export interface Quote {
6
+ symbol: string;
7
+ /** The last traded price. */
8
+ last: number;
9
+ /** The move from the reference price (the prior close; 24 h ago for crypto). */
10
+ change?: number;
11
+ /** The same move, in percent. */
12
+ changePercent?: number;
13
+ open?: number;
14
+ high?: number;
15
+ low?: number;
16
+ /** The prior session's close. */
17
+ prevClose?: number;
18
+ /** Volume over the same period, in the base unit. */
19
+ volume?: number;
20
+ bid?: number;
21
+ ask?: number;
22
+ /** When the quote was made, in ms since the epoch. */
23
+ time?: number;
24
+ }
25
+ /** Live quotes for many symbols at once. */
26
+ export interface QuoteSource {
27
+ /**
28
+ * Send quotes for `symbols` to `onQuotes` as they change (any number per
29
+ * call) until the function it returns is called.
30
+ */
31
+ subscribeQuotes(symbols: readonly string[], onQuotes: (quotes: Quote[]) => void): () => void;
32
+ }
33
+ /**
34
+ * A quote from untrusted input (a host's push, a feed's frame): its symbol
35
+ * and last price must be usable; any other field that isn't a finite number
36
+ * is left out. The change is worked out from the prior close or the open when
37
+ * the input has none. Null when it isn't a quote.
38
+ */
39
+ export declare function readQuote(raw: unknown): Quote | null;
40
+ //# sourceMappingURL=quote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/types/quote.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,4CAA4C;AAC5C,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,eAAe,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC9F;AAID;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,GAAG,IAAI,CAiBpD"}
@@ -1,4 +1,13 @@
1
1
  import { OHLCBar, TimeFrame } from './ohlc.js';
2
+ import { SymbolInfo, SymbolSearchOptions } from './symbol.js';
3
+ import { Quote } from './quote.js';
4
+ import { NewsItem } from './news.js';
5
+ /** One trade: when (ms), at what price, how much. */
6
+ export interface Trade {
7
+ time: number;
8
+ price: number;
9
+ volume: number;
10
+ }
2
11
  export type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'error';
3
12
  export interface ConnectionInfo {
4
13
  state: ConnectionState;
@@ -12,6 +21,9 @@ export interface RawTick {
12
21
  price: number;
13
22
  volume: number;
14
23
  side?: 'buy' | 'sell';
24
+ /** The best bid and ask with it, when the feed has them (the chart marks them). */
25
+ bid?: number;
26
+ ask?: number;
15
27
  }
16
28
  export interface AggregatedBar extends OHLCBar {
17
29
  closed: boolean;
@@ -50,6 +62,12 @@ export type DataAdapterListener<T = unknown> = (event: DataAdapterEvent<T>) => v
50
62
  */
51
63
  export interface DataAdapter {
52
64
  readonly name: string;
65
+ /**
66
+ * Optional: the timeframes the feed serves. Charts build any other
67
+ * timeframe (7m, 90m, 2d…) from the coarsest of these that divides it.
68
+ * Leave it out when the feed serves every timeframe.
69
+ */
70
+ readonly supportedTimeframes?: readonly TimeFrame[];
53
71
  connect(config: DataAdapterConfig): void;
54
72
  disconnect(): void;
55
73
  getConnectionState(): ConnectionState;
@@ -58,6 +76,36 @@ export interface DataAdapter {
58
76
  * Returns bars sorted by time ascending.
59
77
  */
60
78
  fetchHistory(symbol: string, timeframe: TimeFrame, limit?: number): Promise<OHLCBar[]>;
79
+ /**
80
+ * Optional: load up to `limit` bars older than `before` (the oldest loaded
81
+ * bar's time, in the bars' own unit), sorted by time ascending. Return an
82
+ * empty array when no older data exists. A chart connected to an adapter
83
+ * with this method loads older bars as the user scrolls back in time.
84
+ */
85
+ fetchHistoryBefore?(symbol: string, timeframe: TimeFrame, before: number, limit: number): Promise<OHLCBar[]>;
86
+ /** Optional: symbols matching `query`, best first — for a symbol search box. */
87
+ searchSymbols?(query: string, options?: SymbolSearchOptions): Promise<SymbolInfo[]>;
88
+ /**
89
+ * Optional: what the feed knows about `symbol` (name, price step, exchange
90
+ * timezone and hours), or null when it doesn't know it. A connected chart
91
+ * asks for it and applies it.
92
+ */
93
+ resolveSymbol?(symbol: string): Promise<SymbolInfo | null>;
94
+ /**
95
+ * Optional: live quotes (last price, the day's change, high, low, volume)
96
+ * for many symbols at once, until the function it returns is called. A
97
+ * widget's watchlist fills its rows from it.
98
+ */
99
+ subscribeQuotes?(symbols: readonly string[], onQuotes: (quotes: Quote[]) => void): () => void;
100
+ /** Optional: recent headlines about `symbol`, newest first. */
101
+ fetchNews?(symbol: string, limit?: number): Promise<NewsItem[]>;
102
+ /**
103
+ * Optional, with `subscribeTrades`: up to `limit` recent trades, oldest
104
+ * first. A chart builds tick timeframes (`'100T'`) from a feed's trades.
105
+ */
106
+ fetchTrades?(symbol: string, limit?: number): Promise<Trade[]>;
107
+ /** Optional, with `fetchTrades`: live trades of `symbol` until the function it returns is called. */
108
+ subscribeTrades?(symbol: string, onTrades: (trades: Trade[]) => void): () => void;
61
109
  on<T = unknown>(event: DataAdapterEventType, listener: DataAdapterListener<T>): void;
62
110
  off<T = unknown>(event: DataAdapterEventType, listener: DataAdapterListener<T>): void;
63
111
  dispose(): void;
@@ -67,6 +115,8 @@ export interface StreamConfig {
67
115
  symbol: string;
68
116
  timeframe: TimeFrame;
69
117
  historyLimit?: number;
118
+ /** Bars per request when scrolling back for older bars (needs `adapter.fetchHistoryBefore`), default: 500. */
119
+ historyPageSize?: number;
70
120
  autoScroll?: boolean;
71
121
  showCurrentPriceLine?: boolean;
72
122
  aggregateTicks?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../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C;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8GAA8G;IAC9G,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,iBAAiB,EAAE,eAM/B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,OAAO,CAAC,YAAY,CAKvD,CAAC"}
@@ -45,6 +45,17 @@ export interface ViewportState {
45
45
  scaleBaseline?: number;
46
46
  /** Upside down: higher prices lower on screen. */
47
47
  invertScale?: boolean;
48
+ /**
49
+ * How prices on this scale read, when the chart has a price format of its
50
+ * own (`ChartOptions.priceFormat`). Unset: decimals. Indicator panes leave
51
+ * it unset.
52
+ */
53
+ formatPrice?: (price: number) => string;
54
+ /**
55
+ * The step prices move in under that format (a 32nd): the axis puts its
56
+ * ticks on whole numbers of it.
57
+ */
58
+ priceUnit?: number;
48
59
  /**
49
60
  * Optional reference to the current bar series. When set, drawings/indicators
50
61
  * treat `anchor.time` as a real timestamp and convert to bar index via
@@ -1 +1 @@
1
- {"version":3,"file":"rendering.d.ts","sourceRoot":"","sources":["../../src/types/rendering.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,M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ACT,OAAO,IAAI;IACX,EAAE,IAAI;IACN,KAAK,IAAI;CACV"}
@@ -0,0 +1,42 @@
1
+ /** A regular trading window, wall-clock times in the symbol's `timezone`. */
2
+ export interface SymbolSession {
3
+ /** Opening time, `'09:30'`. */
4
+ start: string;
5
+ /** Closing time, `'16:00'`; earlier than `start` wraps past midnight. */
6
+ end: string;
7
+ /**
8
+ * Weekdays it opens on, 0 Sunday … 6 Saturday (a session past midnight
9
+ * belongs to the day it starts); every day when left out. The market
10
+ * status reads them.
11
+ */
12
+ days?: number[];
13
+ }
14
+ /** What a feed knows about a symbol: names, price steps and trading hours. */
15
+ export interface SymbolInfo {
16
+ /** The ticker the adapter uses, e.g. `'BTCUSDT'`. */
17
+ symbol: string;
18
+ /** A readable name: `'BTC / USDT'`, `'Apple Inc.'`. */
19
+ description?: string;
20
+ /** Where it trades: `'Binance'`, `'NASDAQ'`. */
21
+ exchange?: string;
22
+ /** `'crypto'`, `'stock'`, `'forex'`, `'futures'`, `'index'`… */
23
+ type?: string;
24
+ /** Decimals prices show with. */
25
+ pricePrecision?: number;
26
+ /** Smallest price step. */
27
+ minTick?: number;
28
+ /** IANA zone the exchange keeps its hours in, e.g. `'America/New_York'`. */
29
+ timezone?: string;
30
+ /** Regular trading hours in `timezone`; none means around the clock. */
31
+ sessions?: SymbolSession[];
32
+ /** Currency prices are quoted in. */
33
+ currency?: string;
34
+ }
35
+ /** Options for `DataAdapter.searchSymbols`. */
36
+ export interface SymbolSearchOptions {
37
+ /** Most results to return (default 50). */
38
+ limit?: number;
39
+ /** Aborted when a newer query supersedes this one. */
40
+ signal?: AbortSignal;
41
+ }
42
+ //# sourceMappingURL=symbol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symbol.d.ts","sourceRoot":"","sources":["../../src/types/symbol.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB"}
@@ -5,6 +5,10 @@ export interface FontConfig {
5
5
  sizeMedium: number;
6
6
  sizeLarge: number;
7
7
  }
8
+ export interface ShapeConfig {
9
+ /** Corner radius of price tags, axis pills and order badges, px (0: square; 999: pills). */
10
+ tagRadius?: number;
11
+ }
8
12
  export interface Theme {
9
13
  name: string;
10
14
  background: string;
@@ -25,5 +29,7 @@ export interface Theme {
25
29
  axisLabel: string;
26
30
  axisLabelBackground: string;
27
31
  font: FontConfig;
32
+ /** The shapes the chart draws: its price tags and axis pills square, rounded or pills. */
33
+ shape?: ShapeConfig;
28
34
  }
29
35
  //# sourceMappingURL=theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/types/theme.ts"],"names":[],"mappings":"AAAA,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MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB"}
@@ -2,6 +2,8 @@ export type OrderSide = 'buy' | 'sell';
2
2
  export type OrderType = 'market' | 'limit' | 'stop' | 'stopLimit';
3
3
  export type OrderStatus = 'pending' | 'filled' | 'cancelled' | 'rejected';
4
4
  export type OrderLabel = 'LIMIT' | 'STOP' | 'SL' | 'TP' | 'STOP LIMIT';
5
+ /** How long an order works: good till cancelled, or for the day. */
6
+ export type TimeInForce = 'gtc' | 'day';
5
7
  export interface TradingOrder {
6
8
  id: string;
7
9
  side: OrderSide;
@@ -11,6 +13,10 @@ export interface TradingOrder {
11
13
  quantity: number;
12
14
  label?: OrderLabel;
13
15
  draggable?: boolean;
16
+ /** Stop-loss and take-profit the position gets when the order fills. */
17
+ stopLoss?: number;
18
+ takeProfit?: number;
19
+ timeInForce?: TimeInForce;
14
20
  meta?: Record<string, unknown>;
15
21
  }
16
22
  export interface TradingPosition {
@@ -41,6 +47,8 @@ export interface PositionLabelContext {
41
47
  pnl: number;
42
48
  pnlPct: number;
43
49
  precision: number;
50
+ /** The chart's price format, for `{entry}` and `{price}` (decimals at `precision` without one). */
51
+ formatPrice?: (price: number) => string;
44
52
  }
45
53
  export interface DepthLevel {
46
54
  price: number;
@@ -82,6 +90,19 @@ export interface TradingConfig {
82
90
  contextMenu?: {
83
91
  enabled?: boolean;
84
92
  };
93
+ /**
94
+ * Buttons on the lines: × on an order cancels it, × on a position closes it
95
+ * and ⇅ reverses it, × on a stop-loss or take-profit removes it. All on by
96
+ * default.
97
+ */
98
+ lineButtons?: {
99
+ cancel?: boolean;
100
+ close?: boolean;
101
+ reverse?: boolean;
102
+ removeStops?: boolean;
103
+ };
104
+ /** Marks where orders filled (from the execution adapter's fills). On by default. */
105
+ fillMarks?: boolean;
85
106
  pricePrecision?: number;
86
107
  dragThreshold?: number;
87
108
  }
@@ -91,6 +112,10 @@ export interface OrderPlaceIntent {
91
112
  price: number;
92
113
  stopPrice?: number;
93
114
  quantity?: number;
115
+ /** Stop-loss and take-profit for the position the order opens. */
116
+ stopLoss?: number;
117
+ takeProfit?: number;
118
+ timeInForce?: TimeInForce;
94
119
  }
95
120
  export interface OrderModifyIntent {
96
121
  orderId: string;
@@ -104,11 +129,17 @@ export interface OrderCancelIntent {
104
129
  }
105
130
  export interface PositionModifyIntent {
106
131
  positionId: string;
107
- stopLoss?: number;
108
- takeProfit?: number;
132
+ /** A new stop-loss; null removes it, left out keeps it. */
133
+ stopLoss?: number | null;
134
+ /** A new take-profit; null removes it, left out keeps it. */
135
+ takeProfit?: number | null;
109
136
  }
110
137
  export interface PositionCloseIntent {
111
138
  positionId: string;
112
139
  }
140
+ /** Close a position and open the same size the other way. */
141
+ export interface PositionReverseIntent {
142
+ positionId: string;
143
+ }
113
144
  export declare const DEFAULT_TRADING_CONFIG: TradingConfig;
114
145
  //# sourceMappingURL=trading.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trading.d.ts","sourceRoot":"","sources":["../../src/types/trading.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC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d,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB;iFAC6E;IAC7E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,6DAA6D;AAC7D,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,sBAAsB,EAAE,aAUpC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { ChartTypeOptions } from '../types/chart.js';
2
+ /**
3
+ * The chart type settings in `raw` the chart can use: boxes, ranges and
4
+ * reversals above 0, whole line and box counts in range. A type given at
5
+ * all is in the result (empty when none of its settings were usable), so
6
+ * a type's settings can be put back to their defaults.
7
+ */
8
+ export declare function readChartTypeOptions(raw: unknown): ChartTypeOptions;
9
+ //# sourceMappingURL=chartTypeOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chartTypeOptions.d.ts","sourceRoot":"","sources":["../../src/utils/chartTypeOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAO1D;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAiCnE"}
@@ -0,0 +1,8 @@
1
+ import { DrawingOptionDefs, DrawingOptionValue, DrawingOptions } from '../types/drawing.js';
2
+ /** The valid entries of `raw` for a tool's options: unknown keys and wrong values are dropped, numbers clamped. */
3
+ export declare function sanitizeDrawingOptions(defs: DrawingOptionDefs | undefined, raw: unknown): DrawingOptions;
4
+ /** One option of a drawing: its own value when valid, else the tool's default. */
5
+ export declare function drawingOption<T extends DrawingOptionValue = DrawingOptionValue>(defs: DrawingOptionDefs | undefined, options: DrawingOptions | undefined, key: string): T;
6
+ /** Every option of a tool for a drawing, defaults filled in. */
7
+ export declare function resolveDrawingOptions(defs: DrawingOptionDefs | undefined, options: DrawingOptions | undefined): DrawingOptions;
8
+ //# sourceMappingURL=drawingOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawingOptions.d.ts","sourceRoot":"","sources":["../../src/utils/drawingOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkC,iBAAiB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA0CjI,mHAAmH;AACnH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,EAAE,GAAG,EAAE,OAAO,GAAG,cAAc,CAUxG;AAMD,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,EAC7E,IAAI,EAAE,iBAAiB,GAAG,SAAS,EACnC,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,GAAG,EAAE,MAAM,GACV,CAAC,CAKH;AAED,gEAAgE;AAChE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,EAAE,OAAO,EAAE,cAAc,GAAG,SAAS,GAAG,cAAc,CAI9H"}
@@ -0,0 +1,9 @@
1
+ import { DrawingStyle } from '../types/drawing.js';
2
+ /**
3
+ * The valid fields of a drawing style from untrusted data (a saved layout, a
4
+ * template): colours as short strings, a known line style, widths, opacity
5
+ * and font size as finite numbers in range, text cut to length. Anything
6
+ * else is dropped.
7
+ */
8
+ export declare function sanitizeDrawingStyle(raw: unknown): Partial<DrawingStyle>;
9
+ //# sourceMappingURL=drawingStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawingStyle.d.ts","sourceRoot":"","sources":["../../src/utils/drawingStyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAgBxD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAiBxE"}
@@ -3,4 +3,12 @@ export * from './data.js';
3
3
  export * from './color.js';
4
4
  export * from './time.js';
5
5
  export * from './precision.js';
6
+ export * from './priceSource.js';
7
+ export * from './resample.js';
8
+ export * from './timezone.js';
9
+ export * from './symbols.js';
10
+ export * from './marketStatus.js';
11
+ export * from './drawingOptions.js';
12
+ export * from './drawingStyle.js';
13
+ export * from './chartTypeOptions.js';
6
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { SymbolInfo } from '../types/symbol.js';
2
+ /** Whether a symbol's market is trading now, and when that changes. */
3
+ export interface MarketStatus {
4
+ /** `'always'`: no hours known (24/7, such as crypto). */
5
+ state: 'open' | 'closed' | 'always';
6
+ /** When it next closes (open) or opens (closed), in ms; null when unknown. */
7
+ next: number | null;
8
+ }
9
+ /**
10
+ * The market status of `info` at `now`: in a session of its hours (in its
11
+ * exchange's time zone, clocks changes included) or not, and when that
12
+ * changes. Sessions that meet count as one; a session past midnight belongs
13
+ * to the day it starts. Without hours or a zone it knows: `'always'`.
14
+ */
15
+ export declare function marketStatus(info: SymbolInfo | null | undefined, now: number): MarketStatus;
16
+ //# sourceMappingURL=marketStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marketStatus.d.ts","sourceRoot":"","sources":["../../src/utils/marketStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,yDAAyD;IACzD,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACpC,8EAA8E;IAC9E,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAOD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,YAAY,CA4C3F"}