@tradecanvas/core 0.6.0 → 0.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.
- package/README.md +108 -108
- package/dist/charts/HLCAreaRenderer.d.ts +6 -0
- package/dist/charts/HLCAreaRenderer.d.ts.map +1 -0
- package/dist/charts/LineWithMarkersRenderer.d.ts +6 -0
- package/dist/charts/LineWithMarkersRenderer.d.ts.map +1 -0
- package/dist/charts/StepLineRenderer.d.ts +6 -0
- package/dist/charts/StepLineRenderer.d.ts.map +1 -0
- package/dist/charts/VolumeCandleRenderer.d.ts +6 -0
- package/dist/charts/VolumeCandleRenderer.d.ts.map +1 -0
- package/dist/charts/index.d.ts +4 -0
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/engine/RenderEngine.d.ts +6 -0
- package/dist/engine/RenderEngine.d.ts.map +1 -1
- package/dist/features/SignalMarkerManager.d.ts +30 -0
- package/dist/features/SignalMarkerManager.d.ts.map +1 -0
- package/dist/features/TradeZoneManager.d.ts +32 -0
- package/dist/features/TradeZoneManager.d.ts.map +1 -0
- package/dist/features/index.d.ts +2 -0
- package/dist/features/index.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +736 -506
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DARK_THEME as e, DEFAULT_BAR_SPACING as t, DEFAULT_BAR_WIDTH as n, DEFAULT_RECONNECT as r,
|
|
1
|
+
import { DARK_THEME as e, DEFAULT_BAR_SPACING as t, DEFAULT_BAR_WIDTH as n, DEFAULT_RECONNECT as r, DEFAULT_SIGNAL_STYLE as i, DEFAULT_STREAM_CONFIG as a, DEFAULT_TRADE_ZONE_STYLE as o, DEFAULT_TRADING_CONFIG as s, LIGHT_THEME as c, LayerType as l, PRICE_AXIS_WIDTH as u, TIME_AXIS_HEIGHT as d, clamp as f, computePriceRange as p, computeTickStep as m, formatPrice as h, lerpColor as g, sliceVisibleData as _, timeframeToMs as v, withAlpha as y } from "@tradecanvas/commons";
|
|
2
2
|
//#region src/engine/CanvasLayer.ts
|
|
3
|
-
var
|
|
3
|
+
var b = class {
|
|
4
4
|
canvas;
|
|
5
5
|
ctx;
|
|
6
6
|
dpr = 1;
|
|
@@ -24,7 +24,7 @@ var v = class {
|
|
|
24
24
|
destroy() {
|
|
25
25
|
this.canvas.remove();
|
|
26
26
|
}
|
|
27
|
-
},
|
|
27
|
+
}, x = class {
|
|
28
28
|
layers = /* @__PURE__ */ new Map();
|
|
29
29
|
constructor(e) {
|
|
30
30
|
this.container = e;
|
|
@@ -32,11 +32,11 @@ var v = class {
|
|
|
32
32
|
createLayers() {
|
|
33
33
|
this.destroy();
|
|
34
34
|
for (let e of [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
]) this.layers.set(e, new
|
|
35
|
+
l.Background,
|
|
36
|
+
l.Main,
|
|
37
|
+
l.Overlay,
|
|
38
|
+
l.UI
|
|
39
|
+
]) this.layers.set(e, new b(this.container, e));
|
|
40
40
|
}
|
|
41
41
|
getLayer(e) {
|
|
42
42
|
return this.layers.get(e);
|
|
@@ -48,7 +48,7 @@ var v = class {
|
|
|
48
48
|
for (let e of this.layers.values()) e.destroy();
|
|
49
49
|
this.layers.clear();
|
|
50
50
|
}
|
|
51
|
-
},
|
|
51
|
+
}, S = class {
|
|
52
52
|
animFrameId = 0;
|
|
53
53
|
running = !1;
|
|
54
54
|
dirtyLayers = /* @__PURE__ */ new Set();
|
|
@@ -61,7 +61,7 @@ var v = class {
|
|
|
61
61
|
this.dirtyLayers.add(e), this.running && !this.animFrameId && this.scheduleFrame();
|
|
62
62
|
}
|
|
63
63
|
markAllDirty() {
|
|
64
|
-
this.dirtyLayers.add(
|
|
64
|
+
this.dirtyLayers.add(l.Background), this.dirtyLayers.add(l.Main), this.dirtyLayers.add(l.Overlay), this.dirtyLayers.add(l.UI), this.running && !this.animFrameId && this.scheduleFrame();
|
|
65
65
|
}
|
|
66
66
|
start() {
|
|
67
67
|
this.running = !0, this.markAllDirty();
|
|
@@ -77,7 +77,7 @@ var v = class {
|
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
},
|
|
80
|
+
}, C = class {
|
|
81
81
|
observer = null;
|
|
82
82
|
callback = null;
|
|
83
83
|
currentDpr = 1;
|
|
@@ -120,10 +120,10 @@ var v = class {
|
|
|
120
120
|
};
|
|
121
121
|
//#endregion
|
|
122
122
|
//#region src/viewport/ScaleMapping.ts
|
|
123
|
-
function
|
|
123
|
+
function w(e, t) {
|
|
124
124
|
return e * (t.barWidth + t.barSpacing) - t.offset + t.chartRect.x + t.barWidth / 2;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function T(e, t) {
|
|
127
127
|
let { min: n, max: r } = t.priceRange;
|
|
128
128
|
if (t.logScale && n > 0 && r > 0) {
|
|
129
129
|
let i = Math.log(n), a = Math.log(r) - i;
|
|
@@ -136,11 +136,11 @@ function C(e, t) {
|
|
|
136
136
|
let a = (e - n) / i;
|
|
137
137
|
return t.chartRect.y + t.chartRect.height * (1 - a);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function E(e, t) {
|
|
140
140
|
let n = t.barWidth + t.barSpacing;
|
|
141
141
|
return Math.round((e - t.chartRect.x - t.barWidth / 2 + t.offset) / n);
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function D(e, t) {
|
|
144
144
|
let { min: n, max: r } = t.priceRange, i = 1 - (e - t.chartRect.y) / t.chartRect.height;
|
|
145
145
|
if (t.logScale && n > 0 && r > 0) {
|
|
146
146
|
let e = Math.log(n);
|
|
@@ -148,7 +148,7 @@ function T(e, t) {
|
|
|
148
148
|
}
|
|
149
149
|
return n + (r - n) * i;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function O(e, t) {
|
|
152
152
|
if (t.length === 0) return -1;
|
|
153
153
|
if (e <= t[0].time) return 0;
|
|
154
154
|
if (e >= t[t.length - 1].time) return t.length - 1;
|
|
@@ -165,7 +165,7 @@ function E(e, t) {
|
|
|
165
165
|
}
|
|
166
166
|
//#endregion
|
|
167
167
|
//#region src/engine/RenderEngine.ts
|
|
168
|
-
var
|
|
168
|
+
var k = class {
|
|
169
169
|
layerManager;
|
|
170
170
|
renderLoop;
|
|
171
171
|
dprManager;
|
|
@@ -176,14 +176,14 @@ var D = class {
|
|
|
176
176
|
uiLayer;
|
|
177
177
|
onContainerResize = null;
|
|
178
178
|
constructor(e) {
|
|
179
|
-
this.layerManager = new
|
|
179
|
+
this.layerManager = new x(e), this.renderLoop = new S(), this.dprManager = new C(e), this.layerManager.createLayers(), this.cacheLayerRefs(), this.renderLoop.setCallback((e) => this.render(e)), this.dprManager.onResize((e, t) => {
|
|
180
180
|
this.layerManager.resize(e, t), this.renderLoop.markAllDirty(), this.onContainerResize?.(e);
|
|
181
181
|
});
|
|
182
182
|
let t = this.dprManager.getContainerSize(), n = this.dprManager.getDpr();
|
|
183
183
|
this.layerManager.resize(t, n);
|
|
184
184
|
}
|
|
185
185
|
cacheLayerRefs() {
|
|
186
|
-
this.bgLayer = this.layerManager.getLayer(
|
|
186
|
+
this.bgLayer = this.layerManager.getLayer(l.Background), this.mainLayer = this.layerManager.getLayer(l.Main), this.overlayLayer = this.layerManager.getLayer(l.Overlay), this.uiLayer = this.layerManager.getLayer(l.UI);
|
|
187
187
|
}
|
|
188
188
|
setRenderContext(e) {
|
|
189
189
|
this.renderCtx = e;
|
|
@@ -202,7 +202,7 @@ var D = class {
|
|
|
202
202
|
if (!t) return;
|
|
203
203
|
let { viewport: n, theme: r, data: i } = t, a = t.numberLocale ?? "en-US";
|
|
204
204
|
if (!(n.chartRect.width <= 0 || n.chartRect.height <= 0)) {
|
|
205
|
-
if (e.has(
|
|
205
|
+
if (e.has(l.Background) && this.bgLayer && (this.bgLayer.clear(), t.gridRenderer?.render(this.bgLayer.ctx, n, r), t.sessionBreaks?.render(this.bgLayer.ctx, n, r, i), t.watermark?.render(this.bgLayer.ctx, n, r)), e.has(l.Main) && this.mainLayer) {
|
|
206
206
|
this.mainLayer.clear();
|
|
207
207
|
let e = this.mainLayer.ctx;
|
|
208
208
|
e.save(), e.beginPath(), e.rect(n.chartRect.x, n.chartRect.y, n.chartRect.width, n.chartRect.height), e.clip(), t.volumeRenderer?.render(e, i, n, r), t.chartRenderer?.render(e, i, n, r), t.compareRenderer?.render(e, i, n, r), t.indicatorEngine?.renderOverlays(e, n), e.restore();
|
|
@@ -218,51 +218,51 @@ var D = class {
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
if (e.has(
|
|
221
|
+
if (e.has(l.Overlay) && this.overlayLayer) {
|
|
222
222
|
this.overlayLayer.clear();
|
|
223
223
|
let e = this.overlayLayer.ctx;
|
|
224
|
-
t.priceLimits && this.renderPriceLimits(e, n, r, t.priceLimits), t.drawingRenderer?.render(e, n), t.tradingRenderer?.render(e, n, r), t.crosshairHandler?.render(e, n, r);
|
|
224
|
+
t.priceLimits && this.renderPriceLimits(e, n, r, t.priceLimits), t.tradeZoneManager?.render(e, n, r), t.drawingRenderer?.render(e, n), t.tradingRenderer?.render(e, n, r), t.signalMarkerManager?.render(e, n, r), t.alertManager?.render(e, n, r), t.crosshairHandler?.render(e, n, r);
|
|
225
225
|
let i = t.crosshairHandler?.getPosition();
|
|
226
226
|
if (i && t.panels.length > 0) for (let n of t.panels) {
|
|
227
227
|
let a = n.rect;
|
|
228
228
|
if (i.x >= a.x && i.x <= a.x + a.width && i.y >= a.y && i.y <= a.y + a.height) {
|
|
229
|
-
let o = n.viewport, s = i.x, c =
|
|
230
|
-
s =
|
|
229
|
+
let o = n.viewport, s = i.x, c = E(s, o);
|
|
230
|
+
s = w(Math.max(0, Math.min((t.data?.length ?? 1) - 1, Math.round(c))), o), e.save(), e.beginPath(), e.rect(a.x, a.y, a.width, a.height), e.clip(), e.setLineDash([4, 4]), e.strokeStyle = r.crosshair, e.lineWidth = 1, e.beginPath(), e.moveTo(Math.round(s) + .5, a.y), e.lineTo(Math.round(s) + .5, a.y + a.height), e.stroke(), e.beginPath(), e.moveTo(a.x, Math.round(i.y) + .5), e.lineTo(a.x + a.width, Math.round(i.y) + .5), e.stroke(), e.setLineDash([]), e.restore();
|
|
231
231
|
break;
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
if (e.has(
|
|
235
|
+
if (e.has(l.UI) && this.uiLayer) {
|
|
236
236
|
this.uiLayer.clear();
|
|
237
237
|
let e = this.uiLayer.ctx;
|
|
238
238
|
if (t.priceAxis?.render(e, n, r), t.tradingRenderer?.renderAxisBadges(e, n, r), t.currentPriceLine?.render(e, n, r), t.timeAxis?.render(e, n, r, i, t.timeAxisY), t.chartLegend?.render(e, n, r, i), t.barCountdown?.render(e, n, r, i), t.panels.length > 0) {
|
|
239
|
-
let n = t.crosshairHandler?.getPosition(), o = t.indicatorEngine, s = `${r.font.sizeSmall}px ${r.font.family}`,
|
|
239
|
+
let n = t.crosshairHandler?.getPosition(), o = t.indicatorEngine, s = `${r.font.sizeSmall}px ${r.font.family}`, c;
|
|
240
240
|
if (o) {
|
|
241
241
|
let e = o.getPanelIndicators();
|
|
242
|
-
|
|
243
|
-
for (let t of e)
|
|
242
|
+
c = /* @__PURE__ */ new Map();
|
|
243
|
+
for (let t of e) c.set(t.instanceId, t);
|
|
244
244
|
}
|
|
245
|
-
for (let
|
|
246
|
-
let t =
|
|
247
|
-
if (
|
|
245
|
+
for (let l of t.panels) {
|
|
246
|
+
let t = l.viewport, d = l.rect, { min: f, max: p } = t.priceRange;
|
|
247
|
+
if (p - f <= 0 || d.height <= 0) continue;
|
|
248
248
|
let g = d.x + d.width, _ = t.chartRect;
|
|
249
249
|
e.strokeStyle = r.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(g + .5, d.y), e.lineTo(g + .5, d.y + d.height), e.stroke();
|
|
250
|
-
let v = f
|
|
250
|
+
let v = m(f, p, 4), y = Math.ceil(f / v) * v, b = v < 1 ? Math.ceil(-Math.log10(v)) + 1 : +(v < 10);
|
|
251
251
|
e.font = s, e.textBaseline = "middle", e.textAlign = "left";
|
|
252
|
-
for (let n = y; n <=
|
|
253
|
-
let i =
|
|
254
|
-
i < _.y || i > _.y + _.height || (e.strokeStyle = r.axisLine, e.beginPath(), e.moveTo(g, Math.round(i) + .5), e.lineTo(g + 4, Math.round(i) + .5), e.stroke(), e.fillStyle = r.axisLabel, e.fillText(
|
|
252
|
+
for (let n = y; n <= p; n += v) {
|
|
253
|
+
let i = T(n, t);
|
|
254
|
+
i < _.y || i > _.y + _.height || (e.strokeStyle = r.axisLine, e.beginPath(), e.moveTo(g, Math.round(i) + .5), e.lineTo(g + 4, Math.round(i) + .5), e.stroke(), e.fillStyle = r.axisLabel, e.fillText(h(n, b, a), g + 6, i));
|
|
255
255
|
}
|
|
256
256
|
if (n && n.x >= d.x && n.x <= d.x + d.width && n.y >= d.y && n.y <= d.y + d.height) {
|
|
257
|
-
let i =
|
|
257
|
+
let i = h(D(n.y, t), b, a);
|
|
258
258
|
e.font = `bold ${r.font.sizeSmall}px ${r.font.family}`;
|
|
259
|
-
let o = e.measureText(i).width, s = Math.min(o + 10,
|
|
259
|
+
let o = e.measureText(i).width, s = Math.min(o + 10, u - 2);
|
|
260
260
|
e.fillStyle = r.crosshair, e.fillRect(g + 1, n.y - 9, s, 18), e.fillStyle = r.background, e.textBaseline = "middle", e.textAlign = "left", e.fillText(i, g + 5, n.y);
|
|
261
261
|
}
|
|
262
262
|
if (n && o) {
|
|
263
|
-
let a =
|
|
264
|
-
if (f?.series &&
|
|
265
|
-
let t = f.series[
|
|
263
|
+
let a = E(n.x, t), u = Math.max(0, Math.min((i?.length ?? 1) - 1, Math.round(a))), f = o.getOutput(l.instanceId);
|
|
264
|
+
if (f?.series && u < f.series.length) {
|
|
265
|
+
let t = f.series[u];
|
|
266
266
|
if (t) {
|
|
267
267
|
let n = [];
|
|
268
268
|
for (let e in t) {
|
|
@@ -270,7 +270,7 @@ var D = class {
|
|
|
270
270
|
r !== void 0 && n.push(`${e}: ${r.toFixed(b)}`);
|
|
271
271
|
}
|
|
272
272
|
if (n.length > 0) {
|
|
273
|
-
let t =
|
|
273
|
+
let t = c?.get(l.instanceId), i = t ? e.measureText(t.descriptor.name).width + 14 : 10;
|
|
274
274
|
e.font = s, e.fillStyle = r.textSecondary, e.textBaseline = "top", e.textAlign = "left", e.fillText(n.join(" "), d.x + i, d.y + 6);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
@@ -299,27 +299,25 @@ var D = class {
|
|
|
299
299
|
label: "REF"
|
|
300
300
|
}
|
|
301
301
|
], o = `bold 9px ${n.font.family}`, s = `10px ${n.font.family}`;
|
|
302
|
-
for (let { price: n, color: r, label:
|
|
303
|
-
let a =
|
|
302
|
+
for (let { price: n, color: r, label: c } of a) {
|
|
303
|
+
let a = T(n, t);
|
|
304
304
|
if (a < i.y || a > i.y + i.height) continue;
|
|
305
|
-
e.setLineDash([8, 4]), e.strokeStyle = r, e.lineWidth = 1, e.beginPath(), e.moveTo(i.x, Math.round(a) + .5), e.lineTo(i.x + i.width, Math.round(a) + .5), e.stroke(), e.setLineDash([]), e.font = o, e.fillStyle = r, e.textBaseline = "bottom", e.textAlign = "left", e.fillText(`${
|
|
306
|
-
let
|
|
307
|
-
e.fillStyle = r, e.fillRect(
|
|
305
|
+
e.setLineDash([8, 4]), e.strokeStyle = r, e.lineWidth = 1, e.beginPath(), e.moveTo(i.x, Math.round(a) + .5), e.lineTo(i.x + i.width, Math.round(a) + .5), e.stroke(), e.setLineDash([]), e.font = o, e.fillStyle = r, e.textBaseline = "bottom", e.textAlign = "left", e.fillText(`${c} ${n.toFixed(2)}`, i.x + 4, a - 2);
|
|
306
|
+
let l = i.x + i.width + 1;
|
|
307
|
+
e.fillStyle = r, e.fillRect(l, a - 7, u - 2, 14), e.fillStyle = "#000", e.font = s, e.textBaseline = "middle", e.textAlign = "left", e.fillText(n.toFixed(2), l + 4, a);
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
destroy() {
|
|
311
311
|
this.renderLoop.stop(), this.dprManager.destroy(), this.layerManager.destroy();
|
|
312
312
|
}
|
|
313
|
-
},
|
|
313
|
+
}, A = class {
|
|
314
314
|
state;
|
|
315
315
|
dataLength = 0;
|
|
316
316
|
minBarWidth;
|
|
317
317
|
maxBarWidth;
|
|
318
318
|
rightMarginBars;
|
|
319
319
|
constructor(e, r, i = 2, a = 30, o = 5) {
|
|
320
|
-
this.minBarWidth = i, this.maxBarWidth = a, this.rightMarginBars = o
|
|
321
|
-
let s = this.computeChartRect(e, r);
|
|
322
|
-
this.state = {
|
|
320
|
+
this.minBarWidth = i, this.maxBarWidth = a, this.rightMarginBars = o, this.state = {
|
|
323
321
|
visibleRange: {
|
|
324
322
|
from: 0,
|
|
325
323
|
to: 0
|
|
@@ -331,7 +329,7 @@ var D = class {
|
|
|
331
329
|
barWidth: n,
|
|
332
330
|
barSpacing: t,
|
|
333
331
|
offset: 0,
|
|
334
|
-
chartRect:
|
|
332
|
+
chartRect: this.computeChartRect(e, r)
|
|
335
333
|
};
|
|
336
334
|
}
|
|
337
335
|
getState() {
|
|
@@ -358,8 +356,8 @@ var D = class {
|
|
|
358
356
|
return {
|
|
359
357
|
x: 0,
|
|
360
358
|
y: 0,
|
|
361
|
-
width: Math.max(0, e -
|
|
362
|
-
height: Math.max(0, t -
|
|
359
|
+
width: Math.max(0, e - u),
|
|
360
|
+
height: Math.max(0, t - d)
|
|
363
361
|
};
|
|
364
362
|
}
|
|
365
363
|
resize(e, t) {
|
|
@@ -374,7 +372,7 @@ var D = class {
|
|
|
374
372
|
}, this.clampOffset(), this.updateVisibleRange();
|
|
375
373
|
}
|
|
376
374
|
updateData(e, t) {
|
|
377
|
-
this.dataLength = e.length, this.dataLength !== 0 && (this.clampOffset(), this.updateVisibleRange(), t && (this.state.priceRange =
|
|
375
|
+
this.dataLength = e.length, this.dataLength !== 0 && (this.clampOffset(), this.updateVisibleRange(), t && (this.state.priceRange = p(e, this.state.visibleRange.from, Math.min(this.state.visibleRange.to, this.dataLength - 1), .08)));
|
|
378
376
|
}
|
|
379
377
|
setPriceRange(e, t) {
|
|
380
378
|
this.state.priceRange = {
|
|
@@ -394,7 +392,7 @@ var D = class {
|
|
|
394
392
|
this.state.offset = n - this.state.chartRect.width + t, this.updateVisibleRange();
|
|
395
393
|
}
|
|
396
394
|
zoom(e, t) {
|
|
397
|
-
let n = this.state.barWidth, r =
|
|
395
|
+
let n = this.state.barWidth, r = f(n * (1 + e), this.minBarWidth, this.maxBarWidth);
|
|
398
396
|
if (r === n) return;
|
|
399
397
|
let i = this.state.barWidth + this.state.barSpacing, a = (this.state.offset + t) / i;
|
|
400
398
|
this.state.barWidth = r;
|
|
@@ -404,7 +402,7 @@ var D = class {
|
|
|
404
402
|
clampOffset() {
|
|
405
403
|
if (this.state.chartRect.width <= 0) return;
|
|
406
404
|
let e = this.state.barWidth + this.state.barSpacing, t = this.dataLength * e, n = this.rightMarginBars * e, r = t - this.state.chartRect.width + n, i, a;
|
|
407
|
-
r > 0 ? (i = -(this.state.chartRect.width * .5), a = r) : (i = r, a = r), this.state.offset =
|
|
405
|
+
r > 0 ? (i = -(this.state.chartRect.width * .5), a = r) : (i = r, a = r), this.state.offset = f(this.state.offset, i, a);
|
|
408
406
|
}
|
|
409
407
|
updateVisibleRange() {
|
|
410
408
|
let e = this.state.barWidth + this.state.barSpacing;
|
|
@@ -418,12 +416,12 @@ var D = class {
|
|
|
418
416
|
};
|
|
419
417
|
//#endregion
|
|
420
418
|
//#region src/viewport/DataWindow.ts
|
|
421
|
-
function
|
|
422
|
-
return
|
|
419
|
+
function ee(e, t) {
|
|
420
|
+
return _(e, t.visibleRange.from, t.visibleRange.to);
|
|
423
421
|
}
|
|
424
422
|
//#endregion
|
|
425
423
|
//#region src/charts/CandlestickRenderer.ts
|
|
426
|
-
var
|
|
424
|
+
var te = class {
|
|
427
425
|
render(e, t, n, r) {
|
|
428
426
|
let { from: i, to: a } = n.visibleRange, o = n.barWidth, s = o / 2, c = o + n.barSpacing, l = -n.offset + n.chartRect.x + s, { min: u, max: d } = n.priceRange, f = d - u;
|
|
429
427
|
if (f === 0) return;
|
|
@@ -436,7 +434,7 @@ var A = class {
|
|
|
436
434
|
}
|
|
437
435
|
e.strokeStyle = r.candleUpWick, e.lineWidth = 1, e.stroke(_), e.strokeStyle = r.candleDownWick, e.stroke(v), e.fillStyle = r.candleUp, e.fill(y), e.fillStyle = r.candleDown, e.fill(b);
|
|
438
436
|
}
|
|
439
|
-
},
|
|
437
|
+
}, ne = class {
|
|
440
438
|
render(e, t, n, r) {
|
|
441
439
|
let { from: i, to: a } = n.visibleRange;
|
|
442
440
|
if (i > a || t.length === 0) return;
|
|
@@ -451,7 +449,7 @@ var A = class {
|
|
|
451
449
|
}
|
|
452
450
|
e.stroke();
|
|
453
451
|
}
|
|
454
|
-
},
|
|
452
|
+
}, re = class {
|
|
455
453
|
render(e, t, n, r) {
|
|
456
454
|
let { from: i, to: a } = n.visibleRange;
|
|
457
455
|
if (i > a || t.length === 0) return;
|
|
@@ -465,7 +463,7 @@ var A = class {
|
|
|
465
463
|
for (let n = i + 1; n <= a && n < t.length; n++) e.lineTo(n * o + s, d + (l - t[n].close) * p);
|
|
466
464
|
e.stroke();
|
|
467
465
|
}
|
|
468
|
-
},
|
|
466
|
+
}, ie = class {
|
|
469
467
|
render(e, t, n, r) {
|
|
470
468
|
let { from: i, to: a } = n.visibleRange, o = n.barWidth, s = o / 2, c = o + n.barSpacing, l = -n.offset + n.chartRect.x + s, { min: u, max: d } = n.priceRange, f = d - u;
|
|
471
469
|
if (f === 0) return;
|
|
@@ -476,7 +474,7 @@ var A = class {
|
|
|
476
474
|
}
|
|
477
475
|
e.lineWidth = 1, e.strokeStyle = r.candleUp, e.stroke(_), e.strokeStyle = r.candleDown, e.stroke(v);
|
|
478
476
|
}
|
|
479
|
-
},
|
|
477
|
+
}, ae = class {
|
|
480
478
|
render(e, t, n, r) {
|
|
481
479
|
let { from: i, to: a } = n.visibleRange, o = n.barWidth, s = o / 2, c = o + n.barSpacing, l = -n.offset + n.chartRect.x + s, { min: u, max: d } = n.priceRange, f = d - u;
|
|
482
480
|
if (f === 0) return;
|
|
@@ -495,7 +493,7 @@ var A = class {
|
|
|
495
493
|
e.strokeStyle = r.candleDown;
|
|
496
494
|
for (let t of b) e.strokeRect(t.x, t.y, t.w, t.h);
|
|
497
495
|
}
|
|
498
|
-
},
|
|
496
|
+
}, oe = class {
|
|
499
497
|
baselinePrice = null;
|
|
500
498
|
setBaseline(e) {
|
|
501
499
|
this.baselinePrice = e;
|
|
@@ -536,7 +534,7 @@ var A = class {
|
|
|
536
534
|
for (let a = t; a <= n && a < e.length; a++) r += e[a].close, i++;
|
|
537
535
|
return i > 0 ? r / i : 0;
|
|
538
536
|
}
|
|
539
|
-
},
|
|
537
|
+
}, se = class {
|
|
540
538
|
render(e, t, n, r) {
|
|
541
539
|
let { from: i, to: a } = n.visibleRange, o = n.barWidth, s = o / 2, c = o + n.barSpacing, l = -n.offset + n.chartRect.x + s, { min: u, max: d } = n.priceRange, f = d - u;
|
|
542
540
|
if (f === 0) return;
|
|
@@ -547,7 +545,7 @@ var A = class {
|
|
|
547
545
|
}
|
|
548
546
|
e.fillStyle = r.candleUp, e.fill(_), e.fillStyle = r.candleDown, e.fill(v), e.lineWidth = 1, e.strokeStyle = r.candleUp, e.stroke(y), e.strokeStyle = r.candleDown, e.stroke(b);
|
|
549
547
|
}
|
|
550
|
-
},
|
|
548
|
+
}, ce = class {
|
|
551
549
|
render(e, t, n, r) {
|
|
552
550
|
let { from: i, to: a } = n.visibleRange, o = n.barWidth, s = o / 2, c = o + n.barSpacing, l = -n.offset + n.chartRect.x + s, { min: u, max: d } = n.priceRange, f = d - u;
|
|
553
551
|
if (f === 0) return;
|
|
@@ -561,7 +559,7 @@ var A = class {
|
|
|
561
559
|
}
|
|
562
560
|
e.strokeStyle = r.candleUp, e.lineWidth = 3, e.stroke(_), e.strokeStyle = r.candleDown, e.lineWidth = 1, e.stroke(v);
|
|
563
561
|
}
|
|
564
|
-
},
|
|
562
|
+
}, le = class {
|
|
565
563
|
boxSize = 1;
|
|
566
564
|
setBoxSize(e) {
|
|
567
565
|
this.boxSize = e;
|
|
@@ -579,7 +577,88 @@ var A = class {
|
|
|
579
577
|
}
|
|
580
578
|
e.lineWidth = 1.5, e.strokeStyle = r.candleUp, e.stroke(y), e.strokeStyle = r.candleDown, e.stroke(b);
|
|
581
579
|
}
|
|
582
|
-
},
|
|
580
|
+
}, ue = class {
|
|
581
|
+
render(e, t, n, r) {
|
|
582
|
+
let { from: i, to: a } = n.visibleRange, { min: o, max: s } = n.priceRange, c = s - o;
|
|
583
|
+
if (c === 0 || i > a || t.length === 0) return;
|
|
584
|
+
let l = n.barWidth + n.barSpacing, u = -n.offset + n.chartRect.x + n.barWidth / 2, d = n.chartRect.y, f = n.chartRect.height / c, p = n.barWidth, m = 0;
|
|
585
|
+
for (let e = i; e <= a && e < t.length; e++) t[e].volume > m && (m = t[e].volume);
|
|
586
|
+
m === 0 && (m = 1);
|
|
587
|
+
let h = new Path2D(), g = new Path2D(), _ = new Path2D(), v = new Path2D(), y = (e) => e * l + u, b = (e) => d + (s - e) * f;
|
|
588
|
+
for (let e = i; e <= a && e < t.length; e++) {
|
|
589
|
+
let n = t[e], r = y(e), i = b(n.high), a = b(n.low), o = b(n.open), s = b(n.close), c = n.close >= n.open, l = p * Math.max(.2, n.volume / m), u = l / 2, d = c ? h : g;
|
|
590
|
+
d.moveTo(r, i), d.lineTo(r, a);
|
|
591
|
+
let f = c ? s : o, x = Math.max(Math.abs(s - o), 1);
|
|
592
|
+
(c ? _ : v).rect(r - u, f, l, x);
|
|
593
|
+
}
|
|
594
|
+
e.strokeStyle = r.candleUpWick, e.lineWidth = 1, e.stroke(h), e.strokeStyle = r.candleDownWick, e.stroke(g), e.fillStyle = r.candleUp, e.fill(_), e.fillStyle = r.candleDown, e.fill(v);
|
|
595
|
+
}
|
|
596
|
+
}, de = class {
|
|
597
|
+
render(e, t, n, r) {
|
|
598
|
+
let { from: i, to: a } = n.visibleRange;
|
|
599
|
+
if (i > a || t.length === 0) return;
|
|
600
|
+
let { min: o, max: s } = n.priceRange, c = s - o;
|
|
601
|
+
if (c === 0) return;
|
|
602
|
+
let l = n.barWidth + n.barSpacing, u = -n.offset + n.chartRect.x + n.barWidth / 2, d = n.chartRect.y, f = n.chartRect.height / c, p = (e) => e * l + u, m = (e) => d + (s - e) * f, h = [], g = [];
|
|
603
|
+
for (let e = i; e <= a && e < t.length; e++) {
|
|
604
|
+
let n = p(e);
|
|
605
|
+
h.push({
|
|
606
|
+
x: n,
|
|
607
|
+
y: m(t[e].high)
|
|
608
|
+
}), g.push({
|
|
609
|
+
x: n,
|
|
610
|
+
y: m(t[e].low)
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
if (h.length === 0) return;
|
|
614
|
+
let _ = e.createLinearGradient(0, d, 0, d + n.chartRect.height);
|
|
615
|
+
_.addColorStop(0, r.areaTopColor), _.addColorStop(1, r.areaBottomColor), e.beginPath(), e.moveTo(h[0].x, h[0].y);
|
|
616
|
+
for (let t = 1; t < h.length; t++) e.lineTo(h[t].x, h[t].y);
|
|
617
|
+
for (let t = g.length - 1; t >= 0; t--) e.lineTo(g[t].x, g[t].y);
|
|
618
|
+
e.closePath(), e.fillStyle = _, e.fill(), e.beginPath(), e.strokeStyle = r.lineColor, e.lineWidth = 2, e.lineJoin = "round";
|
|
619
|
+
for (let n = i; n <= a && n < t.length; n++) {
|
|
620
|
+
let r = p(n), a = m(t[n].close);
|
|
621
|
+
n === i ? e.moveTo(r, a) : e.lineTo(r, a);
|
|
622
|
+
}
|
|
623
|
+
e.stroke();
|
|
624
|
+
}
|
|
625
|
+
}, fe = class {
|
|
626
|
+
render(e, t, n, r) {
|
|
627
|
+
let { from: i, to: a } = n.visibleRange;
|
|
628
|
+
if (i > a || t.length === 0) return;
|
|
629
|
+
let { min: o, max: s } = n.priceRange, c = s - o;
|
|
630
|
+
if (c === 0) return;
|
|
631
|
+
let l = n.barWidth + n.barSpacing, u = -n.offset + n.chartRect.x + n.barWidth / 2, d = n.chartRect.y, f = n.chartRect.height / c, p = (e) => e * l + u, m = (e) => d + (s - e) * f;
|
|
632
|
+
e.beginPath(), e.strokeStyle = r.lineColor, e.lineWidth = 2, e.lineJoin = "miter";
|
|
633
|
+
let h = 0;
|
|
634
|
+
for (let n = i; n <= a && n < t.length; n++) {
|
|
635
|
+
let r = p(n), a = m(t[n].close);
|
|
636
|
+
n === i ? e.moveTo(r, a) : (e.lineTo(r, h), e.lineTo(r, a)), h = a;
|
|
637
|
+
}
|
|
638
|
+
e.stroke();
|
|
639
|
+
}
|
|
640
|
+
}, pe = class {
|
|
641
|
+
render(e, t, n, r) {
|
|
642
|
+
let { from: i, to: a } = n.visibleRange;
|
|
643
|
+
if (i > a || t.length === 0) return;
|
|
644
|
+
let { min: o, max: s } = n.priceRange, c = s - o;
|
|
645
|
+
if (c === 0) return;
|
|
646
|
+
let l = n.barWidth + n.barSpacing, u = -n.offset + n.chartRect.x + n.barWidth / 2, d = n.chartRect.y, f = n.chartRect.height / c, p = (e) => e * l + u, m = (e) => d + (s - e) * f;
|
|
647
|
+
e.beginPath(), e.strokeStyle = r.lineColor, e.lineWidth = 2, e.lineJoin = "round";
|
|
648
|
+
let h = [];
|
|
649
|
+
for (let n = i; n <= a && n < t.length; n++) {
|
|
650
|
+
let r = p(n), a = m(t[n].close);
|
|
651
|
+
h.push({
|
|
652
|
+
x: r,
|
|
653
|
+
y: a
|
|
654
|
+
}), n === i ? e.moveTo(r, a) : e.lineTo(r, a);
|
|
655
|
+
}
|
|
656
|
+
e.stroke();
|
|
657
|
+
let g = Math.max(2, Math.min(4, n.barWidth * .3)), _ = new Path2D();
|
|
658
|
+
for (let { x: e, y: t } of h) _.moveTo(e + g, t), _.arc(e, t, g, 0, Math.PI * 2);
|
|
659
|
+
e.fillStyle = r.lineColor, e.fill(_), e.strokeStyle = r.background, e.lineWidth = 1, e.stroke(_);
|
|
660
|
+
}
|
|
661
|
+
}, me = class {
|
|
583
662
|
visible = !0;
|
|
584
663
|
heightRatio = .2;
|
|
585
664
|
setVisible(e) {
|
|
@@ -600,7 +679,7 @@ var A = class {
|
|
|
600
679
|
}
|
|
601
680
|
e.globalAlpha = .35, e.fillStyle = r.candleUp, e.fill(h), e.fillStyle = r.candleDown, e.fill(g), e.globalAlpha = 1;
|
|
602
681
|
}
|
|
603
|
-
},
|
|
682
|
+
}, he = class {
|
|
604
683
|
symbols = /* @__PURE__ */ new Map();
|
|
605
684
|
mode = "percent";
|
|
606
685
|
setMode(e) {
|
|
@@ -641,21 +720,21 @@ var A = class {
|
|
|
641
720
|
e.strokeStyle = t.color, e.lineWidth = t.lineWidth ?? 1.5, e.lineJoin = "round", e.beginPath();
|
|
642
721
|
let u = !1, d = Math.min(n.length, t.data.length);
|
|
643
722
|
for (let n = s; n < d; n++) {
|
|
644
|
-
let i =
|
|
723
|
+
let i = w(n, r);
|
|
645
724
|
if (i < a.x - o) continue;
|
|
646
725
|
if (i > a.x + a.width + o) break;
|
|
647
726
|
let s;
|
|
648
|
-
s = this.mode === "percent" ?
|
|
727
|
+
s = this.mode === "percent" ? T(c * (1 + (t.data[n].close - l) / l), r) : T(t.data[n].close, r), u ? e.lineTo(i, s) : (e.moveTo(i, s), u = !0);
|
|
649
728
|
}
|
|
650
729
|
if (e.stroke(), u) {
|
|
651
|
-
let n = Math.min(s + 2, d - 1), i =
|
|
652
|
-
a = this.mode === "percent" ?
|
|
730
|
+
let n = Math.min(s + 2, d - 1), i = w(n, r) + 4, a;
|
|
731
|
+
a = this.mode === "percent" ? T(c * (1 + (t.data[n].close - l) / l), r) - 4 : T(t.data[n].close, r) - 4, e.fillStyle = t.color, e.font = "bold 10px sans-serif", e.textBaseline = "bottom", e.textAlign = "left", e.fillText(t.label, i, a);
|
|
653
732
|
}
|
|
654
733
|
}
|
|
655
734
|
};
|
|
656
735
|
//#endregion
|
|
657
736
|
//#region src/charts/transforms/heikinAshi.ts
|
|
658
|
-
function
|
|
737
|
+
function ge(e) {
|
|
659
738
|
if (e.length === 0) return [];
|
|
660
739
|
let t = [], n = e[0].open, r = (e[0].open + e[0].high + e[0].low + e[0].close) / 4;
|
|
661
740
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -673,10 +752,10 @@ function ue(e) {
|
|
|
673
752
|
}
|
|
674
753
|
//#endregion
|
|
675
754
|
//#region src/charts/transforms/renko.ts
|
|
676
|
-
function
|
|
755
|
+
function _e(e, t) {
|
|
677
756
|
if (e.length === 0) return [];
|
|
678
757
|
let n = t.brickSize;
|
|
679
|
-
t.useATR && e.length > (t.atrPeriod ?? 14) && (n =
|
|
758
|
+
t.useATR && e.length > (t.atrPeriod ?? 14) && (n = ve(e, t.atrPeriod ?? 14)), n <= 0 && (n = 1);
|
|
680
759
|
let r = [], i = Math.round(e[0].close / n) * n, a = e[0].time;
|
|
681
760
|
for (let t = 1; t < e.length; t++) {
|
|
682
761
|
let o = e[t].close - i, s = Math.floor(Math.abs(o) / n);
|
|
@@ -697,7 +776,7 @@ function de(e, t) {
|
|
|
697
776
|
}
|
|
698
777
|
return r;
|
|
699
778
|
}
|
|
700
|
-
function
|
|
779
|
+
function ve(e, t) {
|
|
701
780
|
let n = 0;
|
|
702
781
|
for (let r = 1; r <= Math.min(t, e.length - 1); r++) {
|
|
703
782
|
let t = Math.max(e[r].high - e[r].low, Math.abs(e[r].high - e[r - 1].close), Math.abs(e[r].low - e[r - 1].close));
|
|
@@ -707,7 +786,7 @@ function fe(e, t) {
|
|
|
707
786
|
}
|
|
708
787
|
//#endregion
|
|
709
788
|
//#region src/charts/transforms/lineBreak.ts
|
|
710
|
-
function
|
|
789
|
+
function ye(e, t = 3) {
|
|
711
790
|
if (e.length === 0) return [];
|
|
712
791
|
let n = [], r = 0;
|
|
713
792
|
n.push({
|
|
@@ -748,7 +827,7 @@ function pe(e, t = 3) {
|
|
|
748
827
|
}
|
|
749
828
|
//#endregion
|
|
750
829
|
//#region src/charts/transforms/kagi.ts
|
|
751
|
-
function
|
|
830
|
+
function be(e, t = 4) {
|
|
752
831
|
if (e.length < 2) return e.slice();
|
|
753
832
|
let n = [], r = e[1].close >= e[0].close ? 1 : -1, i = e[0].close, a = e[0].close, o = e[0].close, s = 0;
|
|
754
833
|
for (let c = 1; c < e.length; c++) {
|
|
@@ -787,7 +866,7 @@ function me(e, t = 4) {
|
|
|
787
866
|
}
|
|
788
867
|
//#endregion
|
|
789
868
|
//#region src/charts/transforms/pointAndFigure.ts
|
|
790
|
-
function
|
|
869
|
+
function xe(e, t, n = 3) {
|
|
791
870
|
if (e.length === 0 || t <= 0) return [];
|
|
792
871
|
let r = [], i = 0, a = 0, o = 0, s = 0, c = Math.round(e[0].close / t) * t;
|
|
793
872
|
a = c, o = c, i = 1;
|
|
@@ -820,7 +899,7 @@ function he(e, t, n = 3) {
|
|
|
820
899
|
}
|
|
821
900
|
//#endregion
|
|
822
901
|
//#region src/charts/transforms/rangeBars.ts
|
|
823
|
-
function
|
|
902
|
+
function Se(e, t) {
|
|
824
903
|
if (e.length === 0 || t.rangeSize <= 0) return [];
|
|
825
904
|
let n = [], r = e[0].time, i = e[0].open, a = i, o = i, s = 0, c = (e, c) => {
|
|
826
905
|
for (e > a && (a = e), e < o && (o = e), s += c; a - o >= t.rangeSize;) {
|
|
@@ -880,13 +959,13 @@ var j = class {
|
|
|
880
959
|
for (let s = a; s <= o && s < n.length; s++) {
|
|
881
960
|
let a = e.values.get(n[s].time);
|
|
882
961
|
a && a[t] !== void 0 && i.push({
|
|
883
|
-
x:
|
|
884
|
-
y:
|
|
962
|
+
x: w(s, r),
|
|
963
|
+
y: T(a[t], r)
|
|
885
964
|
});
|
|
886
965
|
}
|
|
887
966
|
return i;
|
|
888
967
|
}
|
|
889
|
-
},
|
|
968
|
+
}, Ce = 1, we = class {
|
|
890
969
|
registry = /* @__PURE__ */ new Map();
|
|
891
970
|
instances = /* @__PURE__ */ new Map();
|
|
892
971
|
register(e) {
|
|
@@ -898,7 +977,7 @@ var j = class {
|
|
|
898
977
|
addIndicator(e, t = {}, n) {
|
|
899
978
|
let r = this.registry.get(e);
|
|
900
979
|
if (!r) throw Error(`Unknown indicator: ${e}`);
|
|
901
|
-
let i = `tc_${e}_${
|
|
980
|
+
let i = `tc_${e}_${Ce++}`, a = {
|
|
902
981
|
id: e,
|
|
903
982
|
instanceId: i,
|
|
904
983
|
params: {
|
|
@@ -1008,7 +1087,7 @@ function N(e, t, n, r = 1) {
|
|
|
1008
1087
|
}
|
|
1009
1088
|
//#endregion
|
|
1010
1089
|
//#region src/indicators/overlay/SMA.ts
|
|
1011
|
-
var
|
|
1090
|
+
var P = class extends j {
|
|
1012
1091
|
descriptor = {
|
|
1013
1092
|
id: "sma",
|
|
1014
1093
|
name: "Simple Moving Average",
|
|
@@ -1035,12 +1114,12 @@ var ye = class extends j {
|
|
|
1035
1114
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
1036
1115
|
let r = i[t];
|
|
1037
1116
|
if (!r || r.value === void 0) continue;
|
|
1038
|
-
let a =
|
|
1117
|
+
let a = w(t, n), o = T(r.value, n);
|
|
1039
1118
|
s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
|
|
1040
1119
|
}
|
|
1041
1120
|
e.stroke();
|
|
1042
1121
|
}
|
|
1043
|
-
},
|
|
1122
|
+
}, F = class extends j {
|
|
1044
1123
|
descriptor = {
|
|
1045
1124
|
id: "ema",
|
|
1046
1125
|
name: "Exponential Moving Average",
|
|
@@ -1072,12 +1151,12 @@ var ye = class extends j {
|
|
|
1072
1151
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
1073
1152
|
let r = i[t];
|
|
1074
1153
|
if (!r || r.value === void 0) continue;
|
|
1075
|
-
let a =
|
|
1154
|
+
let a = w(t, n), o = T(r.value, n);
|
|
1076
1155
|
s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
|
|
1077
1156
|
}
|
|
1078
1157
|
e.stroke();
|
|
1079
1158
|
}
|
|
1080
|
-
},
|
|
1159
|
+
}, Te = class extends j {
|
|
1081
1160
|
descriptor = {
|
|
1082
1161
|
id: "bb",
|
|
1083
1162
|
name: "Bollinger Bands",
|
|
@@ -1116,14 +1195,14 @@ var ye = class extends j {
|
|
|
1116
1195
|
for (let e = a; e <= o && e < i.length; e++) {
|
|
1117
1196
|
let t = i[e];
|
|
1118
1197
|
if (!t || t.upper === void 0) continue;
|
|
1119
|
-
let r =
|
|
1120
|
-
l[s] = r, u[s] =
|
|
1198
|
+
let r = w(e, n);
|
|
1199
|
+
l[s] = r, u[s] = T(t.upper, n), d[s] = r, f[s] = T(t.middle, n), p[s] = r, m[s] = T(t.lower, n), s++;
|
|
1121
1200
|
}
|
|
1122
1201
|
if (!(s < 2)) {
|
|
1123
1202
|
e.beginPath(), e.moveTo(l[0], u[0]);
|
|
1124
1203
|
for (let t = 1; t < s; t++) e.lineTo(l[t], u[t]);
|
|
1125
1204
|
for (let t = s - 1; t >= 0; t--) e.lineTo(p[t], m[t]);
|
|
1126
|
-
e.closePath(), e.fillStyle =
|
|
1205
|
+
e.closePath(), e.fillStyle = y(r.colors[0], .1), e.fill(), e.beginPath(), e.strokeStyle = r.colors[0], e.lineWidth = r.lineWidths[0], e.lineJoin = "round", e.moveTo(l[0], u[0]);
|
|
1127
1206
|
for (let t = 1; t < s; t++) e.lineTo(l[t], u[t]);
|
|
1128
1207
|
e.stroke(), e.beginPath(), e.strokeStyle = r.colors[1] ?? r.colors[0], e.moveTo(d[0], f[0]);
|
|
1129
1208
|
for (let t = 1; t < s; t++) e.lineTo(d[t], f[t]);
|
|
@@ -1132,7 +1211,7 @@ var ye = class extends j {
|
|
|
1132
1211
|
e.stroke();
|
|
1133
1212
|
}
|
|
1134
1213
|
}
|
|
1135
|
-
},
|
|
1214
|
+
}, Ee = class extends j {
|
|
1136
1215
|
descriptor = {
|
|
1137
1216
|
id: "vwap",
|
|
1138
1217
|
name: "Volume Weighted Average Price",
|
|
@@ -1162,12 +1241,12 @@ var ye = class extends j {
|
|
|
1162
1241
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
1163
1242
|
let r = i[t];
|
|
1164
1243
|
if (!r || r.value === void 0) continue;
|
|
1165
|
-
let a =
|
|
1244
|
+
let a = w(t, n), o = T(r.value, n);
|
|
1166
1245
|
s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
|
|
1167
1246
|
}
|
|
1168
1247
|
e.stroke();
|
|
1169
1248
|
}
|
|
1170
|
-
},
|
|
1249
|
+
}, De = class extends j {
|
|
1171
1250
|
descriptor = {
|
|
1172
1251
|
id: "ichimoku",
|
|
1173
1252
|
name: "Ichimoku Cloud",
|
|
@@ -1204,19 +1283,19 @@ var ye = class extends j {
|
|
|
1204
1283
|
render(e, t, n, r) {
|
|
1205
1284
|
let i = t.series;
|
|
1206
1285
|
if (!i) return;
|
|
1207
|
-
let { from: a, to: o } = n.visibleRange, s = o - a + 1, c = new Float64Array(s), l = new Float64Array(s), u = 0, d = new Float64Array(s), f = new Float64Array(s), p = 0, m = new Float64Array(s), h = new Float64Array(s), g = 0,
|
|
1286
|
+
let { from: a, to: o } = n.visibleRange, s = o - a + 1, c = new Float64Array(s), l = new Float64Array(s), u = 0, d = new Float64Array(s), f = new Float64Array(s), p = 0, m = new Float64Array(s), h = new Float64Array(s), g = 0, _ = new Float64Array(s), v = new Float64Array(s), b = 0;
|
|
1208
1287
|
for (let e = a; e <= o && e < i.length; e++) {
|
|
1209
1288
|
let t = i[e];
|
|
1210
1289
|
if (!t) continue;
|
|
1211
|
-
let r =
|
|
1212
|
-
t.tenkan !== void 0 && (c[u] = r, l[u] =
|
|
1290
|
+
let r = w(e, n);
|
|
1291
|
+
t.tenkan !== void 0 && (c[u] = r, l[u] = T(t.tenkan, n), u++), t.kijun !== void 0 && (d[p] = r, f[p] = T(t.kijun, n), p++), t.senkouA !== void 0 && (m[g] = r, h[g] = T(t.senkouA, n), g++), t.senkouB !== void 0 && (_[b] = r, v[b] = T(t.senkouB, n), b++);
|
|
1213
1292
|
}
|
|
1214
1293
|
if (g > 1 && b > 1) {
|
|
1215
1294
|
let t = Math.min(g, b);
|
|
1216
1295
|
e.beginPath(), e.moveTo(m[0], h[0]);
|
|
1217
1296
|
for (let n = 1; n < t; n++) e.lineTo(m[n], h[n]);
|
|
1218
|
-
for (let n = t - 1; n >= 0; n--) e.lineTo(
|
|
1219
|
-
e.closePath(), e.fillStyle =
|
|
1297
|
+
for (let n = t - 1; n >= 0; n--) e.lineTo(_[n], v[n]);
|
|
1298
|
+
e.closePath(), e.fillStyle = y(r.colors[2] ?? "#26A69A", .15), e.fill();
|
|
1220
1299
|
}
|
|
1221
1300
|
let x = (t, n, r, i, a) => {
|
|
1222
1301
|
if (!(r < 2)) {
|
|
@@ -1225,9 +1304,9 @@ var ye = class extends j {
|
|
|
1225
1304
|
e.stroke();
|
|
1226
1305
|
}
|
|
1227
1306
|
};
|
|
1228
|
-
x(c, l, u, r.colors[0], r.lineWidths[0]), x(d, f, p, r.colors[1] ?? "#FF9800", r.lineWidths[0]), x(m, h, g, r.colors[2] ?? "#26A69A", 1), x(
|
|
1307
|
+
x(c, l, u, r.colors[0], r.lineWidths[0]), x(d, f, p, r.colors[1] ?? "#FF9800", r.lineWidths[0]), x(m, h, g, r.colors[2] ?? "#26A69A", 1), x(_, v, b, r.colors[3] ?? "#EF5350", 1);
|
|
1229
1308
|
}
|
|
1230
|
-
},
|
|
1309
|
+
}, Oe = class extends j {
|
|
1231
1310
|
descriptor = {
|
|
1232
1311
|
id: "psar",
|
|
1233
1312
|
name: "Parabolic SAR",
|
|
@@ -1269,11 +1348,11 @@ var ye = class extends j {
|
|
|
1269
1348
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
1270
1349
|
let a = i[t];
|
|
1271
1350
|
if (!a || a.value === void 0) continue;
|
|
1272
|
-
let o =
|
|
1351
|
+
let o = w(t, n), c = T(a.value, n);
|
|
1273
1352
|
e.beginPath(), e.arc(o, c, s, 0, Math.PI * 2), e.fillStyle = a.trend === 1 ? r.colors[0] : r.colors[1] ?? "#EF5350", e.fill();
|
|
1274
1353
|
}
|
|
1275
1354
|
}
|
|
1276
|
-
},
|
|
1355
|
+
}, ke = class extends j {
|
|
1277
1356
|
descriptor = {
|
|
1278
1357
|
id: "supertrend",
|
|
1279
1358
|
name: "Supertrend",
|
|
@@ -1317,11 +1396,11 @@ var ye = class extends j {
|
|
|
1317
1396
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
1318
1397
|
let a = i[t];
|
|
1319
1398
|
if (!a || a.value === void 0) continue;
|
|
1320
|
-
let o =
|
|
1399
|
+
let o = w(t, n), f = T(a.value, n), p = a.trend ?? 1;
|
|
1321
1400
|
d !== 0 && (e.beginPath(), e.strokeStyle = p === 1 ? s : c, e.lineWidth = r.lineWidths[0] + .5, e.moveTo(l, u), e.lineTo(o, f), e.stroke()), l = o, u = f, d = p;
|
|
1322
1401
|
}
|
|
1323
1402
|
}
|
|
1324
|
-
},
|
|
1403
|
+
}, Ae = class extends j {
|
|
1325
1404
|
descriptor = {
|
|
1326
1405
|
id: "keltner",
|
|
1327
1406
|
name: "Keltner Channel",
|
|
@@ -1364,21 +1443,21 @@ var ye = class extends j {
|
|
|
1364
1443
|
for (let e = a; e <= o && e < i.length; e++) {
|
|
1365
1444
|
let t = i[e];
|
|
1366
1445
|
if (!t) continue;
|
|
1367
|
-
let r =
|
|
1446
|
+
let r = w(e, n);
|
|
1368
1447
|
t.upper !== void 0 && s.push({
|
|
1369
1448
|
x: r,
|
|
1370
|
-
y:
|
|
1449
|
+
y: T(t.upper, n)
|
|
1371
1450
|
}), t.middle !== void 0 && c.push({
|
|
1372
1451
|
x: r,
|
|
1373
|
-
y:
|
|
1452
|
+
y: T(t.middle, n)
|
|
1374
1453
|
}), t.lower !== void 0 && l.push({
|
|
1375
1454
|
x: r,
|
|
1376
|
-
y:
|
|
1455
|
+
y: T(t.lower, n)
|
|
1377
1456
|
});
|
|
1378
1457
|
}
|
|
1379
|
-
this.drawBand(e, s, l,
|
|
1458
|
+
this.drawBand(e, s, l, y(r.colors[0], .08)), this.drawLine(e, s, r.colors[0], r.lineWidths[0]), this.drawLine(e, c, r.colors[1] ?? r.colors[0], r.lineWidths[0]), this.drawLine(e, l, r.colors[0], r.lineWidths[0]);
|
|
1380
1459
|
}
|
|
1381
|
-
},
|
|
1460
|
+
}, je = class extends j {
|
|
1382
1461
|
descriptor = {
|
|
1383
1462
|
id: "donchian",
|
|
1384
1463
|
name: "Donchian Channel",
|
|
@@ -1409,21 +1488,21 @@ var ye = class extends j {
|
|
|
1409
1488
|
for (let e = a; e <= o && e < i.length; e++) {
|
|
1410
1489
|
let t = i[e];
|
|
1411
1490
|
if (!t) continue;
|
|
1412
|
-
let r =
|
|
1491
|
+
let r = w(e, n);
|
|
1413
1492
|
t.upper !== void 0 && s.push({
|
|
1414
1493
|
x: r,
|
|
1415
|
-
y:
|
|
1494
|
+
y: T(t.upper, n)
|
|
1416
1495
|
}), t.middle !== void 0 && c.push({
|
|
1417
1496
|
x: r,
|
|
1418
|
-
y:
|
|
1497
|
+
y: T(t.middle, n)
|
|
1419
1498
|
}), t.lower !== void 0 && l.push({
|
|
1420
1499
|
x: r,
|
|
1421
|
-
y:
|
|
1500
|
+
y: T(t.lower, n)
|
|
1422
1501
|
});
|
|
1423
1502
|
}
|
|
1424
|
-
this.drawBand(e, s, l,
|
|
1503
|
+
this.drawBand(e, s, l, y(r.colors[0], .08)), this.drawLine(e, s, r.colors[0], r.lineWidths[0]), this.drawLine(e, c, r.colors[1] ?? "#787B86", 1), this.drawLine(e, l, r.colors[0], r.lineWidths[0]);
|
|
1425
1504
|
}
|
|
1426
|
-
},
|
|
1505
|
+
}, Me = [
|
|
1427
1506
|
"s3",
|
|
1428
1507
|
"s2",
|
|
1429
1508
|
"s1",
|
|
@@ -1431,7 +1510,7 @@ var ye = class extends j {
|
|
|
1431
1510
|
"r1",
|
|
1432
1511
|
"r2",
|
|
1433
1512
|
"r3"
|
|
1434
|
-
],
|
|
1513
|
+
], Ne = class extends j {
|
|
1435
1514
|
descriptor = {
|
|
1436
1515
|
id: "pivots",
|
|
1437
1516
|
name: "Pivot Points (Classic)",
|
|
@@ -1467,19 +1546,19 @@ var ye = class extends j {
|
|
|
1467
1546
|
let i = t.series;
|
|
1468
1547
|
if (!i) return;
|
|
1469
1548
|
let { from: a, to: o } = n.visibleRange, s = r.colors[0], c = r.colors[1] ?? "#EF5350", l = r.colors[2] ?? "#26A69A", u = r.lineWidths[0], d = (e) => e === "pp" ? s : e.startsWith("r") ? c : l;
|
|
1470
|
-
for (let t of
|
|
1549
|
+
for (let t of Me) {
|
|
1471
1550
|
e.beginPath(), e.strokeStyle = d(t), e.lineWidth = t === "pp" ? u : Math.max(1, u - 1), t !== "pp" && e.setLineDash([4, 3]);
|
|
1472
1551
|
let r = !1;
|
|
1473
1552
|
for (let s = a; s <= o && s < i.length; s++) {
|
|
1474
1553
|
let a = i[s]?.[t];
|
|
1475
1554
|
if (a === void 0) continue;
|
|
1476
|
-
let o =
|
|
1555
|
+
let o = w(s, n), c = T(a, n);
|
|
1477
1556
|
r ? e.lineTo(o, c) : (e.moveTo(o, c), r = !0);
|
|
1478
1557
|
}
|
|
1479
1558
|
e.stroke(), e.setLineDash([]);
|
|
1480
1559
|
}
|
|
1481
1560
|
}
|
|
1482
|
-
},
|
|
1561
|
+
}, Pe = class extends j {
|
|
1483
1562
|
descriptor = {
|
|
1484
1563
|
id: "avwap",
|
|
1485
1564
|
name: "Anchored VWAP",
|
|
@@ -1514,12 +1593,12 @@ var ye = class extends j {
|
|
|
1514
1593
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
1515
1594
|
let r = i[t];
|
|
1516
1595
|
if (!r || r.value === void 0) continue;
|
|
1517
|
-
let a =
|
|
1596
|
+
let a = w(t, n), o = T(r.value, n);
|
|
1518
1597
|
s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
|
|
1519
1598
|
}
|
|
1520
1599
|
e.stroke();
|
|
1521
1600
|
}
|
|
1522
|
-
},
|
|
1601
|
+
}, Fe = class extends j {
|
|
1523
1602
|
descriptor = {
|
|
1524
1603
|
id: "zigzag",
|
|
1525
1604
|
name: "ZigZag",
|
|
@@ -1578,13 +1657,13 @@ var ye = class extends j {
|
|
|
1578
1657
|
if (!(!i || i.length < 2)) {
|
|
1579
1658
|
e.beginPath(), e.strokeStyle = r.colors[0], e.lineWidth = r.lineWidths[0], e.lineJoin = "round";
|
|
1580
1659
|
for (let t = 0; t < i.length; t++) {
|
|
1581
|
-
let r = i[t], a =
|
|
1660
|
+
let r = i[t], a = w(r.idx, n), o = T(r.price, n);
|
|
1582
1661
|
t === 0 ? e.moveTo(a, o) : e.lineTo(a, o);
|
|
1583
1662
|
}
|
|
1584
1663
|
e.stroke();
|
|
1585
1664
|
}
|
|
1586
1665
|
}
|
|
1587
|
-
},
|
|
1666
|
+
}, Ie = class extends j {
|
|
1588
1667
|
descriptor = {
|
|
1589
1668
|
id: "lrc",
|
|
1590
1669
|
name: "Linear Regression Channel",
|
|
@@ -1633,21 +1712,21 @@ var ye = class extends j {
|
|
|
1633
1712
|
for (let e = a; e <= o && e < i.length; e++) {
|
|
1634
1713
|
let t = i[e];
|
|
1635
1714
|
if (!t) continue;
|
|
1636
|
-
let r =
|
|
1715
|
+
let r = w(e, n);
|
|
1637
1716
|
t.middle !== void 0 && c.push({
|
|
1638
1717
|
x: r,
|
|
1639
|
-
y:
|
|
1718
|
+
y: T(t.middle, n)
|
|
1640
1719
|
}), t.upper !== void 0 && s.push({
|
|
1641
1720
|
x: r,
|
|
1642
|
-
y:
|
|
1721
|
+
y: T(t.upper, n)
|
|
1643
1722
|
}), t.lower !== void 0 && l.push({
|
|
1644
1723
|
x: r,
|
|
1645
|
-
y:
|
|
1724
|
+
y: T(t.lower, n)
|
|
1646
1725
|
});
|
|
1647
1726
|
}
|
|
1648
|
-
this.drawBand(e, s, l,
|
|
1727
|
+
this.drawBand(e, s, l, y(r.colors[0], .08)), this.drawLine(e, s, r.colors[0], r.lineWidths[0]), this.drawLine(e, c, r.colors[1] ?? r.colors[0], r.lineWidths[0]), this.drawLine(e, l, r.colors[0], r.lineWidths[0]);
|
|
1649
1728
|
}
|
|
1650
|
-
},
|
|
1729
|
+
}, Le = class extends j {
|
|
1651
1730
|
descriptor = {
|
|
1652
1731
|
id: "hma",
|
|
1653
1732
|
name: "Hull Moving Average",
|
|
@@ -1660,7 +1739,7 @@ var ye = class extends j {
|
|
|
1660
1739
|
values: r,
|
|
1661
1740
|
series: i
|
|
1662
1741
|
};
|
|
1663
|
-
let a = e.map((e) => e.close), o = Math.max(2, Math.floor(n / 2)), s = Math.max(2, Math.floor(Math.sqrt(n))), c =
|
|
1742
|
+
let a = e.map((e) => e.close), o = Math.max(2, Math.floor(n / 2)), s = Math.max(2, Math.floor(Math.sqrt(n))), c = Re(a, n), l = Re(a, o), u = ze(a.map((e, t) => c[t] === null || l[t] === null ? null : 2 * l[t] - c[t]), s);
|
|
1664
1743
|
for (let t = 0; t < e.length; t++) {
|
|
1665
1744
|
if (u[t] === null) continue;
|
|
1666
1745
|
let n = { value: u[t] };
|
|
@@ -1680,13 +1759,13 @@ var ye = class extends j {
|
|
|
1680
1759
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
1681
1760
|
let r = i[t];
|
|
1682
1761
|
if (!r || r.value === void 0) continue;
|
|
1683
|
-
let a =
|
|
1762
|
+
let a = w(t, n), o = T(r.value, n);
|
|
1684
1763
|
s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
|
|
1685
1764
|
}
|
|
1686
1765
|
e.stroke();
|
|
1687
1766
|
}
|
|
1688
1767
|
};
|
|
1689
|
-
function
|
|
1768
|
+
function Re(e, t) {
|
|
1690
1769
|
let n = Array(e.length).fill(null);
|
|
1691
1770
|
if (e.length < t) return n;
|
|
1692
1771
|
let r = t * (t + 1) / 2;
|
|
@@ -1697,7 +1776,7 @@ function Me(e, t) {
|
|
|
1697
1776
|
}
|
|
1698
1777
|
return n;
|
|
1699
1778
|
}
|
|
1700
|
-
function
|
|
1779
|
+
function ze(e, t) {
|
|
1701
1780
|
let n = Array(e.length).fill(null), r = t * (t + 1) / 2;
|
|
1702
1781
|
for (let i = t - 1; i < e.length; i++) {
|
|
1703
1782
|
let a = 0, o = !0;
|
|
@@ -1715,7 +1794,7 @@ function Ne(e, t) {
|
|
|
1715
1794
|
}
|
|
1716
1795
|
//#endregion
|
|
1717
1796
|
//#region src/indicators/panel/AwesomeOscillator.ts
|
|
1718
|
-
var
|
|
1797
|
+
var Be = class extends j {
|
|
1719
1798
|
descriptor = {
|
|
1720
1799
|
id: "ao",
|
|
1721
1800
|
name: "Awesome Oscillator",
|
|
@@ -1759,11 +1838,11 @@ var Pe = class extends j {
|
|
|
1759
1838
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
1760
1839
|
let r = i[t];
|
|
1761
1840
|
if (!r || r.value === void 0) continue;
|
|
1762
|
-
let a =
|
|
1841
|
+
let a = w(t, n), o = d(r.value), s = Math.min(o, f), c = Math.max(Math.abs(o - f), 1);
|
|
1763
1842
|
e.fillStyle = r.up ? m : h, e.fillRect(a - p, s, n.barWidth, c);
|
|
1764
1843
|
}
|
|
1765
1844
|
}
|
|
1766
|
-
},
|
|
1845
|
+
}, Ve = class extends j {
|
|
1767
1846
|
descriptor = {
|
|
1768
1847
|
id: "chaikinOsc",
|
|
1769
1848
|
name: "Chaikin Oscillator",
|
|
@@ -1808,11 +1887,11 @@ var Pe = class extends j {
|
|
|
1808
1887
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
1809
1888
|
let r = i[t];
|
|
1810
1889
|
if (!r || r.value === void 0) continue;
|
|
1811
|
-
let a =
|
|
1890
|
+
let a = w(t, n), o = d(r.value), s = Math.min(o, f), c = Math.max(Math.abs(o - f), 1);
|
|
1812
1891
|
e.fillStyle = r.value >= 0 ? m : h, e.fillRect(a - p, s, n.barWidth, c);
|
|
1813
1892
|
}
|
|
1814
1893
|
}
|
|
1815
|
-
},
|
|
1894
|
+
}, He = class extends j {
|
|
1816
1895
|
descriptor = {
|
|
1817
1896
|
id: "rsi",
|
|
1818
1897
|
name: "Relative Strength Index",
|
|
@@ -1858,12 +1937,12 @@ var Pe = class extends j {
|
|
|
1858
1937
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
1859
1938
|
let r = i[t];
|
|
1860
1939
|
if (!r || r.value === void 0) continue;
|
|
1861
|
-
let a =
|
|
1940
|
+
let a = w(t, n), o = c(r.value);
|
|
1862
1941
|
l ? e.lineTo(a, o) : (e.moveTo(a, o), l = !0);
|
|
1863
1942
|
}
|
|
1864
1943
|
e.stroke();
|
|
1865
1944
|
}
|
|
1866
|
-
},
|
|
1945
|
+
}, Ue = class extends j {
|
|
1867
1946
|
descriptor = {
|
|
1868
1947
|
id: "macd",
|
|
1869
1948
|
name: "MACD",
|
|
@@ -1910,27 +1989,27 @@ var Pe = class extends j {
|
|
|
1910
1989
|
if (c === Infinity) return;
|
|
1911
1990
|
let u = l - c || 1, d = (e) => a.y + a.height * (1 - (e - c) / u), f = d(0), p = n.barWidth / 2, m = r.colors[2] ?? "#26A69A", h = r.colors[3] ?? "#EF5350", g = r.colors[0], _ = r.colors[1] ?? "#FF9800";
|
|
1912
1991
|
e.beginPath();
|
|
1913
|
-
let v = new Path2D(), y = new Path2D(), b = !1, x = !1,
|
|
1992
|
+
let v = new Path2D(), y = new Path2D(), b = !1, x = !1, S = new Path2D(), C = new Path2D();
|
|
1914
1993
|
for (let e = o; e <= s && e < i.length; e++) {
|
|
1915
1994
|
let t = i[e];
|
|
1916
1995
|
if (!t) continue;
|
|
1917
|
-
let r =
|
|
1996
|
+
let r = w(e, n);
|
|
1918
1997
|
if (t.histogram !== void 0) {
|
|
1919
1998
|
let e = d(t.histogram), i = Math.min(e, f), a = Math.max(Math.abs(e - f), 1);
|
|
1920
1999
|
t.histogram >= 0 ? v.rect(r - p, i, n.barWidth, a) : y.rect(r - p, i, n.barWidth, a);
|
|
1921
2000
|
}
|
|
1922
2001
|
if (t.macd !== void 0) {
|
|
1923
2002
|
let e = d(t.macd);
|
|
1924
|
-
b ?
|
|
2003
|
+
b ? S.lineTo(r, e) : (S.moveTo(r, e), b = !0);
|
|
1925
2004
|
}
|
|
1926
2005
|
if (t.signal !== void 0) {
|
|
1927
2006
|
let e = d(t.signal);
|
|
1928
|
-
x ?
|
|
2007
|
+
x ? C.lineTo(r, e) : (C.moveTo(r, e), x = !0);
|
|
1929
2008
|
}
|
|
1930
2009
|
}
|
|
1931
|
-
e.fillStyle = m, e.fill(v), e.fillStyle = h, e.fill(y), e.strokeStyle = g, e.lineWidth = r.lineWidths[0], e.lineJoin = "round", e.stroke(
|
|
2010
|
+
e.fillStyle = m, e.fill(v), e.fillStyle = h, e.fill(y), e.strokeStyle = g, e.lineWidth = r.lineWidths[0], e.lineJoin = "round", e.stroke(S), e.strokeStyle = _, e.stroke(C);
|
|
1932
2011
|
}
|
|
1933
|
-
},
|
|
2012
|
+
}, We = class extends j {
|
|
1934
2013
|
descriptor = {
|
|
1935
2014
|
id: "stochastic",
|
|
1936
2015
|
name: "Stochastic Oscillator",
|
|
@@ -1998,14 +2077,14 @@ var Pe = class extends j {
|
|
|
1998
2077
|
for (let r = o; r <= s && r < i.length; r++) {
|
|
1999
2078
|
let a = i[r];
|
|
2000
2079
|
if (!a || a[t] === void 0) continue;
|
|
2001
|
-
let o =
|
|
2080
|
+
let o = w(r, n), s = c(a[t]);
|
|
2002
2081
|
l ? e.lineTo(o, s) : (e.moveTo(o, s), l = !0);
|
|
2003
2082
|
}
|
|
2004
2083
|
e.stroke();
|
|
2005
2084
|
};
|
|
2006
2085
|
l("k", r.colors[0]), l("d", r.colors[1] ?? "#FF9800");
|
|
2007
2086
|
}
|
|
2008
|
-
},
|
|
2087
|
+
}, Ge = class extends j {
|
|
2009
2088
|
descriptor = {
|
|
2010
2089
|
id: "atr",
|
|
2011
2090
|
name: "Average True Range",
|
|
@@ -2053,13 +2132,13 @@ var Pe = class extends j {
|
|
|
2053
2132
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2054
2133
|
let r = i[t];
|
|
2055
2134
|
if (r && r.value !== void 0) {
|
|
2056
|
-
let i =
|
|
2135
|
+
let i = w(t, n), a = p(r.value);
|
|
2057
2136
|
m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
|
|
2058
2137
|
}
|
|
2059
2138
|
}
|
|
2060
2139
|
e.stroke();
|
|
2061
2140
|
}
|
|
2062
|
-
},
|
|
2141
|
+
}, Ke = class extends j {
|
|
2063
2142
|
descriptor = {
|
|
2064
2143
|
id: "adx",
|
|
2065
2144
|
name: "Average Directional Index",
|
|
@@ -2125,14 +2204,14 @@ var Pe = class extends j {
|
|
|
2125
2204
|
for (let r = o; r <= s && r < i.length; r++) {
|
|
2126
2205
|
let a = i[r];
|
|
2127
2206
|
if (!a || a[t] === void 0) continue;
|
|
2128
|
-
let o =
|
|
2207
|
+
let o = w(r, n), s = c(a[t]);
|
|
2129
2208
|
l ? e.lineTo(o, s) : (e.moveTo(o, s), l = !0);
|
|
2130
2209
|
}
|
|
2131
2210
|
e.stroke();
|
|
2132
2211
|
};
|
|
2133
2212
|
l("adx", r.colors[0]), l("plusDI", r.colors[1] ?? "#26A69A"), l("minusDI", r.colors[2] ?? "#EF5350");
|
|
2134
2213
|
}
|
|
2135
|
-
},
|
|
2214
|
+
}, qe = class extends j {
|
|
2136
2215
|
descriptor = {
|
|
2137
2216
|
id: "obv",
|
|
2138
2217
|
name: "On Balance Volume",
|
|
@@ -2172,13 +2251,13 @@ var Pe = class extends j {
|
|
|
2172
2251
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2173
2252
|
let r = i[t];
|
|
2174
2253
|
if (r && r.value !== void 0) {
|
|
2175
|
-
let i =
|
|
2254
|
+
let i = w(t, n), a = p(r.value);
|
|
2176
2255
|
m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
|
|
2177
2256
|
}
|
|
2178
2257
|
}
|
|
2179
2258
|
e.stroke();
|
|
2180
2259
|
}
|
|
2181
|
-
},
|
|
2260
|
+
}, Je = class extends j {
|
|
2182
2261
|
descriptor = {
|
|
2183
2262
|
id: "williamsR",
|
|
2184
2263
|
name: "Williams %R",
|
|
@@ -2212,13 +2291,13 @@ var Pe = class extends j {
|
|
|
2212
2291
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2213
2292
|
let r = i[t];
|
|
2214
2293
|
if (r && r.value !== void 0) {
|
|
2215
|
-
let i =
|
|
2294
|
+
let i = w(t, n), a = c(r.value);
|
|
2216
2295
|
l ? e.lineTo(i, a) : (e.moveTo(i, a), l = !0);
|
|
2217
2296
|
}
|
|
2218
2297
|
}
|
|
2219
2298
|
e.stroke();
|
|
2220
2299
|
}
|
|
2221
|
-
},
|
|
2300
|
+
}, Ye = class extends j {
|
|
2222
2301
|
descriptor = {
|
|
2223
2302
|
id: "cci",
|
|
2224
2303
|
name: "Commodity Channel Index",
|
|
@@ -2267,13 +2346,13 @@ var Pe = class extends j {
|
|
|
2267
2346
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2268
2347
|
let r = i[t];
|
|
2269
2348
|
if (r && r.value !== void 0) {
|
|
2270
|
-
let i =
|
|
2349
|
+
let i = w(t, n), a = m(r.value);
|
|
2271
2350
|
h ? e.lineTo(i, a) : (e.moveTo(i, a), h = !0);
|
|
2272
2351
|
}
|
|
2273
2352
|
}
|
|
2274
2353
|
e.stroke();
|
|
2275
2354
|
}
|
|
2276
|
-
},
|
|
2355
|
+
}, Xe = class extends j {
|
|
2277
2356
|
descriptor = {
|
|
2278
2357
|
id: "mfi",
|
|
2279
2358
|
name: "Money Flow Index",
|
|
@@ -2312,13 +2391,13 @@ var Pe = class extends j {
|
|
|
2312
2391
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2313
2392
|
let r = i[t];
|
|
2314
2393
|
if (r && r.value !== void 0) {
|
|
2315
|
-
let i =
|
|
2394
|
+
let i = w(t, n), a = c(r.value);
|
|
2316
2395
|
l ? e.lineTo(i, a) : (e.moveTo(i, a), l = !0);
|
|
2317
2396
|
}
|
|
2318
2397
|
}
|
|
2319
2398
|
e.stroke();
|
|
2320
2399
|
}
|
|
2321
|
-
},
|
|
2400
|
+
}, Ze = class extends j {
|
|
2322
2401
|
descriptor = {
|
|
2323
2402
|
id: "aroon",
|
|
2324
2403
|
name: "Aroon",
|
|
@@ -2353,14 +2432,14 @@ var Pe = class extends j {
|
|
|
2353
2432
|
for (let r = o; r <= s && r < i.length; r++) {
|
|
2354
2433
|
let a = i[r];
|
|
2355
2434
|
if (!a || a[t] === void 0) continue;
|
|
2356
|
-
let o =
|
|
2435
|
+
let o = w(r, n), s = c(a[t]);
|
|
2357
2436
|
l ? e.lineTo(o, s) : (e.moveTo(o, s), l = !0);
|
|
2358
2437
|
}
|
|
2359
2438
|
e.stroke();
|
|
2360
2439
|
};
|
|
2361
2440
|
l("up", r.colors[0]), l("down", r.colors[1] ?? "#EF5350");
|
|
2362
2441
|
}
|
|
2363
|
-
},
|
|
2442
|
+
}, Qe = class extends j {
|
|
2364
2443
|
descriptor = {
|
|
2365
2444
|
id: "roc",
|
|
2366
2445
|
name: "Rate of Change",
|
|
@@ -2398,13 +2477,13 @@ var Pe = class extends j {
|
|
|
2398
2477
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2399
2478
|
let r = i[t];
|
|
2400
2479
|
if (r && r.value !== void 0) {
|
|
2401
|
-
let i =
|
|
2480
|
+
let i = w(t, n), a = m(r.value);
|
|
2402
2481
|
h ? e.lineTo(i, a) : (e.moveTo(i, a), h = !0);
|
|
2403
2482
|
}
|
|
2404
2483
|
}
|
|
2405
2484
|
e.stroke();
|
|
2406
2485
|
}
|
|
2407
|
-
},
|
|
2486
|
+
}, $e = class extends j {
|
|
2408
2487
|
descriptor = {
|
|
2409
2488
|
id: "tsi",
|
|
2410
2489
|
name: "True Strength Index",
|
|
@@ -2466,14 +2545,14 @@ var Pe = class extends j {
|
|
|
2466
2545
|
for (let r = o; r <= s && r < i.length; r++) {
|
|
2467
2546
|
let a = i[r];
|
|
2468
2547
|
if (!a || a[t] === void 0) continue;
|
|
2469
|
-
let o =
|
|
2548
|
+
let o = w(r, n), s = m(a[t]);
|
|
2470
2549
|
c ? e.lineTo(o, s) : (e.moveTo(o, s), c = !0);
|
|
2471
2550
|
}
|
|
2472
2551
|
e.stroke();
|
|
2473
2552
|
};
|
|
2474
2553
|
h("tsi", r.colors[0]), h("signal", r.colors[1] ?? "#FF9800");
|
|
2475
2554
|
}
|
|
2476
|
-
},
|
|
2555
|
+
}, et = class extends j {
|
|
2477
2556
|
descriptor = {
|
|
2478
2557
|
id: "cmf",
|
|
2479
2558
|
name: "Chaikin Money Flow",
|
|
@@ -2511,14 +2590,14 @@ var Pe = class extends j {
|
|
|
2511
2590
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2512
2591
|
let a = i[t];
|
|
2513
2592
|
if (a && a.value !== void 0) {
|
|
2514
|
-
let i =
|
|
2593
|
+
let i = w(t, n), o = m(a.value), s = m(0);
|
|
2515
2594
|
e.fillStyle = a.value >= 0 ? r.colors[0] : r.colors[1] ?? "#EF5350";
|
|
2516
2595
|
let c = Math.min(o, s);
|
|
2517
2596
|
e.fillRect(i - h, c, n.barWidth, Math.max(Math.abs(o - s), 1));
|
|
2518
2597
|
}
|
|
2519
2598
|
}
|
|
2520
2599
|
}
|
|
2521
|
-
},
|
|
2600
|
+
}, tt = class extends j {
|
|
2522
2601
|
descriptor = {
|
|
2523
2602
|
id: "stddev",
|
|
2524
2603
|
name: "Standard Deviation",
|
|
@@ -2558,13 +2637,13 @@ var Pe = class extends j {
|
|
|
2558
2637
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2559
2638
|
let r = i[t];
|
|
2560
2639
|
if (r && r.value !== void 0) {
|
|
2561
|
-
let i =
|
|
2640
|
+
let i = w(t, n), a = p(r.value);
|
|
2562
2641
|
m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
|
|
2563
2642
|
}
|
|
2564
2643
|
}
|
|
2565
2644
|
e.stroke();
|
|
2566
2645
|
}
|
|
2567
|
-
},
|
|
2646
|
+
}, nt = class extends j {
|
|
2568
2647
|
descriptor = {
|
|
2569
2648
|
id: "volumeProfile",
|
|
2570
2649
|
name: "Volume Profile",
|
|
@@ -2614,7 +2693,7 @@ var Pe = class extends j {
|
|
|
2614
2693
|
e.fillStyle = l[t] > u * .7 ? r.colors[1] ?? "rgba(255, 152, 0, 0.5)" : r.colors[0] ?? "rgba(33, 150, 243, 0.3)", e.fillRect(i.x, s - d / 2, p, Math.max(d - 1, 1));
|
|
2615
2694
|
}
|
|
2616
2695
|
}
|
|
2617
|
-
},
|
|
2696
|
+
}, rt = class extends j {
|
|
2618
2697
|
descriptor = {
|
|
2619
2698
|
id: "ad",
|
|
2620
2699
|
name: "Accumulation/Distribution",
|
|
@@ -2654,13 +2733,13 @@ var Pe = class extends j {
|
|
|
2654
2733
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2655
2734
|
let r = i[t];
|
|
2656
2735
|
if (r && r.value !== void 0) {
|
|
2657
|
-
let i =
|
|
2736
|
+
let i = w(t, n), a = p(r.value);
|
|
2658
2737
|
m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
|
|
2659
2738
|
}
|
|
2660
2739
|
}
|
|
2661
2740
|
e.stroke();
|
|
2662
2741
|
}
|
|
2663
|
-
},
|
|
2742
|
+
}, it = class extends j {
|
|
2664
2743
|
descriptor = {
|
|
2665
2744
|
id: "vroc",
|
|
2666
2745
|
name: "Volume Rate of Change",
|
|
@@ -2693,7 +2772,7 @@ var Pe = class extends j {
|
|
|
2693
2772
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2694
2773
|
let r = i[t];
|
|
2695
2774
|
if (r && r.value !== void 0) {
|
|
2696
|
-
let i =
|
|
2775
|
+
let i = w(t, n), a = m(r.value);
|
|
2697
2776
|
h ? e.lineTo(i, a) : (e.moveTo(i, a), h = !0);
|
|
2698
2777
|
}
|
|
2699
2778
|
}
|
|
@@ -2702,19 +2781,19 @@ var Pe = class extends j {
|
|
|
2702
2781
|
};
|
|
2703
2782
|
//#endregion
|
|
2704
2783
|
//#region src/indicators/registry.ts
|
|
2705
|
-
function
|
|
2706
|
-
e.register(new
|
|
2784
|
+
function at(e) {
|
|
2785
|
+
e.register(new P()), e.register(new F()), e.register(new Te()), e.register(new Ee()), e.register(new De()), e.register(new Oe()), e.register(new ke()), e.register(new Ae()), e.register(new je()), e.register(new Ne()), e.register(new Pe()), e.register(new Fe()), e.register(new Ie()), e.register(new Le()), e.register(new He()), e.register(new Ue()), e.register(new We()), e.register(new Ge()), e.register(new Ke()), e.register(new qe()), e.register(new Je()), e.register(new Ye()), e.register(new Xe()), e.register(new Ze()), e.register(new Qe()), e.register(new $e()), e.register(new et()), e.register(new tt()), e.register(new nt()), e.register(new rt()), e.register(new it()), e.register(new Be()), e.register(new Ve());
|
|
2707
2786
|
}
|
|
2708
2787
|
//#endregion
|
|
2709
2788
|
//#region src/indicators/worker/messages.ts
|
|
2710
|
-
function
|
|
2789
|
+
function ot(e) {
|
|
2711
2790
|
if (typeof e != "object" || !e) return !1;
|
|
2712
2791
|
let t = e;
|
|
2713
2792
|
return typeof t.requestId == "number" ? t.type === "result" || t.type === "pong" || t.type === "error" : !1;
|
|
2714
2793
|
}
|
|
2715
2794
|
//#endregion
|
|
2716
2795
|
//#region src/indicators/worker/IndicatorWorkerHost.ts
|
|
2717
|
-
var
|
|
2796
|
+
var st = class {
|
|
2718
2797
|
worker;
|
|
2719
2798
|
fallbackPlugins;
|
|
2720
2799
|
timeoutMs;
|
|
@@ -2779,7 +2858,7 @@ var tt = class {
|
|
|
2779
2858
|
handleMessage(e) {
|
|
2780
2859
|
let t = e.data;
|
|
2781
2860
|
if (t !== void 0) {
|
|
2782
|
-
if (!
|
|
2861
|
+
if (!ot(t)) return;
|
|
2783
2862
|
this.dispatchResponse(t);
|
|
2784
2863
|
return;
|
|
2785
2864
|
}
|
|
@@ -2800,7 +2879,7 @@ var tt = class {
|
|
|
2800
2879
|
t.resolve(e.output);
|
|
2801
2880
|
}
|
|
2802
2881
|
}
|
|
2803
|
-
},
|
|
2882
|
+
}, ct = class {
|
|
2804
2883
|
visible = !0;
|
|
2805
2884
|
setVisible(e) {
|
|
2806
2885
|
this.visible = e;
|
|
@@ -2816,20 +2895,20 @@ var tt = class {
|
|
|
2816
2895
|
if (a <= 0) return;
|
|
2817
2896
|
let o = 1 / a;
|
|
2818
2897
|
e.beginPath();
|
|
2819
|
-
let s =
|
|
2898
|
+
let s = m(i.min, i.max, 8), c = Math.ceil(i.min / s) * s;
|
|
2820
2899
|
for (let t = c; t <= i.max; t += s) {
|
|
2821
2900
|
let n = Math.round(r.y + r.height * (1 - (t - i.min) * o)) + .5;
|
|
2822
2901
|
e.moveTo(r.x, n), e.lineTo(r.x + r.width, n);
|
|
2823
2902
|
}
|
|
2824
|
-
let l = t.barWidth + t.barSpacing, u = Math.max(1, Math.ceil(80 / l)), { from: d, to:
|
|
2825
|
-
for (let t = d; t <=
|
|
2903
|
+
let l = t.barWidth + t.barSpacing, u = Math.max(1, Math.ceil(80 / l)), { from: d, to: f } = t.visibleRange, p = -t.offset + r.x + t.barWidth / 2;
|
|
2904
|
+
for (let t = d; t <= f; t++) {
|
|
2826
2905
|
if (t % u !== 0) continue;
|
|
2827
|
-
let n = Math.round(t * l +
|
|
2906
|
+
let n = Math.round(t * l + p) + .5;
|
|
2828
2907
|
e.moveTo(n, r.y), e.lineTo(n, r.y + r.height);
|
|
2829
2908
|
}
|
|
2830
2909
|
e.stroke();
|
|
2831
2910
|
}
|
|
2832
|
-
},
|
|
2911
|
+
}, lt = class {
|
|
2833
2912
|
locale = "en-US";
|
|
2834
2913
|
setLocale(e) {
|
|
2835
2914
|
this.locale = e;
|
|
@@ -2839,20 +2918,20 @@ var tt = class {
|
|
|
2839
2918
|
if (o <= 0) return;
|
|
2840
2919
|
let s = 1 / o;
|
|
2841
2920
|
e.strokeStyle = n.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(a + .5, r.y), e.lineTo(a + .5, r.y + r.height), e.stroke();
|
|
2842
|
-
let
|
|
2843
|
-
for (let e =
|
|
2921
|
+
let c = m(i.min, i.max, 8), l = Math.ceil(i.min / c) * c, d = c < 1 ? Math.ceil(-Math.log10(c)) + 1 : 2, f = `${n.font.sizeSmall}px ${n.font.family}`, p = [];
|
|
2922
|
+
for (let e = l; e <= i.max; e += c) {
|
|
2844
2923
|
let t = r.y + r.height * (1 - (e - i.min) * s);
|
|
2845
|
-
|
|
2924
|
+
p.push({
|
|
2846
2925
|
y: t,
|
|
2847
|
-
text:
|
|
2926
|
+
text: h(e, d, this.locale)
|
|
2848
2927
|
});
|
|
2849
2928
|
}
|
|
2850
|
-
e.font =
|
|
2851
|
-
for (let { y: t } of
|
|
2929
|
+
e.font = f, e.textBaseline = "middle", e.textAlign = "left", e.fillStyle = n.axisLabelBackground;
|
|
2930
|
+
for (let { y: t } of p) e.fillRect(a + 1, t - 8, u - 2, 16);
|
|
2852
2931
|
e.fillStyle = n.axisLabel;
|
|
2853
|
-
for (let { y: t, text: n } of
|
|
2932
|
+
for (let { y: t, text: n } of p) e.fillText(n, a + 5, t);
|
|
2854
2933
|
}
|
|
2855
|
-
}, I = /* @__PURE__ */ new Date(),
|
|
2934
|
+
}, I = /* @__PURE__ */ new Date(), ut = (e) => e < 10 ? "0" + e : "" + e, dt = -(/* @__PURE__ */ new Date()).getTimezoneOffset() / 60, ft = `UTC${dt >= 0 ? "+" : ""}${dt}`, pt = class {
|
|
2856
2935
|
render(e, t, n, r, i) {
|
|
2857
2936
|
let { chartRect: a } = t, o = i ?? a.y + a.height;
|
|
2858
2937
|
e.strokeStyle = n.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(a.x, o + .5), e.lineTo(a.x + a.width, o + .5), e.stroke();
|
|
@@ -2864,12 +2943,12 @@ var tt = class {
|
|
|
2864
2943
|
let n = t * s + d, i = r[t].time, a = i > 0xe8d4a51000 ? i : i * 1e3;
|
|
2865
2944
|
I.setTime(a);
|
|
2866
2945
|
let l = I.getDate(), u = I.getMonth() + 1, p = I.getHours(), m = I.getMinutes(), h;
|
|
2867
|
-
l === f ? h = `${
|
|
2946
|
+
l === f ? h = `${ut(p)}:${ut(m)}` : (h = `${u}/${l}`, f = l), e.fillText(h, n, o + 5);
|
|
2868
2947
|
}
|
|
2869
2948
|
let p = a.x + a.width - 4, m = o + 4;
|
|
2870
|
-
e.font = `${n.font.sizeSmall - 1}px ${n.font.family}`, e.textAlign = "right", e.textBaseline = "top", e.fillStyle = n.textSecondary, e.fillText(
|
|
2949
|
+
e.font = `${n.font.sizeSmall - 1}px ${n.font.family}`, e.textAlign = "right", e.textBaseline = "top", e.fillStyle = n.textSecondary, e.fillText(ft, p, m);
|
|
2871
2950
|
}
|
|
2872
|
-
},
|
|
2951
|
+
}, mt = class {
|
|
2873
2952
|
panHandler = null;
|
|
2874
2953
|
zoomHandler = null;
|
|
2875
2954
|
crosshairHandler = null;
|
|
@@ -2997,7 +3076,7 @@ var tt = class {
|
|
|
2997
3076
|
y: (e.clientY + t.clientY) / 2 - n.top
|
|
2998
3077
|
};
|
|
2999
3078
|
}
|
|
3000
|
-
},
|
|
3079
|
+
}, ht = class {
|
|
3001
3080
|
dragging = !1;
|
|
3002
3081
|
lastX = 0;
|
|
3003
3082
|
lastTime = 0;
|
|
@@ -3033,7 +3112,7 @@ var tt = class {
|
|
|
3033
3112
|
stopMomentum() {
|
|
3034
3113
|
this.momentumId &&= (cancelAnimationFrame(this.momentumId), 0);
|
|
3035
3114
|
}
|
|
3036
|
-
},
|
|
3115
|
+
}, gt = class {
|
|
3037
3116
|
callback;
|
|
3038
3117
|
sensitivity;
|
|
3039
3118
|
pendingDelta = 0;
|
|
@@ -3052,7 +3131,7 @@ var tt = class {
|
|
|
3052
3131
|
dispose() {
|
|
3053
3132
|
this.rafId &&= (cancelAnimationFrame(this.rafId), 0);
|
|
3054
3133
|
}
|
|
3055
|
-
},
|
|
3134
|
+
}, _t = class {
|
|
3056
3135
|
position = null;
|
|
3057
3136
|
callback = null;
|
|
3058
3137
|
data = [];
|
|
@@ -3098,13 +3177,13 @@ var tt = class {
|
|
|
3098
3177
|
if (!this.position || this.mode === "hidden") return;
|
|
3099
3178
|
let { chartRect: r } = t, { x: i, y: a } = this.position;
|
|
3100
3179
|
if (i < r.x || i > r.x + r.width || a < r.y || a > r.y + r.height) return;
|
|
3101
|
-
let o =
|
|
3102
|
-
o = Math.max(0, Math.min(this.data.length - 1, o)), this.magnetMode && o >= 0 && o < this.data.length && (i =
|
|
3180
|
+
let o = E(i, t);
|
|
3181
|
+
o = Math.max(0, Math.min(this.data.length - 1, o)), this.magnetMode && o >= 0 && o < this.data.length && (i = w(o, t)), o !== this.lastCallbackBarIndex && (this.pendingBarIndex = o, this.pendingPoint = {
|
|
3103
3182
|
x: i,
|
|
3104
3183
|
y: a
|
|
3105
3184
|
}, this.lastCallbackBarIndex = o, this.scheduleCallback()), e.setLineDash([4, 4]), e.strokeStyle = n.crosshair, e.lineWidth = 1, e.beginPath(), e.moveTo(Math.round(i) + .5, r.y), e.lineTo(Math.round(i) + .5, r.y + r.height), e.stroke(), e.beginPath(), e.moveTo(r.x, Math.round(a) + .5), e.lineTo(r.x + r.width, Math.round(a) + .5), e.stroke(), e.setLineDash([]);
|
|
3106
|
-
let s =
|
|
3107
|
-
e.fillStyle = n.axisLabelBackground, e.fillRect(
|
|
3185
|
+
let s = h(D(a, t), this.pricePrecision, this.locale), c = r.x + r.width + 1;
|
|
3186
|
+
e.fillStyle = n.axisLabelBackground, e.fillRect(c, a - 10, u - 2, 20), e.fillStyle = n.axisLabel, e.font = `${n.font.sizeSmall}px ${n.font.family}`, e.textBaseline = "middle", e.textAlign = "left", e.fillText(s, c + 5, a);
|
|
3108
3187
|
}
|
|
3109
3188
|
scheduleCallback() {
|
|
3110
3189
|
this.callbackScheduled || (this.callbackScheduled = !0, queueMicrotask(() => {
|
|
@@ -3114,7 +3193,7 @@ var tt = class {
|
|
|
3114
3193
|
flushCallback(e, t) {
|
|
3115
3194
|
this.callback?.(e, t);
|
|
3116
3195
|
}
|
|
3117
|
-
},
|
|
3196
|
+
}, vt = class {
|
|
3118
3197
|
callbacks;
|
|
3119
3198
|
enabled = !0;
|
|
3120
3199
|
constructor(e) {
|
|
@@ -3140,7 +3219,7 @@ var tt = class {
|
|
|
3140
3219
|
default: return !1;
|
|
3141
3220
|
}
|
|
3142
3221
|
}
|
|
3143
|
-
},
|
|
3222
|
+
}, yt = class {
|
|
3144
3223
|
el = null;
|
|
3145
3224
|
visible = !1;
|
|
3146
3225
|
timeEl;
|
|
@@ -3179,8 +3258,8 @@ var tt = class {
|
|
|
3179
3258
|
this.changeEl.textContent = `${l}${a(s)} (${l}${c.toFixed(2)}%)`, this.changeEl.style.color = i;
|
|
3180
3259
|
let u = t.volume;
|
|
3181
3260
|
this.volEl.textContent = `Vol ${u >= 1e6 ? (u / 1e6).toFixed(1) + "M" : u >= 1e3 ? (u / 1e3).toFixed(1) + "K" : u.toFixed(0)}`, this.volEl.style.color = n.textSecondary;
|
|
3182
|
-
let d =
|
|
3183
|
-
this.el.style.background = d ?
|
|
3261
|
+
let d = bt(n.background);
|
|
3262
|
+
this.el.style.background = d ? xt(n.background, .95) : xt(n.background, .97), this.el.style.border = `1px solid ${n.axisLine}`, this.el.style.boxShadow = d ? "0 4px 12px rgba(0,0,0,0.5)" : "0 4px 12px rgba(0,0,0,0.15)", this.el.style.color = n.text, this.el.style.backdropFilter = "blur(8px)", !this.measured && this.visible && (this.measuredWidth = this.el.offsetWidth, this.measuredHeight = this.el.offsetHeight, this.measured = !0);
|
|
3184
3263
|
let f = e.x + 16, p = e.y - 40;
|
|
3185
3264
|
f + this.measuredWidth > r.width - 80 && (f = e.x - this.measuredWidth - 16), p < 4 && (p = 4), p + this.measuredHeight > r.height && (p = r.height - this.measuredHeight - 4), this.el.style.transform = `translate(${Math.round(f)}px, ${Math.round(p)}px)`, this.el.style.left = "0", this.el.style.top = "0", this.visible ||= (this.el.style.display = "block", !0);
|
|
3186
3265
|
}
|
|
@@ -3205,7 +3284,7 @@ var tt = class {
|
|
|
3205
3284
|
return document.createElement("span");
|
|
3206
3285
|
}
|
|
3207
3286
|
};
|
|
3208
|
-
function
|
|
3287
|
+
function bt(e) {
|
|
3209
3288
|
if (e.startsWith("#")) {
|
|
3210
3289
|
let t = e.slice(1), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t.slice(0, 6), r = parseInt(n.slice(0, 2), 16), i = parseInt(n.slice(2, 4), 16), a = parseInt(n.slice(4, 6), 16);
|
|
3211
3290
|
return (.299 * r + .587 * i + .114 * a) / 255 < .5;
|
|
@@ -3217,7 +3296,7 @@ function mt(e) {
|
|
|
3217
3296
|
}
|
|
3218
3297
|
return !0;
|
|
3219
3298
|
}
|
|
3220
|
-
function
|
|
3299
|
+
function xt(e, t) {
|
|
3221
3300
|
if (e.startsWith("#")) {
|
|
3222
3301
|
let n = e.slice(1), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n.slice(0, 6);
|
|
3223
3302
|
return `rgba(${parseInt(r.slice(0, 2), 16)}, ${parseInt(r.slice(2, 4), 16)}, ${parseInt(r.slice(4, 6), 16)}, ${t})`;
|
|
@@ -3226,7 +3305,7 @@ function ht(e, t) {
|
|
|
3226
3305
|
}
|
|
3227
3306
|
//#endregion
|
|
3228
3307
|
//#region src/events/EventBus.ts
|
|
3229
|
-
var
|
|
3308
|
+
var St = class {
|
|
3230
3309
|
listeners = /* @__PURE__ */ new Map();
|
|
3231
3310
|
tauriBridge = null;
|
|
3232
3311
|
on(e, t) {
|
|
@@ -3267,14 +3346,14 @@ var gt = class {
|
|
|
3267
3346
|
}
|
|
3268
3347
|
anchorToPixel(e, t) {
|
|
3269
3348
|
return {
|
|
3270
|
-
x:
|
|
3271
|
-
y:
|
|
3349
|
+
x: w(e.time, t),
|
|
3350
|
+
y: T(e.price, t)
|
|
3272
3351
|
};
|
|
3273
3352
|
}
|
|
3274
3353
|
pixelToAnchor(e, t) {
|
|
3275
3354
|
return {
|
|
3276
|
-
time:
|
|
3277
|
-
price:
|
|
3355
|
+
time: E(e.x, t),
|
|
3356
|
+
price: D(e.y, t)
|
|
3278
3357
|
};
|
|
3279
3358
|
}
|
|
3280
3359
|
applyLineStyle(e, t) {
|
|
@@ -3312,7 +3391,7 @@ var gt = class {
|
|
|
3312
3391
|
let r = n.x - t.x, i = n.y - t.y, a = Math.hypot(r, i);
|
|
3313
3392
|
return a === 0 ? Math.hypot(e.x - t.x, e.y - t.y) : Math.abs(r * (t.y - e.y) - i * (t.x - e.x)) / a;
|
|
3314
3393
|
}
|
|
3315
|
-
},
|
|
3394
|
+
}, Ct = 1;
|
|
3316
3395
|
function R(e) {
|
|
3317
3396
|
return {
|
|
3318
3397
|
...e,
|
|
@@ -3321,7 +3400,7 @@ function R(e) {
|
|
|
3321
3400
|
meta: e.meta ? { ...e.meta } : void 0
|
|
3322
3401
|
};
|
|
3323
3402
|
}
|
|
3324
|
-
var
|
|
3403
|
+
var wt = class {
|
|
3325
3404
|
registry = /* @__PURE__ */ new Map();
|
|
3326
3405
|
drawings = [];
|
|
3327
3406
|
state = "idle";
|
|
@@ -3480,7 +3559,7 @@ var vt = class {
|
|
|
3480
3559
|
if (this.state === "creating" && this.creatingDrawing) {
|
|
3481
3560
|
let n = this.registry.get(this.creatingDrawing.type);
|
|
3482
3561
|
if (n && this.committedAnchors < n.descriptor.requiredAnchors) {
|
|
3483
|
-
let n =
|
|
3562
|
+
let n = E(e.x, t), r = D(e.y, t);
|
|
3484
3563
|
return this.previewAnchor = this.snapToOHLC(n, r, t), this.requestRender?.(), !0;
|
|
3485
3564
|
}
|
|
3486
3565
|
}
|
|
@@ -3526,7 +3605,7 @@ var vt = class {
|
|
|
3526
3605
|
let t = this.drawings.find((t) => t.id === e);
|
|
3527
3606
|
if (!t) return null;
|
|
3528
3607
|
let n = structuredClone(t);
|
|
3529
|
-
return n.id = `tc_drawing_${
|
|
3608
|
+
return n.id = `tc_drawing_${Ct++}`, n.anchors = n.anchors.map((e) => ({
|
|
3530
3609
|
...e,
|
|
3531
3610
|
time: e.time + 3
|
|
3532
3611
|
})), n.locked = !1, this.drawings.push(n), this.undoRedo?.push({
|
|
@@ -3566,9 +3645,9 @@ var vt = class {
|
|
|
3566
3645
|
if (!this.activeTool) return !1;
|
|
3567
3646
|
let n = this.registry.get(this.activeTool);
|
|
3568
3647
|
if (!n) return !1;
|
|
3569
|
-
let r =
|
|
3648
|
+
let r = E(e.x, t), i = D(e.y, t), a = this.snapToOHLC(r, i, t);
|
|
3570
3649
|
return this.creatingDrawing ? (this.creatingDrawing.anchors.push(a), this.committedAnchors++, this.previewAnchor = null, this.committedAnchors >= n.descriptor.requiredAnchors && this.finalizeCreation(), this.requestRender?.(), !0) : (this.creatingDrawing = {
|
|
3571
|
-
id: `tc_drawing_${
|
|
3650
|
+
id: `tc_drawing_${Ct++}`,
|
|
3572
3651
|
type: this.activeTool,
|
|
3573
3652
|
anchors: [a],
|
|
3574
3653
|
style: { ...this.activeStyle },
|
|
@@ -3606,7 +3685,7 @@ var vt = class {
|
|
|
3606
3685
|
handleMove(e, t) {
|
|
3607
3686
|
let n = this.drawings.find((e) => e.id === this.selectedDrawingId);
|
|
3608
3687
|
if (!n || !this.dragStartPoint) return !1;
|
|
3609
|
-
let r =
|
|
3688
|
+
let r = E(e.x, t) - E(this.dragStartPoint.x, t), i = D(e.y, t) - D(this.dragStartPoint.y, t);
|
|
3610
3689
|
return n.anchors = this.dragStartAnchors.map((e) => ({
|
|
3611
3690
|
time: e.time + r,
|
|
3612
3691
|
price: e.price + i
|
|
@@ -3615,18 +3694,18 @@ var vt = class {
|
|
|
3615
3694
|
handleResize(e, t) {
|
|
3616
3695
|
let n = this.drawings.find((e) => e.id === this.selectedDrawingId);
|
|
3617
3696
|
return !n || this.dragAnchorIndex < 0 ? !1 : (n.anchors[this.dragAnchorIndex] = {
|
|
3618
|
-
time:
|
|
3619
|
-
price:
|
|
3697
|
+
time: E(e.x, t),
|
|
3698
|
+
price: D(e.y, t)
|
|
3620
3699
|
}, this.requestRender?.(), !0);
|
|
3621
3700
|
}
|
|
3622
|
-
},
|
|
3701
|
+
}, Tt = class {
|
|
3623
3702
|
constructor(e) {
|
|
3624
3703
|
this.manager = e;
|
|
3625
3704
|
}
|
|
3626
3705
|
render(e, t) {
|
|
3627
3706
|
this.manager.render(e, t);
|
|
3628
3707
|
}
|
|
3629
|
-
},
|
|
3708
|
+
}, Et = class extends L {
|
|
3630
3709
|
descriptor = {
|
|
3631
3710
|
type: "trendLine",
|
|
3632
3711
|
name: "Trend Line",
|
|
@@ -3642,7 +3721,7 @@ var vt = class {
|
|
|
3642
3721
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
|
|
3643
3722
|
return this.distanceToLine(e, i, a) <= r;
|
|
3644
3723
|
}
|
|
3645
|
-
},
|
|
3724
|
+
}, Dt = class extends L {
|
|
3646
3725
|
descriptor = {
|
|
3647
3726
|
type: "horizontalLine",
|
|
3648
3727
|
name: "Horizontal Line",
|
|
@@ -3650,15 +3729,15 @@ var vt = class {
|
|
|
3650
3729
|
};
|
|
3651
3730
|
render(e, t, n, r) {
|
|
3652
3731
|
if (t.anchors.length < 1) return;
|
|
3653
|
-
let i =
|
|
3732
|
+
let i = T(t.anchors[0].price, n), { chartRect: a } = n;
|
|
3654
3733
|
this.applyLineStyle(e, t.style), e.beginPath(), e.moveTo(a.x, i), e.lineTo(a.x + a.width, i), e.stroke(), this.resetLineStyle(e), e.fillStyle = t.style.color, e.font = "11px sans-serif", e.textBaseline = "bottom", e.fillText(t.anchors[0].price.toFixed(2), a.x + 4, i - 3), r && this.renderAnchorHandles(e, t, n);
|
|
3655
3734
|
}
|
|
3656
3735
|
hitTest(e, t, n, r) {
|
|
3657
3736
|
if (t.anchors.length < 1) return !1;
|
|
3658
|
-
let i =
|
|
3737
|
+
let i = T(t.anchors[0].price, n);
|
|
3659
3738
|
return Math.abs(e.y - i) <= r && e.x >= n.chartRect.x && e.x <= n.chartRect.x + n.chartRect.width;
|
|
3660
3739
|
}
|
|
3661
|
-
},
|
|
3740
|
+
}, Ot = class extends L {
|
|
3662
3741
|
descriptor = {
|
|
3663
3742
|
type: "verticalLine",
|
|
3664
3743
|
name: "Vertical Line",
|
|
@@ -3674,7 +3753,7 @@ var vt = class {
|
|
|
3674
3753
|
let i = this.anchorToPixel(t.anchors[0], n), { chartRect: a } = n;
|
|
3675
3754
|
return Math.abs(e.x - i.x) <= r && e.y >= a.y && e.y <= a.y + a.height;
|
|
3676
3755
|
}
|
|
3677
|
-
},
|
|
3756
|
+
}, kt = class extends L {
|
|
3678
3757
|
descriptor = {
|
|
3679
3758
|
type: "ray",
|
|
3680
3759
|
name: "Ray",
|
|
@@ -3692,7 +3771,7 @@ var vt = class {
|
|
|
3692
3771
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = a.x - i.x, s = a.y - i.y;
|
|
3693
3772
|
return ((e.x - i.x) * o + (e.y - i.y) * s) / (o * o + s * s) < 0 ? !1 : this.distanceToInfiniteLine(e, i, a) <= r;
|
|
3694
3773
|
}
|
|
3695
|
-
},
|
|
3774
|
+
}, At = class extends L {
|
|
3696
3775
|
descriptor = {
|
|
3697
3776
|
type: "extendedLine",
|
|
3698
3777
|
name: "Extended Line",
|
|
@@ -3710,7 +3789,7 @@ var vt = class {
|
|
|
3710
3789
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
|
|
3711
3790
|
return this.distanceToInfiniteLine(e, i, a) <= r;
|
|
3712
3791
|
}
|
|
3713
|
-
},
|
|
3792
|
+
}, jt = class extends L {
|
|
3714
3793
|
descriptor = {
|
|
3715
3794
|
type: "parallelChannel",
|
|
3716
3795
|
name: "Parallel Channel",
|
|
@@ -3747,7 +3826,7 @@ var vt = class {
|
|
|
3747
3826
|
}
|
|
3748
3827
|
return !1;
|
|
3749
3828
|
}
|
|
3750
|
-
},
|
|
3829
|
+
}, Mt = class extends L {
|
|
3751
3830
|
descriptor = {
|
|
3752
3831
|
type: "regressionChannel",
|
|
3753
3832
|
name: "Regression Channel",
|
|
@@ -3778,7 +3857,7 @@ var vt = class {
|
|
|
3778
3857
|
.618,
|
|
3779
3858
|
.786,
|
|
3780
3859
|
1
|
|
3781
|
-
],
|
|
3860
|
+
], Nt = class extends L {
|
|
3782
3861
|
descriptor = {
|
|
3783
3862
|
type: "fibRetracement",
|
|
3784
3863
|
name: "Fibonacci Retracement",
|
|
@@ -3789,12 +3868,12 @@ var vt = class {
|
|
|
3789
3868
|
let { chartRect: i } = n, a = t.anchors[0].price, o = t.anchors[1].price, s = a - o;
|
|
3790
3869
|
e.font = "11px sans-serif", e.textBaseline = "middle";
|
|
3791
3870
|
for (let r of z) {
|
|
3792
|
-
let a = o + s * (1 - r), c =
|
|
3871
|
+
let a = o + s * (1 - r), c = T(a, n);
|
|
3793
3872
|
this.applyLineStyle(e, t.style), e.globalAlpha = r === 0 || r === 1 ? 1 : .7, e.beginPath(), e.moveTo(i.x, c), e.lineTo(i.x + i.width, c), e.stroke(), e.fillStyle = t.style.color, e.textAlign = "left", e.fillText(`${(r * 100).toFixed(1)}% (${a.toFixed(2)})`, i.x + 4, c - 2);
|
|
3794
3873
|
}
|
|
3795
3874
|
if (e.globalAlpha = 1, t.style.fillColor) {
|
|
3796
3875
|
for (let r = 0; r < z.length - 1; r++) {
|
|
3797
|
-
let a = o + s * (1 - z[r]), c = o + s * (1 - z[r + 1]), l =
|
|
3876
|
+
let a = o + s * (1 - z[r]), c = o + s * (1 - z[r + 1]), l = T(a, n), u = T(c, n);
|
|
3798
3877
|
e.fillStyle = t.style.fillColor, e.globalAlpha = .05 + r * .02, e.fillRect(i.x, Math.min(l, u), i.width, Math.abs(u - l));
|
|
3799
3878
|
}
|
|
3800
3879
|
e.globalAlpha = 1;
|
|
@@ -3807,12 +3886,12 @@ var vt = class {
|
|
|
3807
3886
|
if (e.x < i.x - r || e.x > i.x + i.width + r) return !1;
|
|
3808
3887
|
let a = t.anchors[0].price, o = t.anchors[1].price, s = a - o;
|
|
3809
3888
|
for (let t of z) {
|
|
3810
|
-
let i =
|
|
3889
|
+
let i = T(o + s * (1 - t), n);
|
|
3811
3890
|
if (Math.abs(e.y - i) <= r) return !0;
|
|
3812
3891
|
}
|
|
3813
3892
|
return !1;
|
|
3814
3893
|
}
|
|
3815
|
-
},
|
|
3894
|
+
}, Pt = [
|
|
3816
3895
|
0,
|
|
3817
3896
|
.618,
|
|
3818
3897
|
1,
|
|
@@ -3821,7 +3900,7 @@ var vt = class {
|
|
|
3821
3900
|
2.618,
|
|
3822
3901
|
3.618,
|
|
3823
3902
|
4.236
|
|
3824
|
-
],
|
|
3903
|
+
], Ft = class extends L {
|
|
3825
3904
|
descriptor = {
|
|
3826
3905
|
type: "fibExtension",
|
|
3827
3906
|
name: "Fibonacci Extension",
|
|
@@ -3837,8 +3916,8 @@ var vt = class {
|
|
|
3837
3916
|
}
|
|
3838
3917
|
let { chartRect: i } = n, a = t.anchors[0].price, o = t.anchors[1].price, s = t.anchors[2].price, c = a - o;
|
|
3839
3918
|
e.font = "11px sans-serif", e.textBaseline = "middle", e.textAlign = "left";
|
|
3840
|
-
for (let r of
|
|
3841
|
-
let a =
|
|
3919
|
+
for (let r of Pt) {
|
|
3920
|
+
let a = T(s + c * r, n);
|
|
3842
3921
|
this.applyLineStyle(e, t.style), e.globalAlpha = r === 0 || r === 1 ? 1 : .6, e.beginPath(), e.moveTo(i.x, a), e.lineTo(i.x + i.width, a), e.stroke(), e.fillStyle = t.style.color, e.fillText(`${(r * 100).toFixed(1)}%`, i.x + 4, a - 2);
|
|
3843
3922
|
}
|
|
3844
3923
|
e.globalAlpha = 1, this.resetLineStyle(e), r && this.renderAnchorHandles(e, t, n);
|
|
@@ -3848,13 +3927,13 @@ var vt = class {
|
|
|
3848
3927
|
let { chartRect: i } = n;
|
|
3849
3928
|
if (e.x < i.x - r || e.x > i.x + i.width + r) return !1;
|
|
3850
3929
|
let a = t.anchors[0].price - t.anchors[1].price;
|
|
3851
|
-
for (let i of
|
|
3852
|
-
let o =
|
|
3930
|
+
for (let i of Pt) {
|
|
3931
|
+
let o = T(t.anchors[2].price + a * i, n);
|
|
3853
3932
|
if (Math.abs(e.y - o) <= r) return !0;
|
|
3854
3933
|
}
|
|
3855
3934
|
return !1;
|
|
3856
3935
|
}
|
|
3857
|
-
},
|
|
3936
|
+
}, It = class extends L {
|
|
3858
3937
|
descriptor = {
|
|
3859
3938
|
type: "rectangle",
|
|
3860
3939
|
name: "Rectangle",
|
|
@@ -3872,7 +3951,7 @@ var vt = class {
|
|
|
3872
3951
|
let u = Math.min(i.x, a.x) + r, d = Math.min(i.y, a.y) + r, f = Math.max(i.x, a.x) - r, p = Math.max(i.y, a.y) - r;
|
|
3873
3952
|
return !(e.x > u && e.x < f && e.y > d && e.y < p) || !!t.style.fillColor;
|
|
3874
3953
|
}
|
|
3875
|
-
},
|
|
3954
|
+
}, Lt = class extends L {
|
|
3876
3955
|
descriptor = {
|
|
3877
3956
|
type: "ellipse",
|
|
3878
3957
|
name: "Ellipse",
|
|
@@ -3888,7 +3967,7 @@ var vt = class {
|
|
|
3888
3967
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = (i.x + a.x) / 2, s = (i.y + a.y) / 2, c = Math.max(Math.abs(a.x - i.x) / 2, 1), l = Math.max(Math.abs(a.y - i.y) / 2, 1), u = (e.x - o) / c, d = (e.y - s) / l, f = Math.sqrt(u * u + d * d), p = r / Math.max(Math.min(c, l), 4);
|
|
3889
3968
|
return t.style.fillColor ? f <= 1 + p : Math.abs(f - 1) <= p;
|
|
3890
3969
|
}
|
|
3891
|
-
},
|
|
3970
|
+
}, Rt = class extends L {
|
|
3892
3971
|
descriptor = {
|
|
3893
3972
|
type: "triangle",
|
|
3894
3973
|
name: "Triangle",
|
|
@@ -3914,7 +3993,7 @@ var vt = class {
|
|
|
3914
3993
|
}
|
|
3915
3994
|
return !1;
|
|
3916
3995
|
}
|
|
3917
|
-
},
|
|
3996
|
+
}, zt = class extends L {
|
|
3918
3997
|
descriptor = {
|
|
3919
3998
|
type: "pitchfork",
|
|
3920
3999
|
name: "Andrews' Pitchfork",
|
|
@@ -3950,7 +4029,7 @@ var vt = class {
|
|
|
3950
4029
|
};
|
|
3951
4030
|
return this.distanceToInfiniteLine(e, a, u) <= r || this.distanceToInfiniteLine(e, o, d) <= r;
|
|
3952
4031
|
}
|
|
3953
|
-
},
|
|
4032
|
+
}, Bt = [
|
|
3954
4033
|
"1",
|
|
3955
4034
|
"2",
|
|
3956
4035
|
"3",
|
|
@@ -3959,7 +4038,7 @@ var vt = class {
|
|
|
3959
4038
|
"A",
|
|
3960
4039
|
"B",
|
|
3961
4040
|
"C"
|
|
3962
|
-
],
|
|
4041
|
+
], Vt = class extends L {
|
|
3963
4042
|
descriptor = {
|
|
3964
4043
|
type: "elliottWave",
|
|
3965
4044
|
name: "Elliott Wave",
|
|
@@ -3971,9 +4050,9 @@ var vt = class {
|
|
|
3971
4050
|
this.applyLineStyle(e, t.style), e.beginPath(), e.moveTo(i[0].x, i[0].y);
|
|
3972
4051
|
for (let t = 1; t < i.length; t++) e.lineTo(i[t].x, i[t].y);
|
|
3973
4052
|
e.stroke(), this.resetLineStyle(e), e.font = "bold 12px sans-serif", e.fillStyle = t.style.color, e.textAlign = "center";
|
|
3974
|
-
for (let t = 0; t < i.length && t <
|
|
4053
|
+
for (let t = 0; t < i.length && t < Bt.length; t++) {
|
|
3975
4054
|
let n = t % 2 == 0 ? -12 : 12;
|
|
3976
|
-
e.textBaseline = n < 0 ? "bottom" : "top", e.fillText(
|
|
4055
|
+
e.textBaseline = n < 0 ? "bottom" : "top", e.fillText(Bt[t], i[t].x, i[t].y + n);
|
|
3977
4056
|
}
|
|
3978
4057
|
r && this.renderAnchorHandles(e, t, n);
|
|
3979
4058
|
}
|
|
@@ -3983,7 +4062,7 @@ var vt = class {
|
|
|
3983
4062
|
for (let t = 0; t < i.length - 1; t++) if (this.distanceToLine(e, i[t], i[t + 1]) <= r) return !0;
|
|
3984
4063
|
return !1;
|
|
3985
4064
|
}
|
|
3986
|
-
},
|
|
4065
|
+
}, Ht = class extends L {
|
|
3987
4066
|
descriptor = {
|
|
3988
4067
|
type: "priceRange",
|
|
3989
4068
|
name: "Price Range",
|
|
@@ -4001,7 +4080,7 @@ var vt = class {
|
|
|
4001
4080
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = Math.min(i.x, a.x), s = Math.max(i.x, a.x), c = Math.min(i.y, a.y), l = Math.max(i.y, a.y);
|
|
4002
4081
|
return e.x >= o - r && e.x <= s + r && e.y >= c - r && e.y <= l + r;
|
|
4003
4082
|
}
|
|
4004
|
-
},
|
|
4083
|
+
}, Ut = class extends L {
|
|
4005
4084
|
descriptor = {
|
|
4006
4085
|
type: "dateRange",
|
|
4007
4086
|
name: "Date Range",
|
|
@@ -4019,7 +4098,7 @@ var vt = class {
|
|
|
4019
4098
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), { chartRect: o } = n, s = Math.min(i.x, a.x), c = Math.max(i.x, a.x);
|
|
4020
4099
|
return e.x >= s - r && e.x <= c + r && e.y >= o.y && e.y <= o.y + o.height;
|
|
4021
4100
|
}
|
|
4022
|
-
},
|
|
4101
|
+
}, Wt = class extends L {
|
|
4023
4102
|
descriptor = {
|
|
4024
4103
|
type: "measure",
|
|
4025
4104
|
name: "Measure",
|
|
@@ -4044,12 +4123,12 @@ var vt = class {
|
|
|
4044
4123
|
};
|
|
4045
4124
|
//#endregion
|
|
4046
4125
|
//#region src/drawings/tools/TextAnnotation.ts
|
|
4047
|
-
function
|
|
4126
|
+
function Gt(e, t = "Text") {
|
|
4048
4127
|
if (typeof e.style.text == "string" && e.style.text.length > 0) return e.style.text;
|
|
4049
4128
|
let n = e.meta?.text;
|
|
4050
4129
|
return typeof n == "string" && n.length > 0 ? n : t;
|
|
4051
4130
|
}
|
|
4052
|
-
var
|
|
4131
|
+
var Kt = class extends L {
|
|
4053
4132
|
descriptor = {
|
|
4054
4133
|
type: "text",
|
|
4055
4134
|
name: "Text",
|
|
@@ -4057,7 +4136,7 @@ var Bt = class extends L {
|
|
|
4057
4136
|
};
|
|
4058
4137
|
render(e, t, n, r) {
|
|
4059
4138
|
if (t.anchors.length < 1) return;
|
|
4060
|
-
let i = this.anchorToPixel(t.anchors[0], n), a =
|
|
4139
|
+
let i = this.anchorToPixel(t.anchors[0], n), a = Gt(t), o = t.style.fontSize || 14;
|
|
4061
4140
|
if (e.font = `${o}px sans-serif`, e.fillStyle = t.style.color, e.textAlign = "left", e.textBaseline = "top", r) {
|
|
4062
4141
|
let n = e.measureText(a);
|
|
4063
4142
|
e.strokeStyle = t.style.color, e.lineWidth = 1, e.setLineDash([3, 3]), e.strokeRect(i.x - 2, i.y - 2, n.width + 4, o + 4), e.setLineDash([]);
|
|
@@ -4069,7 +4148,7 @@ var Bt = class extends L {
|
|
|
4069
4148
|
let i = this.anchorToPixel(t.anchors[0], n), a = t.style.fontSize || 14;
|
|
4070
4149
|
return e.x >= i.x - r && e.x <= i.x + 80 + r && e.y >= i.y - r && e.y <= i.y + a + r;
|
|
4071
4150
|
}
|
|
4072
|
-
},
|
|
4151
|
+
}, qt = class extends L {
|
|
4073
4152
|
descriptor = {
|
|
4074
4153
|
type: "arrow",
|
|
4075
4154
|
name: "Arrow",
|
|
@@ -4087,7 +4166,7 @@ var Bt = class extends L {
|
|
|
4087
4166
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
|
|
4088
4167
|
return this.distanceToLine(e, i, a) <= r;
|
|
4089
4168
|
}
|
|
4090
|
-
},
|
|
4169
|
+
}, Jt = [
|
|
4091
4170
|
{
|
|
4092
4171
|
label: "8x1",
|
|
4093
4172
|
ratio: 8
|
|
@@ -4124,7 +4203,7 @@ var Bt = class extends L {
|
|
|
4124
4203
|
label: "1x8",
|
|
4125
4204
|
ratio: .125
|
|
4126
4205
|
}
|
|
4127
|
-
],
|
|
4206
|
+
], Yt = class extends L {
|
|
4128
4207
|
descriptor = {
|
|
4129
4208
|
type: "gannFan",
|
|
4130
4209
|
name: "Gann Fan",
|
|
@@ -4136,7 +4215,7 @@ var Bt = class extends L {
|
|
|
4136
4215
|
if (Math.abs(o) < 1) return;
|
|
4137
4216
|
let c = s / o, l = o > 0 ? 1 : -1, { chartRect: u } = n, d = l > 0 ? u.x + u.width : u.x;
|
|
4138
4217
|
this.applyLineStyle(e, t.style);
|
|
4139
|
-
for (let { label: n, ratio: r } of
|
|
4218
|
+
for (let { label: n, ratio: r } of Jt) {
|
|
4140
4219
|
let a = c * r, o = d, s = i.y + a * (o - i.x);
|
|
4141
4220
|
e.globalAlpha = r === 1 ? 1 : .5, e.lineWidth = r === 1 ? t.style.lineWidth : Math.max(.5, t.style.lineWidth * .7), e.beginPath(), e.moveTo(i.x, i.y), e.lineTo(o, s), e.stroke();
|
|
4142
4221
|
let f = o - l * 4, p = s;
|
|
@@ -4149,7 +4228,7 @@ var Bt = class extends L {
|
|
|
4149
4228
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = a.x - i.x, s = a.y - i.y;
|
|
4150
4229
|
if (Math.abs(o) < 1) return !1;
|
|
4151
4230
|
let c = s / o, l = o > 0 ? 1 : -1, { chartRect: u } = n, d = l > 0 ? u.x + u.width : u.x;
|
|
4152
|
-
for (let { ratio: t } of
|
|
4231
|
+
for (let { ratio: t } of Jt) {
|
|
4153
4232
|
let n = c * t, a = d, o = i.y + n * (a - i.x);
|
|
4154
4233
|
if (this.distanceToLine(e, i, {
|
|
4155
4234
|
x: a,
|
|
@@ -4166,7 +4245,7 @@ var Bt = class extends L {
|
|
|
4166
4245
|
.667,
|
|
4167
4246
|
.75,
|
|
4168
4247
|
1
|
|
4169
|
-
],
|
|
4248
|
+
], Xt = class extends L {
|
|
4170
4249
|
descriptor = {
|
|
4171
4250
|
type: "gannBox",
|
|
4172
4251
|
name: "Gann Box",
|
|
@@ -4213,7 +4292,7 @@ var Bt = class extends L {
|
|
|
4213
4292
|
y: l
|
|
4214
4293
|
}) <= r;
|
|
4215
4294
|
}
|
|
4216
|
-
},
|
|
4295
|
+
}, Zt = class extends L {
|
|
4217
4296
|
descriptor = {
|
|
4218
4297
|
type: "anchoredVWAP",
|
|
4219
4298
|
name: "Anchored VWAP",
|
|
@@ -4233,7 +4312,7 @@ var Bt = class extends L {
|
|
|
4233
4312
|
if (a >= i.length) return;
|
|
4234
4313
|
let { vwap: o, upper1: s, lower1: c, upper2: l, lower2: u } = this.computeVWAP(i, a), { chartRect: d } = n, f = n.barWidth + n.barSpacing;
|
|
4235
4314
|
if (this.applyLineStyle(e, t.style), e.lineWidth = t.style.lineWidth + .5, this.drawLine(e, o, a, n, d, f), this.showBands && o.length > 1 && (e.globalAlpha = .4, e.lineWidth = Math.max(.5, t.style.lineWidth * .6), e.setLineDash([4, 3]), this.drawLine(e, s, a, n, d, f), this.drawLine(e, c, a, n, d, f), e.globalAlpha = .25, this.drawLine(e, l, a, n, d, f), this.drawLine(e, u, a, n, d, f), e.globalAlpha = 1), this.resetLineStyle(e), o.length > 0) {
|
|
4236
|
-
let r = o[o.length - 1], i =
|
|
4315
|
+
let r = o[o.length - 1], i = w(a + o.length - 1, n), s = T(r, n);
|
|
4237
4316
|
i >= d.x && i <= d.x + d.width && (e.fillStyle = t.style.color, e.font = "bold 9px sans-serif", e.textAlign = "left", e.textBaseline = "middle", e.fillText(`AVWAP ${r.toFixed(2)}`, i + 6, s));
|
|
4238
4317
|
}
|
|
4239
4318
|
r && this.renderAnchorHandles(e, t, n);
|
|
@@ -4242,10 +4321,10 @@ var Bt = class extends L {
|
|
|
4242
4321
|
e.beginPath();
|
|
4243
4322
|
let o = !1;
|
|
4244
4323
|
for (let s = 0; s < t.length; s++) {
|
|
4245
|
-
let c =
|
|
4324
|
+
let c = w(n + s, r);
|
|
4246
4325
|
if (c < i.x - a) continue;
|
|
4247
4326
|
if (c > i.x + i.width + a) break;
|
|
4248
|
-
let l =
|
|
4327
|
+
let l = T(t[s], r);
|
|
4249
4328
|
o ? e.lineTo(c, l) : (e.moveTo(c, l), o = !0);
|
|
4250
4329
|
}
|
|
4251
4330
|
e.stroke();
|
|
@@ -4274,7 +4353,7 @@ var Bt = class extends L {
|
|
|
4274
4353
|
if (a >= i.length) return !1;
|
|
4275
4354
|
let { vwap: o } = this.computeVWAP(i, a);
|
|
4276
4355
|
for (let t = 1; t < o.length; t++) {
|
|
4277
|
-
let i =
|
|
4356
|
+
let i = w(a + t - 1, n), s = T(o[t - 1], n), c = w(a + t, n), l = T(o[t], n);
|
|
4278
4357
|
if (this.distanceToLine(e, {
|
|
4279
4358
|
x: i,
|
|
4280
4359
|
y: s
|
|
@@ -4285,7 +4364,7 @@ var Bt = class extends L {
|
|
|
4285
4364
|
}
|
|
4286
4365
|
return !1;
|
|
4287
4366
|
}
|
|
4288
|
-
},
|
|
4367
|
+
}, Qt = class extends L {
|
|
4289
4368
|
descriptor = {
|
|
4290
4369
|
type: "volumeProfileRange",
|
|
4291
4370
|
name: "Volume Profile (Range)",
|
|
@@ -4311,15 +4390,15 @@ var Bt = class extends L {
|
|
|
4311
4390
|
if (d === 0) return;
|
|
4312
4391
|
let f = 0;
|
|
4313
4392
|
for (let e = 1; e < this.numBins; e++) u[e] > u[f] && (f = e);
|
|
4314
|
-
let p =
|
|
4393
|
+
let p = w(o, n) + n.barWidth, m = t.style.color, h = t.style.fillColor ?? "#FF9800";
|
|
4315
4394
|
e.save();
|
|
4316
4395
|
for (let t = 0; t < this.numBins; t++) {
|
|
4317
|
-
let r = u[t] / d * 100, i = s + (t + 1) * l, a = s + t * l, o =
|
|
4396
|
+
let r = u[t] / d * 100, i = s + (t + 1) * l, a = s + t * l, o = T(i, n), c = T(a, n), g = Math.abs(c - o);
|
|
4318
4397
|
e.globalAlpha = .35, e.fillStyle = t === f ? h : m, e.fillRect(p, Math.min(o, c), r, Math.max(1, g - .5));
|
|
4319
4398
|
}
|
|
4320
|
-
let g = s + (f + .5) * l, _ =
|
|
4399
|
+
let g = s + (f + .5) * l, _ = T(g, n);
|
|
4321
4400
|
e.globalAlpha = .7, e.strokeStyle = h, e.lineWidth = 1, e.setLineDash([4, 3]), e.beginPath();
|
|
4322
|
-
let v =
|
|
4401
|
+
let v = w(a, n) - n.barWidth / 2;
|
|
4323
4402
|
e.moveTo(v, _), e.lineTo(p + 100, _), e.stroke(), e.fillStyle = h, e.font = "9px sans-serif", e.textAlign = "left", e.textBaseline = "bottom", e.globalAlpha = .8, e.fillText(`POC ${g.toFixed(2)}`, p + 100 + 4, _ - 2), e.restore(), r && this.renderAnchorHandles(e, t, n);
|
|
4324
4403
|
}
|
|
4325
4404
|
hitTest(e, t, n, r) {
|
|
@@ -4330,16 +4409,16 @@ var Bt = class extends L {
|
|
|
4330
4409
|
};
|
|
4331
4410
|
//#endregion
|
|
4332
4411
|
//#region src/drawings/tools/index.ts
|
|
4333
|
-
function
|
|
4334
|
-
e.register(new
|
|
4412
|
+
function $t(e) {
|
|
4413
|
+
e.register(new Et()), e.register(new Dt()), e.register(new Ot()), e.register(new kt()), e.register(new At()), e.register(new jt()), e.register(new Mt()), e.register(new Nt()), e.register(new Ft()), e.register(new It()), e.register(new Lt()), e.register(new Rt()), e.register(new zt()), e.register(new Vt()), e.register(new Ht()), e.register(new Ut()), e.register(new Wt()), e.register(new Kt()), e.register(new qt()), e.register(new Yt()), e.register(new Xt()), e.register(new Zt()), e.register(new Qt());
|
|
4335
4414
|
}
|
|
4336
4415
|
//#endregion
|
|
4337
4416
|
//#region src/trading/OrderRenderer.ts
|
|
4338
|
-
var
|
|
4417
|
+
var en = class {
|
|
4339
4418
|
render(e, t, n, r, i, a) {
|
|
4340
4419
|
let o = i.orderColors?.buy ?? "#26A69A", s = i.orderColors?.sell ?? "#EF5350", { chartRect: c } = n;
|
|
4341
4420
|
for (let i of t) {
|
|
4342
|
-
let t = a?.orderId === i.id && a.sourceType === "order", l =
|
|
4421
|
+
let t = a?.orderId === i.id && a.sourceType === "order", l = T(t ? a.currentPrice : i.price, n);
|
|
4343
4422
|
if (l < c.y || l > c.y + c.height) continue;
|
|
4344
4423
|
let u = i.side === "buy" ? o : s;
|
|
4345
4424
|
e.setLineDash([6, 4]), e.strokeStyle = u, e.lineWidth = 1, e.beginPath(), e.moveTo(c.x, Math.round(l) + .5), e.lineTo(c.x + c.width, Math.round(l) + .5), e.stroke(), e.setLineDash([]);
|
|
@@ -4349,26 +4428,26 @@ var Jt = class {
|
|
|
4349
4428
|
e.fillStyle = u, e.fillRect(c.x + 4, l - 8, f, 16), e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.textAlign = "left", e.fillText(d, c.x + 8, l);
|
|
4350
4429
|
let p = c.x + 4 + f + 6;
|
|
4351
4430
|
if (e.fillStyle = u, e.beginPath(), i.side === "buy" ? (e.moveTo(p, l + 4), e.lineTo(p + 5, l - 2), e.lineTo(p + 10, l + 4)) : (e.moveTo(p, l - 4), e.lineTo(p + 5, l + 2), e.lineTo(p + 10, l - 4)), e.fill(), t) {
|
|
4352
|
-
let t =
|
|
4431
|
+
let t = T(a.startPrice, n);
|
|
4353
4432
|
e.setLineDash([2, 4]), e.strokeStyle = u, e.globalAlpha = .3, e.beginPath(), e.moveTo(c.x, Math.round(t) + .5), e.lineTo(c.x + c.width, Math.round(t) + .5), e.stroke(), e.globalAlpha = 1, e.setLineDash([]);
|
|
4354
4433
|
}
|
|
4355
4434
|
}
|
|
4356
4435
|
}
|
|
4357
4436
|
renderAxisBadges(e, t, n, r, i, a) {
|
|
4358
|
-
let o = i.orderColors?.buy ?? "#26A69A", s = i.orderColors?.sell ?? "#EF5350",
|
|
4437
|
+
let o = i.orderColors?.buy ?? "#26A69A", s = i.orderColors?.sell ?? "#EF5350", c = i.pricePrecision ?? 2, { chartRect: l } = n, d = l.x + l.width + 1;
|
|
4359
4438
|
for (let i of t) {
|
|
4360
|
-
let t = a?.orderId === i.id && a.sourceType === "order" ? a.currentPrice : i.price, f =
|
|
4361
|
-
if (f <
|
|
4362
|
-
let p = i.side === "buy" ? o : s, m = `${t.toFixed(
|
|
4439
|
+
let t = a?.orderId === i.id && a.sourceType === "order" ? a.currentPrice : i.price, f = T(t, n);
|
|
4440
|
+
if (f < l.y || f > l.y + l.height) continue;
|
|
4441
|
+
let p = i.side === "buy" ? o : s, m = `${t.toFixed(c)} x ${i.quantity}`;
|
|
4363
4442
|
e.font = `11px ${r.font.family}`;
|
|
4364
4443
|
let h = e.measureText(m).width + 10;
|
|
4365
|
-
e.fillStyle = p, e.fillRect(d, f - 9, Math.min(h,
|
|
4444
|
+
e.fillStyle = p, e.fillRect(d, f - 9, Math.min(h, u - 2), 18), e.fillStyle = "#FFFFFF", e.textAlign = "left", e.textBaseline = "middle", e.fillText(m, d + 5, f);
|
|
4366
4445
|
}
|
|
4367
4446
|
}
|
|
4368
4447
|
hitTest(e, t, n, r) {
|
|
4369
4448
|
for (let i of t) {
|
|
4370
4449
|
if (i.draggable === !1) continue;
|
|
4371
|
-
let t =
|
|
4450
|
+
let t = T(i.price, n);
|
|
4372
4451
|
if (Math.abs(e - t) <= r) return i;
|
|
4373
4452
|
}
|
|
4374
4453
|
return null;
|
|
@@ -4376,7 +4455,7 @@ var Jt = class {
|
|
|
4376
4455
|
};
|
|
4377
4456
|
//#endregion
|
|
4378
4457
|
//#region src/trading/positionFormat.ts
|
|
4379
|
-
function
|
|
4458
|
+
function tn(e, t, n) {
|
|
4380
4459
|
let r = Math.min(Math.max(e.closedQuantity ?? 0, 0), e.quantity), i = e.quantity - r, a = e.side === "buy" ? 1 : -1, o = (t - e.entryPrice) * i * a, s = e.entryPrice === 0 ? 0 : (t - e.entryPrice) / e.entryPrice * 100 * a;
|
|
4381
4460
|
return {
|
|
4382
4461
|
side: e.side,
|
|
@@ -4390,9 +4469,9 @@ function Yt(e, t, n) {
|
|
|
4390
4469
|
precision: n
|
|
4391
4470
|
};
|
|
4392
4471
|
}
|
|
4393
|
-
var
|
|
4394
|
-
function
|
|
4395
|
-
return e.replace(
|
|
4472
|
+
var nn = /\{(side|qty|closedQty|openQty|entry|price|pnl|pnlPct|pnlSign)\}/g;
|
|
4473
|
+
function rn(e, t) {
|
|
4474
|
+
return e.replace(nn, (e, n) => {
|
|
4396
4475
|
switch (n) {
|
|
4397
4476
|
case "side": return t.side.toUpperCase();
|
|
4398
4477
|
case "qty": return String(t.quantity);
|
|
@@ -4407,10 +4486,10 @@ function Zt(e, t) {
|
|
|
4407
4486
|
}
|
|
4408
4487
|
});
|
|
4409
4488
|
}
|
|
4410
|
-
function
|
|
4411
|
-
return typeof e == "function" ? e(t) :
|
|
4489
|
+
function an(e, t) {
|
|
4490
|
+
return typeof e == "function" ? e(t) : rn(e ?? "{side} {qty} | P&L: {pnlSign}{pnl}", t);
|
|
4412
4491
|
}
|
|
4413
|
-
function
|
|
4492
|
+
function on(e, t, n) {
|
|
4414
4493
|
if (!t || t.length === 0) return n;
|
|
4415
4494
|
let r = [...t].sort((e, t) => e.pnl - t.pnl), i;
|
|
4416
4495
|
for (let t of r) if (e >= t.pnl) i = t.color;
|
|
@@ -4419,43 +4498,43 @@ function $t(e, t, n) {
|
|
|
4419
4498
|
}
|
|
4420
4499
|
//#endregion
|
|
4421
4500
|
//#region src/trading/PositionRenderer.ts
|
|
4422
|
-
var
|
|
4501
|
+
var sn = class {
|
|
4423
4502
|
render(e, t, n, r, i, a) {
|
|
4424
4503
|
let { chartRect: o } = r, s = a.positionColors?.profit ?? "#26A69A", c = a.positionColors?.loss ?? "#EF5350", l = a.positionColors?.entry ?? "#2196F3", u = a.pricePrecision ?? 2;
|
|
4425
4504
|
for (let d of t) {
|
|
4426
|
-
let t =
|
|
4505
|
+
let t = T(d.entryPrice, r);
|
|
4427
4506
|
if (e.strokeStyle = l, e.lineWidth = 1.5, e.setLineDash([]), e.beginPath(), e.moveTo(o.x, Math.round(t) + .5), e.lineTo(o.x + o.width, Math.round(t) + .5), e.stroke(), n !== null) {
|
|
4428
|
-
let f =
|
|
4507
|
+
let f = T(n, r), p = tn(d, n, u), m = p.pnl, h = m >= 0 ? s : c, g = on(m, a.pnlThresholds, h);
|
|
4429
4508
|
e.fillStyle = g, e.globalAlpha = .08;
|
|
4430
4509
|
let _ = Math.min(t, f), v = Math.abs(f - t);
|
|
4431
4510
|
if (e.fillRect(o.x, _, o.width, v), e.globalAlpha = 1, p.closedQuantity > 0 && d.quantity > 0) {
|
|
4432
4511
|
let t = p.closedQuantity / d.quantity;
|
|
4433
4512
|
e.fillStyle = l, e.globalAlpha = .25, e.fillRect(o.x, _, Math.max(2, o.width * t * .04) + 2, v), e.globalAlpha = 1;
|
|
4434
4513
|
}
|
|
4435
|
-
let y =
|
|
4514
|
+
let y = an(a.positionLabel, p);
|
|
4436
4515
|
e.font = `bold 11px ${i.font.family}`;
|
|
4437
4516
|
let b = e.measureText(y).width + 12, x = o.x + 8;
|
|
4438
4517
|
e.fillStyle = g, e.globalAlpha = .9, e.fillRect(x, t - 10, b, 20), e.globalAlpha = 1, e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.textAlign = "left", e.fillText(y, x + 6, t);
|
|
4439
4518
|
}
|
|
4440
4519
|
if (d.stopLoss !== void 0) {
|
|
4441
|
-
let t =
|
|
4520
|
+
let t = T(d.stopLoss, r);
|
|
4442
4521
|
e.setLineDash([4, 4]), e.strokeStyle = c, e.lineWidth = 1, e.beginPath(), e.moveTo(o.x, Math.round(t) + .5), e.lineTo(o.x + o.width, Math.round(t) + .5), e.stroke(), e.font = `bold 10px ${i.font.family}`, e.fillStyle = c, e.fillRect(o.x + 4, t - 8, 24, 16), e.fillStyle = "#FFFFFF", e.textAlign = "left", e.textBaseline = "middle", e.fillText("SL", o.x + 8, t);
|
|
4443
4522
|
}
|
|
4444
4523
|
if (d.takeProfit !== void 0) {
|
|
4445
|
-
let t =
|
|
4524
|
+
let t = T(d.takeProfit, r);
|
|
4446
4525
|
e.setLineDash([4, 4]), e.strokeStyle = s, e.lineWidth = 1, e.beginPath(), e.moveTo(o.x, Math.round(t) + .5), e.lineTo(o.x + o.width, Math.round(t) + .5), e.stroke(), e.font = `bold 10px ${i.font.family}`, e.fillStyle = s, e.fillRect(o.x + 4, t - 8, 24, 16), e.fillStyle = "#FFFFFF", e.textAlign = "left", e.textBaseline = "middle", e.fillText("TP", o.x + 8, t);
|
|
4447
4526
|
}
|
|
4448
4527
|
e.setLineDash([]);
|
|
4449
4528
|
}
|
|
4450
4529
|
}
|
|
4451
4530
|
renderAxisBadges(e, t, n, r, i) {
|
|
4452
|
-
let { chartRect: a } = n, o = i.positionColors?.entry ?? "#2196F3", s = i.pricePrecision ?? 2,
|
|
4531
|
+
let { chartRect: a } = n, o = i.positionColors?.entry ?? "#2196F3", s = i.pricePrecision ?? 2, c = a.x + a.width + 1;
|
|
4453
4532
|
for (let i of t) {
|
|
4454
|
-
let t =
|
|
4455
|
-
e.fillStyle = o, e.fillRect(
|
|
4533
|
+
let t = T(i.entryPrice, n);
|
|
4534
|
+
e.fillStyle = o, e.fillRect(c, t - 9, u - 2, 18), e.fillStyle = "#FFFFFF", e.font = `11px ${r.font.family}`, e.textAlign = "left", e.textBaseline = "middle", e.fillText(i.entryPrice.toFixed(s), c + 5, t);
|
|
4456
4535
|
}
|
|
4457
4536
|
}
|
|
4458
|
-
},
|
|
4537
|
+
}, V = class {
|
|
4459
4538
|
render(e, t, n, r) {
|
|
4460
4539
|
if (!r.depthOverlay?.enabled) return;
|
|
4461
4540
|
let { chartRect: i } = n, a = r.depthOverlay.bidColor ?? "rgba(38,166,154,0.15)", o = r.depthOverlay.askColor ?? "rgba(239,83,80,0.15)", s = r.depthOverlay.maxWidth ?? 100, c = 0, l = [], u = 0;
|
|
@@ -4470,23 +4549,23 @@ var en = class {
|
|
|
4470
4549
|
cumVol: u
|
|
4471
4550
|
}), u > c && (c = u);
|
|
4472
4551
|
if (c === 0) return;
|
|
4473
|
-
let f = Math.max(1, t.bids.length > 1 ? Math.abs(
|
|
4552
|
+
let f = Math.max(1, t.bids.length > 1 ? Math.abs(T(t.bids[0].price, n) - T(t.bids[1].price, n)) : 4), p = i.x + i.width;
|
|
4474
4553
|
e.fillStyle = a;
|
|
4475
4554
|
for (let { price: t, cumVol: r } of l) {
|
|
4476
|
-
let a =
|
|
4555
|
+
let a = T(t, n);
|
|
4477
4556
|
if (a < i.y || a > i.y + i.height) continue;
|
|
4478
4557
|
let o = r / c * s;
|
|
4479
4558
|
e.fillRect(p - o, a - f / 2, o, f);
|
|
4480
4559
|
}
|
|
4481
4560
|
e.fillStyle = o;
|
|
4482
4561
|
for (let { price: t, cumVol: r } of d) {
|
|
4483
|
-
let a =
|
|
4562
|
+
let a = T(t, n);
|
|
4484
4563
|
if (a < i.y || a > i.y + i.height) continue;
|
|
4485
4564
|
let o = r / c * s;
|
|
4486
4565
|
e.fillRect(p - o, a - f / 2, o, f);
|
|
4487
4566
|
}
|
|
4488
4567
|
}
|
|
4489
|
-
},
|
|
4568
|
+
}, cn = class {
|
|
4490
4569
|
dragState = null;
|
|
4491
4570
|
startY = 0;
|
|
4492
4571
|
dragging = !1;
|
|
@@ -4496,7 +4575,7 @@ var en = class {
|
|
|
4496
4575
|
onPointerDown(e, t, n, r, i) {
|
|
4497
4576
|
for (let n of t) {
|
|
4498
4577
|
if (n.draggable === !1) continue;
|
|
4499
|
-
let t =
|
|
4578
|
+
let t = T(n.price, r);
|
|
4500
4579
|
if (Math.abs(e.y - t) <= i) return this.dragState = {
|
|
4501
4580
|
orderId: n.id,
|
|
4502
4581
|
sourceType: "order",
|
|
@@ -4506,7 +4585,7 @@ var en = class {
|
|
|
4506
4585
|
}
|
|
4507
4586
|
for (let t of n) {
|
|
4508
4587
|
if (t.stopLoss !== void 0) {
|
|
4509
|
-
let n =
|
|
4588
|
+
let n = T(t.stopLoss, r);
|
|
4510
4589
|
if (Math.abs(e.y - n) <= i) return this.dragState = {
|
|
4511
4590
|
orderId: t.id,
|
|
4512
4591
|
sourceType: "stopLoss",
|
|
@@ -4515,7 +4594,7 @@ var en = class {
|
|
|
4515
4594
|
}, this.startY = e.y, this.dragging = !1, !0;
|
|
4516
4595
|
}
|
|
4517
4596
|
if (t.takeProfit !== void 0) {
|
|
4518
|
-
let n =
|
|
4597
|
+
let n = T(t.takeProfit, r);
|
|
4519
4598
|
if (Math.abs(e.y - n) <= i) return this.dragState = {
|
|
4520
4599
|
orderId: t.id,
|
|
4521
4600
|
sourceType: "takeProfit",
|
|
@@ -4532,7 +4611,7 @@ var en = class {
|
|
|
4532
4611
|
if (Math.abs(e.y - this.startY) < this.dragThreshold) return !0;
|
|
4533
4612
|
this.dragging = !0;
|
|
4534
4613
|
}
|
|
4535
|
-
return this.dragState.currentPrice =
|
|
4614
|
+
return this.dragState.currentPrice = D(e.y, t), !0;
|
|
4536
4615
|
}
|
|
4537
4616
|
onPointerUp() {
|
|
4538
4617
|
if (!this.dragState) return null;
|
|
@@ -4550,7 +4629,7 @@ var en = class {
|
|
|
4550
4629
|
isActive() {
|
|
4551
4630
|
return this.dragState !== null;
|
|
4552
4631
|
}
|
|
4553
|
-
},
|
|
4632
|
+
}, ln = class {
|
|
4554
4633
|
menuElement = null;
|
|
4555
4634
|
removeHandler = null;
|
|
4556
4635
|
onItemSelect = null;
|
|
@@ -4634,25 +4713,25 @@ var en = class {
|
|
|
4634
4713
|
destroy() {
|
|
4635
4714
|
this.hide(), this.onItemSelect = null;
|
|
4636
4715
|
}
|
|
4637
|
-
},
|
|
4716
|
+
}, un = class {
|
|
4638
4717
|
orders = [];
|
|
4639
4718
|
positions = [];
|
|
4640
4719
|
depthData = null;
|
|
4641
4720
|
currentPrice = null;
|
|
4642
4721
|
config;
|
|
4643
|
-
orderRenderer = new
|
|
4644
|
-
positionRenderer = new
|
|
4645
|
-
depthOverlay = new
|
|
4722
|
+
orderRenderer = new en();
|
|
4723
|
+
positionRenderer = new sn();
|
|
4724
|
+
depthOverlay = new V();
|
|
4646
4725
|
dragHandler;
|
|
4647
|
-
contextMenu = new
|
|
4726
|
+
contextMenu = new ln();
|
|
4648
4727
|
requestRender = null;
|
|
4649
4728
|
eventCallback = null;
|
|
4650
4729
|
container = null;
|
|
4651
4730
|
constructor(e) {
|
|
4652
4731
|
this.config = {
|
|
4653
|
-
...
|
|
4732
|
+
...s,
|
|
4654
4733
|
...e
|
|
4655
|
-
}, this.dragHandler = new
|
|
4734
|
+
}, this.dragHandler = new cn(this.config.dragThreshold), this.contextMenu.onItemSelect = (e) => {
|
|
4656
4735
|
this.eventCallback?.("orderPlace", e);
|
|
4657
4736
|
};
|
|
4658
4737
|
}
|
|
@@ -4701,7 +4780,7 @@ var en = class {
|
|
|
4701
4780
|
}
|
|
4702
4781
|
onContextMenu(e, t) {
|
|
4703
4782
|
if (!this.config.enabled || !this.config.contextMenu?.enabled || !this.container) return !1;
|
|
4704
|
-
let n =
|
|
4783
|
+
let n = D(e.y, t);
|
|
4705
4784
|
return this.contextMenu.show(e, n, this.container, this.config), !0;
|
|
4706
4785
|
}
|
|
4707
4786
|
render(e, t, n) {
|
|
@@ -4713,7 +4792,7 @@ var en = class {
|
|
|
4713
4792
|
destroy() {
|
|
4714
4793
|
this.contextMenu.destroy();
|
|
4715
4794
|
}
|
|
4716
|
-
},
|
|
4795
|
+
}, dn = class {
|
|
4717
4796
|
constructor(e) {
|
|
4718
4797
|
this.manager = e;
|
|
4719
4798
|
}
|
|
@@ -4745,7 +4824,7 @@ var en = class {
|
|
|
4745
4824
|
removeAllListeners() {
|
|
4746
4825
|
this.listeners.clear();
|
|
4747
4826
|
}
|
|
4748
|
-
},
|
|
4827
|
+
}, fn = class extends H {
|
|
4749
4828
|
currentBar = null;
|
|
4750
4829
|
timeframeMs;
|
|
4751
4830
|
tickRing;
|
|
@@ -4753,10 +4832,10 @@ var en = class {
|
|
|
4753
4832
|
ringCount = 0;
|
|
4754
4833
|
ringCapacity;
|
|
4755
4834
|
constructor(e, t = 1e3) {
|
|
4756
|
-
super(), this.timeframeMs =
|
|
4835
|
+
super(), this.timeframeMs = v(e), this.ringCapacity = t, this.tickRing = Array(t);
|
|
4757
4836
|
}
|
|
4758
4837
|
setTimeframe(e) {
|
|
4759
|
-
this.timeframeMs =
|
|
4838
|
+
this.timeframeMs = v(e), this.currentBar = null, this.ringHead = 0, this.ringCount = 0;
|
|
4760
4839
|
}
|
|
4761
4840
|
processTick(e) {
|
|
4762
4841
|
let t = (this.ringHead + this.ringCount) % this.ringCapacity;
|
|
@@ -4854,7 +4933,7 @@ var en = class {
|
|
|
4854
4933
|
let e = this.config.baseDelay, t = this.config.backoffMultiplier ** (this.attempt - 1), n = Math.min(e * t, this.config.maxDelay), r = n * .25 * (Math.random() * 2 - 1);
|
|
4855
4934
|
return Math.max(0, Math.round(n + r));
|
|
4856
4935
|
}
|
|
4857
|
-
},
|
|
4936
|
+
}, pn = class {
|
|
4858
4937
|
price = null;
|
|
4859
4938
|
previousClose = null;
|
|
4860
4939
|
visible = !0;
|
|
@@ -4874,23 +4953,23 @@ var en = class {
|
|
|
4874
4953
|
}
|
|
4875
4954
|
render(e, t, n) {
|
|
4876
4955
|
if (!this.visible || this.price === null) return;
|
|
4877
|
-
let r =
|
|
4956
|
+
let r = T(this.price, t), { chartRect: i } = t;
|
|
4878
4957
|
if (r < i.y || r > i.y + i.height) return;
|
|
4879
4958
|
let a = this.previousClose === null || this.price >= this.previousClose ? n.candleUp ?? "#26A69A" : n.candleDown ?? "#EF5350", o = Date.now() < this.flashUntil;
|
|
4880
4959
|
e.setLineDash([4, 3]), e.strokeStyle = a, e.lineWidth = 1, e.globalAlpha = o ? 1 : .7, e.beginPath(), e.moveTo(i.x, Math.round(r) + .5), e.lineTo(i.x + i.width, Math.round(r) + .5), e.stroke(), e.setLineDash([]), e.globalAlpha = 1;
|
|
4881
|
-
let s = i.x + i.width + 1,
|
|
4960
|
+
let s = i.x + i.width + 1, c = this.price.toFixed(this.pricePrecision);
|
|
4882
4961
|
e.font = `bold 11px ${n.font.family}`;
|
|
4883
|
-
let
|
|
4962
|
+
let l = e.measureText(c).width, d = Math.min(l + 12, u - 2);
|
|
4884
4963
|
e.fillStyle = a, e.fillRect(s, r - 10, d, 20);
|
|
4885
4964
|
let f = s - 5;
|
|
4886
|
-
e.beginPath(), e.moveTo(f, r), e.lineTo(f + 5, r - 5), e.lineTo(f + 5, r + 5), e.closePath(), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.textAlign = "left", e.fillText(
|
|
4965
|
+
e.beginPath(), e.moveTo(f, r), e.lineTo(f + 5, r - 5), e.lineTo(f + 5, r + 5), e.closePath(), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.textAlign = "left", e.fillText(c, s + 5, r);
|
|
4887
4966
|
}
|
|
4888
|
-
},
|
|
4967
|
+
}, mn = class extends H {
|
|
4889
4968
|
config = null;
|
|
4890
4969
|
adapter = null;
|
|
4891
4970
|
aggregator = null;
|
|
4892
4971
|
reconnector;
|
|
4893
|
-
priceLine = new
|
|
4972
|
+
priceLine = new pn();
|
|
4894
4973
|
state = "disconnected";
|
|
4895
4974
|
lastPrice = null;
|
|
4896
4975
|
previousClose = null;
|
|
@@ -4902,9 +4981,9 @@ var en = class {
|
|
|
4902
4981
|
}
|
|
4903
4982
|
async connect(e) {
|
|
4904
4983
|
this.disconnect(), this.config = {
|
|
4905
|
-
...
|
|
4984
|
+
...a,
|
|
4906
4985
|
...e
|
|
4907
|
-
}, this.adapter = e.adapter, this.aggregator = new
|
|
4986
|
+
}, this.adapter = e.adapter, this.aggregator = new fn(e.timeframe), this.reconnector.removeAllListeners(), this.reconnector.stop(), this.reconnector = new U(e.reconnect ?? r), this.wireReconnector(), this.aggregator.on("bar", (e) => {
|
|
4908
4987
|
this.emit("barUpdate", e), this.updatePrice(e.close);
|
|
4909
4988
|
}), this.aggregator.on("barClose", (e) => {
|
|
4910
4989
|
this.previousClose = e.close, this.emit("barClose", e);
|
|
@@ -5017,7 +5096,7 @@ var en = class {
|
|
|
5017
5096
|
};
|
|
5018
5097
|
//#endregion
|
|
5019
5098
|
//#region src/realtime/adapters/binanceTypes.ts
|
|
5020
|
-
function
|
|
5099
|
+
function hn(e) {
|
|
5021
5100
|
if (!Array.isArray(e) || e.length < 6) return null;
|
|
5022
5101
|
let t = e[0];
|
|
5023
5102
|
if (typeof t != "number" || !Number.isFinite(t)) return null;
|
|
@@ -5031,8 +5110,8 @@ function ln(e) {
|
|
|
5031
5110
|
volume: o
|
|
5032
5111
|
};
|
|
5033
5112
|
}
|
|
5034
|
-
function
|
|
5035
|
-
if (!
|
|
5113
|
+
function gn(e) {
|
|
5114
|
+
if (!_n(e)) return null;
|
|
5036
5115
|
let t = e.t;
|
|
5037
5116
|
if (typeof t != "number" || !Number.isFinite(t)) return null;
|
|
5038
5117
|
let n = W(e.o), r = W(e.h), i = W(e.l), a = W(e.c), o = W(e.v);
|
|
@@ -5058,12 +5137,12 @@ function W(e) {
|
|
|
5058
5137
|
}
|
|
5059
5138
|
return null;
|
|
5060
5139
|
}
|
|
5061
|
-
function
|
|
5140
|
+
function _n(e) {
|
|
5062
5141
|
return typeof e == "object" && !!e;
|
|
5063
5142
|
}
|
|
5064
5143
|
//#endregion
|
|
5065
5144
|
//#region src/realtime/adapters/BinanceAdapter.ts
|
|
5066
|
-
var
|
|
5145
|
+
var vn = {
|
|
5067
5146
|
"1s": "1s",
|
|
5068
5147
|
"1m": "1m",
|
|
5069
5148
|
"3m": "3m",
|
|
@@ -5080,7 +5159,7 @@ var fn = {
|
|
|
5080
5159
|
"3d": "3d",
|
|
5081
5160
|
"1w": "1w",
|
|
5082
5161
|
"1M": "1M"
|
|
5083
|
-
},
|
|
5162
|
+
}, yn = class {
|
|
5084
5163
|
name = "binance";
|
|
5085
5164
|
ws = null;
|
|
5086
5165
|
state = "disconnected";
|
|
@@ -5101,13 +5180,13 @@ var fn = {
|
|
|
5101
5180
|
return this.state;
|
|
5102
5181
|
}
|
|
5103
5182
|
async fetchHistory(e, t, n = 500) {
|
|
5104
|
-
let r =
|
|
5183
|
+
let r = vn[t] ?? "15m", i = `${this.restBase}/klines?symbol=${e}&interval=${r}&limit=${n}`, a = await fetch(i);
|
|
5105
5184
|
if (!a.ok) throw Error(`Binance REST error: ${a.status}`);
|
|
5106
5185
|
let o = await a.json();
|
|
5107
5186
|
if (!Array.isArray(o)) return [];
|
|
5108
5187
|
let s = [];
|
|
5109
5188
|
for (let e of o) {
|
|
5110
|
-
let t =
|
|
5189
|
+
let t = hn(e);
|
|
5111
5190
|
t && s.push(t);
|
|
5112
5191
|
}
|
|
5113
5192
|
return s;
|
|
@@ -5124,7 +5203,7 @@ var fn = {
|
|
|
5124
5203
|
}
|
|
5125
5204
|
connectWs() {
|
|
5126
5205
|
if (!this.config) return;
|
|
5127
|
-
let e = `${this.config.symbol.toLowerCase()}@kline_${
|
|
5206
|
+
let e = `${this.config.symbol.toLowerCase()}@kline_${vn[this.config.timeframe] ?? "15m"}`, t = `${this.wsBase}/${e}`;
|
|
5128
5207
|
this.setState("connecting");
|
|
5129
5208
|
try {
|
|
5130
5209
|
this.ws = new WebSocket(t);
|
|
@@ -5149,7 +5228,7 @@ var fn = {
|
|
|
5149
5228
|
};
|
|
5150
5229
|
}
|
|
5151
5230
|
handleKline(e) {
|
|
5152
|
-
let t =
|
|
5231
|
+
let t = gn(e);
|
|
5153
5232
|
if (!t) return;
|
|
5154
5233
|
let { bar: n, closed: r } = t;
|
|
5155
5234
|
this.emitEvent("bar", {
|
|
@@ -5175,7 +5254,7 @@ var fn = {
|
|
|
5175
5254
|
for (let e of n) e(r);
|
|
5176
5255
|
}
|
|
5177
5256
|
}
|
|
5178
|
-
},
|
|
5257
|
+
}, bn = class {
|
|
5179
5258
|
name = "mock";
|
|
5180
5259
|
state = "disconnected";
|
|
5181
5260
|
listeners = /* @__PURE__ */ new Map();
|
|
@@ -5215,7 +5294,7 @@ var fn = {
|
|
|
5215
5294
|
this.disconnect(), this.listeners.clear();
|
|
5216
5295
|
}
|
|
5217
5296
|
generateHistory(e, t) {
|
|
5218
|
-
let n = [], r = Date.now(), i =
|
|
5297
|
+
let n = [], r = Date.now(), i = v(e), a = this.options.basePrice, o = this.options.volatility / 100;
|
|
5219
5298
|
for (let e = t - 1; e >= 0; e--) {
|
|
5220
5299
|
let t = r - e * i, s = (Math.random() - .48) * a * o, c = a;
|
|
5221
5300
|
a += s;
|
|
@@ -5238,7 +5317,7 @@ var fn = {
|
|
|
5238
5317
|
if (this.state !== "connected" || !this.config) return;
|
|
5239
5318
|
let e = this.options.volatility / 100, t = (Math.random() - .48) * this.currentPrice * e * .3;
|
|
5240
5319
|
this.currentPrice += t;
|
|
5241
|
-
let n = Date.now(), r =
|
|
5320
|
+
let n = Date.now(), r = v(this.config.timeframe), i = {
|
|
5242
5321
|
time: Math.floor(n / r) * r,
|
|
5243
5322
|
open: this.currentPrice - t,
|
|
5244
5323
|
high: Math.max(this.currentPrice, this.currentPrice - t) + Math.abs(t) * .2,
|
|
@@ -5270,7 +5349,7 @@ var fn = {
|
|
|
5270
5349
|
for (let e of n) e(r);
|
|
5271
5350
|
}
|
|
5272
5351
|
}
|
|
5273
|
-
},
|
|
5352
|
+
}, xn = {
|
|
5274
5353
|
visible: !0,
|
|
5275
5354
|
showSymbol: !0,
|
|
5276
5355
|
showOHLC: !0,
|
|
@@ -5278,8 +5357,8 @@ var fn = {
|
|
|
5278
5357
|
showVolume: !0,
|
|
5279
5358
|
position: "top-left",
|
|
5280
5359
|
fontSize: 12
|
|
5281
|
-
},
|
|
5282
|
-
config = { ...
|
|
5360
|
+
}, Sn = class {
|
|
5361
|
+
config = { ...xn };
|
|
5283
5362
|
symbol = "";
|
|
5284
5363
|
timeframe = "";
|
|
5285
5364
|
hoverBar = null;
|
|
@@ -5370,7 +5449,7 @@ var fn = {
|
|
|
5370
5449
|
}
|
|
5371
5450
|
}
|
|
5372
5451
|
}
|
|
5373
|
-
},
|
|
5452
|
+
}, Cn = class {
|
|
5374
5453
|
static toDataURL(e, t) {
|
|
5375
5454
|
let n = e.querySelectorAll("canvas");
|
|
5376
5455
|
if (n.length === 0) return "";
|
|
@@ -5392,7 +5471,7 @@ var fn = {
|
|
|
5392
5471
|
let i = document.createElement("a");
|
|
5393
5472
|
i.href = r, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i);
|
|
5394
5473
|
}
|
|
5395
|
-
},
|
|
5474
|
+
}, wn = class {
|
|
5396
5475
|
config = null;
|
|
5397
5476
|
setConfig(e) {
|
|
5398
5477
|
this.config = e;
|
|
@@ -5402,7 +5481,7 @@ var fn = {
|
|
|
5402
5481
|
let { chartRect: r } = t, i = this.config.fontSize ?? 48, a = this.config.color ?? n.textSecondary;
|
|
5403
5482
|
e.save(), e.globalAlpha = .07, e.font = `bold ${i}px ${n.font.family}`, e.fillStyle = a, e.textAlign = "center", e.textBaseline = "middle", e.fillText(this.config.text, r.x + r.width / 2, r.y + r.height / 2), e.restore();
|
|
5404
5483
|
}
|
|
5405
|
-
},
|
|
5484
|
+
}, Tn = class {
|
|
5406
5485
|
visible = !0;
|
|
5407
5486
|
timeframeMs = 0;
|
|
5408
5487
|
setVisible(e) {
|
|
@@ -5418,14 +5497,14 @@ var fn = {
|
|
|
5418
5497
|
if (!this.visible || this.timeframeMs <= 0 || r.length === 0) return;
|
|
5419
5498
|
let i = r[r.length - 1], a = (i.time > 0xe8d4a51000 ? i.time : i.time * 1e3) + this.timeframeMs - Date.now();
|
|
5420
5499
|
if (a <= 0) return;
|
|
5421
|
-
let o = this.formatRemaining(a), s =
|
|
5500
|
+
let o = this.formatRemaining(a), s = w(r.length - 1, t), c = t.chartRect.y + t.chartRect.height - 4;
|
|
5422
5501
|
s < t.chartRect.x || s > t.chartRect.x + t.chartRect.width || (e.font = `${n.font.sizeSmall}px ${n.font.family}`, e.textBaseline = "bottom", e.textAlign = "center", e.fillStyle = n.textSecondary, e.fillText(o, s, c));
|
|
5423
5502
|
}
|
|
5424
5503
|
formatRemaining(e) {
|
|
5425
5504
|
let t = Math.ceil(e / 1e3), n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), i = t % 60;
|
|
5426
5505
|
return n > 0 ? `${n}:${String(r).padStart(2, "0")}:${String(i).padStart(2, "0")}` : `${r}:${String(i).padStart(2, "0")}`;
|
|
5427
5506
|
}
|
|
5428
|
-
},
|
|
5507
|
+
}, En = class {
|
|
5429
5508
|
config = { visible: !1 };
|
|
5430
5509
|
cachedBreaks = [];
|
|
5431
5510
|
lastDataLength = 0;
|
|
@@ -5459,7 +5538,7 @@ var fn = {
|
|
|
5459
5538
|
let { chartRect: a } = t, o = this.config.color ?? n.axisLine, s = this.config.lineWidth ?? 1, c = this.config.lineStyle ?? "dashed";
|
|
5460
5539
|
e.save(), e.strokeStyle = o, e.lineWidth = s, e.globalAlpha = .4, c === "dashed" ? e.setLineDash([6, 4]) : c === "dotted" && e.setLineDash([2, 3]), e.beginPath();
|
|
5461
5540
|
for (let n of i) {
|
|
5462
|
-
let r =
|
|
5541
|
+
let r = w(n, t) - (t.barWidth + t.barSpacing) / 2;
|
|
5463
5542
|
if (r < a.x - 1 || r > a.x + a.width + 1) continue;
|
|
5464
5543
|
let i = Math.round(r) + .5;
|
|
5465
5544
|
e.moveTo(i, a.y), e.lineTo(i, a.y + a.height);
|
|
@@ -5469,7 +5548,7 @@ var fn = {
|
|
|
5469
5548
|
invalidateCache() {
|
|
5470
5549
|
this.lastDataLength = 0, this.cachedBreaks = [];
|
|
5471
5550
|
}
|
|
5472
|
-
},
|
|
5551
|
+
}, Dn = 1, On = class extends H {
|
|
5473
5552
|
alerts = [];
|
|
5474
5553
|
lastPrice = null;
|
|
5475
5554
|
requestRender = null;
|
|
@@ -5481,7 +5560,7 @@ var fn = {
|
|
|
5481
5560
|
this.pricePrecision = e;
|
|
5482
5561
|
}
|
|
5483
5562
|
addAlert(e, t = "crossing", n, r = !1) {
|
|
5484
|
-
let i = `tc_alert_${
|
|
5563
|
+
let i = `tc_alert_${Dn++}`, a = {
|
|
5485
5564
|
id: i,
|
|
5486
5565
|
price: e,
|
|
5487
5566
|
condition: t,
|
|
@@ -5553,7 +5632,7 @@ var fn = {
|
|
|
5553
5632
|
render(e, t, n) {
|
|
5554
5633
|
let { chartRect: r } = t;
|
|
5555
5634
|
for (let i of this.alerts) {
|
|
5556
|
-
let a =
|
|
5635
|
+
let a = T(i.price, t);
|
|
5557
5636
|
if (a < r.y || a > r.y + r.height) continue;
|
|
5558
5637
|
let o = i.triggered ? "#FF9800" : "#FFD700";
|
|
5559
5638
|
e.setLineDash([2, 6]), e.strokeStyle = o, e.lineWidth = 1, e.beginPath(), e.moveTo(r.x, Math.round(a) + .5), e.lineTo(r.x + r.width, Math.round(a) + .5), e.stroke(), e.setLineDash([]), e.font = `10px ${n.font.family}`, e.fillStyle = o, e.textBaseline = "bottom", e.textAlign = "right";
|
|
@@ -5561,7 +5640,7 @@ var fn = {
|
|
|
5561
5640
|
e.fillText(s, r.x + r.width - 4, a - 2);
|
|
5562
5641
|
}
|
|
5563
5642
|
}
|
|
5564
|
-
},
|
|
5643
|
+
}, kn = class extends H {
|
|
5565
5644
|
data = [];
|
|
5566
5645
|
currentIndex = 0;
|
|
5567
5646
|
timer = null;
|
|
@@ -5622,13 +5701,13 @@ function K(e) {
|
|
|
5622
5701
|
function q(e) {
|
|
5623
5702
|
return Array.isArray(e) ? e : [];
|
|
5624
5703
|
}
|
|
5625
|
-
function
|
|
5704
|
+
function An(e, t) {
|
|
5626
5705
|
return typeof e == "string" ? e : t;
|
|
5627
5706
|
}
|
|
5628
5707
|
function J(e, t) {
|
|
5629
5708
|
return typeof e == "number" && Number.isFinite(e) ? e : t;
|
|
5630
5709
|
}
|
|
5631
|
-
function
|
|
5710
|
+
function jn(e) {
|
|
5632
5711
|
if (!K(e) || typeof e.id != "string" || typeof e.type != "string" || !Array.isArray(e.anchors) || e.anchors.length === 0 || !K(e.style)) return null;
|
|
5633
5712
|
let t = [];
|
|
5634
5713
|
for (let n of e.anchors) {
|
|
@@ -5649,14 +5728,14 @@ function Tn(e) {
|
|
|
5649
5728
|
meta: K(e.meta) ? e.meta : void 0
|
|
5650
5729
|
};
|
|
5651
5730
|
}
|
|
5652
|
-
function
|
|
5731
|
+
function Mn(e) {
|
|
5653
5732
|
return !K(e) || typeof e.id != "string" || typeof e.side != "string" || typeof e.type != "string" || typeof e.price != "number" || typeof e.quantity != "number" ? null : e;
|
|
5654
5733
|
}
|
|
5655
|
-
function
|
|
5734
|
+
function Nn(e) {
|
|
5656
5735
|
return !K(e) || typeof e.id != "string" || typeof e.side != "string" || typeof e.entryPrice != "number" || typeof e.quantity != "number" ? null : e;
|
|
5657
5736
|
}
|
|
5658
|
-
function
|
|
5659
|
-
if (!K(e)) return
|
|
5737
|
+
function Pn(e) {
|
|
5738
|
+
if (!K(e)) return Fn();
|
|
5660
5739
|
typeof e.version == "number" && e.version !== G && console.warn(`Chart state version mismatch: ${e.version} vs ${G}`);
|
|
5661
5740
|
let t = K(e.viewport) ? e.viewport : {}, n = [];
|
|
5662
5741
|
for (let t of q(e.indicators)) K(t) && (typeof t.id != "string" || typeof t.instanceId != "string" || K(t.params) && n.push({
|
|
@@ -5667,17 +5746,17 @@ function On(e) {
|
|
|
5667
5746
|
}));
|
|
5668
5747
|
let r = [];
|
|
5669
5748
|
for (let t of q(e.drawings)) {
|
|
5670
|
-
let e =
|
|
5749
|
+
let e = jn(t);
|
|
5671
5750
|
e && r.push(e);
|
|
5672
5751
|
}
|
|
5673
5752
|
let i = [];
|
|
5674
5753
|
for (let t of q(e.orders)) {
|
|
5675
|
-
let e =
|
|
5754
|
+
let e = Mn(t);
|
|
5676
5755
|
e && i.push(e);
|
|
5677
5756
|
}
|
|
5678
5757
|
let a = [];
|
|
5679
5758
|
for (let t of q(e.positions)) {
|
|
5680
|
-
let e =
|
|
5759
|
+
let e = Nn(t);
|
|
5681
5760
|
e && a.push(e);
|
|
5682
5761
|
}
|
|
5683
5762
|
let o = [];
|
|
@@ -5687,7 +5766,7 @@ function On(e) {
|
|
|
5687
5766
|
timestamp: J(e.timestamp, Date.now()),
|
|
5688
5767
|
symbol: typeof e.symbol == "string" ? e.symbol : void 0,
|
|
5689
5768
|
timeframe: typeof e.timeframe == "string" ? e.timeframe : void 0,
|
|
5690
|
-
chartType:
|
|
5769
|
+
chartType: An(e.chartType, "candlestick"),
|
|
5691
5770
|
viewport: {
|
|
5692
5771
|
barWidth: J(t.barWidth, 8),
|
|
5693
5772
|
barSpacing: J(t.barSpacing, 2),
|
|
@@ -5702,7 +5781,7 @@ function On(e) {
|
|
|
5702
5781
|
alerts: o
|
|
5703
5782
|
};
|
|
5704
5783
|
}
|
|
5705
|
-
function
|
|
5784
|
+
function Fn() {
|
|
5706
5785
|
return {
|
|
5707
5786
|
version: G,
|
|
5708
5787
|
timestamp: Date.now(),
|
|
@@ -5719,7 +5798,7 @@ function kn() {
|
|
|
5719
5798
|
alerts: []
|
|
5720
5799
|
};
|
|
5721
5800
|
}
|
|
5722
|
-
var
|
|
5801
|
+
var In = class {
|
|
5723
5802
|
static capture(e, t) {
|
|
5724
5803
|
return {
|
|
5725
5804
|
version: G,
|
|
@@ -5744,7 +5823,7 @@ var An = class {
|
|
|
5744
5823
|
return JSON.stringify(e);
|
|
5745
5824
|
}
|
|
5746
5825
|
static deserialize(e) {
|
|
5747
|
-
return
|
|
5826
|
+
return Pn(JSON.parse(e));
|
|
5748
5827
|
}
|
|
5749
5828
|
static saveToStorage(e, t) {
|
|
5750
5829
|
localStorage.setItem(e, this.serialize(t));
|
|
@@ -5771,7 +5850,7 @@ var An = class {
|
|
|
5771
5850
|
}, n.click();
|
|
5772
5851
|
});
|
|
5773
5852
|
}
|
|
5774
|
-
},
|
|
5853
|
+
}, Ln = class {
|
|
5775
5854
|
undoStack = [];
|
|
5776
5855
|
redoStack = [];
|
|
5777
5856
|
maxHistory = 50;
|
|
@@ -5807,7 +5886,7 @@ var An = class {
|
|
|
5807
5886
|
redoCount: this.redoStack.length
|
|
5808
5887
|
};
|
|
5809
5888
|
}
|
|
5810
|
-
},
|
|
5889
|
+
}, Rn = class {
|
|
5811
5890
|
static toCSV(e) {
|
|
5812
5891
|
return ["Time,Open,High,Low,Close,Volume", ...e.map((e) => `${new Date(e.time).toISOString()},${e.open},${e.high},${e.low},${e.close},${e.volume}`)].join("\n");
|
|
5813
5892
|
}
|
|
@@ -5825,7 +5904,158 @@ var An = class {
|
|
|
5825
5904
|
let r = new Blob([e], { type: n }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
5826
5905
|
a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
5827
5906
|
}
|
|
5828
|
-
},
|
|
5907
|
+
}, zn = 1, Bn = class extends H {
|
|
5908
|
+
markers = [];
|
|
5909
|
+
style = { ...i };
|
|
5910
|
+
requestRender = null;
|
|
5911
|
+
dataGetter = null;
|
|
5912
|
+
setRequestRender(e) {
|
|
5913
|
+
this.requestRender = e;
|
|
5914
|
+
}
|
|
5915
|
+
setDataGetter(e) {
|
|
5916
|
+
this.dataGetter = e;
|
|
5917
|
+
}
|
|
5918
|
+
setStyle(e) {
|
|
5919
|
+
this.style = {
|
|
5920
|
+
...this.style,
|
|
5921
|
+
...e
|
|
5922
|
+
}, this.requestRender?.();
|
|
5923
|
+
}
|
|
5924
|
+
getStyle() {
|
|
5925
|
+
return { ...this.style };
|
|
5926
|
+
}
|
|
5927
|
+
addMarker(e) {
|
|
5928
|
+
let t = e.id ?? `tc_signal_${zn++}`, n = {
|
|
5929
|
+
...e,
|
|
5930
|
+
id: t
|
|
5931
|
+
};
|
|
5932
|
+
return this.markers.push(n), this.emit("added", n), this.requestRender?.(), t;
|
|
5933
|
+
}
|
|
5934
|
+
removeMarker(e) {
|
|
5935
|
+
this.markers = this.markers.filter((t) => t.id !== e), this.emit("removed", e), this.requestRender?.();
|
|
5936
|
+
}
|
|
5937
|
+
getMarkers() {
|
|
5938
|
+
return [...this.markers];
|
|
5939
|
+
}
|
|
5940
|
+
clearMarkers() {
|
|
5941
|
+
this.markers = [], this.emit("cleared", void 0), this.requestRender?.();
|
|
5942
|
+
}
|
|
5943
|
+
setMarkers(e) {
|
|
5944
|
+
this.markers = [...e], this.requestRender?.();
|
|
5945
|
+
}
|
|
5946
|
+
render(e, t, n) {
|
|
5947
|
+
let r = this.dataGetter?.();
|
|
5948
|
+
if (!r || r.length === 0 || this.markers.length === 0) return;
|
|
5949
|
+
let { chartRect: i, visibleRange: a } = t, o = this.style, s = o.arrowSize ?? 12;
|
|
5950
|
+
e.save(), e.beginPath(), e.rect(i.x, i.y, i.width, i.height), e.clip();
|
|
5951
|
+
for (let c of this.markers) {
|
|
5952
|
+
let l = O(c.time, r);
|
|
5953
|
+
if (l < a.from - 1 || l > a.to + 1) continue;
|
|
5954
|
+
let u = w(l, t), d = T(c.price, t);
|
|
5955
|
+
if (u < i.x - s || u > i.x + i.width + s || d < i.y - s || d > i.y + i.height + s) continue;
|
|
5956
|
+
let f = this.resolveColor(c, o), p = s * Math.max(.6, Math.min(1, c.confidence));
|
|
5957
|
+
if (this.renderArrow(e, u, d, c.direction, p, f), o.showLabel && c.label) {
|
|
5958
|
+
e.font = `10px ${n.font.family}`, e.fillStyle = f, e.textAlign = "center", e.textBaseline = c.direction === "long" ? "top" : "bottom";
|
|
5959
|
+
let t = c.direction === "long" ? d + p + 3 : d - p - 3;
|
|
5960
|
+
e.fillText(c.label, u, t);
|
|
5961
|
+
}
|
|
5962
|
+
if (o.showConfidence && c.confidence < 1) {
|
|
5963
|
+
e.font = `9px ${n.font.family}`, e.fillStyle = f, e.globalAlpha = .7, e.textAlign = "center", e.textBaseline = c.direction === "long" ? "top" : "bottom";
|
|
5964
|
+
let t = c.direction === "long" ? d + p + (c.label ? 14 : 3) : d - p - (c.label ? 14 : 3);
|
|
5965
|
+
e.fillText(`${Math.round(c.confidence * 100)}%`, u, t), e.globalAlpha = 1;
|
|
5966
|
+
}
|
|
5967
|
+
}
|
|
5968
|
+
e.restore();
|
|
5969
|
+
}
|
|
5970
|
+
resolveColor(e, t) {
|
|
5971
|
+
if (e.color) return e.color;
|
|
5972
|
+
if (t.sourceColors?.[e.source]) return t.sourceColors[e.source];
|
|
5973
|
+
switch (e.direction) {
|
|
5974
|
+
case "long": return t.longColor ?? "#26A69A";
|
|
5975
|
+
case "short": return t.shortColor ?? "#EF5350";
|
|
5976
|
+
default: return t.neutralColor ?? "#9E9E9E";
|
|
5977
|
+
}
|
|
5978
|
+
}
|
|
5979
|
+
renderArrow(e, t, n, r, i, a) {
|
|
5980
|
+
e.fillStyle = a, e.beginPath(), r === "long" ? (e.moveTo(t, n - i), e.lineTo(t - i * .6, n), e.lineTo(t - i * .2, n), e.lineTo(t - i * .2, n + i * .4), e.lineTo(t + i * .2, n + i * .4), e.lineTo(t + i * .2, n), e.lineTo(t + i * .6, n)) : r === "short" ? (e.moveTo(t, n + i), e.lineTo(t - i * .6, n), e.lineTo(t - i * .2, n), e.lineTo(t - i * .2, n - i * .4), e.lineTo(t + i * .2, n - i * .4), e.lineTo(t + i * .2, n), e.lineTo(t + i * .6, n)) : e.arc(t, n, i * .4, 0, Math.PI * 2), e.closePath(), e.fill();
|
|
5981
|
+
}
|
|
5982
|
+
}, Vn = 1, Hn = class extends H {
|
|
5983
|
+
zones = [];
|
|
5984
|
+
style = { ...o };
|
|
5985
|
+
requestRender = null;
|
|
5986
|
+
dataGetter = null;
|
|
5987
|
+
pricePrecision = 2;
|
|
5988
|
+
setRequestRender(e) {
|
|
5989
|
+
this.requestRender = e;
|
|
5990
|
+
}
|
|
5991
|
+
setDataGetter(e) {
|
|
5992
|
+
this.dataGetter = e;
|
|
5993
|
+
}
|
|
5994
|
+
setPricePrecision(e) {
|
|
5995
|
+
this.pricePrecision = e;
|
|
5996
|
+
}
|
|
5997
|
+
setStyle(e) {
|
|
5998
|
+
this.style = {
|
|
5999
|
+
...this.style,
|
|
6000
|
+
...e
|
|
6001
|
+
}, this.requestRender?.();
|
|
6002
|
+
}
|
|
6003
|
+
getStyle() {
|
|
6004
|
+
return { ...this.style };
|
|
6005
|
+
}
|
|
6006
|
+
addZone(e) {
|
|
6007
|
+
let t = e.id ?? `tc_zone_${Vn++}`, n = {
|
|
6008
|
+
...e,
|
|
6009
|
+
id: t
|
|
6010
|
+
};
|
|
6011
|
+
return this.zones.push(n), this.emit("added", n), this.requestRender?.(), t;
|
|
6012
|
+
}
|
|
6013
|
+
updateZone(e, t) {
|
|
6014
|
+
let n = this.zones.findIndex((t) => t.id === e);
|
|
6015
|
+
n !== -1 && (this.zones[n] = {
|
|
6016
|
+
...this.zones[n],
|
|
6017
|
+
...t
|
|
6018
|
+
}, this.requestRender?.());
|
|
6019
|
+
}
|
|
6020
|
+
removeZone(e) {
|
|
6021
|
+
this.zones = this.zones.filter((t) => t.id !== e), this.emit("removed", e), this.requestRender?.();
|
|
6022
|
+
}
|
|
6023
|
+
getZones() {
|
|
6024
|
+
return [...this.zones];
|
|
6025
|
+
}
|
|
6026
|
+
clearZones() {
|
|
6027
|
+
this.zones = [], this.emit("cleared", void 0), this.requestRender?.();
|
|
6028
|
+
}
|
|
6029
|
+
setZones(e) {
|
|
6030
|
+
this.zones = [...e], this.requestRender?.();
|
|
6031
|
+
}
|
|
6032
|
+
render(e, t, n) {
|
|
6033
|
+
let r = this.dataGetter?.();
|
|
6034
|
+
if (!r || r.length === 0 || this.zones.length === 0) return;
|
|
6035
|
+
let { chartRect: i } = t, a = this.style;
|
|
6036
|
+
e.save(), e.beginPath(), e.rect(i.x, i.y, i.width, i.height), e.clip();
|
|
6037
|
+
for (let i of this.zones) this.renderZone(e, i, r, t, n, a);
|
|
6038
|
+
e.restore();
|
|
6039
|
+
}
|
|
6040
|
+
renderZone(e, t, n, r, i, a) {
|
|
6041
|
+
let { chartRect: o, visibleRange: s } = r, c = O(t.entryTime, n), l = t.exitTime == null ? n.length - 1 : O(t.exitTime, n);
|
|
6042
|
+
if (l < s.from || c > s.to) return;
|
|
6043
|
+
let u = w(c, r), d = w(l, r), f = Math.max(o.x, Math.min(u, d)), p = Math.min(o.x + o.width, Math.max(u, d));
|
|
6044
|
+
if (p - f < 1) return;
|
|
6045
|
+
let m = T(t.entryPrice, r), h = t.exitPrice == null ? T(t.entryPrice, r) : T(t.exitPrice, r), g = Math.min(m, h), _ = Math.max(Math.max(m, h) - g, 2), v = t.exitTime == null, y = t.pnl == null ? t.direction === "long" ? (t.exitPrice ?? t.entryPrice) >= t.entryPrice : (t.exitPrice ?? t.entryPrice) <= t.entryPrice : t.pnl >= 0, b = v ? a.activeColor ?? "#2196F3" : y ? a.profitColor ?? "#26A69A" : a.lossColor ?? "#EF5350";
|
|
6046
|
+
e.fillStyle = b, e.globalAlpha = a.fillOpacity ?? .12, e.fillRect(f, g, p - f, _), e.globalAlpha = 1;
|
|
6047
|
+
let x = a.borderWidth ?? 1;
|
|
6048
|
+
e.strokeStyle = b, e.lineWidth = x, e.setLineDash([]), e.beginPath(), e.moveTo(f, Math.round(m) + .5), e.lineTo(p, Math.round(m) + .5), e.stroke(), !v && t.exitPrice != null && (e.setLineDash([3, 3]), e.beginPath(), e.moveTo(f, Math.round(h) + .5), e.lineTo(p, Math.round(h) + .5), e.stroke(), e.setLineDash([]));
|
|
6049
|
+
let S = t.direction === "long" ? "▲" : "▼";
|
|
6050
|
+
if (e.font = `bold 10px ${i.font.family}`, e.fillStyle = b, e.textBaseline = "bottom", e.textAlign = "left", e.fillText(`${S} ${t.entryPrice.toFixed(this.pricePrecision)}`, f + 4, m - 3), a.showPnl && !v && t.pnl != null) {
|
|
6051
|
+
let n = t.pnl >= 0 ? "+" : "", r = t.pnlPercent == null ? `${n}${t.pnl.toFixed(2)}` : `${n}${t.pnl.toFixed(2)} (${n}${t.pnlPercent.toFixed(2)}%)`;
|
|
6052
|
+
e.font = `bold 10px ${i.font.family}`, e.fillStyle = b, e.textBaseline = "top", e.textAlign = "right";
|
|
6053
|
+
let a = e.measureText(r).width + 8, o = p - a - 2, s = g + 2;
|
|
6054
|
+
e.globalAlpha = .85, e.fillStyle = i.background, e.fillRect(o, s, a, 14), e.globalAlpha = 1, e.fillStyle = b, e.fillText(r, p - 4, s + 1);
|
|
6055
|
+
}
|
|
6056
|
+
a.showLabel && t.label && (e.font = `9px ${i.font.family}`, e.fillStyle = b, e.globalAlpha = .8, e.textBaseline = "top", e.textAlign = "left", e.fillText(t.label, f + 4, m + 3), e.globalAlpha = 1);
|
|
6057
|
+
}
|
|
6058
|
+
}, Un = {
|
|
5829
6059
|
linear: (e) => e,
|
|
5830
6060
|
easeOutCubic: (e) => 1 - (1 - e) ** 3,
|
|
5831
6061
|
easeOutQuart: (e) => 1 - (1 - e) ** 4,
|
|
@@ -5833,7 +6063,7 @@ var An = class {
|
|
|
5833
6063
|
easeOutExpo: (e) => e === 1 ? 1 : 1 - 2 ** (-10 * e),
|
|
5834
6064
|
easeOutElastic: (e) => e === 0 || e === 1 ? e : 2 ** (-10 * e) * Math.sin((e * 10 - .75) * (2 * Math.PI / 3)) + 1,
|
|
5835
6065
|
spring: (e) => 1 - Math.E ** (-6 * e) * Math.cos(8 * e)
|
|
5836
|
-
},
|
|
6066
|
+
}, Wn = class {
|
|
5837
6067
|
animations = /* @__PURE__ */ new Map();
|
|
5838
6068
|
frameId = 0;
|
|
5839
6069
|
running = !1;
|
|
@@ -5841,7 +6071,7 @@ var An = class {
|
|
|
5841
6071
|
this.animations.set(e, {
|
|
5842
6072
|
startTime: -1,
|
|
5843
6073
|
duration: t.duration,
|
|
5844
|
-
easing: t.easing ??
|
|
6074
|
+
easing: t.easing ?? Un.easeOutCubic,
|
|
5845
6075
|
onUpdate: t.onUpdate,
|
|
5846
6076
|
onComplete: t.onComplete
|
|
5847
6077
|
}), this.running || (this.running = !0, this.tick());
|
|
@@ -5876,10 +6106,10 @@ var An = class {
|
|
|
5876
6106
|
};
|
|
5877
6107
|
//#endregion
|
|
5878
6108
|
//#region src/finance/BaseFinanceChart.ts
|
|
5879
|
-
function
|
|
5880
|
-
return !t || t === "dark" ? e : t === "light" ?
|
|
6109
|
+
function Gn(t) {
|
|
6110
|
+
return !t || t === "dark" ? e : t === "light" ? c : t;
|
|
5881
6111
|
}
|
|
5882
|
-
var
|
|
6112
|
+
var Kn = class {
|
|
5883
6113
|
canvas;
|
|
5884
6114
|
ctx;
|
|
5885
6115
|
container;
|
|
@@ -5890,7 +6120,7 @@ var In = class {
|
|
|
5890
6120
|
frameId = null;
|
|
5891
6121
|
resizeObserver;
|
|
5892
6122
|
constructor(e, t) {
|
|
5893
|
-
this.container = e, this.theme =
|
|
6123
|
+
this.container = e, this.theme = Gn(t), this.canvas = document.createElement("canvas"), this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.display = "block", e.appendChild(this.canvas), this.ctx = this.canvas.getContext("2d"), this.dpr = window.devicePixelRatio || 1, this.updateSize(), this.resizeObserver = new ResizeObserver(() => {
|
|
5894
6124
|
this.updateSize(), this.requestRender();
|
|
5895
6125
|
}), this.resizeObserver.observe(e);
|
|
5896
6126
|
}
|
|
@@ -5905,12 +6135,12 @@ var In = class {
|
|
|
5905
6135
|
}));
|
|
5906
6136
|
}
|
|
5907
6137
|
setTheme(e) {
|
|
5908
|
-
this.theme =
|
|
6138
|
+
this.theme = Gn(e), this.requestRender();
|
|
5909
6139
|
}
|
|
5910
6140
|
destroy() {
|
|
5911
6141
|
this.frameId !== null && cancelAnimationFrame(this.frameId), this.resizeObserver.disconnect(), this.canvas.remove();
|
|
5912
6142
|
}
|
|
5913
|
-
},
|
|
6143
|
+
}, qn = class {
|
|
5914
6144
|
pos = null;
|
|
5915
6145
|
canvas;
|
|
5916
6146
|
onUpdate;
|
|
@@ -5942,7 +6172,7 @@ var In = class {
|
|
|
5942
6172
|
};
|
|
5943
6173
|
//#endregion
|
|
5944
6174
|
//#region src/finance/SparklineRenderer.ts
|
|
5945
|
-
function
|
|
6175
|
+
function Jn(e, t, n, r, i) {
|
|
5946
6176
|
let { data: a, mode: o = "area", lineWidth: s = 1.5, showLastPoint: c = !1, showMinMax: l = !1 } = r;
|
|
5947
6177
|
if (a.length < 2 || t <= 0 || n <= 0) return;
|
|
5948
6178
|
let u = r.color ?? i.lineColor, d = r.fillColor ?? u, f = t - 4, p = n - 4, m = Infinity, h = -Infinity, g = 0, _ = 0;
|
|
@@ -5967,8 +6197,8 @@ function Rn(e, t, n, r, i) {
|
|
|
5967
6197
|
}
|
|
5968
6198
|
//#endregion
|
|
5969
6199
|
//#region src/finance/DepthChartRenderer.ts
|
|
5970
|
-
var
|
|
5971
|
-
function
|
|
6200
|
+
var Yn = 50, Xn = 60, Y = 20, Zn = .2;
|
|
6201
|
+
function Qn(e) {
|
|
5972
6202
|
let t = [...e].sort((e, t) => t.price - e.price), n = [], r = 0;
|
|
5973
6203
|
for (let e of t) r += e.volume, n.push({
|
|
5974
6204
|
price: e.price,
|
|
@@ -5976,7 +6206,7 @@ function Hn(e) {
|
|
|
5976
6206
|
});
|
|
5977
6207
|
return n;
|
|
5978
6208
|
}
|
|
5979
|
-
function
|
|
6209
|
+
function $n(e) {
|
|
5980
6210
|
let t = [...e].sort((e, t) => e.price - t.price), n = [], r = 0;
|
|
5981
6211
|
for (let e of t) r += e.volume, n.push({
|
|
5982
6212
|
price: e.price,
|
|
@@ -5984,35 +6214,35 @@ function Un(e) {
|
|
|
5984
6214
|
});
|
|
5985
6215
|
return n;
|
|
5986
6216
|
}
|
|
5987
|
-
function
|
|
6217
|
+
function er(e, t) {
|
|
5988
6218
|
return {
|
|
5989
|
-
left:
|
|
5990
|
-
right: e -
|
|
6219
|
+
left: Yn,
|
|
6220
|
+
right: e - Xn,
|
|
5991
6221
|
top: Y,
|
|
5992
6222
|
bottom: t - Y,
|
|
5993
|
-
plotWidth: e -
|
|
6223
|
+
plotWidth: e - Yn - Xn,
|
|
5994
6224
|
plotHeight: t - Y * 2
|
|
5995
6225
|
};
|
|
5996
6226
|
}
|
|
5997
|
-
function
|
|
6227
|
+
function tr(e, t, n, r) {
|
|
5998
6228
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
5999
6229
|
}
|
|
6000
|
-
function
|
|
6001
|
-
let { left: c, right: l, top: u, bottom: d, plotWidth:
|
|
6230
|
+
function nr(e, t, n, r, i, a, o, s) {
|
|
6231
|
+
let { left: c, right: l, top: u, bottom: d, plotWidth: f, plotHeight: p } = t;
|
|
6002
6232
|
e.save(), e.strokeStyle = a.grid, e.lineWidth = .5, e.fillStyle = a.axisLabel, e.font = `${a.font.sizeSmall}px ${a.font.family}`;
|
|
6003
|
-
let h =
|
|
6233
|
+
let h = m(0, i, 5);
|
|
6004
6234
|
for (let t = 0; t <= i; t += h) {
|
|
6005
|
-
let n = d - t / i *
|
|
6235
|
+
let n = d - t / i * p;
|
|
6006
6236
|
e.beginPath(), e.moveTo(c, n), e.lineTo(l, n), e.stroke(), e.textAlign = "right", e.textBaseline = "middle", e.fillText(s(t), c - 4, n);
|
|
6007
6237
|
}
|
|
6008
|
-
let g = r - n, _ =
|
|
6238
|
+
let g = r - n, _ = m(n, r, 6), v = Math.ceil(n / _) * _;
|
|
6009
6239
|
for (let t = v; t <= r; t += _) {
|
|
6010
|
-
let r = c + (t - n) / g *
|
|
6240
|
+
let r = c + (t - n) / g * f;
|
|
6011
6241
|
e.beginPath(), e.moveTo(r, u), e.lineTo(r, d), e.stroke(), e.textAlign = "center", e.textBaseline = "top", e.fillText(o(t), r, d + 4);
|
|
6012
6242
|
}
|
|
6013
6243
|
e.restore();
|
|
6014
6244
|
}
|
|
6015
|
-
function
|
|
6245
|
+
function rr(e, t, n, r, i, a, o, s, c) {
|
|
6016
6246
|
if (t.length === 0) return;
|
|
6017
6247
|
let { left: l, bottom: u, plotWidth: d, plotHeight: f } = n, p = (e) => l + (e - r) / i * d, m = (e) => u - e / a * f;
|
|
6018
6248
|
if (e.beginPath(), c === "bid") {
|
|
@@ -6045,14 +6275,14 @@ function qn(e, t, n, r, i, a, o, s, c) {
|
|
|
6045
6275
|
}
|
|
6046
6276
|
e.strokeStyle = s, e.lineWidth = 1.5, e.stroke();
|
|
6047
6277
|
}
|
|
6048
|
-
function
|
|
6278
|
+
function ir(e, t, n, r, i, a, o, s, c) {
|
|
6049
6279
|
let { left: l, top: u, bottom: d, plotWidth: f } = r, p = l + (t - i) / a * f;
|
|
6050
6280
|
if (e.save(), e.strokeStyle = o.textSecondary, e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(p, u), e.lineTo(p, d), e.stroke(), e.restore(), s) {
|
|
6051
6281
|
let t = `Spread: ${c(n)}`;
|
|
6052
6282
|
e.save(), e.font = `${o.font.sizeSmall}px ${o.font.family}`, e.fillStyle = o.textSecondary, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(t, p, u - 2), e.restore();
|
|
6053
6283
|
}
|
|
6054
6284
|
}
|
|
6055
|
-
function
|
|
6285
|
+
function ar(e, t, n, r, i, a, o, s, c, l, u) {
|
|
6056
6286
|
let { left: d, top: f, bottom: p, plotWidth: m, plotHeight: h } = i, g = t.x;
|
|
6057
6287
|
if (g < d || g > i.right) return;
|
|
6058
6288
|
let _ = a + (g - d) / m * o, v = 0, y = "";
|
|
@@ -6078,47 +6308,47 @@ function Yn(e, t, n, r, i, a, o, s, c, l, u) {
|
|
|
6078
6308
|
for (let t = 0; t < b.length; t++) e.fillText(b[t], C + 8, w + 6 + t * (c.font.sizeSmall + 4));
|
|
6079
6309
|
e.restore();
|
|
6080
6310
|
}
|
|
6081
|
-
function
|
|
6311
|
+
function or(e) {
|
|
6082
6312
|
return e.toFixed(2);
|
|
6083
6313
|
}
|
|
6084
|
-
function
|
|
6314
|
+
function sr(e) {
|
|
6085
6315
|
return e >= 1e6 ? (e / 1e6).toFixed(2) + "M" : e >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(0);
|
|
6086
6316
|
}
|
|
6087
|
-
function
|
|
6317
|
+
function cr(e, t, n, r, i, a) {
|
|
6088
6318
|
let { data: o } = r;
|
|
6089
6319
|
if (o.bids.length === 0 && o.asks.length === 0 || t <= 0 || n <= 0) return;
|
|
6090
|
-
let s = r.bidColor ?? i.candleUp, c = r.askColor ?? i.candleDown, l = r.bidFillColor ?? s + "40", u = r.askFillColor ?? c + "40", d = r.midPriceLine !== !1, f = r.spreadLabel !== !1, p = r.priceFormat ??
|
|
6091
|
-
|
|
6320
|
+
let s = r.bidColor ?? i.candleUp, c = r.askColor ?? i.candleDown, l = r.bidFillColor ?? s + "40", u = r.askFillColor ?? c + "40", d = r.midPriceLine !== !1, f = r.spreadLabel !== !1, p = r.priceFormat ?? or, m = r.volumeFormat ?? sr, h = Qn(o.bids), g = $n(o.asks), _ = h.length > 0 ? h[0].price : 0, v = g.length > 0 ? g[0].price : 0, y = h.length > 0 && g.length > 0 ? (_ + v) / 2 : _ || v, b = g.length > 0 && h.length > 0 ? v - _ : 0, x = h.length > 0 ? h[h.length - 1].price : y, S = g.length > 0 ? g[g.length - 1].price : y, C = Math.max(y - x, S - y) * (1 + Zn), w = y - C, T = y + C, E = T - w, D = h.length > 0 ? h[h.length - 1].cumulativeVolume : 0, O = g.length > 0 ? g[g.length - 1].cumulativeVolume : 0, k = Math.max(D, O) || 1, A = er(t, n);
|
|
6321
|
+
tr(e, t, n, i.background), nr(e, A, w, T, k, i, p, m), rr(e, h, A, w, E, k, l, s, "bid"), rr(e, g, A, w, E, k, u, c, "ask"), d && ir(e, y, b, A, w, E, i, f, p), a && ar(e, a, h, g, A, w, E, k, i, p, m);
|
|
6092
6322
|
}
|
|
6093
6323
|
//#endregion
|
|
6094
6324
|
//#region src/finance/EquityCurveRenderer.ts
|
|
6095
|
-
var
|
|
6096
|
-
function
|
|
6325
|
+
var lr = 70, ur = 30, dr = 20, fr = 20, pr = .05;
|
|
6326
|
+
function mr(e, t) {
|
|
6097
6327
|
return {
|
|
6098
|
-
left:
|
|
6099
|
-
right: e -
|
|
6100
|
-
top:
|
|
6101
|
-
bottom: t -
|
|
6102
|
-
plotWidth: e -
|
|
6103
|
-
plotHeight: t -
|
|
6328
|
+
left: lr,
|
|
6329
|
+
right: e - dr,
|
|
6330
|
+
top: fr,
|
|
6331
|
+
bottom: t - ur,
|
|
6332
|
+
plotWidth: e - lr - dr,
|
|
6333
|
+
plotHeight: t - fr - ur
|
|
6104
6334
|
};
|
|
6105
6335
|
}
|
|
6106
|
-
function
|
|
6336
|
+
function hr(e, t) {
|
|
6107
6337
|
let n = Infinity, r = -Infinity;
|
|
6108
6338
|
for (let t of e) t.value < n && (n = t.value), t.value > r && (r = t.value);
|
|
6109
6339
|
if (t) for (let e of t) e.value < n && (n = e.value), e.value > r && (r = e.value);
|
|
6110
|
-
let i = (r - n) *
|
|
6340
|
+
let i = (r - n) * pr;
|
|
6111
6341
|
return {
|
|
6112
6342
|
valMin: n - i,
|
|
6113
6343
|
valMax: r + i
|
|
6114
6344
|
};
|
|
6115
6345
|
}
|
|
6116
|
-
function
|
|
6346
|
+
function gr(e) {
|
|
6117
6347
|
let t = [], n = -Infinity;
|
|
6118
6348
|
for (let r of e) r.value > n && (n = r.value), t.push(n);
|
|
6119
6349
|
return t;
|
|
6120
6350
|
}
|
|
6121
|
-
function
|
|
6351
|
+
function _r(e) {
|
|
6122
6352
|
let t = 864e5;
|
|
6123
6353
|
if (365.25 * t, e < 7 * t) {
|
|
6124
6354
|
let e = new Intl.DateTimeFormat(void 0, {
|
|
@@ -6140,42 +6370,42 @@ function sr(e) {
|
|
|
6140
6370
|
});
|
|
6141
6371
|
return (e) => n.format(new Date(e));
|
|
6142
6372
|
}
|
|
6143
|
-
function
|
|
6373
|
+
function vr(e) {
|
|
6144
6374
|
return Math.abs(e) >= 1e6 ? (e / 1e6).toFixed(2) + "M" : Math.abs(e) >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(2);
|
|
6145
6375
|
}
|
|
6146
|
-
function
|
|
6376
|
+
function yr(e, t, n, r) {
|
|
6147
6377
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
6148
6378
|
}
|
|
6149
|
-
function
|
|
6150
|
-
let { left: l, right: u, top: d, bottom:
|
|
6379
|
+
function br(e, t, n, r, i, a, o, s, c) {
|
|
6380
|
+
let { left: l, right: u, top: d, bottom: f, plotWidth: p, plotHeight: h } = t;
|
|
6151
6381
|
e.save(), e.strokeStyle = o.grid, e.lineWidth = .5, e.fillStyle = o.axisLabel, e.font = `${o.font.sizeSmall}px ${o.font.family}`;
|
|
6152
|
-
let g =
|
|
6382
|
+
let g = m(n, r, 6), _ = Math.ceil(n / g) * g;
|
|
6153
6383
|
for (let t = _; t <= r; t += g) {
|
|
6154
|
-
let i =
|
|
6384
|
+
let i = f - (t - n) / (r - n) * h;
|
|
6155
6385
|
e.beginPath(), e.moveTo(l, i), e.lineTo(u, i), e.stroke(), e.textAlign = "right", e.textBaseline = "middle", e.fillText(s(t), l - 6, i);
|
|
6156
6386
|
}
|
|
6157
|
-
let v = a - i, y =
|
|
6387
|
+
let v = a - i, y = m(i, a, 6), b = Math.ceil(i / y) * y;
|
|
6158
6388
|
for (let t = b; t <= a; t += y) {
|
|
6159
|
-
let n = l + (t - i) / v *
|
|
6160
|
-
e.beginPath(), e.moveTo(n, d), e.lineTo(n,
|
|
6389
|
+
let n = l + (t - i) / v * p;
|
|
6390
|
+
e.beginPath(), e.moveTo(n, d), e.lineTo(n, f), e.stroke(), e.textAlign = "center", e.textBaseline = "top", e.fillText(c(t), n, f + 4);
|
|
6161
6391
|
}
|
|
6162
6392
|
e.restore();
|
|
6163
6393
|
}
|
|
6164
|
-
function
|
|
6394
|
+
function xr(e, t, n, r, i, a, o, s, c) {
|
|
6165
6395
|
if (t.length < 2) return;
|
|
6166
6396
|
let { left: l, bottom: u, plotWidth: d, plotHeight: f } = n, p = (e) => l + (e - r) / i * d, m = (e) => u - (e - a) / o * f;
|
|
6167
6397
|
e.save(), e.beginPath(), e.moveTo(p(t[0].time), m(t[0].value));
|
|
6168
6398
|
for (let n = 1; n < t.length; n++) e.lineTo(p(t[n].time), m(t[n].value));
|
|
6169
6399
|
e.strokeStyle = s, e.lineWidth = c, e.lineJoin = "round", e.stroke(), e.restore();
|
|
6170
6400
|
}
|
|
6171
|
-
function
|
|
6401
|
+
function Sr(e, t, n, r, i, a, o, s) {
|
|
6172
6402
|
if (t.length < 2) return;
|
|
6173
6403
|
let { left: c, bottom: l, plotWidth: u, plotHeight: d } = n, f = (e) => c + (e - r) / i * u, p = (e) => l - (e - a) / o * d, m = e.createLinearGradient(0, n.top, 0, l);
|
|
6174
6404
|
m.addColorStop(0, s + "40"), m.addColorStop(1, "transparent"), e.save(), e.beginPath(), e.moveTo(f(t[0].time), p(t[0].value));
|
|
6175
6405
|
for (let n = 1; n < t.length; n++) e.lineTo(f(t[n].time), p(t[n].value));
|
|
6176
6406
|
e.lineTo(f(t[t.length - 1].time), l), e.lineTo(f(t[0].time), l), e.closePath(), e.fillStyle = m, e.fill(), e.restore();
|
|
6177
6407
|
}
|
|
6178
|
-
function
|
|
6408
|
+
function Cr(e, t, n, r, i, a, o, s, c) {
|
|
6179
6409
|
if (t.length < 2) return;
|
|
6180
6410
|
let { left: l, bottom: u, plotWidth: d, plotHeight: f } = r, p = (e) => l + (e - i) / a * d, m = (e) => u - (e - o) / s * f;
|
|
6181
6411
|
e.save(), e.fillStyle = c, e.beginPath(), e.moveTo(p(t[0].time), m(n[0]));
|
|
@@ -6183,12 +6413,12 @@ function pr(e, t, n, r, i, a, o, s, c) {
|
|
|
6183
6413
|
for (let n = t.length - 1; n >= 0; n--) e.lineTo(p(t[n].time), m(t[n].value));
|
|
6184
6414
|
e.closePath(), e.fill(), e.restore();
|
|
6185
6415
|
}
|
|
6186
|
-
function
|
|
6416
|
+
function wr(e, t, n, r, i, a, o, s, c, l) {
|
|
6187
6417
|
if (t.length === 0) return;
|
|
6188
6418
|
let { left: u, bottom: d, plotWidth: f, plotHeight: p } = n, m = t[t.length - 1], h = u + (m.time - r) / i * f, g = d - (m.value - a) / o * p;
|
|
6189
6419
|
e.save(), e.font = `${l.font.sizeSmall}px ${l.font.family}`, e.fillStyle = c, e.textAlign = "left", e.textBaseline = "middle", e.fillText(s, h + 4, g), e.restore();
|
|
6190
6420
|
}
|
|
6191
|
-
function
|
|
6421
|
+
function Tr(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
6192
6422
|
let { left: f, top: p, bottom: m, plotWidth: h, plotHeight: g } = i, _ = t.x;
|
|
6193
6423
|
if (_ < f || _ > i.right) return;
|
|
6194
6424
|
e.save(), e.strokeStyle = l.crosshair, e.lineWidth = .5, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(_, p), e.lineTo(_, m), e.stroke(), e.restore();
|
|
@@ -6206,15 +6436,15 @@ function hr(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
6206
6436
|
for (let t = 0; t < S.length; t++) e.fillText(S[t], D + 8, O + 6 + t * (l.font.sizeSmall + 4));
|
|
6207
6437
|
e.restore();
|
|
6208
6438
|
}
|
|
6209
|
-
function
|
|
6439
|
+
function Er(e, t, n, r, i, a) {
|
|
6210
6440
|
let { data: o } = r;
|
|
6211
6441
|
if (o.length < 2 || t <= 0 || n <= 0) return;
|
|
6212
|
-
let s = r.lineColor ?? i.lineColor, c = r.lineWidth ?? 1.5, l = r.drawdown === !0, u = r.drawdownColor ?? i.candleDown + "30", d = r.fillArea === !0, f = r.benchmark, p = r.benchmarkColor ?? i.textSecondary, m = r.benchmarkLabel ?? "Benchmark", h = r.valueFormat ??
|
|
6213
|
-
|
|
6442
|
+
let s = r.lineColor ?? i.lineColor, c = r.lineWidth ?? 1.5, l = r.drawdown === !0, u = r.drawdownColor ?? i.candleDown + "30", d = r.fillArea === !0, f = r.benchmark, p = r.benchmarkColor ?? i.textSecondary, m = r.benchmarkLabel ?? "Benchmark", h = r.valueFormat ?? vr, { valMin: g, valMax: _ } = hr(o, f), v = _ - g || 1, y = o[0].time, b = o[o.length - 1].time, x = b - y || 1, S = r.timeFormat ?? _r(x), C = mr(t, n);
|
|
6443
|
+
yr(e, t, n, i.background), br(e, C, g, _, y, b, i, h, S), l && Cr(e, o, gr(o), C, y, x, g, v, u), d && Sr(e, o, C, y, x, g, v, s), xr(e, o, C, y, x, g, v, s, c), f && f.length >= 2 && (xr(e, f, C, y, x, g, v, p, 1), wr(e, f, C, y, x, g, v, m, p, i)), a && Tr(e, a, o, f, C, y, x, g, v, i, S, h);
|
|
6214
6444
|
}
|
|
6215
6445
|
//#endregion
|
|
6216
6446
|
//#region src/finance/HeatmapLayout.ts
|
|
6217
|
-
function
|
|
6447
|
+
function Dr(e, t, n) {
|
|
6218
6448
|
if (e.length === 0) return [];
|
|
6219
6449
|
let r = e.length, i = Math.ceil(Math.sqrt(r)), a = Math.ceil(r / i), o = t.width / i, s = t.height / a, c = [];
|
|
6220
6450
|
for (let a = 0; a < r; a++) {
|
|
@@ -6231,7 +6461,7 @@ function _r(e, t, n) {
|
|
|
6231
6461
|
}
|
|
6232
6462
|
return c;
|
|
6233
6463
|
}
|
|
6234
|
-
function
|
|
6464
|
+
function Or(e, t) {
|
|
6235
6465
|
let n = e.reduce((e, t) => e + t, 0);
|
|
6236
6466
|
if (n === 0 || t === 0) return Infinity;
|
|
6237
6467
|
let r = 0;
|
|
@@ -6261,7 +6491,7 @@ function X(e, t, n, r, i, a) {
|
|
|
6261
6491
|
}), l += s;
|
|
6262
6492
|
}
|
|
6263
6493
|
}
|
|
6264
|
-
function
|
|
6494
|
+
function kr(e, t, n, r, i) {
|
|
6265
6495
|
if (e.length === 0) return;
|
|
6266
6496
|
let a = n.width >= n.height, o = a ? n.height : n.width;
|
|
6267
6497
|
if (e.length === 1) {
|
|
@@ -6271,7 +6501,7 @@ function yr(e, t, n, r, i) {
|
|
|
6271
6501
|
let s = [], c = [], l = 0;
|
|
6272
6502
|
for (; l < e.length;) {
|
|
6273
6503
|
let u = [...s, e[l]];
|
|
6274
|
-
if (s.length === 0 ||
|
|
6504
|
+
if (s.length === 0 || Or(u, o) <= Or(s, o)) s.push(e[l]), c.push(t[l]), l++;
|
|
6275
6505
|
else {
|
|
6276
6506
|
X(s, c, n, a, r, i);
|
|
6277
6507
|
let u = s.reduce((e, t) => e + t, 0), d = o > 0 ? u / o : 0;
|
|
@@ -6285,43 +6515,43 @@ function yr(e, t, n, r, i) {
|
|
|
6285
6515
|
y: n.y + d,
|
|
6286
6516
|
width: n.width,
|
|
6287
6517
|
height: n.height - d
|
|
6288
|
-
},
|
|
6518
|
+
}, kr(e.slice(l), t.slice(l), n, r, i);
|
|
6289
6519
|
return;
|
|
6290
6520
|
}
|
|
6291
6521
|
}
|
|
6292
6522
|
s.length > 0 && X(s, c, n, a, r, i);
|
|
6293
6523
|
}
|
|
6294
|
-
function
|
|
6524
|
+
function Ar(e, t, n) {
|
|
6295
6525
|
if (e.length === 0) return [];
|
|
6296
6526
|
let r = [...e].sort((e, t) => t.weight - e.weight), i = r.reduce((e, t) => e + Math.max(0, t.weight), 0);
|
|
6297
6527
|
if (i === 0) return [];
|
|
6298
6528
|
let a = t.width * t.height, o = r.map((e) => Math.max(0, e.weight) / i * a), s = r.map((e) => e.id), c = [];
|
|
6299
|
-
return
|
|
6529
|
+
return kr(o, s, { ...t }, n, c), c;
|
|
6300
6530
|
}
|
|
6301
6531
|
//#endregion
|
|
6302
6532
|
//#region src/finance/HeatmapRenderer.ts
|
|
6303
|
-
function
|
|
6533
|
+
function jr(e) {
|
|
6304
6534
|
return (e >= 0 ? "+" : "") + e.toFixed(2) + "%";
|
|
6305
6535
|
}
|
|
6306
|
-
function
|
|
6536
|
+
function Mr(e) {
|
|
6307
6537
|
return e.label;
|
|
6308
6538
|
}
|
|
6309
|
-
function
|
|
6539
|
+
function Nr(e, t) {
|
|
6310
6540
|
let n = t.min ?? -5, r = t.max ?? 5;
|
|
6311
6541
|
if (e <= n) return t.negative;
|
|
6312
6542
|
if (e >= r) return t.positive;
|
|
6313
6543
|
if (e < 0) {
|
|
6314
6544
|
let r = 1 - e / n;
|
|
6315
|
-
return
|
|
6545
|
+
return g(t.negative, t.zero, r);
|
|
6316
6546
|
}
|
|
6317
6547
|
let i = e / r;
|
|
6318
|
-
return
|
|
6548
|
+
return g(t.zero, t.positive, i);
|
|
6319
6549
|
}
|
|
6320
6550
|
function Z(e, t, n, r, i, a) {
|
|
6321
6551
|
let o = Math.min(a, r / 2, i / 2);
|
|
6322
6552
|
e.beginPath(), e.moveTo(t + o, n), e.lineTo(t + r - o, n), e.arcTo(t + r, n, t + r, n + o, o), e.lineTo(t + r, n + i - o), e.arcTo(t + r, n + i, t + r - o, n + i, o), e.lineTo(t + o, n + i), e.arcTo(t, n + i, t, n + i - o, o), e.lineTo(t, n + o), e.arcTo(t, n, t + o, n, o), e.closePath();
|
|
6323
6553
|
}
|
|
6324
|
-
function
|
|
6554
|
+
function Pr(e, t, n, r, i, a, o, s, c, l, u) {
|
|
6325
6555
|
if (i < 40 || a < 30) return;
|
|
6326
6556
|
let d = n + i / 2, f = r + a / 2;
|
|
6327
6557
|
if (e.save(), e.shadowColor = "rgba(0,0,0,0.6)", e.shadowBlur = 2, e.fillStyle = "#FFFFFF", e.textAlign = "center", s) {
|
|
@@ -6334,7 +6564,7 @@ function wr(e, t, n, r, i, a, o, s, c, l, u) {
|
|
|
6334
6564
|
}
|
|
6335
6565
|
e.restore();
|
|
6336
6566
|
}
|
|
6337
|
-
function
|
|
6567
|
+
function Fr(e, t, n, r, i, a, o, s) {
|
|
6338
6568
|
let c = [o(t), s(t.value)];
|
|
6339
6569
|
if (t.meta) for (let [e, n] of Object.entries(t.meta)) c.push(e + ": " + String(n));
|
|
6340
6570
|
e.save(), e.font = a.font.sizeSmall + "px " + a.font.family;
|
|
@@ -6343,13 +6573,13 @@ function Tr(e, t, n, r, i, a, o, s) {
|
|
|
6343
6573
|
for (let t = 0; t < c.length; t++) e.fillText(c[t], f + 8, p + 6 + t * u);
|
|
6344
6574
|
e.restore();
|
|
6345
6575
|
}
|
|
6346
|
-
function
|
|
6576
|
+
function Ir(e, t, n, r, i, a, o, s) {
|
|
6347
6577
|
if (r.length === 0 || i.length === 0 || t <= 0 || n <= 0) return null;
|
|
6348
6578
|
let c = a.colorScale ?? {
|
|
6349
6579
|
negative: "#EF5350",
|
|
6350
6580
|
zero: "#424242",
|
|
6351
6581
|
positive: "#26A69A"
|
|
6352
|
-
}, l = a.cellRadius ?? 4, u = a.showLabels !== !1, d = a.showValues !== !1, f = a.valueFormat ??
|
|
6582
|
+
}, l = a.cellRadius ?? 4, u = a.showLabels !== !1, d = a.showValues !== !1, f = a.valueFormat ?? jr, p = a.labelFormat ?? Mr, m = /* @__PURE__ */ new Map();
|
|
6353
6583
|
for (let e of r) m.set(e.id, e);
|
|
6354
6584
|
let h = null, g = null;
|
|
6355
6585
|
if (s) for (let e of i) {
|
|
@@ -6370,37 +6600,37 @@ function Er(e, t, n, r, i, a, o, s) {
|
|
|
6370
6600
|
if (!n) continue;
|
|
6371
6601
|
let { x: r, y: i, width: a, height: s } = t.rect;
|
|
6372
6602
|
if (a <= 0 || s <= 0) continue;
|
|
6373
|
-
let g =
|
|
6374
|
-
Z(e, r, i, a, s, l), e.fillStyle = g, e.fill(),
|
|
6603
|
+
let g = Nr(n.value, c);
|
|
6604
|
+
Z(e, r, i, a, s, l), e.fillStyle = g, e.fill(), Pr(e, n, r, i, a, s, o, u, d, p, f), t.id === h && (Z(e, r, i, a, s, l), e.strokeStyle = "#FFFFFF", e.lineWidth = 1.5, e.stroke());
|
|
6375
6605
|
}
|
|
6376
|
-
return g && s &&
|
|
6606
|
+
return g && s && Fr(e, g.cell, s, t, n, o, p, f), g;
|
|
6377
6607
|
}
|
|
6378
6608
|
//#endregion
|
|
6379
6609
|
//#region src/finance/WaterfallRenderer.ts
|
|
6380
|
-
var
|
|
6381
|
-
function
|
|
6610
|
+
var Lr = 60, Rr = 12, zr = 24, Br = 40, Vr = .7, Hr = 1;
|
|
6611
|
+
function Ur(e) {
|
|
6382
6612
|
return e.type ? e.type : e.value > 0 ? "positive" : e.value < 0 ? "negative" : "subtotal";
|
|
6383
6613
|
}
|
|
6384
|
-
function
|
|
6614
|
+
function Wr(e) {
|
|
6385
6615
|
let t = Math.abs(e);
|
|
6386
6616
|
return t >= 1e6 ? (e / 1e6).toFixed(2) + "M" : t >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(2);
|
|
6387
6617
|
}
|
|
6388
|
-
function
|
|
6618
|
+
function Gr(e, t) {
|
|
6389
6619
|
return {
|
|
6390
|
-
left:
|
|
6391
|
-
right: e -
|
|
6392
|
-
top:
|
|
6393
|
-
bottom: t -
|
|
6394
|
-
plotWidth: e -
|
|
6395
|
-
plotHeight: t -
|
|
6620
|
+
left: Lr,
|
|
6621
|
+
right: e - Rr,
|
|
6622
|
+
top: zr,
|
|
6623
|
+
bottom: t - Br,
|
|
6624
|
+
plotWidth: e - Lr - Rr,
|
|
6625
|
+
plotHeight: t - zr - Br
|
|
6396
6626
|
};
|
|
6397
6627
|
}
|
|
6398
|
-
function
|
|
6628
|
+
function Kr(e, t, n, r, i) {
|
|
6399
6629
|
let a = Array(e.length), o = Array(e.length), s = t.plotWidth / e.length, c = s * n, l = (s - c) / 2, { left: u, bottom: d, plotHeight: f } = t, p = 0;
|
|
6400
6630
|
for (let t = 0; t < e.length; t++) {
|
|
6401
|
-
let n = e[t], m =
|
|
6631
|
+
let n = e[t], m = Ur(n), h, g;
|
|
6402
6632
|
m === "total" || m === "subtotal" ? (h = 0, g = n.value, p = n.value) : (h = p, g = p + n.value, p = g);
|
|
6403
|
-
let _ = Math.min(h, g), v = Math.max(h, g), y = d - (_ - r) / i * f, b = d - (v - r) / i * f, x = Math.min(y, b), S = Math.max(Math.abs(b - y),
|
|
6633
|
+
let _ = Math.min(h, g), v = Math.max(h, g), y = d - (_ - r) / i * f, b = d - (v - r) / i * f, x = Math.min(y, b), S = Math.max(Math.abs(b - y), Hr), C = u + t * s, w = C + l;
|
|
6404
6634
|
a[t] = {
|
|
6405
6635
|
label: n.label,
|
|
6406
6636
|
value: n.value,
|
|
@@ -6420,14 +6650,14 @@ function Ir(e, t, n, r, i) {
|
|
|
6420
6650
|
cumulatives: o
|
|
6421
6651
|
};
|
|
6422
6652
|
}
|
|
6423
|
-
function
|
|
6653
|
+
function qr(e) {
|
|
6424
6654
|
if (e.length === 0) return {
|
|
6425
6655
|
valMin: 0,
|
|
6426
6656
|
valMax: 1
|
|
6427
6657
|
};
|
|
6428
6658
|
let t = 0, n = 0, r = 0;
|
|
6429
6659
|
for (let i = 0; i < e.length; i++) {
|
|
6430
|
-
let a = e[i], o =
|
|
6660
|
+
let a = e[i], o = Ur(a), s, c;
|
|
6431
6661
|
o === "total" || o === "subtotal" ? (s = 0, c = a.value, r = a.value) : (s = r, c = r + a.value, r = c), s < t && (t = s), c < t && (t = c), s > n && (n = s), c > n && (n = c);
|
|
6432
6662
|
}
|
|
6433
6663
|
let i = (n - t || 1) * .1;
|
|
@@ -6436,20 +6666,20 @@ function Lr(e) {
|
|
|
6436
6666
|
valMax: n + i
|
|
6437
6667
|
};
|
|
6438
6668
|
}
|
|
6439
|
-
function
|
|
6669
|
+
function Jr(e, t, n, r) {
|
|
6440
6670
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
6441
6671
|
}
|
|
6442
|
-
function
|
|
6672
|
+
function Yr(e, t, n, r, i, a) {
|
|
6443
6673
|
let { left: o, right: s, top: c, bottom: l, plotHeight: u } = t, d = r - n || 1;
|
|
6444
6674
|
e.strokeStyle = i.grid, e.lineWidth = .5, e.fillStyle = i.axisLabel, e.font = `${i.font.sizeSmall}px ${i.font.family}`, e.textAlign = "right", e.textBaseline = "middle";
|
|
6445
|
-
let
|
|
6675
|
+
let f = m(n, r, 5), p = Math.ceil(n / f) * f;
|
|
6446
6676
|
e.beginPath();
|
|
6447
|
-
for (let t =
|
|
6677
|
+
for (let t = p; t <= r; t += f) {
|
|
6448
6678
|
let r = Math.round(l - (t - n) / d * u) + .5;
|
|
6449
6679
|
r < c || r > l || (e.moveTo(o, r), e.lineTo(s, r));
|
|
6450
6680
|
}
|
|
6451
6681
|
e.stroke();
|
|
6452
|
-
for (let t =
|
|
6682
|
+
for (let t = p; t <= r; t += f) {
|
|
6453
6683
|
let r = l - (t - n) / d * u;
|
|
6454
6684
|
r < c - 1 || r > l + 1 || e.fillText(a(t), o - 6, r);
|
|
6455
6685
|
}
|
|
@@ -6458,7 +6688,7 @@ function zr(e, t, n, r, i, a) {
|
|
|
6458
6688
|
e.strokeStyle = i.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(o, t), e.lineTo(s, t), e.stroke();
|
|
6459
6689
|
}
|
|
6460
6690
|
}
|
|
6461
|
-
function
|
|
6691
|
+
function Xr(e, t, n) {
|
|
6462
6692
|
let r = [
|
|
6463
6693
|
"positive",
|
|
6464
6694
|
"negative",
|
|
@@ -6477,7 +6707,7 @@ function Br(e, t, n) {
|
|
|
6477
6707
|
s && (e.fillStyle = o, e.fill());
|
|
6478
6708
|
}
|
|
6479
6709
|
}
|
|
6480
|
-
function
|
|
6710
|
+
function Zr(e, t, n, r, i, a, o) {
|
|
6481
6711
|
if (o === "none" || t.length < 2) return;
|
|
6482
6712
|
let { bottom: s, plotHeight: c } = n;
|
|
6483
6713
|
e.strokeStyle = a, e.lineWidth = 1, o === "dashed" ? e.setLineDash([4, 4]) : e.setLineDash([]), e.beginPath();
|
|
@@ -6487,7 +6717,7 @@ function Vr(e, t, n, r, i, a, o) {
|
|
|
6487
6717
|
}
|
|
6488
6718
|
e.stroke(), e.setLineDash([]);
|
|
6489
6719
|
}
|
|
6490
|
-
function
|
|
6720
|
+
function Qr(e, t, n, r, i, a) {
|
|
6491
6721
|
e.fillStyle = r.text, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center";
|
|
6492
6722
|
for (let r = 0; r < t.length; r++) {
|
|
6493
6723
|
let o = t[r], s;
|
|
@@ -6496,7 +6726,7 @@ function Hr(e, t, n, r, i, a) {
|
|
|
6496
6726
|
o.end < o.start ? (e.textBaseline = "top", e.fillText(s, c, o.rectY + o.rectH + 4)) : (e.textBaseline = "bottom", e.fillText(s, c, o.rectY - 4));
|
|
6497
6727
|
}
|
|
6498
6728
|
}
|
|
6499
|
-
function
|
|
6729
|
+
function $r(e, t, n, r, i) {
|
|
6500
6730
|
e.fillStyle = r.axisLabel, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center", e.textBaseline = "top";
|
|
6501
6731
|
let a = n.bottom + 6, o = t.length > 0 ? t[0].slotW - 4 : 0, s = !1;
|
|
6502
6732
|
for (let n = 0; n < t.length; n++) if (e.measureText(i(t[n].label)).width > o) {
|
|
@@ -6517,7 +6747,7 @@ function Ur(e, t, n, r, i) {
|
|
|
6517
6747
|
}
|
|
6518
6748
|
e.setTransform(1, 0, 0, 1, 0, 0), e.restore();
|
|
6519
6749
|
}
|
|
6520
|
-
function
|
|
6750
|
+
function ei(e, t, n) {
|
|
6521
6751
|
if (t < n.left || t > n.right) return null;
|
|
6522
6752
|
for (let n = 0; n < e.length; n++) {
|
|
6523
6753
|
let r = e[n];
|
|
@@ -6525,7 +6755,7 @@ function Wr(e, t, n) {
|
|
|
6525
6755
|
}
|
|
6526
6756
|
return null;
|
|
6527
6757
|
}
|
|
6528
|
-
function
|
|
6758
|
+
function ti(e, t, n, r, i, a, o, s) {
|
|
6529
6759
|
let c = t[r], l = n[r], u = Math.round(c.slotX + c.slotW / 2) + .5;
|
|
6530
6760
|
e.strokeStyle = o.crosshair, e.lineWidth = .5, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(u, a.top), e.lineTo(u, a.bottom), e.stroke(), e.setLineDash([]);
|
|
6531
6761
|
let d = [
|
|
@@ -6544,31 +6774,31 @@ function Gr(e, t, n, r, i, a, o, s) {
|
|
|
6544
6774
|
let _ = o.font.sizeSmall + 4;
|
|
6545
6775
|
for (let t = 0; t < d.length; t++) e.fillText(d[t], h + 8, g + 6 + t * _);
|
|
6546
6776
|
}
|
|
6547
|
-
function
|
|
6777
|
+
function ni(e, t, n, r, i, a) {
|
|
6548
6778
|
let { data: o } = r;
|
|
6549
6779
|
if (!o || o.length === 0 || t <= 0 || n <= 0) return { hitBar: null };
|
|
6550
|
-
let s = r.positiveColor ?? i.candleUp, c = r.negativeColor ?? i.candleDown, l = r.totalColor ?? i.lineColor, u = r.subtotalColor ?? i.textSecondary, d = r.connectorColor ?? i.textSecondary, f = r.connectorStyle ?? "dashed", p = r.barWidth ??
|
|
6551
|
-
|
|
6780
|
+
let s = r.positiveColor ?? i.candleUp, c = r.negativeColor ?? i.candleDown, l = r.totalColor ?? i.lineColor, u = r.subtotalColor ?? i.textSecondary, d = r.connectorColor ?? i.textSecondary, f = r.connectorStyle ?? "dashed", p = r.barWidth ?? Vr, m = r.showValues !== !1, h = r.showDelta !== !1, g = r.valueFormat ?? Wr, _ = r.labelFormat ?? ((e) => e), { valMin: v, valMax: y } = qr(o), b = y - v || 1, x = Gr(t, n), { bars: S, cumulatives: C } = Kr(o, x, p, v, b);
|
|
6781
|
+
Jr(e, t, n, i.background), Yr(e, x, v, y, i, g), Zr(e, S, x, v, b, d, f), Xr(e, S, {
|
|
6552
6782
|
positive: s,
|
|
6553
6783
|
negative: c,
|
|
6554
6784
|
total: l,
|
|
6555
6785
|
subtotal: u
|
|
6556
|
-
}), m &&
|
|
6557
|
-
let w = a ?
|
|
6558
|
-
return a && w !== null &&
|
|
6786
|
+
}), m && Qr(e, S, C, i, g, h), $r(e, S, x, i, _);
|
|
6787
|
+
let w = a ? ei(S, a.x, x) : null;
|
|
6788
|
+
return a && w !== null && ti(e, S, C, w, a, x, i, g), { hitBar: w };
|
|
6559
6789
|
}
|
|
6560
6790
|
//#endregion
|
|
6561
6791
|
//#region src/finance/GaugeRenderer.ts
|
|
6562
|
-
var
|
|
6563
|
-
function
|
|
6792
|
+
var ri = Math.PI / 180, ii = 135, ai = 405, oi = .25;
|
|
6793
|
+
function si(e) {
|
|
6564
6794
|
let t = Math.abs(e);
|
|
6565
6795
|
return t >= 1e6 ? (e / 1e6).toFixed(2) + "M" : t >= 1e3 ? (e / 1e3).toFixed(1) + "K" : Number.isInteger(e) ? e.toFixed(0) : e.toFixed(1);
|
|
6566
6796
|
}
|
|
6567
6797
|
function Q(e, t, n) {
|
|
6568
6798
|
return e < t ? t : e > n ? n : e;
|
|
6569
6799
|
}
|
|
6570
|
-
function
|
|
6571
|
-
let r = n.min ?? 0, i = n.max ?? 100, a = i - r || 1, o = (n.startAngle ??
|
|
6800
|
+
function ci(e, t, n) {
|
|
6801
|
+
let r = n.min ?? 0, i = n.max ?? 100, a = i - r || 1, o = (n.startAngle ?? ii) * ri, s = (n.endAngle ?? ai) * ri, c = n.thickness ?? oi, l = e / 2, u = t / 2 + t * .05, d = Math.max(10, Math.min(e, t) / 2 - 24);
|
|
6572
6802
|
return {
|
|
6573
6803
|
cx: l,
|
|
6574
6804
|
cy: u,
|
|
@@ -6586,38 +6816,38 @@ function $(e, t) {
|
|
|
6586
6816
|
let n = Q((e - t.min) / t.range, 0, 1);
|
|
6587
6817
|
return t.startAngle + t.angleRange * n;
|
|
6588
6818
|
}
|
|
6589
|
-
function
|
|
6819
|
+
function li(e, t, n, r) {
|
|
6590
6820
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
6591
6821
|
}
|
|
6592
|
-
function
|
|
6822
|
+
function ui(e, t, n) {
|
|
6593
6823
|
e.beginPath(), e.arc(t.cx, t.cy, t.radius, t.startAngle, t.endAngle, !1), e.arc(t.cx, t.cy, t.innerRadius, t.endAngle, t.startAngle, !0), e.closePath(), e.fillStyle = n, e.fill();
|
|
6594
6824
|
}
|
|
6595
|
-
function
|
|
6825
|
+
function di(e, t, n) {
|
|
6596
6826
|
let r = Q(n.from, t.min, t.max), i = Q(n.to, t.min, t.max);
|
|
6597
6827
|
if (i <= r) return;
|
|
6598
6828
|
let a = $(r, t), o = $(i, t);
|
|
6599
6829
|
e.beginPath(), e.arc(t.cx, t.cy, t.radius, a, o, !1), e.arc(t.cx, t.cy, t.innerRadius, o, a, !0), e.closePath(), e.fillStyle = n.color, e.fill();
|
|
6600
6830
|
}
|
|
6601
|
-
function
|
|
6831
|
+
function fi(e, t, n, r, i) {
|
|
6602
6832
|
let a = $(n, t);
|
|
6603
6833
|
a <= t.startAngle || (e.globalAlpha = i, e.beginPath(), e.arc(t.cx, t.cy, t.radius, t.startAngle, a, !1), e.arc(t.cx, t.cy, t.innerRadius, a, t.startAngle, !0), e.closePath(), e.fillStyle = r, e.fill(), e.globalAlpha = 1);
|
|
6604
6834
|
}
|
|
6605
|
-
function
|
|
6835
|
+
function pi(e, t, n, r) {
|
|
6606
6836
|
let i = $(n, t), a = Math.cos(i), o = Math.sin(i), s = t.radius - 2, c = t.innerRadius * .25, l = -o, u = a, d = t.cx + a * s, f = t.cy + o * s, p = t.cx + l * 4 - a * c, m = t.cy + u * 4 - o * c, h = t.cx - l * 4 - a * c, g = t.cy - u * 4 - o * c;
|
|
6607
6837
|
e.beginPath(), e.moveTo(d, f), e.lineTo(p, m), e.lineTo(h, g), e.closePath(), e.fillStyle = r, e.fill(), e.beginPath(), e.arc(t.cx, t.cy, Math.max(4, t.innerRadius * .12), 0, Math.PI * 2), e.fill();
|
|
6608
6838
|
}
|
|
6609
|
-
function
|
|
6839
|
+
function mi(e, t, n, r, i) {
|
|
6610
6840
|
let a = Math.round(t.innerRadius * .55), o = Math.round(i.font.sizeMedium);
|
|
6611
6841
|
e.fillStyle = i.text, e.textAlign = "center", e.textBaseline = "middle", e.font = `600 ${a}px ${i.font.family}`;
|
|
6612
6842
|
let s = !!r, c = s ? t.cy - o * .6 : t.cy - a * .1;
|
|
6613
6843
|
e.fillText(n, t.cx, c), s && (e.fillStyle = i.textSecondary, e.font = `${o}px ${i.font.family}`, e.fillText(r, t.cx, t.cy + a * .55));
|
|
6614
6844
|
}
|
|
6615
|
-
function
|
|
6845
|
+
function hi(e, t, n, r) {
|
|
6616
6846
|
e.fillStyle = r.textSecondary, e.font = `${r.font.sizeSmall}px ${r.font.family}`;
|
|
6617
6847
|
let i = t.radius + 10, a = Math.cos(t.startAngle), o = Math.sin(t.startAngle), s = Math.cos(t.endAngle), c = Math.sin(t.endAngle), l = t.cx + a * i, u = t.cy + o * i, d = t.cx + s * i, f = t.cy + c * i;
|
|
6618
6848
|
e.textBaseline = "middle", e.textAlign = a < -.2 ? "right" : a > .2 ? "left" : "center", e.fillText(n(t.min), l, u), e.textAlign = s < -.2 ? "right" : s > .2 ? "left" : "center", e.fillText(n(t.max), d, f);
|
|
6619
6849
|
}
|
|
6620
|
-
function
|
|
6850
|
+
function gi(e, t, n, r) {
|
|
6621
6851
|
e.fillStyle = r.textSecondary, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
6622
6852
|
let i = (t.radius + t.innerRadius) / 2;
|
|
6623
6853
|
for (let r = 0; r < n.length; r++) {
|
|
@@ -6627,15 +6857,15 @@ function oi(e, t, n, r) {
|
|
|
6627
6857
|
e.fillText(a.label, s, c);
|
|
6628
6858
|
}
|
|
6629
6859
|
}
|
|
6630
|
-
function
|
|
6860
|
+
function _i(e, t, n, r, i, a) {
|
|
6631
6861
|
if (t <= 0 || n <= 0) return;
|
|
6632
|
-
let o =
|
|
6633
|
-
|
|
6862
|
+
let o = ci(t, n, r), s = r.trackColor ?? i.grid, c = r.needleColor ?? i.text, l = r.showValue !== !1, u = r.showZoneLabels === !0, d = r.valueFormat ?? si, f = Q(a, o.min, o.max);
|
|
6863
|
+
li(e, t, n, i.background), ui(e, o, s);
|
|
6634
6864
|
let p = r.zones;
|
|
6635
|
-
if (p && p.length > 0) for (let t = 0; t < p.length; t++)
|
|
6636
|
-
|
|
6865
|
+
if (p && p.length > 0) for (let t = 0; t < p.length; t++) di(e, o, p[t]);
|
|
6866
|
+
fi(e, o, f, c, .12), pi(e, o, f, c), l && mi(e, o, d(f), r.label, i), hi(e, o, d, i), u && p && p.length > 0 && gi(e, o, p, i);
|
|
6637
6867
|
}
|
|
6638
6868
|
//#endregion
|
|
6639
|
-
export {
|
|
6869
|
+
export { Ke as ADXIndicator, Ge as ATRIndicator, rt as AccumulationDistributionIndicator, On as AlertManager, Pe as AnchoredVWAPIndicator, Zt as AnchoredVWAPTool, Wn as Animator, re as AreaRenderer, Ze as AroonIndicator, qt as ArrowTool, Be as AwesomeOscillatorIndicator, Tn as BarCountdown, ie as BarRenderer, Kn as BaseFinanceChart, oe as BaselineRenderer, yn as BinanceAdapter, Te as BollingerBandsIndicator, Ye as CCIIndicator, et as CMFIndicator, te as CandlestickRenderer, b as CanvasLayer, Ve as ChaikinOscillatorIndicator, Sn as ChartLegend, In as ChartStateManager, he as CompareRenderer, _t as CrosshairHandler, yt as CrosshairTooltip, pn as CurrentPriceLine, xn as DEFAULT_LEGEND_CONFIG, C as DPRManager, Rn as DataExporter, Ut as DateRangeTool, V as DepthOverlay, je as DonchianChannelIndicator, L as DrawingBase, wt as DrawingManager, Tt as DrawingRenderer, F as EMAIndicator, Un as Easing, Vt as ElliottWaveTool, Lt as EllipseTool, H as Emitter, St as EventBus, At as ExtendedLineTool, Ft as FibExtensionTool, Nt as FibRetracementTool, qn as FinanceCrosshair, Xt as GannBoxTool, Yt as GannFanTool, ct as GridRenderer, de as HLCAreaRenderer, ae as HollowCandleRenderer, Dt as HorizontalLineTool, Le as HullMAIndicator, De as IchimokuIndicator, j as IndicatorBase, we as IndicatorEngine, st as IndicatorWorkerHost, mt as InteractionManager, ce as KagiRenderer, Ae as KeltnerChannelIndicator, vt as KeyboardHandler, x as LayerManager, ne as LineRenderer, pe as LineWithMarkersRenderer, Ie as LinearRegressionChannelIndicator, Ue as MACDIndicator, Xe as MFIIndicator, Wt as MeasureTool, bn as MockAdapter, qe as OBVIndicator, en as OrderRenderer, ht as PanHandler, Oe as ParabolicSARIndicator, jt as ParallelChannelTool, zt as PitchforkTool, Ne as PivotPointsIndicator, le as PointAndFigureRenderer, sn as PositionRenderer, lt as PriceAxis, Ht as PriceRangeTool, Qe as ROCIndicator, He as RSIIndicator, kt as RayTool, U as ReconnectManager, It as RectangleTool, Mt as RegressionChannelTool, k as RenderEngine, S as RenderLoop, se as RenkoRenderer, kn as ReplayManager, P as SMAIndicator, Cn as Screenshot, En as SessionBreaks, Bn as SignalMarkerManager, tt as StdDevIndicator, fe as StepLineRenderer, We as StochasticIndicator, mn as StreamManager, ke as SupertrendIndicator, $e as TSIIndicator, Kt as TextAnnotationTool, fn as TickAggregator, pt as TimeAxis, Hn as TradeZoneManager, ln as TradingContextMenu, cn as TradingDragHandler, un as TradingManager, dn as TradingRenderer, Et as TrendLineTool, Rt as TriangleTool, Ln as UndoRedoManager, it as VROCIndicator, Ee as VWAPIndicator, Ot as VerticalLineTool, A as Viewport, ue as VolumeCandleRenderer, nt as VolumeProfileIndicator, Qt as VolumeProfileRangeTool, me as VolumeRenderer, wn as Watermark, Je as WilliamsRIndicator, Fe as ZigZagIndicator, gt as ZoomHandler, w as barIndexToX, N as getIntParam, M as getNumberParam, ee as getVisibleData, ot as isWorkerResponse, Ar as layoutSquarifiedTreemap, Dr as layoutUniformGrid, T as priceToY, $t as registerBuiltInDrawingTools, at as registerBuiltInIndicators, cr as renderDepthChart, Er as renderEquityCurve, _i as renderGauge, Ir as renderHeatmap, Jn as renderSparkline, ni as renderWaterfall, O as timestampToBarIndex, ge as toHeikinAshi, be as toKagi, ye as toLineBreak, xe as toPointAndFigure, Se as toRangeBars, _e as toRenko, E as xToBarIndex, D as yToPrice };
|
|
6640
6870
|
|
|
6641
6871
|
//# sourceMappingURL=index.js.map
|