@tradecanvas/chart 1.1.0 → 1.2.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.
- package/LICENSE +21 -21
- package/README.md +79 -9
- package/dist/Chart.d.ts +28 -0
- package/dist/Chart.d.ts.map +1 -1
- package/dist/DataManager.d.ts.map +1 -1
- package/dist/{DragDropImporter-CLtRQjKD.js → DragDropImporter-BcTzFeRP.js} +312 -223
- package/dist/DragDropImporter-BcTzFeRP.js.map +1 -0
- package/dist/DragDropImporter-DZBrretS.cjs +2 -0
- package/dist/DragDropImporter-DZBrretS.cjs.map +1 -0
- package/dist/charts/IndicatorPriceRange.d.ts +7 -3
- package/dist/charts/IndicatorPriceRange.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -19
- package/dist/index.js.map +1 -1
- package/dist/layout/LayoutManager.d.ts +3 -0
- package/dist/layout/LayoutManager.d.ts.map +1 -1
- package/dist/layout/priceAxisWidth.d.ts +22 -0
- package/dist/layout/priceAxisWidth.d.ts.map +1 -0
- package/dist/widget/ChartWidget.d.ts +24 -1
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
- package/dist/widget/WidgetHotkeySheet.d.ts +3 -1
- package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
- package/dist/widget/WidgetLoadingOverlay.d.ts +41 -0
- package/dist/widget/WidgetLoadingOverlay.d.ts.map +1 -0
- package/dist/widget/WidgetObjectTree.d.ts.map +1 -1
- package/dist/widget/WidgetSettings.d.ts +3 -1
- package/dist/widget/WidgetSettings.d.ts.map +1 -1
- package/dist/widget/WidgetToolbar.d.ts +4 -1
- package/dist/widget/WidgetToolbar.d.ts.map +1 -1
- package/dist/widget/WidgetWatchlist.d.ts +4 -1
- package/dist/widget/WidgetWatchlist.d.ts.map +1 -1
- package/dist/widget/i18n.d.ts +70 -0
- package/dist/widget/i18n.d.ts.map +1 -0
- package/dist/widget/icons.d.ts.map +1 -1
- package/dist/widget/index.cjs +2458 -2380
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +635 -237
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/types.d.ts +10 -0
- package/dist/widget/types.d.ts.map +1 -1
- package/dist/widget/widgetConfig.d.ts.map +1 -1
- package/package.json +6 -3
- package/dist/DragDropImporter-CLtRQjKD.js.map +0 -1
- package/dist/DragDropImporter-pPS0fl5H.cjs +0 -2
- package/dist/DragDropImporter-pPS0fl5H.cjs.map +0 -1
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o,
|
|
2
|
-
import { AlertDragHandler as
|
|
1
|
+
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, computePriceLimits as c, formatPrice as l, mergeBar as u, setLocale as d, timeframeToMs as f } from "@tradecanvas/commons";
|
|
2
|
+
import { AlertDragHandler as p, AlertManager as m, Animator as ee, AreaRenderer as te, AxisDragHandler as ne, BarCountdown as re, BarRenderer as ie, BaselineRenderer as ae, CandlestickRenderer as h, ChartLegend as oe, ChartStateManager as g, CompareRenderer as se, CrosshairHandler as ce, CrosshairTooltip as le, CurrentPriceLine as ue, DataExporter as _, DepthHeatmapRenderer as de, DrawingManager as fe, DrawingRenderer as pe, EquivolumeRenderer as me, EventBus as he, GridRenderer as ge, HLCAreaRenderer as _e, HollowCandleRenderer as ve, IndicatorEngine as v, InteractionManager as ye, KagiRenderer as be, KeyboardHandler as xe, LineRenderer as Se, LineWithMarkersRenderer as Ce, MarketProfileRenderer as we, MeasureOverlay as Te, PanHandler as Ee, PaneResizeHandler as De, PeriodLevelsRenderer as Oe, PinnedTooltip as ke, PivotMarkersRenderer as Ae, PointAndFigureRenderer as je, PriceAxis as Me, RenderEngine as y, RenkoRenderer as b, ReplayManager as x, Screenshot as S, SessionBreaks as Ne, SessionShading as Pe, SignalMarkerManager as Fe, StepLineRenderer as Ie, StreamManager as Le, TimeAxis as Re, TradeZoneManager as ze, TradingManager as Be, TradingRenderer as Ve, UndoRedoManager as He, Viewport as Ue, VolumeCandleRenderer as We, VolumeProfileRenderer as Ge, VolumeRenderer as Ke, Watermark as qe, ZoomHandler as Je, findDominantSwing as Ye, registerBuiltInDrawingTools as Xe, registerBuiltInIndicators as C, toHeikinAshi as Ze, toKagi as Qe, toLineBreak as $e, toPointAndFigure as et, toRangeBars as tt, toRenko as nt, xToBarIndex as rt } from "@tradecanvas/core";
|
|
3
3
|
//#region src/charts/ChartTypeStrategy.ts
|
|
4
|
-
function
|
|
4
|
+
function w(e) {
|
|
5
5
|
switch (e) {
|
|
6
6
|
case "candlestick":
|
|
7
7
|
case "heikinAshi":
|
|
8
8
|
case "lineBreak":
|
|
9
|
-
case "rangeBars": return new
|
|
10
|
-
case "line": return new
|
|
11
|
-
case "area": return new
|
|
12
|
-
case "bar": return new
|
|
13
|
-
case "hollowCandle": return new
|
|
14
|
-
case "baseline": return new
|
|
9
|
+
case "rangeBars": return new h();
|
|
10
|
+
case "line": return new Se();
|
|
11
|
+
case "area": return new te();
|
|
12
|
+
case "bar": return new ie();
|
|
13
|
+
case "hollowCandle": return new ve();
|
|
14
|
+
case "baseline": return new ae();
|
|
15
15
|
case "renko": return new b();
|
|
16
|
-
case "kagi": return new
|
|
17
|
-
case "pointAndFigure": return new
|
|
18
|
-
case "volumeCandles": return new
|
|
19
|
-
case "equivolume": return new
|
|
20
|
-
case "hlcArea": return new
|
|
21
|
-
case "stepLine": return new
|
|
22
|
-
case "lineWithMarkers": return new
|
|
23
|
-
default: return new
|
|
16
|
+
case "kagi": return new be();
|
|
17
|
+
case "pointAndFigure": return new je();
|
|
18
|
+
case "volumeCandles": return new We();
|
|
19
|
+
case "equivolume": return new me();
|
|
20
|
+
case "hlcArea": return new _e();
|
|
21
|
+
case "stepLine": return new Ie();
|
|
22
|
+
case "lineWithMarkers": return new Ce();
|
|
23
|
+
default: return new h();
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function it(e, t) {
|
|
27
27
|
if (t.length === 0) return t;
|
|
28
28
|
switch (e) {
|
|
29
|
-
case "heikinAshi": return
|
|
30
|
-
case "renko": return
|
|
29
|
+
case "heikinAshi": return Ze(t);
|
|
30
|
+
case "renko": return nt(t, {
|
|
31
31
|
brickSize: 0,
|
|
32
32
|
useATR: !0,
|
|
33
33
|
atrPeriod: 14
|
|
34
34
|
});
|
|
35
|
-
case "lineBreak": return
|
|
36
|
-
case "kagi": return
|
|
37
|
-
case "pointAndFigure": return
|
|
38
|
-
case "rangeBars": return
|
|
35
|
+
case "lineBreak": return $e(t, 3);
|
|
36
|
+
case "kagi": return Qe(t, 4);
|
|
37
|
+
case "pointAndFigure": return et(t, T(t) * .01, 3);
|
|
38
|
+
case "rangeBars": return tt(t, { rangeSize: T(t) * .005 });
|
|
39
39
|
default: return t;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -44,14 +44,14 @@ function T(e) {
|
|
|
44
44
|
for (let n of e) t += n.close;
|
|
45
45
|
return t / e.length;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function at(e, t) {
|
|
48
48
|
let n = t?.(e);
|
|
49
|
-
return n ? n.createRenderer() :
|
|
49
|
+
return n ? n.createRenderer() : w(e);
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function ot(e, t, n) {
|
|
52
52
|
if (t.length === 0) return t;
|
|
53
53
|
let r = n?.(e);
|
|
54
|
-
return r?.transform ? r.transform(t) :
|
|
54
|
+
return r?.transform ? r.transform(t) : it(e, t);
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/charts/IndicatorPriceRange.ts
|
|
@@ -59,26 +59,38 @@ var E = {
|
|
|
59
59
|
min: 0,
|
|
60
60
|
max: 100
|
|
61
61
|
}, D = .1;
|
|
62
|
-
function
|
|
62
|
+
function st(e, t, n) {
|
|
63
63
|
if (!e) return { ...E };
|
|
64
|
-
let r = Infinity, i = -Infinity
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
let r = Infinity, i = -Infinity;
|
|
65
|
+
if (e.series) {
|
|
66
|
+
let a = Math.min(n, e.series.length - 1);
|
|
67
|
+
for (let n = Math.max(0, t); n <= a; n++) {
|
|
68
|
+
let t = e.series[n];
|
|
69
|
+
if (t) for (let e in t) {
|
|
70
|
+
let n = t[e];
|
|
71
|
+
n !== void 0 && Number.isFinite(n) && (n < r && (r = n), n > i && (i = n));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
let a = 0;
|
|
76
|
+
for (let [, o] of e.values) {
|
|
77
|
+
if (a >= t && a <= n) for (let e in o) {
|
|
78
|
+
let t = o[e];
|
|
79
|
+
t !== void 0 && Number.isFinite(t) && (t < r && (r = t), t > i && (i = t));
|
|
80
|
+
}
|
|
81
|
+
a++;
|
|
69
82
|
}
|
|
70
|
-
a++;
|
|
71
83
|
}
|
|
72
84
|
if (r === Infinity) return { ...E };
|
|
73
|
-
let
|
|
85
|
+
let a = i - r || 1;
|
|
74
86
|
return {
|
|
75
|
-
min: r -
|
|
76
|
-
max: i +
|
|
87
|
+
min: r - a * D,
|
|
88
|
+
max: i + a * D
|
|
77
89
|
};
|
|
78
90
|
}
|
|
79
91
|
//#endregion
|
|
80
92
|
//#region src/state/AutoSaveScheduler.ts
|
|
81
|
-
var
|
|
93
|
+
var ct = class {
|
|
82
94
|
timer = null;
|
|
83
95
|
delayMs = 0;
|
|
84
96
|
key = null;
|
|
@@ -113,6 +125,9 @@ function O(e) {
|
|
|
113
125
|
let { open: t, high: n, low: r, close: i } = e;
|
|
114
126
|
return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
|
|
115
127
|
}
|
|
128
|
+
function lt(e) {
|
|
129
|
+
return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
|
|
130
|
+
}
|
|
116
131
|
function k(e) {
|
|
117
132
|
return {
|
|
118
133
|
...e,
|
|
@@ -127,7 +142,12 @@ var A = class {
|
|
|
127
142
|
return this.data;
|
|
128
143
|
}
|
|
129
144
|
setData(e) {
|
|
130
|
-
|
|
145
|
+
let t = [];
|
|
146
|
+
for (let n = 0; n < e.length; n++) {
|
|
147
|
+
let r = e[n];
|
|
148
|
+
O(r) && t.push(lt(r) ? r : k(r));
|
|
149
|
+
}
|
|
150
|
+
this.data = t;
|
|
131
151
|
}
|
|
132
152
|
appendBar(e) {
|
|
133
153
|
O(e) && this.data.push(k(e));
|
|
@@ -142,7 +162,7 @@ var A = class {
|
|
|
142
162
|
this.data[this.data.length - 1] = t;
|
|
143
163
|
}
|
|
144
164
|
updateLastBarFromTick(e) {
|
|
145
|
-
this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] =
|
|
165
|
+
this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = u(this.data[this.data.length - 1], e)));
|
|
146
166
|
}
|
|
147
167
|
getLength() {
|
|
148
168
|
return this.data.length;
|
|
@@ -165,6 +185,7 @@ var A = class {
|
|
|
165
185
|
panels = [];
|
|
166
186
|
containerWidth = 0;
|
|
167
187
|
containerHeight = 0;
|
|
188
|
+
priceAxisWidth = a;
|
|
168
189
|
resize(e, t) {
|
|
169
190
|
this.containerWidth = e, this.containerHeight = t;
|
|
170
191
|
}
|
|
@@ -195,105 +216,127 @@ var A = class {
|
|
|
195
216
|
let n = this.panels.find((t) => t.id === e);
|
|
196
217
|
n && (n.size = Math.max(n.minSize, t));
|
|
197
218
|
}
|
|
219
|
+
setPriceAxisWidth(e) {
|
|
220
|
+
this.priceAxisWidth = e;
|
|
221
|
+
}
|
|
198
222
|
getPanels() {
|
|
199
223
|
return this.panels;
|
|
200
224
|
}
|
|
201
225
|
resolve() {
|
|
202
|
-
let e = this.panels.filter((e) => e.position === "left"), t = this.panels.filter((e) => e.position === "right"), n = this.panels.filter((e) => e.position === "top"), r = this.panels.filter((e) => e.position === "bottom"), i = e.reduce((e, t) => e + t.size, 0),
|
|
226
|
+
let e = this.panels.filter((e) => e.position === "left"), t = this.panels.filter((e) => e.position === "right"), n = this.panels.filter((e) => e.position === "top"), r = this.panels.filter((e) => e.position === "bottom"), i = e.reduce((e, t) => e + t.size, 0), a = t.reduce((e, t) => e + t.size, 0), s = n.reduce((e, t) => e + t.size, 0), c = r.reduce((e, t) => e + t.size, 0), l = {
|
|
203
227
|
x: i,
|
|
204
|
-
y:
|
|
205
|
-
width: Math.max(0, this.containerWidth - i -
|
|
206
|
-
height: Math.max(0, this.containerHeight -
|
|
207
|
-
},
|
|
208
|
-
for (let t of e)
|
|
228
|
+
y: s,
|
|
229
|
+
width: Math.max(0, this.containerWidth - i - a - this.priceAxisWidth),
|
|
230
|
+
height: Math.max(0, this.containerHeight - s - c - o)
|
|
231
|
+
}, u = [], d = [], f = 0;
|
|
232
|
+
for (let t of e) u.push({
|
|
209
233
|
config: t,
|
|
210
234
|
rect: {
|
|
211
|
-
x:
|
|
235
|
+
x: f,
|
|
212
236
|
y: 0,
|
|
213
237
|
width: t.size,
|
|
214
238
|
height: this.containerHeight - o
|
|
215
239
|
}
|
|
216
|
-
}),
|
|
240
|
+
}), d.push({
|
|
217
241
|
panelId: t.id,
|
|
218
242
|
rect: {
|
|
219
|
-
x:
|
|
243
|
+
x: f + t.size - 2,
|
|
220
244
|
y: 0,
|
|
221
245
|
width: 4,
|
|
222
246
|
height: this.containerHeight
|
|
223
247
|
},
|
|
224
248
|
orientation: "vertical"
|
|
225
|
-
}),
|
|
226
|
-
let
|
|
227
|
-
for (let e of n)
|
|
249
|
+
}), f += t.size;
|
|
250
|
+
let p = 0;
|
|
251
|
+
for (let e of n) u.push({
|
|
228
252
|
config: e,
|
|
229
253
|
rect: {
|
|
230
254
|
x: i,
|
|
231
|
-
y:
|
|
232
|
-
width:
|
|
255
|
+
y: p,
|
|
256
|
+
width: l.width,
|
|
233
257
|
height: e.size
|
|
234
258
|
}
|
|
235
|
-
}),
|
|
259
|
+
}), d.push({
|
|
236
260
|
panelId: e.id,
|
|
237
261
|
rect: {
|
|
238
262
|
x: i,
|
|
239
|
-
y:
|
|
240
|
-
width:
|
|
263
|
+
y: p + e.size - 2,
|
|
264
|
+
width: l.width,
|
|
241
265
|
height: 4
|
|
242
266
|
},
|
|
243
267
|
orientation: "horizontal"
|
|
244
|
-
}),
|
|
245
|
-
|
|
246
|
-
for (let e of r)
|
|
268
|
+
}), p += e.size;
|
|
269
|
+
p = l.y + l.height;
|
|
270
|
+
for (let e of r) u.push({
|
|
247
271
|
config: e,
|
|
248
272
|
rect: {
|
|
249
273
|
x: i,
|
|
250
|
-
y:
|
|
251
|
-
width:
|
|
274
|
+
y: p,
|
|
275
|
+
width: l.width,
|
|
252
276
|
height: e.size
|
|
253
277
|
}
|
|
254
|
-
}),
|
|
278
|
+
}), d.push({
|
|
255
279
|
panelId: e.id,
|
|
256
280
|
rect: {
|
|
257
281
|
x: i,
|
|
258
|
-
y:
|
|
259
|
-
width:
|
|
282
|
+
y: p - 2,
|
|
283
|
+
width: l.width,
|
|
260
284
|
height: 4
|
|
261
285
|
},
|
|
262
286
|
orientation: "horizontal"
|
|
263
|
-
}),
|
|
264
|
-
|
|
265
|
-
for (let e of t)
|
|
287
|
+
}), p += e.size;
|
|
288
|
+
f = i + l.width + this.priceAxisWidth;
|
|
289
|
+
for (let e of t) u.push({
|
|
266
290
|
config: e,
|
|
267
291
|
rect: {
|
|
268
|
-
x:
|
|
292
|
+
x: f,
|
|
269
293
|
y: 0,
|
|
270
294
|
width: e.size,
|
|
271
295
|
height: this.containerHeight - o
|
|
272
296
|
}
|
|
273
|
-
}),
|
|
297
|
+
}), d.push({
|
|
274
298
|
panelId: e.id,
|
|
275
299
|
rect: {
|
|
276
|
-
x:
|
|
300
|
+
x: f - 2,
|
|
277
301
|
y: 0,
|
|
278
302
|
width: 4,
|
|
279
303
|
height: this.containerHeight
|
|
280
304
|
},
|
|
281
305
|
orientation: "vertical"
|
|
282
|
-
}),
|
|
306
|
+
}), f += e.size;
|
|
283
307
|
return {
|
|
284
|
-
mainChartRect:
|
|
285
|
-
panels:
|
|
286
|
-
dividers:
|
|
308
|
+
mainChartRect: l,
|
|
309
|
+
panels: u,
|
|
310
|
+
dividers: d
|
|
287
311
|
};
|
|
288
312
|
}
|
|
289
313
|
getMainChartRect() {
|
|
290
314
|
return this.resolve().mainChartRect;
|
|
291
315
|
}
|
|
292
|
-
},
|
|
293
|
-
function
|
|
316
|
+
}, ut = 14, dt = 14, ft = 22, F = 4;
|
|
317
|
+
function pt(e) {
|
|
318
|
+
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: u } = e, d = s(t, n), f = e.tagPrecision ?? d, p = r === null ? [t, n] : [
|
|
319
|
+
t,
|
|
320
|
+
n,
|
|
321
|
+
r
|
|
322
|
+
], m = a;
|
|
323
|
+
for (let e of p) {
|
|
324
|
+
if (!Number.isFinite(e)) continue;
|
|
325
|
+
let t = l(e, d, i), n = l(e, f, i);
|
|
326
|
+
m = Math.max(m, u(t, `500 ${c}px ${o}`) + ut, u(n, `bold 11px ${o}`) + dt, u(n, `600 ${c}px ${o}`) + ft);
|
|
327
|
+
}
|
|
328
|
+
return m <= a ? a : Math.ceil(m / F) * F;
|
|
329
|
+
}
|
|
330
|
+
function mt(e, t) {
|
|
331
|
+
return t > e || t <= e - 12 ? t : e;
|
|
332
|
+
}
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/plugins/contracts.ts
|
|
335
|
+
var ht = 1;
|
|
336
|
+
function I(e, t) {
|
|
294
337
|
return e.filter((e) => (e.descriptor.layer ?? "overlay") === t);
|
|
295
338
|
}
|
|
296
|
-
function
|
|
339
|
+
function L(e) {
|
|
297
340
|
switch (e.kind) {
|
|
298
341
|
case "indicator": return `indicator:${e.plugin.descriptor.id}`;
|
|
299
342
|
case "drawing": return `drawing:${e.plugin.descriptor.type}`;
|
|
@@ -303,25 +346,25 @@ function I(e) {
|
|
|
303
346
|
}
|
|
304
347
|
//#endregion
|
|
305
348
|
//#region src/plugins/registry.ts
|
|
306
|
-
var
|
|
307
|
-
function
|
|
308
|
-
|
|
349
|
+
var R = /* @__PURE__ */ new Map();
|
|
350
|
+
function gt(e) {
|
|
351
|
+
R.set(L(e), e);
|
|
309
352
|
}
|
|
310
|
-
function
|
|
311
|
-
return
|
|
353
|
+
function _t(e) {
|
|
354
|
+
return R.delete(e);
|
|
312
355
|
}
|
|
313
|
-
function
|
|
314
|
-
return [...
|
|
356
|
+
function z() {
|
|
357
|
+
return [...R.values()];
|
|
315
358
|
}
|
|
316
|
-
function
|
|
317
|
-
|
|
359
|
+
function vt() {
|
|
360
|
+
R.clear();
|
|
318
361
|
}
|
|
319
362
|
//#endregion
|
|
320
363
|
//#region src/plugins/PluginManager.ts
|
|
321
|
-
var
|
|
364
|
+
var B = class {
|
|
322
365
|
plugins = /* @__PURE__ */ new Map();
|
|
323
366
|
constructor(e, t = {}) {
|
|
324
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
367
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of z()) this.add(e);
|
|
325
368
|
for (let e of t.plugins ?? []) this.add(e);
|
|
326
369
|
}
|
|
327
370
|
register(e) {
|
|
@@ -349,20 +392,20 @@ var z = class {
|
|
|
349
392
|
return e;
|
|
350
393
|
}
|
|
351
394
|
add(e) {
|
|
352
|
-
this.plugins.set(
|
|
395
|
+
this.plugins.set(L(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
353
396
|
}
|
|
354
|
-
},
|
|
397
|
+
}, V = {
|
|
355
398
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
356
399
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
357
400
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
358
401
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
359
402
|
positionClose: (e, t) => e.closePosition(t)
|
|
360
403
|
};
|
|
361
|
-
function
|
|
404
|
+
function yt(e, t) {
|
|
362
405
|
let n = [], r = (e) => t.setOrders(e.data ?? []), i = (e) => t.setPositions(e.data ?? []), a = (e) => t.onError(e.data ?? { message: "Execution error" });
|
|
363
406
|
e.on("orders", r), e.on("positions", i), e.on("error", a), n.push(() => e.off("orders", r), () => e.off("positions", i), () => e.off("error", a));
|
|
364
|
-
for (let r of Object.keys(
|
|
365
|
-
let i =
|
|
407
|
+
for (let r of Object.keys(V)) {
|
|
408
|
+
let i = V[r], a = t.onIntent(r, (n) => {
|
|
366
409
|
Promise.resolve(i(e, n)).catch((e) => t.onError({
|
|
367
410
|
message: `Execution command failed: ${r}`,
|
|
368
411
|
cause: e
|
|
@@ -376,8 +419,8 @@ function dt(e, t) {
|
|
|
376
419
|
}
|
|
377
420
|
//#endregion
|
|
378
421
|
//#region src/Chart.ts
|
|
379
|
-
var
|
|
380
|
-
static version = "1.
|
|
422
|
+
var bt = 6, xt = class {
|
|
423
|
+
static version = "1.2.0";
|
|
381
424
|
engine;
|
|
382
425
|
viewport;
|
|
383
426
|
dataManager;
|
|
@@ -398,6 +441,8 @@ var ft = 6, pt = class {
|
|
|
398
441
|
resolvedLayoutCache = null;
|
|
399
442
|
panelInfoCache = null;
|
|
400
443
|
renderScheduled = !1;
|
|
444
|
+
priceAxisWidth = a;
|
|
445
|
+
measureCtx;
|
|
401
446
|
containerSizeCache = null;
|
|
402
447
|
containerSizeCacheTime = 0;
|
|
403
448
|
lastEmittedRange = null;
|
|
@@ -421,8 +466,9 @@ var ft = 6, pt = class {
|
|
|
421
466
|
tradeZoneManager;
|
|
422
467
|
measureOverlay;
|
|
423
468
|
replayManager;
|
|
469
|
+
replayBarUnsub = null;
|
|
424
470
|
undoRedoManager;
|
|
425
|
-
autoSaveScheduler = new
|
|
471
|
+
autoSaveScheduler = new ct((e) => this.saveState(e));
|
|
426
472
|
animator;
|
|
427
473
|
crosshairTooltip;
|
|
428
474
|
pinnedTooltip;
|
|
@@ -438,11 +484,12 @@ var ft = 6, pt = class {
|
|
|
438
484
|
container;
|
|
439
485
|
currentPriceLine;
|
|
440
486
|
numberLocale;
|
|
487
|
+
defaultAutoScale;
|
|
441
488
|
keyboardHandler = null;
|
|
442
489
|
onWindowKeyDown = null;
|
|
443
490
|
currentSymbol = "";
|
|
444
491
|
constructor(e, t) {
|
|
445
|
-
this.container = e, this.options = t, this.numberLocale = t.numberLocale ?? "en-US";
|
|
492
|
+
this.container = e, this.options = t, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
446
493
|
let n = t.features ?? {};
|
|
447
494
|
this.features = {
|
|
448
495
|
drawings: n.drawings ?? !0,
|
|
@@ -456,6 +503,7 @@ var ft = 6, pt = class {
|
|
|
456
503
|
panning: n.panning ?? !0,
|
|
457
504
|
zooming: n.zooming ?? !0,
|
|
458
505
|
crosshair: n.crosshair ?? !0,
|
|
506
|
+
crosshairTooltip: n.crosshairTooltip ?? !0,
|
|
459
507
|
keyboard: n.keyboard ?? !0,
|
|
460
508
|
priceAxis: n.priceAxis ?? !0,
|
|
461
509
|
timeAxis: n.timeAxis ?? !0,
|
|
@@ -474,36 +522,36 @@ var ft = 6, pt = class {
|
|
|
474
522
|
logScale: n.logScale ?? !0,
|
|
475
523
|
timeframes: n.timeframes ?? [],
|
|
476
524
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
477
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new A(), this.themeManager = new j(t.theme), this.layoutManager = new P(), this.indicatorEngine = new
|
|
525
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new A(), this.themeManager = new j(t.theme), this.layoutManager = new P(), this.indicatorEngine = new v(), this.pluginManager = new B(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new he(), C(this.indicatorEngine), this.drawingManager = new fe(), Xe(this.drawingManager), this.drawingRenderer = new pe(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
478
526
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
479
527
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
480
528
|
this.eventBus.emit(e, t);
|
|
481
|
-
}), this.undoRedoManager = new
|
|
529
|
+
}), this.undoRedoManager = new He(), this.drawingManager.setUndoRedoManager(this.undoRedoManager), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new Be({
|
|
482
530
|
enabled: this.features.trading,
|
|
483
531
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
484
|
-
}), this.tradingRenderer = new
|
|
532
|
+
}), this.tradingRenderer = new Ve(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
485
533
|
this.eventBus.emit(e, t);
|
|
486
|
-
}), this.engine = new
|
|
534
|
+
}), this.engine = new y(e);
|
|
487
535
|
let i = this.engine.dprManager.getContainerSize();
|
|
488
|
-
if (this.viewport = new
|
|
536
|
+
if (this.viewport = new Ue(i.width, i.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.layoutManager.resize(i.width, i.height), this.engine.onContainerResize = (e) => {
|
|
489
537
|
if (e.width <= 0 || e.height <= 0) return;
|
|
490
538
|
let t = this.viewport.isAtEnd();
|
|
491
539
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
492
|
-
}, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new
|
|
540
|
+
}, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new ge(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Me(), this.priceAxis.setLocale(this.numberLocale), this.timeAxis = new Re(), this.crosshairHandler = new ce(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
|
|
493
541
|
if (e !== null && t) {
|
|
494
542
|
let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
|
|
495
|
-
this.chartLegend.setHoverBar(r ?? null), r && this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize()), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
543
|
+
this.chartLegend.setHoverBar(r ?? null), r && this.features.crosshairTooltip && this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize()), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
496
544
|
point: t,
|
|
497
545
|
bar: r,
|
|
498
546
|
barIndex: e
|
|
499
547
|
});
|
|
500
548
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null);
|
|
501
|
-
}), this.chartLegend = new
|
|
549
|
+
}), this.chartLegend = new oe(), this.chartLegend.setChartType(t.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new qe(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Ke(), this.volumeProfile = new Ge(), this.marketProfile = new we(), this.depthHeatmap = new de(), this.periodLevels = new Oe(), this.pivotMarkers = new Ae(), this.barCountdown = new re(), this.sessionBreaks = new Ne(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new Pe(), this.compareRenderer = new se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
502
550
|
visible: t.sessionBreaks.visible ?? !0,
|
|
503
551
|
color: t.sessionBreaks.color,
|
|
504
552
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
505
553
|
lineWidth: t.sessionBreaks.lineWidth
|
|
506
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
554
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new ee(), this.crosshairTooltip = new le(), this.crosshairTooltip.create(e), this.pinnedTooltip = new ke(), this.pinnedTooltip.create(e), this.keyboardHandler = new xe({
|
|
507
555
|
scrollBars: (e) => {
|
|
508
556
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
509
557
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -523,7 +571,7 @@ var ft = 6, pt = class {
|
|
|
523
571
|
if (!this.keyboardHandler) return;
|
|
524
572
|
let t = document.activeElement;
|
|
525
573
|
t && t !== this.container && !this.container.contains(t) || t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable) || this.keyboardHandler.handleKey(e) && e.preventDefault();
|
|
526
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
574
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new ue(), this.currentPriceLine.setLocale(this.numberLocale), this.alertManager = new m(), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
527
575
|
let t = {
|
|
528
576
|
id: e.id,
|
|
529
577
|
price: e.price,
|
|
@@ -555,7 +603,7 @@ var ft = 6, pt = class {
|
|
|
555
603
|
message: e.message,
|
|
556
604
|
triggered: e.triggered
|
|
557
605
|
});
|
|
558
|
-
}), this.signalMarkerManager = new
|
|
606
|
+
}), this.signalMarkerManager = new Fe(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
|
|
559
607
|
this.eventBus.emit("signalMarkerAdd", {
|
|
560
608
|
id: e.id,
|
|
561
609
|
source: e.source,
|
|
@@ -563,26 +611,26 @@ var ft = 6, pt = class {
|
|
|
563
611
|
});
|
|
564
612
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
565
613
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
566
|
-
}), this.tradeZoneManager = new
|
|
614
|
+
}), this.tradeZoneManager = new ze(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
|
|
567
615
|
this.eventBus.emit("tradeZoneAdd", {
|
|
568
616
|
id: e.id,
|
|
569
617
|
direction: e.direction
|
|
570
618
|
});
|
|
571
619
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
572
620
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
573
|
-
}), this.replayManager = new x(), this.measureOverlay = new
|
|
621
|
+
}), this.replayManager = new x(), this.measureOverlay = new Te(), this.interactionManager = new ye(e), this.features.panning) {
|
|
574
622
|
let e = 0;
|
|
575
|
-
this.interactionManager.setPanHandler(new
|
|
576
|
-
t && this.viewport.scrollBy(t), n && (e += n, (this.options.autoScale === !1 || Math.abs(e) >
|
|
623
|
+
this.interactionManager.setPanHandler(new Ee((t, n) => {
|
|
624
|
+
t && this.viewport.scrollBy(t), n && (e += n, (this.options.autoScale === !1 || Math.abs(e) > bt) && (this.options.autoScale = !1, this.viewport.panPriceRange(n))), this.updateViewportAndRender();
|
|
577
625
|
}, () => {
|
|
578
626
|
e = 0;
|
|
579
627
|
}));
|
|
580
628
|
}
|
|
581
629
|
if (this.features.zooming) {
|
|
582
|
-
this.interactionManager.setZoomHandler(new
|
|
630
|
+
this.interactionManager.setZoomHandler(new Je((e, t) => {
|
|
583
631
|
this.viewport.zoom(e, t), this.updateViewportAndRender();
|
|
584
632
|
}));
|
|
585
|
-
let e = new
|
|
633
|
+
let e = new ne((e) => {
|
|
586
634
|
this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
587
635
|
}, (e) => {
|
|
588
636
|
let t = this.viewport.getState().chartRect.width;
|
|
@@ -599,10 +647,10 @@ var ft = 6, pt = class {
|
|
|
599
647
|
...this.viewport.getState(),
|
|
600
648
|
data: this.getDisplayData()
|
|
601
649
|
})), this.features.alerts) {
|
|
602
|
-
let e = new
|
|
650
|
+
let e = new p(this.alertManager, () => this.viewport.getState());
|
|
603
651
|
this.interactionManager.setAlertDragHandler(e);
|
|
604
652
|
}
|
|
605
|
-
let a = new
|
|
653
|
+
let a = new De();
|
|
606
654
|
a.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(a), this.interactionManager.setAltClickHandler((e) => {
|
|
607
655
|
let t = this.getDisplayData();
|
|
608
656
|
if (t.length === 0) return;
|
|
@@ -614,7 +662,7 @@ var ft = 6, pt = class {
|
|
|
614
662
|
x: e.x,
|
|
615
663
|
y: e.y
|
|
616
664
|
}), t.length === 0) return;
|
|
617
|
-
let n =
|
|
665
|
+
let n = rt(e.x, this.viewport.getState());
|
|
618
666
|
n < 0 || n >= t.length || this.eventBus.emit("barClick", {
|
|
619
667
|
bar: t[n],
|
|
620
668
|
barIndex: n,
|
|
@@ -641,22 +689,29 @@ var ft = 6, pt = class {
|
|
|
641
689
|
}), this.interactionManager.attach(), this.syncRenderContext(), this.engine.start();
|
|
642
690
|
}
|
|
643
691
|
setData(e) {
|
|
644
|
-
this.dataManager.setData(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.alertManager.clearLastValues(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), e.length > 0 && this.currentPriceLine.setPrice(e[e.length - 1].close), this.updateViewportAndRender(!0), this.eventBus.emit("dataUpdate", { length: e.length });
|
|
692
|
+
this.dataManager.setData(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.options.autoScale = this.defaultAutoScale, this.alertManager.clearLastValues(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), e.length > 0 && this.currentPriceLine.setPrice(e[e.length - 1].close), this.updateViewportAndRender(!0), this.eventBus.emit("dataUpdate", { length: e.length });
|
|
645
693
|
}
|
|
646
694
|
appendBar(e) {
|
|
647
|
-
|
|
695
|
+
let t = this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
696
|
+
this.dataManager.appendBar(e);
|
|
697
|
+
let n = this.dataManager.getData();
|
|
698
|
+
this.crosshairHandler.setData(n), this.displayDataCache = null, this.indicatorEngine.recalculateFrom(n, n.length - 2), this.updateViewportAndRender(t);
|
|
648
699
|
}
|
|
649
700
|
appendBars(e) {
|
|
650
|
-
if (e.length
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
701
|
+
if (e.length === 0) return;
|
|
702
|
+
let t = this.viewport.isAtEnd(), n = this.dataManager.getLength() - 1;
|
|
703
|
+
for (let t of e) this.dataManager.appendBar(t);
|
|
704
|
+
this.displayDataCache = null, this.indicatorEngine.recalculateFrom(this.dataManager.getData(), n), this.crosshairHandler.setData(this.dataManager.getData()), this.updateViewportAndRender(t);
|
|
654
705
|
}
|
|
655
706
|
updateLastBar(e) {
|
|
656
|
-
this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close), this.options.chartType !== "candlestick" && this.options.chartType !== "line" && this.options.chartType !== "area" && this.options.chartType !== "bar" && this.options.chartType !== "hollowCandle" && (this.displayDataCache = null)
|
|
707
|
+
this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close), this.options.chartType !== "candlestick" && this.options.chartType !== "line" && this.options.chartType !== "area" && this.options.chartType !== "bar" && this.options.chartType !== "hollowCandle" && (this.displayDataCache = null);
|
|
708
|
+
let t = this.dataManager.getData();
|
|
709
|
+
this.indicatorEngine.recalculateFrom(t, t.length - 1), this.scheduleRender();
|
|
657
710
|
}
|
|
658
711
|
updateLastBarFromTick(e) {
|
|
659
|
-
this.dataManager.updateLastBarFromTick(e), this.currentPriceLine.setPrice(e.price), this.options.chartType !== "candlestick" && this.options.chartType !== "line" && this.options.chartType !== "area" && this.options.chartType !== "bar" && this.options.chartType !== "hollowCandle" && (this.displayDataCache = null)
|
|
712
|
+
this.dataManager.updateLastBarFromTick(e), this.currentPriceLine.setPrice(e.price), this.options.chartType !== "candlestick" && this.options.chartType !== "line" && this.options.chartType !== "area" && this.options.chartType !== "bar" && this.options.chartType !== "hollowCandle" && (this.displayDataCache = null);
|
|
713
|
+
let t = this.dataManager.getData();
|
|
714
|
+
this.indicatorEngine.recalculateFrom(t, t.length - 1), this.scheduleRender();
|
|
660
715
|
}
|
|
661
716
|
setChartType(e) {
|
|
662
717
|
this.options.chartType = e, this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0);
|
|
@@ -686,8 +741,8 @@ var ft = 6, pt = class {
|
|
|
686
741
|
return this.pluginManager;
|
|
687
742
|
}
|
|
688
743
|
static indicators() {
|
|
689
|
-
let e = new
|
|
690
|
-
return
|
|
744
|
+
let e = new v();
|
|
745
|
+
return C(e), e.getAvailableIndicators();
|
|
691
746
|
}
|
|
692
747
|
setPanelPosition(e, t) {
|
|
693
748
|
this.layoutManager.setPanelPosition(e, t), this.engine.requestRender();
|
|
@@ -726,7 +781,7 @@ var ft = 6, pt = class {
|
|
|
726
781
|
}
|
|
727
782
|
autoFib() {
|
|
728
783
|
if (!this.features.drawings) return null;
|
|
729
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
784
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = Ye(e, t.visibleRange.from, t.visibleRange.to);
|
|
730
785
|
return n ? this.addDrawing({
|
|
731
786
|
type: "fibRetracement",
|
|
732
787
|
anchors: [n[0], n[1]]
|
|
@@ -781,21 +836,21 @@ var ft = 6, pt = class {
|
|
|
781
836
|
exportVisibleData(e = "csv", t) {
|
|
782
837
|
let n = this.viewport.getState(), r = this.dataManager.getData(), i = Math.max(0, n.visibleRange.from), a = Math.min(r.length - 1, n.visibleRange.to), o = r.slice(i, a + 1);
|
|
783
838
|
if (e === "json") {
|
|
784
|
-
let e =
|
|
785
|
-
|
|
839
|
+
let e = _.toJSON(o);
|
|
840
|
+
_.download(e, t ?? "chart-data.json", "application/json");
|
|
786
841
|
} else {
|
|
787
|
-
let e =
|
|
788
|
-
|
|
842
|
+
let e = _.toCSV(o);
|
|
843
|
+
_.download(e, t ?? "chart-data.csv", "text/csv");
|
|
789
844
|
}
|
|
790
845
|
}
|
|
791
846
|
exportAllData(e = "csv", t) {
|
|
792
847
|
let n = this.dataManager.getData();
|
|
793
848
|
if (e === "json") {
|
|
794
|
-
let e =
|
|
795
|
-
|
|
849
|
+
let e = _.toJSON(n);
|
|
850
|
+
_.download(e, t ?? "chart-data.json", "application/json");
|
|
796
851
|
} else {
|
|
797
|
-
let e =
|
|
798
|
-
|
|
852
|
+
let e = _.toCSV(n);
|
|
853
|
+
_.download(e, t ?? "chart-data.csv", "text/csv");
|
|
799
854
|
}
|
|
800
855
|
}
|
|
801
856
|
setAutoSave(e, t = 5e3) {
|
|
@@ -893,26 +948,33 @@ var ft = 6, pt = class {
|
|
|
893
948
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
894
949
|
}
|
|
895
950
|
async connect(e) {
|
|
896
|
-
this.disconnectStream(), this.streamManager = new
|
|
951
|
+
this.disconnectStream(), this.streamManager = new Le(), this.streamManager.on("snapshot", (e) => {
|
|
897
952
|
this.setData(e);
|
|
898
953
|
}), this.streamManager.on("barClose", (e) => {
|
|
899
|
-
|
|
954
|
+
let t = this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
955
|
+
this.dataManager.appendBar(e);
|
|
956
|
+
let n = this.dataManager.getData();
|
|
957
|
+
this.crosshairHandler.setData(n), this.displayDataCache = null, this.indicatorEngine.recalculateFrom(n, n.length - 2), this.updateViewportAndRender(t);
|
|
900
958
|
}), this.streamManager.on("barUpdate", (e) => {
|
|
901
|
-
this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close)
|
|
902
|
-
|
|
903
|
-
this.
|
|
959
|
+
this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close);
|
|
960
|
+
let t = this.dataManager.getData();
|
|
961
|
+
this.indicatorEngine.recalculateFrom(t, t.length - 1), this.scheduleRender();
|
|
962
|
+
}), this.streamManager.on("priceChange", ({ price: e, previousClose: t }) => {
|
|
963
|
+
this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e, t ?? void 0), this.engine.requestRender(r.Overlay), this.engine.requestRender(r.UI);
|
|
904
964
|
}), this.streamManager.on("connectionChange", (e) => {
|
|
905
965
|
this.eventBus.emit("dataUpdate", { connection: e });
|
|
906
966
|
}), this.streamManager.on("error", (e) => {
|
|
907
967
|
this.eventBus.emit("dataUpdate", { error: e.message });
|
|
908
|
-
}), this.autoScrollOnNewBar = e.autoScroll !== !1, this.currentSymbol = e.symbol
|
|
909
|
-
let t =
|
|
910
|
-
|
|
968
|
+
}), this.autoScrollOnNewBar = e.autoScroll !== !1, this.currentSymbol = e.symbol;
|
|
969
|
+
let t = this.streamManager;
|
|
970
|
+
if (await t.connect(e), this.streamManager !== t) return;
|
|
971
|
+
let n = f(e.timeframe);
|
|
972
|
+
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
911
973
|
this.barCountdown.isVisible() && this.engine.requestRender(r.UI);
|
|
912
974
|
}, 1e3);
|
|
913
975
|
}
|
|
914
976
|
async switchStream(e, t) {
|
|
915
|
-
this.streamManager && (this.currentSymbol = e, await this.streamManager.switchTo(e, t));
|
|
977
|
+
this.streamManager && (this.currentSymbol = e, this.barCountdown.setTimeframeMs(f(t)), await this.streamManager.switchTo(e, t));
|
|
916
978
|
}
|
|
917
979
|
async setTimeframe(e) {
|
|
918
980
|
if (!this.streamManager) throw Error("No active stream. Call connect() first.");
|
|
@@ -923,7 +985,7 @@ var ft = 6, pt = class {
|
|
|
923
985
|
}
|
|
924
986
|
connectExecution(e, t = {}) {
|
|
925
987
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
926
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
988
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = yt(e, {
|
|
927
989
|
onIntent: (e, t) => {
|
|
928
990
|
let n = (e) => t(e.payload);
|
|
929
991
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -1061,7 +1123,7 @@ var ft = 6, pt = class {
|
|
|
1061
1123
|
}), this.engine.requestRender(r.Background);
|
|
1062
1124
|
}
|
|
1063
1125
|
setAutoScale(e) {
|
|
1064
|
-
this.options.autoScale = e, this.updateViewportAndRender();
|
|
1126
|
+
this.options.autoScale = e, this.defaultAutoScale = e, this.updateViewportAndRender();
|
|
1065
1127
|
}
|
|
1066
1128
|
isAutoScale() {
|
|
1067
1129
|
return this.options.autoScale !== !1;
|
|
@@ -1246,9 +1308,15 @@ var ft = 6, pt = class {
|
|
|
1246
1308
|
replayStart(e) {
|
|
1247
1309
|
if (!this.features.replay) return;
|
|
1248
1310
|
let t = this.dataManager.getData();
|
|
1249
|
-
this.replayManager.load(t)
|
|
1250
|
-
|
|
1251
|
-
|
|
1311
|
+
this.replayManager.load(t);
|
|
1312
|
+
let n = -1;
|
|
1313
|
+
this.replayBarUnsub?.(), this.replayBarUnsub = this.replayManager.on("bar", ({ bar: e, index: r }) => {
|
|
1314
|
+
let i = r + 1;
|
|
1315
|
+
if (n > 0 && i > n && this.dataManager.getLength() === n) {
|
|
1316
|
+
for (let e = n; e < i; e++) this.dataManager.appendBar(t[e]);
|
|
1317
|
+
this.indicatorEngine.recalculateFrom(this.dataManager.getData(), n);
|
|
1318
|
+
} else this.dataManager.setData(t.slice(0, i)), this.indicatorEngine.recalculateAll(this.dataManager.getData());
|
|
1319
|
+
n = i, this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.updateViewportAndRender();
|
|
1252
1320
|
}), this.replayManager.play(e);
|
|
1253
1321
|
}
|
|
1254
1322
|
replayPause() {
|
|
@@ -1274,16 +1342,16 @@ var ft = 6, pt = class {
|
|
|
1274
1342
|
}
|
|
1275
1343
|
saveState(e) {
|
|
1276
1344
|
if (!this.features.saveLoad) return null;
|
|
1277
|
-
let t =
|
|
1345
|
+
let t = g.capture({
|
|
1278
1346
|
getDrawings: () => this.getDrawings(),
|
|
1279
1347
|
getTheme: () => this.getTheme(),
|
|
1280
1348
|
getAlerts: () => this.getAlerts()
|
|
1281
|
-
}, { chartType: this.options.chartType }), n =
|
|
1282
|
-
return e &&
|
|
1349
|
+
}, { chartType: this.options.chartType }), n = g.serialize(t);
|
|
1350
|
+
return e && g.saveToStorage(e, t), n;
|
|
1283
1351
|
}
|
|
1284
1352
|
loadState(e) {
|
|
1285
1353
|
if (!this.features.saveLoad) return;
|
|
1286
|
-
let t =
|
|
1354
|
+
let t = g.deserialize(e);
|
|
1287
1355
|
if (t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), t.theme && this.setTheme(t.theme), t.alerts) {
|
|
1288
1356
|
this.clearAlerts();
|
|
1289
1357
|
for (let e of t.alerts) this.addAlert(e.price, e.condition, e.message);
|
|
@@ -1291,28 +1359,28 @@ var ft = 6, pt = class {
|
|
|
1291
1359
|
}
|
|
1292
1360
|
loadStateFromStorage(e) {
|
|
1293
1361
|
if (!this.features.saveLoad) return !1;
|
|
1294
|
-
let t =
|
|
1295
|
-
return t ? (this.loadState(
|
|
1362
|
+
let t = g.loadFromStorage(e);
|
|
1363
|
+
return t ? (this.loadState(g.serialize(t)), !0) : !1;
|
|
1296
1364
|
}
|
|
1297
1365
|
downloadState(e) {
|
|
1298
1366
|
if (!this.features.saveLoad) return;
|
|
1299
|
-
let t =
|
|
1367
|
+
let t = g.capture({
|
|
1300
1368
|
getDrawings: () => this.getDrawings(),
|
|
1301
1369
|
getTheme: () => this.getTheme(),
|
|
1302
1370
|
getAlerts: () => this.getAlerts()
|
|
1303
1371
|
}, { chartType: this.options.chartType });
|
|
1304
|
-
|
|
1372
|
+
g.downloadFile(t, e);
|
|
1305
1373
|
}
|
|
1306
1374
|
async loadStateFromFile() {
|
|
1307
1375
|
if (!this.features.saveLoad) return;
|
|
1308
|
-
let e = await
|
|
1309
|
-
this.loadState(
|
|
1376
|
+
let e = await g.loadFromFile();
|
|
1377
|
+
this.loadState(g.serialize(e));
|
|
1310
1378
|
}
|
|
1311
1379
|
setLocale(e) {
|
|
1312
|
-
|
|
1380
|
+
d(e), this.engine.requestRender();
|
|
1313
1381
|
}
|
|
1314
1382
|
setNumberLocale(e) {
|
|
1315
|
-
this.numberLocale = e, this.priceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.
|
|
1383
|
+
this.numberLocale = e, this.priceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.chartLegend.setLocale(e), this.sessionBreaks.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
|
|
1316
1384
|
}
|
|
1317
1385
|
getNumberLocale() {
|
|
1318
1386
|
return this.numberLocale;
|
|
@@ -1330,13 +1398,13 @@ var ft = 6, pt = class {
|
|
|
1330
1398
|
};
|
|
1331
1399
|
this.themeManager.setTheme(t);
|
|
1332
1400
|
}
|
|
1333
|
-
e.pricePrecision !== void 0 && (this.tradingManager.setConfig({ pricePrecision: e.pricePrecision }), this.alertManager.setPricePrecision(e.pricePrecision), this.streamManager?.priceLine.setPricePrecision(e.pricePrecision), this.
|
|
1401
|
+
e.pricePrecision !== void 0 && (this.tradingManager.setConfig({ pricePrecision: e.pricePrecision }), this.alertManager.setPricePrecision(e.pricePrecision), this.streamManager?.priceLine.setPricePrecision(e.pricePrecision), this.currentPriceLine.setPricePrecision(e.pricePrecision), this.crosshairHandler.setPricePrecision(e.pricePrecision), this.chartLegend.setPricePrecision(e.pricePrecision)), this.updateViewportAndRender();
|
|
1334
1402
|
}
|
|
1335
1403
|
getMarket() {
|
|
1336
1404
|
return this.marketConfig;
|
|
1337
1405
|
}
|
|
1338
1406
|
setPriceLimits(e) {
|
|
1339
|
-
this.marketConfig && (
|
|
1407
|
+
this.marketConfig && (c(e, this.marketConfig) && (this.marketConfig.priceLimits = {
|
|
1340
1408
|
...this.marketConfig.priceLimits,
|
|
1341
1409
|
referencePrice: e
|
|
1342
1410
|
}), this.engine.requestRender());
|
|
@@ -1345,7 +1413,7 @@ var ft = 6, pt = class {
|
|
|
1345
1413
|
return this.features;
|
|
1346
1414
|
}
|
|
1347
1415
|
setFeatures(e) {
|
|
1348
|
-
Object.assign(this.features, e), e.crosshair === !1 && this.crosshairTooltip.hide(), e.grid !== void 0 && this.engine.requestRender(r.Background), e.volume !== void 0 && (this.volumeRenderer.setVisible(e.volume), this.engine.requestRender(r.Main)), e.drawings === !1 && this.drawingManager.setActiveTool(null), e.trading === !1 && (this.tradingManager.setOrders([]), this.tradingManager.setPositions([])), e.keyboard !== void 0 && this.keyboardHandler?.setEnabled(e.keyboard), this.engine.requestRender();
|
|
1416
|
+
Object.assign(this.features, e), (e.crosshair === !1 || e.crosshairTooltip === !1) && this.crosshairTooltip.hide(), e.grid !== void 0 && this.engine.requestRender(r.Background), e.volume !== void 0 && (this.volumeRenderer.setVisible(e.volume), this.engine.requestRender(r.Main)), e.drawings === !1 && this.drawingManager.setActiveTool(null), e.trading === !1 && (this.tradingManager.setOrders([]), this.tradingManager.setPositions([])), e.keyboard !== void 0 && this.keyboardHandler?.setEnabled(e.keyboard), this.engine.requestRender();
|
|
1349
1417
|
}
|
|
1350
1418
|
resize() {
|
|
1351
1419
|
let e = this.engine.dprManager.readContainerSize();
|
|
@@ -1360,42 +1428,63 @@ var ft = 6, pt = class {
|
|
|
1360
1428
|
this.countdownInterval && clearInterval(this.countdownInterval), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
|
|
1361
1429
|
}
|
|
1362
1430
|
createChartRenderer(e) {
|
|
1363
|
-
return
|
|
1431
|
+
return at(e, (e) => this.pluginManager.getChartType(e));
|
|
1364
1432
|
}
|
|
1365
1433
|
getDisplayData() {
|
|
1366
1434
|
if (this.displayDataCache) return this.displayDataCache;
|
|
1367
1435
|
let e = this.dataManager.getData();
|
|
1368
1436
|
if (e.length === 0) return e;
|
|
1369
|
-
let t =
|
|
1437
|
+
let t = ot(this.options.chartType, e, (e) => this.pluginManager.getChartType(e));
|
|
1370
1438
|
return this.displayDataCache = t, t;
|
|
1371
1439
|
}
|
|
1372
1440
|
scheduleRender() {
|
|
1373
1441
|
this.renderScheduled || (this.renderScheduled = !0, requestAnimationFrame(() => {
|
|
1374
|
-
this.renderScheduled = !1;
|
|
1375
|
-
let e = this.getDisplayData();
|
|
1376
|
-
this.viewport.updateData(e, this.options.autoScale !== !1), this.syncRenderContext(), this.engine.requestRender();
|
|
1442
|
+
this.renderScheduled = !1, this.applyDataToViewport(), this.fitPriceAxisWidth() && this.applyDataToViewport(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1377
1443
|
}));
|
|
1378
1444
|
}
|
|
1379
|
-
|
|
1380
|
-
this.
|
|
1381
|
-
|
|
1382
|
-
this.viewport.
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
this.viewport.setScaleBaseline(n[t]?.close);
|
|
1445
|
+
applyDataToViewport(e = !1) {
|
|
1446
|
+
let t = this.getDisplayData(), n = this.options.autoScale !== !1;
|
|
1447
|
+
this.viewport.updateData(t, n && !e), e && (this.viewport.scrollToEnd(), n && this.viewport.updateData(t, !0));
|
|
1448
|
+
let r = this.viewport.getState();
|
|
1449
|
+
if (t.length > 0) {
|
|
1450
|
+
let e = Math.max(0, Math.min(r.visibleRange.from, t.length - 1));
|
|
1451
|
+
this.viewport.setScaleBaseline(t[e]?.close);
|
|
1387
1452
|
}
|
|
1388
|
-
if (
|
|
1389
|
-
let e = this.
|
|
1390
|
-
if (
|
|
1391
|
-
let
|
|
1392
|
-
if (
|
|
1393
|
-
let e = i -
|
|
1394
|
-
this.viewport.setPriceRange(
|
|
1453
|
+
if (n) {
|
|
1454
|
+
let e = this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1));
|
|
1455
|
+
if (e) {
|
|
1456
|
+
let t = r.priceRange, n = Math.min(t.min, e.min), i = Math.max(t.max, e.max);
|
|
1457
|
+
if (n < t.min || i > t.max) {
|
|
1458
|
+
let e = i - n || 1;
|
|
1459
|
+
this.viewport.setPriceRange(n - e * .02, i + e * .02);
|
|
1395
1460
|
}
|
|
1396
1461
|
}
|
|
1397
1462
|
}
|
|
1398
|
-
|
|
1463
|
+
return t;
|
|
1464
|
+
}
|
|
1465
|
+
updateViewportAndRender(e = !1) {
|
|
1466
|
+
this.resolvedLayoutCache = null, this.panelInfoCache = null;
|
|
1467
|
+
let t = this.getResolvedLayout();
|
|
1468
|
+
this.viewport.setChartRect(t.mainChartRect), this.applyDataToViewport(e), this.fitPriceAxisWidth() && this.applyDataToViewport(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1469
|
+
}
|
|
1470
|
+
fitPriceAxisWidth() {
|
|
1471
|
+
if (!this.features.priceAxis) return !1;
|
|
1472
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = pt({
|
|
1473
|
+
min: e.min,
|
|
1474
|
+
max: e.max,
|
|
1475
|
+
lastPrice: this.currentPriceLine.getPrice(),
|
|
1476
|
+
tagPrecision: this.marketConfig?.pricePrecision ?? null,
|
|
1477
|
+
locale: this.numberLocale,
|
|
1478
|
+
fontFamily: t.font.family,
|
|
1479
|
+
fontSizeSmall: t.font.sizeSmall,
|
|
1480
|
+
measure: (e, t) => this.measureText(e, t)
|
|
1481
|
+
}), r = mt(this.priceAxisWidth, n);
|
|
1482
|
+
return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
1483
|
+
}
|
|
1484
|
+
measureText(e, t) {
|
|
1485
|
+
this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null);
|
|
1486
|
+
let n = this.measureCtx;
|
|
1487
|
+
return n ? (n.font = t, n.measureText(e).width) : e.length * 7;
|
|
1399
1488
|
}
|
|
1400
1489
|
emitViewportEvents() {
|
|
1401
1490
|
let e = this.viewport.getState(), t = Math.max(0, Math.floor(e.visibleRange.from)), n = Math.max(t, Math.ceil(e.visibleRange.to));
|
|
@@ -1425,7 +1514,7 @@ var ft = 6, pt = class {
|
|
|
1425
1514
|
buildPanelRenderInfos() {
|
|
1426
1515
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
1427
1516
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
1428
|
-
let i =
|
|
1517
|
+
let i = st(this.indicatorEngine.getOutput(e.config.id), n, r), a = {
|
|
1429
1518
|
x: e.rect.x,
|
|
1430
1519
|
y: e.rect.y + 20,
|
|
1431
1520
|
width: e.rect.width,
|
|
@@ -1455,7 +1544,7 @@ var ft = 6, pt = class {
|
|
|
1455
1544
|
indicatorEngine: this.features.indicators ? this.indicatorEngine : null,
|
|
1456
1545
|
drawingRenderer: this.features.drawings ? this.drawingRenderer : null,
|
|
1457
1546
|
tradingRenderer: this.features.trading ? this.tradingRenderer : null,
|
|
1458
|
-
currentPriceLine: this.
|
|
1547
|
+
currentPriceLine: this.currentPriceLine,
|
|
1459
1548
|
chartLegend: this.features.legend ? this.chartLegend : null,
|
|
1460
1549
|
volumeRenderer: this.features.volume ? this.volumeRenderer : null,
|
|
1461
1550
|
volumeProfile: this.volumeProfile,
|
|
@@ -1486,7 +1575,7 @@ var ft = 6, pt = class {
|
|
|
1486
1575
|
});
|
|
1487
1576
|
}
|
|
1488
1577
|
drawOverlayPlugins(e, t) {
|
|
1489
|
-
let n =
|
|
1578
|
+
let n = I(this.pluginManager.getOverlays(), t);
|
|
1490
1579
|
if (n.length === 0) return;
|
|
1491
1580
|
let r = {
|
|
1492
1581
|
viewport: this.viewport.getState(),
|
|
@@ -1497,7 +1586,7 @@ var ft = 6, pt = class {
|
|
|
1497
1586
|
}
|
|
1498
1587
|
buildPriceLimits() {
|
|
1499
1588
|
if (!this.marketConfig?.priceLimits?.enabled || !this.marketConfig.priceLimits.referencePrice) return null;
|
|
1500
|
-
let e =
|
|
1589
|
+
let e = c(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
|
|
1501
1590
|
return e ? {
|
|
1502
1591
|
...e,
|
|
1503
1592
|
colors: this.marketConfig.colorScheme ? {
|
|
@@ -1507,26 +1596,26 @@ var ft = 6, pt = class {
|
|
|
1507
1596
|
} : void 0
|
|
1508
1597
|
} : null;
|
|
1509
1598
|
}
|
|
1510
|
-
},
|
|
1599
|
+
}, H = [
|
|
1511
1600
|
"time",
|
|
1512
1601
|
"timestamp",
|
|
1513
1602
|
"date",
|
|
1514
1603
|
"datetime",
|
|
1515
1604
|
"t"
|
|
1516
|
-
],
|
|
1605
|
+
], U = ["open", "o"], W = ["high", "h"], G = ["low", "l"], K = ["close", "c"], q = [
|
|
1517
1606
|
"volume",
|
|
1518
1607
|
"vol",
|
|
1519
1608
|
"v"
|
|
1520
1609
|
];
|
|
1521
|
-
function
|
|
1610
|
+
function J(e) {
|
|
1522
1611
|
let t = e.trim();
|
|
1523
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
1612
|
+
return t ? t[0] === "[" || t[0] === "{" ? St(t) : Ct(t) : {
|
|
1524
1613
|
data: [],
|
|
1525
1614
|
rowCount: 0,
|
|
1526
1615
|
skipped: 0
|
|
1527
1616
|
};
|
|
1528
1617
|
}
|
|
1529
|
-
function
|
|
1618
|
+
function St(e) {
|
|
1530
1619
|
let t;
|
|
1531
1620
|
try {
|
|
1532
1621
|
t = JSON.parse(e);
|
|
@@ -1536,19 +1625,19 @@ function mt(e) {
|
|
|
1536
1625
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
1537
1626
|
let n = [], r = 0;
|
|
1538
1627
|
for (let e of t) {
|
|
1539
|
-
let t = Array.isArray(e) ?
|
|
1628
|
+
let t = Array.isArray(e) ? Dt(e) : Et(e);
|
|
1540
1629
|
t ? n.push(t) : r++;
|
|
1541
1630
|
}
|
|
1542
|
-
return
|
|
1631
|
+
return Q(n, t.length, r);
|
|
1543
1632
|
}
|
|
1544
|
-
function
|
|
1633
|
+
function Ct(e) {
|
|
1545
1634
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
1546
1635
|
if (t.length === 0) return {
|
|
1547
1636
|
data: [],
|
|
1548
1637
|
rowCount: 0,
|
|
1549
1638
|
skipped: 0
|
|
1550
1639
|
};
|
|
1551
|
-
let n =
|
|
1640
|
+
let n = wt(t[0]), r = Y(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Tt(r) : {
|
|
1552
1641
|
time: 0,
|
|
1553
1642
|
open: 1,
|
|
1554
1643
|
high: 2,
|
|
@@ -1559,7 +1648,7 @@ function ht(e) {
|
|
|
1559
1648
|
if (a.time < 0 || a.open < 0 || a.high < 0 || a.low < 0 || a.close < 0) throw Error("CSV is missing required column(s): time, open, high, low, close");
|
|
1560
1649
|
let o = [], s = 0;
|
|
1561
1650
|
for (let e = +!!i; e < t.length; e++) {
|
|
1562
|
-
let r =
|
|
1651
|
+
let r = Y(t[e], n), i = Z(r[a.time]), c = X(r[a.open]), l = X(r[a.high]), u = X(r[a.low]), d = X(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
1563
1652
|
if (i === null || ![
|
|
1564
1653
|
c,
|
|
1565
1654
|
l,
|
|
@@ -1578,9 +1667,9 @@ function ht(e) {
|
|
|
1578
1667
|
volume: Number.isFinite(f) ? f : 0
|
|
1579
1668
|
});
|
|
1580
1669
|
}
|
|
1581
|
-
return
|
|
1670
|
+
return Q(o, t.length - +!!i, s);
|
|
1582
1671
|
}
|
|
1583
|
-
function
|
|
1672
|
+
function wt(e) {
|
|
1584
1673
|
let t = {
|
|
1585
1674
|
",": 0,
|
|
1586
1675
|
";": 0,
|
|
@@ -1592,7 +1681,7 @@ function gt(e) {
|
|
|
1592
1681
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
1593
1682
|
return n;
|
|
1594
1683
|
}
|
|
1595
|
-
function
|
|
1684
|
+
function Y(e, t) {
|
|
1596
1685
|
let n = [], r = "", i = !1;
|
|
1597
1686
|
for (let a = 0; a < e.length; a++) {
|
|
1598
1687
|
let o = e[a];
|
|
@@ -1600,25 +1689,25 @@ function J(e, t) {
|
|
|
1600
1689
|
}
|
|
1601
1690
|
return n.push(r), n;
|
|
1602
1691
|
}
|
|
1603
|
-
function
|
|
1692
|
+
function Tt(e) {
|
|
1604
1693
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
1605
1694
|
return {
|
|
1606
|
-
time: t(
|
|
1607
|
-
open: t(
|
|
1608
|
-
high: t(
|
|
1609
|
-
low: t(
|
|
1610
|
-
close: t(
|
|
1611
|
-
volume: t(
|
|
1695
|
+
time: t(H),
|
|
1696
|
+
open: t(U),
|
|
1697
|
+
high: t(W),
|
|
1698
|
+
low: t(G),
|
|
1699
|
+
close: t(K),
|
|
1700
|
+
volume: t(q)
|
|
1612
1701
|
};
|
|
1613
1702
|
}
|
|
1614
|
-
function
|
|
1703
|
+
function Et(e) {
|
|
1615
1704
|
let t = (t) => {
|
|
1616
1705
|
for (let n of t) {
|
|
1617
1706
|
if (e[n] !== void 0) return e[n];
|
|
1618
1707
|
let t = n.toUpperCase();
|
|
1619
1708
|
if (e[t] !== void 0) return e[t];
|
|
1620
1709
|
}
|
|
1621
|
-
}, n =
|
|
1710
|
+
}, n = Z(String(t(H) ?? "")), r = Number(t(U)), i = Number(t(W)), a = Number(t(G)), o = Number(t(K)), s = Number(t(q) ?? 0);
|
|
1622
1711
|
return n === null || ![
|
|
1623
1712
|
r,
|
|
1624
1713
|
i,
|
|
@@ -1633,9 +1722,9 @@ function vt(e) {
|
|
|
1633
1722
|
volume: Number.isFinite(s) ? s : 0
|
|
1634
1723
|
};
|
|
1635
1724
|
}
|
|
1636
|
-
function
|
|
1725
|
+
function Dt(e) {
|
|
1637
1726
|
if (e.length < 5) return null;
|
|
1638
|
-
let t =
|
|
1727
|
+
let t = Z(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
|
|
1639
1728
|
return t === null || ![
|
|
1640
1729
|
n,
|
|
1641
1730
|
r,
|
|
@@ -1650,10 +1739,10 @@ function yt(e) {
|
|
|
1650
1739
|
volume: Number.isFinite(o) ? o : 0
|
|
1651
1740
|
};
|
|
1652
1741
|
}
|
|
1653
|
-
function
|
|
1742
|
+
function X(e) {
|
|
1654
1743
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
1655
1744
|
}
|
|
1656
|
-
function
|
|
1745
|
+
function Z(e) {
|
|
1657
1746
|
let t = e.trim();
|
|
1658
1747
|
if (!t) return null;
|
|
1659
1748
|
let n = Number(t);
|
|
@@ -1661,7 +1750,7 @@ function X(e) {
|
|
|
1661
1750
|
let r = Date.parse(t);
|
|
1662
1751
|
return Number.isFinite(r) ? r : null;
|
|
1663
1752
|
}
|
|
1664
|
-
function
|
|
1753
|
+
function Q(e, t, n) {
|
|
1665
1754
|
e.sort((e, t) => e.time - t.time);
|
|
1666
1755
|
let r = [];
|
|
1667
1756
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -1673,7 +1762,7 @@ function Z(e, t, n) {
|
|
|
1673
1762
|
}
|
|
1674
1763
|
//#endregion
|
|
1675
1764
|
//#region src/io/DragDropImporter.ts
|
|
1676
|
-
var
|
|
1765
|
+
var Ot = class {
|
|
1677
1766
|
host;
|
|
1678
1767
|
overlay = null;
|
|
1679
1768
|
callbacks;
|
|
@@ -1706,7 +1795,7 @@ var Q = class {
|
|
|
1706
1795
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
1707
1796
|
let t = e.dataTransfer?.files?.[0];
|
|
1708
1797
|
if (t) try {
|
|
1709
|
-
let e =
|
|
1798
|
+
let e = J(await t.text());
|
|
1710
1799
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
1711
1800
|
this.callbacks.onData(e.data, e, t);
|
|
1712
1801
|
} catch (e) {
|
|
@@ -1741,6 +1830,6 @@ function $(e) {
|
|
|
1741
1830
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
1742
1831
|
}
|
|
1743
1832
|
//#endregion
|
|
1744
|
-
export {
|
|
1833
|
+
export { vt as a, _t as c, L as d, P as f, B as i, ht as l, A as m, J as n, z as o, j as p, xt as r, gt as s, Ot as t, I as u };
|
|
1745
1834
|
|
|
1746
|
-
//# sourceMappingURL=DragDropImporter-
|
|
1835
|
+
//# sourceMappingURL=DragDropImporter-BcTzFeRP.js.map
|