@tradecanvas/core 0.5.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 -92
- 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/charts/transforms/index.d.ts +2 -0
- package/dist/charts/transforms/index.d.ts.map +1 -1
- package/dist/charts/transforms/rangeBars.d.ts +18 -0
- package/dist/charts/transforms/rangeBars.d.ts.map +1 -0
- package/dist/drawings/tools/TextAnnotation.d.ts +5 -0
- package/dist/drawings/tools/TextAnnotation.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/ChartState.d.ts +6 -1
- package/dist/features/ChartState.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 +1504 -534
- package/dist/index.js.map +1 -1
- package/dist/indicators/index.d.ts +12 -0
- package/dist/indicators/index.d.ts.map +1 -1
- package/dist/indicators/overlay/AnchoredVWAP.d.ts +20 -0
- package/dist/indicators/overlay/AnchoredVWAP.d.ts.map +1 -0
- package/dist/indicators/overlay/BollingerBands.d.ts.map +1 -1
- package/dist/indicators/overlay/DonchianChannel.d.ts.map +1 -1
- package/dist/indicators/overlay/EMA.d.ts.map +1 -1
- package/dist/indicators/overlay/HullMA.d.ts +19 -0
- package/dist/indicators/overlay/HullMA.d.ts.map +1 -0
- package/dist/indicators/overlay/Ichimoku.d.ts.map +1 -1
- package/dist/indicators/overlay/KeltnerChannel.d.ts.map +1 -1
- package/dist/indicators/overlay/LinearRegressionChannel.d.ts +20 -0
- package/dist/indicators/overlay/LinearRegressionChannel.d.ts.map +1 -0
- package/dist/indicators/overlay/ParabolicSAR.d.ts.map +1 -1
- package/dist/indicators/overlay/PivotPoints.d.ts +15 -0
- package/dist/indicators/overlay/PivotPoints.d.ts.map +1 -0
- package/dist/indicators/overlay/SMA.d.ts.map +1 -1
- package/dist/indicators/overlay/Supertrend.d.ts.map +1 -1
- package/dist/indicators/overlay/ZigZag.d.ts +20 -0
- package/dist/indicators/overlay/ZigZag.d.ts.map +1 -0
- package/dist/indicators/panel/ADX.d.ts.map +1 -1
- package/dist/indicators/panel/ATR.d.ts.map +1 -1
- package/dist/indicators/panel/Aroon.d.ts.map +1 -1
- package/dist/indicators/panel/AwesomeOscillator.d.ts +16 -0
- package/dist/indicators/panel/AwesomeOscillator.d.ts.map +1 -0
- package/dist/indicators/panel/CCI.d.ts.map +1 -1
- package/dist/indicators/panel/CMF.d.ts.map +1 -1
- package/dist/indicators/panel/ChaikinOscillator.d.ts +21 -0
- package/dist/indicators/panel/ChaikinOscillator.d.ts.map +1 -0
- package/dist/indicators/panel/MACD.d.ts.map +1 -1
- package/dist/indicators/panel/MFI.d.ts.map +1 -1
- package/dist/indicators/panel/ROC.d.ts.map +1 -1
- package/dist/indicators/panel/RSI.d.ts.map +1 -1
- package/dist/indicators/panel/StdDev.d.ts.map +1 -1
- package/dist/indicators/panel/Stochastic.d.ts.map +1 -1
- package/dist/indicators/panel/TSI.d.ts.map +1 -1
- package/dist/indicators/panel/VROC.d.ts.map +1 -1
- package/dist/indicators/panel/VolumeProfile.d.ts.map +1 -1
- package/dist/indicators/panel/WilliamsR.d.ts.map +1 -1
- package/dist/indicators/params.d.ts +10 -0
- package/dist/indicators/params.d.ts.map +1 -0
- package/dist/indicators/registry.d.ts.map +1 -1
- package/dist/indicators/worker/IndicatorWorkerHost.d.ts +49 -0
- package/dist/indicators/worker/IndicatorWorkerHost.d.ts.map +1 -0
- package/dist/indicators/worker/indicator.worker.d.ts +2 -0
- package/dist/indicators/worker/indicator.worker.d.ts.map +1 -0
- package/dist/indicators/worker/messages.d.ts +27 -0
- package/dist/indicators/worker/messages.d.ts.map +1 -0
- package/dist/realtime/adapters/BinanceAdapter.d.ts.map +1 -1
- package/dist/realtime/adapters/binanceTypes.d.ts +58 -0
- package/dist/realtime/adapters/binanceTypes.d.ts.map +1 -0
- package/dist/trading/PositionRenderer.d.ts.map +1 -1
- package/dist/trading/positionFormat.d.ts +15 -0
- package/dist/trading/positionFormat.d.ts.map +1 -0
- package/package.json +8 -3
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,18 +299,18 @@ 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;
|
|
@@ -356,8 +356,8 @@ var D = class {
|
|
|
356
356
|
return {
|
|
357
357
|
x: 0,
|
|
358
358
|
y: 0,
|
|
359
|
-
width: Math.max(0, e -
|
|
360
|
-
height: Math.max(0, t -
|
|
359
|
+
width: Math.max(0, e - u),
|
|
360
|
+
height: Math.max(0, t - d)
|
|
361
361
|
};
|
|
362
362
|
}
|
|
363
363
|
resize(e, t) {
|
|
@@ -372,7 +372,7 @@ var D = class {
|
|
|
372
372
|
}, this.clampOffset(), this.updateVisibleRange();
|
|
373
373
|
}
|
|
374
374
|
updateData(e, t) {
|
|
375
|
-
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)));
|
|
376
376
|
}
|
|
377
377
|
setPriceRange(e, t) {
|
|
378
378
|
this.state.priceRange = {
|
|
@@ -392,7 +392,7 @@ var D = class {
|
|
|
392
392
|
this.state.offset = n - this.state.chartRect.width + t, this.updateVisibleRange();
|
|
393
393
|
}
|
|
394
394
|
zoom(e, t) {
|
|
395
|
-
let n = this.state.barWidth, r =
|
|
395
|
+
let n = this.state.barWidth, r = f(n * (1 + e), this.minBarWidth, this.maxBarWidth);
|
|
396
396
|
if (r === n) return;
|
|
397
397
|
let i = this.state.barWidth + this.state.barSpacing, a = (this.state.offset + t) / i;
|
|
398
398
|
this.state.barWidth = r;
|
|
@@ -402,7 +402,7 @@ var D = class {
|
|
|
402
402
|
clampOffset() {
|
|
403
403
|
if (this.state.chartRect.width <= 0) return;
|
|
404
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;
|
|
405
|
-
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);
|
|
406
406
|
}
|
|
407
407
|
updateVisibleRange() {
|
|
408
408
|
let e = this.state.barWidth + this.state.barSpacing;
|
|
@@ -416,12 +416,12 @@ var D = class {
|
|
|
416
416
|
};
|
|
417
417
|
//#endregion
|
|
418
418
|
//#region src/viewport/DataWindow.ts
|
|
419
|
-
function
|
|
420
|
-
return
|
|
419
|
+
function ee(e, t) {
|
|
420
|
+
return _(e, t.visibleRange.from, t.visibleRange.to);
|
|
421
421
|
}
|
|
422
422
|
//#endregion
|
|
423
423
|
//#region src/charts/CandlestickRenderer.ts
|
|
424
|
-
var
|
|
424
|
+
var te = class {
|
|
425
425
|
render(e, t, n, r) {
|
|
426
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;
|
|
427
427
|
if (f === 0) return;
|
|
@@ -434,7 +434,7 @@ var A = class {
|
|
|
434
434
|
}
|
|
435
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);
|
|
436
436
|
}
|
|
437
|
-
},
|
|
437
|
+
}, ne = class {
|
|
438
438
|
render(e, t, n, r) {
|
|
439
439
|
let { from: i, to: a } = n.visibleRange;
|
|
440
440
|
if (i > a || t.length === 0) return;
|
|
@@ -449,7 +449,7 @@ var A = class {
|
|
|
449
449
|
}
|
|
450
450
|
e.stroke();
|
|
451
451
|
}
|
|
452
|
-
},
|
|
452
|
+
}, re = class {
|
|
453
453
|
render(e, t, n, r) {
|
|
454
454
|
let { from: i, to: a } = n.visibleRange;
|
|
455
455
|
if (i > a || t.length === 0) return;
|
|
@@ -463,7 +463,7 @@ var A = class {
|
|
|
463
463
|
for (let n = i + 1; n <= a && n < t.length; n++) e.lineTo(n * o + s, d + (l - t[n].close) * p);
|
|
464
464
|
e.stroke();
|
|
465
465
|
}
|
|
466
|
-
},
|
|
466
|
+
}, ie = class {
|
|
467
467
|
render(e, t, n, r) {
|
|
468
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;
|
|
469
469
|
if (f === 0) return;
|
|
@@ -474,7 +474,7 @@ var A = class {
|
|
|
474
474
|
}
|
|
475
475
|
e.lineWidth = 1, e.strokeStyle = r.candleUp, e.stroke(_), e.strokeStyle = r.candleDown, e.stroke(v);
|
|
476
476
|
}
|
|
477
|
-
},
|
|
477
|
+
}, ae = class {
|
|
478
478
|
render(e, t, n, r) {
|
|
479
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;
|
|
480
480
|
if (f === 0) return;
|
|
@@ -493,7 +493,7 @@ var A = class {
|
|
|
493
493
|
e.strokeStyle = r.candleDown;
|
|
494
494
|
for (let t of b) e.strokeRect(t.x, t.y, t.w, t.h);
|
|
495
495
|
}
|
|
496
|
-
},
|
|
496
|
+
}, oe = class {
|
|
497
497
|
baselinePrice = null;
|
|
498
498
|
setBaseline(e) {
|
|
499
499
|
this.baselinePrice = e;
|
|
@@ -534,7 +534,7 @@ var A = class {
|
|
|
534
534
|
for (let a = t; a <= n && a < e.length; a++) r += e[a].close, i++;
|
|
535
535
|
return i > 0 ? r / i : 0;
|
|
536
536
|
}
|
|
537
|
-
},
|
|
537
|
+
}, se = class {
|
|
538
538
|
render(e, t, n, r) {
|
|
539
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;
|
|
540
540
|
if (f === 0) return;
|
|
@@ -545,7 +545,7 @@ var A = class {
|
|
|
545
545
|
}
|
|
546
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);
|
|
547
547
|
}
|
|
548
|
-
},
|
|
548
|
+
}, ce = class {
|
|
549
549
|
render(e, t, n, r) {
|
|
550
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;
|
|
551
551
|
if (f === 0) return;
|
|
@@ -559,7 +559,7 @@ var A = class {
|
|
|
559
559
|
}
|
|
560
560
|
e.strokeStyle = r.candleUp, e.lineWidth = 3, e.stroke(_), e.strokeStyle = r.candleDown, e.lineWidth = 1, e.stroke(v);
|
|
561
561
|
}
|
|
562
|
-
},
|
|
562
|
+
}, le = class {
|
|
563
563
|
boxSize = 1;
|
|
564
564
|
setBoxSize(e) {
|
|
565
565
|
this.boxSize = e;
|
|
@@ -577,7 +577,88 @@ var A = class {
|
|
|
577
577
|
}
|
|
578
578
|
e.lineWidth = 1.5, e.strokeStyle = r.candleUp, e.stroke(y), e.strokeStyle = r.candleDown, e.stroke(b);
|
|
579
579
|
}
|
|
580
|
-
},
|
|
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 {
|
|
581
662
|
visible = !0;
|
|
582
663
|
heightRatio = .2;
|
|
583
664
|
setVisible(e) {
|
|
@@ -598,7 +679,7 @@ var A = class {
|
|
|
598
679
|
}
|
|
599
680
|
e.globalAlpha = .35, e.fillStyle = r.candleUp, e.fill(h), e.fillStyle = r.candleDown, e.fill(g), e.globalAlpha = 1;
|
|
600
681
|
}
|
|
601
|
-
},
|
|
682
|
+
}, he = class {
|
|
602
683
|
symbols = /* @__PURE__ */ new Map();
|
|
603
684
|
mode = "percent";
|
|
604
685
|
setMode(e) {
|
|
@@ -639,21 +720,21 @@ var A = class {
|
|
|
639
720
|
e.strokeStyle = t.color, e.lineWidth = t.lineWidth ?? 1.5, e.lineJoin = "round", e.beginPath();
|
|
640
721
|
let u = !1, d = Math.min(n.length, t.data.length);
|
|
641
722
|
for (let n = s; n < d; n++) {
|
|
642
|
-
let i =
|
|
723
|
+
let i = w(n, r);
|
|
643
724
|
if (i < a.x - o) continue;
|
|
644
725
|
if (i > a.x + a.width + o) break;
|
|
645
726
|
let s;
|
|
646
|
-
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);
|
|
647
728
|
}
|
|
648
729
|
if (e.stroke(), u) {
|
|
649
|
-
let n = Math.min(s + 2, d - 1), i =
|
|
650
|
-
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);
|
|
651
732
|
}
|
|
652
733
|
}
|
|
653
734
|
};
|
|
654
735
|
//#endregion
|
|
655
736
|
//#region src/charts/transforms/heikinAshi.ts
|
|
656
|
-
function
|
|
737
|
+
function ge(e) {
|
|
657
738
|
if (e.length === 0) return [];
|
|
658
739
|
let t = [], n = e[0].open, r = (e[0].open + e[0].high + e[0].low + e[0].close) / 4;
|
|
659
740
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -671,10 +752,10 @@ function ue(e) {
|
|
|
671
752
|
}
|
|
672
753
|
//#endregion
|
|
673
754
|
//#region src/charts/transforms/renko.ts
|
|
674
|
-
function
|
|
755
|
+
function _e(e, t) {
|
|
675
756
|
if (e.length === 0) return [];
|
|
676
757
|
let n = t.brickSize;
|
|
677
|
-
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);
|
|
678
759
|
let r = [], i = Math.round(e[0].close / n) * n, a = e[0].time;
|
|
679
760
|
for (let t = 1; t < e.length; t++) {
|
|
680
761
|
let o = e[t].close - i, s = Math.floor(Math.abs(o) / n);
|
|
@@ -695,7 +776,7 @@ function de(e, t) {
|
|
|
695
776
|
}
|
|
696
777
|
return r;
|
|
697
778
|
}
|
|
698
|
-
function
|
|
779
|
+
function ve(e, t) {
|
|
699
780
|
let n = 0;
|
|
700
781
|
for (let r = 1; r <= Math.min(t, e.length - 1); r++) {
|
|
701
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));
|
|
@@ -705,7 +786,7 @@ function fe(e, t) {
|
|
|
705
786
|
}
|
|
706
787
|
//#endregion
|
|
707
788
|
//#region src/charts/transforms/lineBreak.ts
|
|
708
|
-
function
|
|
789
|
+
function ye(e, t = 3) {
|
|
709
790
|
if (e.length === 0) return [];
|
|
710
791
|
let n = [], r = 0;
|
|
711
792
|
n.push({
|
|
@@ -746,7 +827,7 @@ function pe(e, t = 3) {
|
|
|
746
827
|
}
|
|
747
828
|
//#endregion
|
|
748
829
|
//#region src/charts/transforms/kagi.ts
|
|
749
|
-
function
|
|
830
|
+
function be(e, t = 4) {
|
|
750
831
|
if (e.length < 2) return e.slice();
|
|
751
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;
|
|
752
833
|
for (let c = 1; c < e.length; c++) {
|
|
@@ -785,7 +866,7 @@ function me(e, t = 4) {
|
|
|
785
866
|
}
|
|
786
867
|
//#endregion
|
|
787
868
|
//#region src/charts/transforms/pointAndFigure.ts
|
|
788
|
-
function
|
|
869
|
+
function xe(e, t, n = 3) {
|
|
789
870
|
if (e.length === 0 || t <= 0) return [];
|
|
790
871
|
let r = [], i = 0, a = 0, o = 0, s = 0, c = Math.round(e[0].close / t) * t;
|
|
791
872
|
a = c, o = c, i = 1;
|
|
@@ -817,6 +898,37 @@ function he(e, t, n = 3) {
|
|
|
817
898
|
}), r;
|
|
818
899
|
}
|
|
819
900
|
//#endregion
|
|
901
|
+
//#region src/charts/transforms/rangeBars.ts
|
|
902
|
+
function Se(e, t) {
|
|
903
|
+
if (e.length === 0 || t.rangeSize <= 0) return [];
|
|
904
|
+
let n = [], r = e[0].time, i = e[0].open, a = i, o = i, s = 0, c = (e, c) => {
|
|
905
|
+
for (e > a && (a = e), e < o && (o = e), s += c; a - o >= t.rangeSize;) {
|
|
906
|
+
let c = e >= i, l = c ? i + t.rangeSize : i - t.rangeSize;
|
|
907
|
+
n.push({
|
|
908
|
+
time: r++,
|
|
909
|
+
open: i,
|
|
910
|
+
high: c ? l : i,
|
|
911
|
+
low: c ? i : l,
|
|
912
|
+
close: l,
|
|
913
|
+
volume: s
|
|
914
|
+
}), i = l, a = l, o = l, s = 0;
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
for (let t of e) {
|
|
918
|
+
let e = t.close >= t.open ? [
|
|
919
|
+
t.low,
|
|
920
|
+
t.high,
|
|
921
|
+
t.close
|
|
922
|
+
] : [
|
|
923
|
+
t.high,
|
|
924
|
+
t.low,
|
|
925
|
+
t.close
|
|
926
|
+
], n = t.volume / e.length;
|
|
927
|
+
for (let t of e) c(t, n);
|
|
928
|
+
}
|
|
929
|
+
return n;
|
|
930
|
+
}
|
|
931
|
+
//#endregion
|
|
820
932
|
//#region src/indicators/IndicatorBase.ts
|
|
821
933
|
var j = class {
|
|
822
934
|
drawLine(e, t, n, r) {
|
|
@@ -847,13 +959,13 @@ var j = class {
|
|
|
847
959
|
for (let s = a; s <= o && s < n.length; s++) {
|
|
848
960
|
let a = e.values.get(n[s].time);
|
|
849
961
|
a && a[t] !== void 0 && i.push({
|
|
850
|
-
x:
|
|
851
|
-
y:
|
|
962
|
+
x: w(s, r),
|
|
963
|
+
y: T(a[t], r)
|
|
852
964
|
});
|
|
853
965
|
}
|
|
854
966
|
return i;
|
|
855
967
|
}
|
|
856
|
-
},
|
|
968
|
+
}, Ce = 1, we = class {
|
|
857
969
|
registry = /* @__PURE__ */ new Map();
|
|
858
970
|
instances = /* @__PURE__ */ new Map();
|
|
859
971
|
register(e) {
|
|
@@ -865,7 +977,7 @@ var j = class {
|
|
|
865
977
|
addIndicator(e, t = {}, n) {
|
|
866
978
|
let r = this.registry.get(e);
|
|
867
979
|
if (!r) throw Error(`Unknown indicator: ${e}`);
|
|
868
|
-
let i = `tc_${e}_${
|
|
980
|
+
let i = `tc_${e}_${Ce++}`, a = {
|
|
869
981
|
id: e,
|
|
870
982
|
instanceId: i,
|
|
871
983
|
params: {
|
|
@@ -957,7 +1069,25 @@ var j = class {
|
|
|
957
1069
|
});
|
|
958
1070
|
return e;
|
|
959
1071
|
}
|
|
960
|
-
}
|
|
1072
|
+
};
|
|
1073
|
+
//#endregion
|
|
1074
|
+
//#region src/indicators/params.ts
|
|
1075
|
+
function M(e, t, n) {
|
|
1076
|
+
let r = e.params[t];
|
|
1077
|
+
if (typeof r == "number" && Number.isFinite(r)) return r;
|
|
1078
|
+
if (typeof r == "string") {
|
|
1079
|
+
let e = Number(r);
|
|
1080
|
+
if (Number.isFinite(e)) return e;
|
|
1081
|
+
}
|
|
1082
|
+
return n;
|
|
1083
|
+
}
|
|
1084
|
+
function N(e, t, n, r = 1) {
|
|
1085
|
+
let i = M(e, t, n);
|
|
1086
|
+
return Math.max(r, Math.floor(i));
|
|
1087
|
+
}
|
|
1088
|
+
//#endregion
|
|
1089
|
+
//#region src/indicators/overlay/SMA.ts
|
|
1090
|
+
var P = class extends j {
|
|
961
1091
|
descriptor = {
|
|
962
1092
|
id: "sma",
|
|
963
1093
|
name: "Simple Moving Average",
|
|
@@ -965,7 +1095,7 @@ var j = class {
|
|
|
965
1095
|
defaultConfig: { period: 20 }
|
|
966
1096
|
};
|
|
967
1097
|
calculate(e, t) {
|
|
968
|
-
let n = t
|
|
1098
|
+
let n = N(t, "period", 20, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null), a = 0;
|
|
969
1099
|
for (let t = 0; t < e.length; t++) if (a += e[t].close, t >= n && (a -= e[t - n].close), t >= n - 1) {
|
|
970
1100
|
let o = { value: a / n };
|
|
971
1101
|
r.set(e[t].time, o), i[t] = o;
|
|
@@ -984,12 +1114,12 @@ var j = class {
|
|
|
984
1114
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
985
1115
|
let r = i[t];
|
|
986
1116
|
if (!r || r.value === void 0) continue;
|
|
987
|
-
let a =
|
|
1117
|
+
let a = w(t, n), o = T(r.value, n);
|
|
988
1118
|
s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
|
|
989
1119
|
}
|
|
990
1120
|
e.stroke();
|
|
991
1121
|
}
|
|
992
|
-
},
|
|
1122
|
+
}, F = class extends j {
|
|
993
1123
|
descriptor = {
|
|
994
1124
|
id: "ema",
|
|
995
1125
|
name: "Exponential Moving Average",
|
|
@@ -997,7 +1127,7 @@ var j = class {
|
|
|
997
1127
|
defaultConfig: { period: 20 }
|
|
998
1128
|
};
|
|
999
1129
|
calculate(e, t) {
|
|
1000
|
-
let n = t
|
|
1130
|
+
let n = N(t, "period", 20, 1), r = 2 / (n + 1), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null), o = 0;
|
|
1001
1131
|
for (let t = 0; t < e.length; t++) {
|
|
1002
1132
|
if (t < n - 1) {
|
|
1003
1133
|
o += e[t].close;
|
|
@@ -1021,12 +1151,12 @@ var j = class {
|
|
|
1021
1151
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
1022
1152
|
let r = i[t];
|
|
1023
1153
|
if (!r || r.value === void 0) continue;
|
|
1024
|
-
let a =
|
|
1154
|
+
let a = w(t, n), o = T(r.value, n);
|
|
1025
1155
|
s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
|
|
1026
1156
|
}
|
|
1027
1157
|
e.stroke();
|
|
1028
1158
|
}
|
|
1029
|
-
},
|
|
1159
|
+
}, Te = class extends j {
|
|
1030
1160
|
descriptor = {
|
|
1031
1161
|
id: "bb",
|
|
1032
1162
|
name: "Bollinger Bands",
|
|
@@ -1037,7 +1167,7 @@ var j = class {
|
|
|
1037
1167
|
}
|
|
1038
1168
|
};
|
|
1039
1169
|
calculate(e, t) {
|
|
1040
|
-
let n = t
|
|
1170
|
+
let n = N(t, "period", 20, 1), r = M(t, "stdDev", 2), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null), o = 0, s = 0;
|
|
1041
1171
|
for (let t = 0; t < e.length; t++) {
|
|
1042
1172
|
let c = e[t].close;
|
|
1043
1173
|
if (o += c, s += c * c, t >= n) {
|
|
@@ -1065,14 +1195,14 @@ var j = class {
|
|
|
1065
1195
|
for (let e = a; e <= o && e < i.length; e++) {
|
|
1066
1196
|
let t = i[e];
|
|
1067
1197
|
if (!t || t.upper === void 0) continue;
|
|
1068
|
-
let r =
|
|
1069
|
-
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++;
|
|
1070
1200
|
}
|
|
1071
1201
|
if (!(s < 2)) {
|
|
1072
1202
|
e.beginPath(), e.moveTo(l[0], u[0]);
|
|
1073
1203
|
for (let t = 1; t < s; t++) e.lineTo(l[t], u[t]);
|
|
1074
1204
|
for (let t = s - 1; t >= 0; t--) e.lineTo(p[t], m[t]);
|
|
1075
|
-
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]);
|
|
1076
1206
|
for (let t = 1; t < s; t++) e.lineTo(l[t], u[t]);
|
|
1077
1207
|
e.stroke(), e.beginPath(), e.strokeStyle = r.colors[1] ?? r.colors[0], e.moveTo(d[0], f[0]);
|
|
1078
1208
|
for (let t = 1; t < s; t++) e.lineTo(d[t], f[t]);
|
|
@@ -1081,7 +1211,7 @@ var j = class {
|
|
|
1081
1211
|
e.stroke();
|
|
1082
1212
|
}
|
|
1083
1213
|
}
|
|
1084
|
-
},
|
|
1214
|
+
}, Ee = class extends j {
|
|
1085
1215
|
descriptor = {
|
|
1086
1216
|
id: "vwap",
|
|
1087
1217
|
name: "Volume Weighted Average Price",
|
|
@@ -1111,12 +1241,12 @@ var j = class {
|
|
|
1111
1241
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
1112
1242
|
let r = i[t];
|
|
1113
1243
|
if (!r || r.value === void 0) continue;
|
|
1114
|
-
let a =
|
|
1244
|
+
let a = w(t, n), o = T(r.value, n);
|
|
1115
1245
|
s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
|
|
1116
1246
|
}
|
|
1117
1247
|
e.stroke();
|
|
1118
1248
|
}
|
|
1119
|
-
},
|
|
1249
|
+
}, De = class extends j {
|
|
1120
1250
|
descriptor = {
|
|
1121
1251
|
id: "ichimoku",
|
|
1122
1252
|
name: "Ichimoku Cloud",
|
|
@@ -1129,7 +1259,7 @@ var j = class {
|
|
|
1129
1259
|
}
|
|
1130
1260
|
};
|
|
1131
1261
|
calculate(e, t) {
|
|
1132
|
-
let n = t
|
|
1262
|
+
let n = N(t, "tenkan", 9, 1), r = N(t, "kijun", 26, 1), i = N(t, "senkou", 52, 1), a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null), s = (t) => {
|
|
1133
1263
|
let n = new Float64Array(e.length), r = new Float64Array(e.length);
|
|
1134
1264
|
for (let i = 0; i < e.length; i++) {
|
|
1135
1265
|
let a = -Infinity, o = Infinity, s = Math.max(0, i - t + 1);
|
|
@@ -1153,19 +1283,19 @@ var j = class {
|
|
|
1153
1283
|
render(e, t, n, r) {
|
|
1154
1284
|
let i = t.series;
|
|
1155
1285
|
if (!i) return;
|
|
1156
|
-
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;
|
|
1157
1287
|
for (let e = a; e <= o && e < i.length; e++) {
|
|
1158
1288
|
let t = i[e];
|
|
1159
1289
|
if (!t) continue;
|
|
1160
|
-
let r =
|
|
1161
|
-
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++);
|
|
1162
1292
|
}
|
|
1163
1293
|
if (g > 1 && b > 1) {
|
|
1164
1294
|
let t = Math.min(g, b);
|
|
1165
1295
|
e.beginPath(), e.moveTo(m[0], h[0]);
|
|
1166
1296
|
for (let n = 1; n < t; n++) e.lineTo(m[n], h[n]);
|
|
1167
|
-
for (let n = t - 1; n >= 0; n--) e.lineTo(
|
|
1168
|
-
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();
|
|
1169
1299
|
}
|
|
1170
1300
|
let x = (t, n, r, i, a) => {
|
|
1171
1301
|
if (!(r < 2)) {
|
|
@@ -1174,9 +1304,9 @@ var j = class {
|
|
|
1174
1304
|
e.stroke();
|
|
1175
1305
|
}
|
|
1176
1306
|
};
|
|
1177
|
-
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);
|
|
1178
1308
|
}
|
|
1179
|
-
},
|
|
1309
|
+
}, Oe = class extends j {
|
|
1180
1310
|
descriptor = {
|
|
1181
1311
|
id: "psar",
|
|
1182
1312
|
name: "Parabolic SAR",
|
|
@@ -1187,7 +1317,7 @@ var j = class {
|
|
|
1187
1317
|
}
|
|
1188
1318
|
};
|
|
1189
1319
|
calculate(e, t) {
|
|
1190
|
-
let n = t
|
|
1320
|
+
let n = M(t, "step", .02), r = M(t, "max", .2), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
|
|
1191
1321
|
if (e.length < 2) return {
|
|
1192
1322
|
values: i,
|
|
1193
1323
|
series: a
|
|
@@ -1218,11 +1348,11 @@ var j = class {
|
|
|
1218
1348
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
1219
1349
|
let a = i[t];
|
|
1220
1350
|
if (!a || a.value === void 0) continue;
|
|
1221
|
-
let o =
|
|
1351
|
+
let o = w(t, n), c = T(a.value, n);
|
|
1222
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();
|
|
1223
1353
|
}
|
|
1224
1354
|
}
|
|
1225
|
-
},
|
|
1355
|
+
}, ke = class extends j {
|
|
1226
1356
|
descriptor = {
|
|
1227
1357
|
id: "supertrend",
|
|
1228
1358
|
name: "Supertrend",
|
|
@@ -1233,7 +1363,7 @@ var j = class {
|
|
|
1233
1363
|
}
|
|
1234
1364
|
};
|
|
1235
1365
|
calculate(e, t) {
|
|
1236
|
-
let n = t
|
|
1366
|
+
let n = N(t, "period", 10, 1), r = M(t, "multiplier", 3), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
|
|
1237
1367
|
if (e.length < n) return {
|
|
1238
1368
|
values: i,
|
|
1239
1369
|
series: a
|
|
@@ -1266,11 +1396,11 @@ var j = class {
|
|
|
1266
1396
|
for (let t = a; t <= o && t < i.length; t++) {
|
|
1267
1397
|
let a = i[t];
|
|
1268
1398
|
if (!a || a.value === void 0) continue;
|
|
1269
|
-
let o =
|
|
1399
|
+
let o = w(t, n), f = T(a.value, n), p = a.trend ?? 1;
|
|
1270
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;
|
|
1271
1401
|
}
|
|
1272
1402
|
}
|
|
1273
|
-
},
|
|
1403
|
+
}, Ae = class extends j {
|
|
1274
1404
|
descriptor = {
|
|
1275
1405
|
id: "keltner",
|
|
1276
1406
|
name: "Keltner Channel",
|
|
@@ -1282,7 +1412,7 @@ var j = class {
|
|
|
1282
1412
|
}
|
|
1283
1413
|
};
|
|
1284
1414
|
calculate(e, t) {
|
|
1285
|
-
let n = t
|
|
1415
|
+
let n = N(t, "emaPeriod", 20, 1), r = N(t, "atrPeriod", 10, 1), i = M(t, "multiplier", 1.5), a = /* @__PURE__ */ new Map();
|
|
1286
1416
|
if (e.length < Math.max(n, r)) return { values: a };
|
|
1287
1417
|
let o = 2 / (n + 1), s = e[0].close, c = [s];
|
|
1288
1418
|
for (let t = 1; t < e.length; t++) s = (e[t].close - s) * o + s, c.push(s);
|
|
@@ -1313,21 +1443,21 @@ var j = class {
|
|
|
1313
1443
|
for (let e = a; e <= o && e < i.length; e++) {
|
|
1314
1444
|
let t = i[e];
|
|
1315
1445
|
if (!t) continue;
|
|
1316
|
-
let r =
|
|
1446
|
+
let r = w(e, n);
|
|
1317
1447
|
t.upper !== void 0 && s.push({
|
|
1318
1448
|
x: r,
|
|
1319
|
-
y:
|
|
1449
|
+
y: T(t.upper, n)
|
|
1320
1450
|
}), t.middle !== void 0 && c.push({
|
|
1321
1451
|
x: r,
|
|
1322
|
-
y:
|
|
1452
|
+
y: T(t.middle, n)
|
|
1323
1453
|
}), t.lower !== void 0 && l.push({
|
|
1324
1454
|
x: r,
|
|
1325
|
-
y:
|
|
1455
|
+
y: T(t.lower, n)
|
|
1326
1456
|
});
|
|
1327
1457
|
}
|
|
1328
|
-
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]);
|
|
1329
1459
|
}
|
|
1330
|
-
},
|
|
1460
|
+
}, je = class extends j {
|
|
1331
1461
|
descriptor = {
|
|
1332
1462
|
id: "donchian",
|
|
1333
1463
|
name: "Donchian Channel",
|
|
@@ -1335,7 +1465,7 @@ var j = class {
|
|
|
1335
1465
|
defaultConfig: { period: 20 }
|
|
1336
1466
|
};
|
|
1337
1467
|
calculate(e, t) {
|
|
1338
|
-
let n = t
|
|
1468
|
+
let n = N(t, "period", 20, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1339
1469
|
for (let t = n - 1; t < e.length; t++) {
|
|
1340
1470
|
let a = -Infinity, o = Infinity;
|
|
1341
1471
|
for (let r = t - n + 1; r <= t; r++) e[r].high > a && (a = e[r].high), e[r].low < o && (o = e[r].low);
|
|
@@ -1358,21 +1488,410 @@ var j = class {
|
|
|
1358
1488
|
for (let e = a; e <= o && e < i.length; e++) {
|
|
1359
1489
|
let t = i[e];
|
|
1360
1490
|
if (!t) continue;
|
|
1361
|
-
let r =
|
|
1491
|
+
let r = w(e, n);
|
|
1362
1492
|
t.upper !== void 0 && s.push({
|
|
1363
1493
|
x: r,
|
|
1364
|
-
y:
|
|
1494
|
+
y: T(t.upper, n)
|
|
1365
1495
|
}), t.middle !== void 0 && c.push({
|
|
1366
1496
|
x: r,
|
|
1367
|
-
y:
|
|
1497
|
+
y: T(t.middle, n)
|
|
1368
1498
|
}), t.lower !== void 0 && l.push({
|
|
1369
1499
|
x: r,
|
|
1370
|
-
y:
|
|
1500
|
+
y: T(t.lower, n)
|
|
1371
1501
|
});
|
|
1372
1502
|
}
|
|
1373
|
-
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]);
|
|
1504
|
+
}
|
|
1505
|
+
}, Me = [
|
|
1506
|
+
"s3",
|
|
1507
|
+
"s2",
|
|
1508
|
+
"s1",
|
|
1509
|
+
"pp",
|
|
1510
|
+
"r1",
|
|
1511
|
+
"r2",
|
|
1512
|
+
"r3"
|
|
1513
|
+
], Ne = class extends j {
|
|
1514
|
+
descriptor = {
|
|
1515
|
+
id: "pivots",
|
|
1516
|
+
name: "Pivot Points (Classic)",
|
|
1517
|
+
placement: "overlay",
|
|
1518
|
+
defaultConfig: { lookback: 24 }
|
|
1519
|
+
};
|
|
1520
|
+
calculate(e, t) {
|
|
1521
|
+
let n = N(t, "lookback", 24, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1522
|
+
if (e.length <= n) return {
|
|
1523
|
+
values: r,
|
|
1524
|
+
series: i
|
|
1525
|
+
};
|
|
1526
|
+
for (let t = n; t < e.length; t++) {
|
|
1527
|
+
let a = -Infinity, o = Infinity;
|
|
1528
|
+
for (let r = t - n; r < t; r++) e[r].high > a && (a = e[r].high), e[r].low < o && (o = e[r].low);
|
|
1529
|
+
let s = e[t - 1].close, c = (a + o + s) / 3, l = a - o, u = {
|
|
1530
|
+
pp: c,
|
|
1531
|
+
r1: 2 * c - o,
|
|
1532
|
+
s1: 2 * c - a,
|
|
1533
|
+
r2: c + l,
|
|
1534
|
+
s2: c - l,
|
|
1535
|
+
r3: a + 2 * (c - o),
|
|
1536
|
+
s3: o - 2 * (a - c)
|
|
1537
|
+
};
|
|
1538
|
+
r.set(e[t].time, u), i[t] = u;
|
|
1539
|
+
}
|
|
1540
|
+
return {
|
|
1541
|
+
values: r,
|
|
1542
|
+
series: i
|
|
1543
|
+
};
|
|
1374
1544
|
}
|
|
1375
|
-
|
|
1545
|
+
render(e, t, n, r) {
|
|
1546
|
+
let i = t.series;
|
|
1547
|
+
if (!i) return;
|
|
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;
|
|
1549
|
+
for (let t of Me) {
|
|
1550
|
+
e.beginPath(), e.strokeStyle = d(t), e.lineWidth = t === "pp" ? u : Math.max(1, u - 1), t !== "pp" && e.setLineDash([4, 3]);
|
|
1551
|
+
let r = !1;
|
|
1552
|
+
for (let s = a; s <= o && s < i.length; s++) {
|
|
1553
|
+
let a = i[s]?.[t];
|
|
1554
|
+
if (a === void 0) continue;
|
|
1555
|
+
let o = w(s, n), c = T(a, n);
|
|
1556
|
+
r ? e.lineTo(o, c) : (e.moveTo(o, c), r = !0);
|
|
1557
|
+
}
|
|
1558
|
+
e.stroke(), e.setLineDash([]);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
}, Pe = class extends j {
|
|
1562
|
+
descriptor = {
|
|
1563
|
+
id: "avwap",
|
|
1564
|
+
name: "Anchored VWAP",
|
|
1565
|
+
placement: "overlay",
|
|
1566
|
+
defaultConfig: { anchorTime: 0 }
|
|
1567
|
+
};
|
|
1568
|
+
calculate(e, t) {
|
|
1569
|
+
let n = M(t, "anchorTime", 0), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null), a = 0;
|
|
1570
|
+
if (n > 0 && (a = e.findIndex((e) => e.time >= n), a < 0)) return {
|
|
1571
|
+
values: r,
|
|
1572
|
+
series: i
|
|
1573
|
+
};
|
|
1574
|
+
let o = 0, s = 0;
|
|
1575
|
+
for (let t = a; t < e.length; t++) {
|
|
1576
|
+
let n = (e[t].high + e[t].low + e[t].close) / 3;
|
|
1577
|
+
if (o += e[t].volume, s += n * e[t].volume, o > 0) {
|
|
1578
|
+
let n = { value: s / o };
|
|
1579
|
+
r.set(e[t].time, n), i[t] = n;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
return {
|
|
1583
|
+
values: r,
|
|
1584
|
+
series: i
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
render(e, t, n, r) {
|
|
1588
|
+
let i = t.series;
|
|
1589
|
+
if (!i) return;
|
|
1590
|
+
let { from: a, to: o } = n.visibleRange;
|
|
1591
|
+
e.beginPath(), e.strokeStyle = r.colors[0], e.lineWidth = r.lineWidths[0], e.lineJoin = "round";
|
|
1592
|
+
let s = !1;
|
|
1593
|
+
for (let t = a; t <= o && t < i.length; t++) {
|
|
1594
|
+
let r = i[t];
|
|
1595
|
+
if (!r || r.value === void 0) continue;
|
|
1596
|
+
let a = w(t, n), o = T(r.value, n);
|
|
1597
|
+
s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
|
|
1598
|
+
}
|
|
1599
|
+
e.stroke();
|
|
1600
|
+
}
|
|
1601
|
+
}, Fe = class extends j {
|
|
1602
|
+
descriptor = {
|
|
1603
|
+
id: "zigzag",
|
|
1604
|
+
name: "ZigZag",
|
|
1605
|
+
placement: "overlay",
|
|
1606
|
+
defaultConfig: { deviation: 5 }
|
|
1607
|
+
};
|
|
1608
|
+
calculate(e, t) {
|
|
1609
|
+
let n = Math.max(.01, M(t, "deviation", 5)) / 100, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1610
|
+
if (e.length < 2) return {
|
|
1611
|
+
values: r,
|
|
1612
|
+
series: i,
|
|
1613
|
+
meta: { pivots: [] }
|
|
1614
|
+
};
|
|
1615
|
+
let a = [], o = null, s = 0, c = e[0].close;
|
|
1616
|
+
for (let t = 1; t < e.length; t++) {
|
|
1617
|
+
let r = e[t].high, i = e[t].low;
|
|
1618
|
+
if (o === null) {
|
|
1619
|
+
r >= c * (1 + n) ? (a.push({
|
|
1620
|
+
idx: s,
|
|
1621
|
+
price: c,
|
|
1622
|
+
type: "low"
|
|
1623
|
+
}), o = "up", s = t, c = r) : i <= c * (1 - n) && (a.push({
|
|
1624
|
+
idx: s,
|
|
1625
|
+
price: c,
|
|
1626
|
+
type: "high"
|
|
1627
|
+
}), o = "down", s = t, c = i);
|
|
1628
|
+
continue;
|
|
1629
|
+
}
|
|
1630
|
+
o === "up" ? r > c ? (s = t, c = r) : i <= c * (1 - n) && (a.push({
|
|
1631
|
+
idx: s,
|
|
1632
|
+
price: c,
|
|
1633
|
+
type: "high"
|
|
1634
|
+
}), o = "down", s = t, c = i) : i < c ? (s = t, c = i) : r >= c * (1 + n) && (a.push({
|
|
1635
|
+
idx: s,
|
|
1636
|
+
price: c,
|
|
1637
|
+
type: "low"
|
|
1638
|
+
}), o = "up", s = t, c = r);
|
|
1639
|
+
}
|
|
1640
|
+
a.push({
|
|
1641
|
+
idx: s,
|
|
1642
|
+
price: c,
|
|
1643
|
+
type: o === "up" ? "high" : "low"
|
|
1644
|
+
});
|
|
1645
|
+
for (let t of a) {
|
|
1646
|
+
let n = { pivot: t.price };
|
|
1647
|
+
r.set(e[t.idx].time, n), i[t.idx] = n;
|
|
1648
|
+
}
|
|
1649
|
+
return {
|
|
1650
|
+
values: r,
|
|
1651
|
+
series: i,
|
|
1652
|
+
meta: { pivots: a }
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
render(e, t, n, r) {
|
|
1656
|
+
let i = t.meta?.pivots;
|
|
1657
|
+
if (!(!i || i.length < 2)) {
|
|
1658
|
+
e.beginPath(), e.strokeStyle = r.colors[0], e.lineWidth = r.lineWidths[0], e.lineJoin = "round";
|
|
1659
|
+
for (let t = 0; t < i.length; t++) {
|
|
1660
|
+
let r = i[t], a = w(r.idx, n), o = T(r.price, n);
|
|
1661
|
+
t === 0 ? e.moveTo(a, o) : e.lineTo(a, o);
|
|
1662
|
+
}
|
|
1663
|
+
e.stroke();
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
}, Ie = class extends j {
|
|
1667
|
+
descriptor = {
|
|
1668
|
+
id: "lrc",
|
|
1669
|
+
name: "Linear Regression Channel",
|
|
1670
|
+
placement: "overlay",
|
|
1671
|
+
defaultConfig: {
|
|
1672
|
+
period: 100,
|
|
1673
|
+
stdDev: 2
|
|
1674
|
+
}
|
|
1675
|
+
};
|
|
1676
|
+
calculate(e, t) {
|
|
1677
|
+
let n = N(t, "period", 100, 2), r = M(t, "stdDev", 2), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
|
|
1678
|
+
if (e.length < n) return {
|
|
1679
|
+
values: i,
|
|
1680
|
+
series: a
|
|
1681
|
+
};
|
|
1682
|
+
for (let t = n - 1; t < e.length; t++) {
|
|
1683
|
+
let o = t - n + 1, s = 0, c = 0, l = 0, u = 0;
|
|
1684
|
+
for (let t = 0; t < n; t++) {
|
|
1685
|
+
let n = t, r = e[o + t].close;
|
|
1686
|
+
s += n, c += r, l += n * r, u += n * n;
|
|
1687
|
+
}
|
|
1688
|
+
let d = n * u - s * s;
|
|
1689
|
+
if (d === 0) continue;
|
|
1690
|
+
let f = (n * l - s * c) / d, p = (c - f * s) / n, m = 0;
|
|
1691
|
+
for (let t = 0; t < n; t++) {
|
|
1692
|
+
let n = f * t + p, r = e[o + t].close - n;
|
|
1693
|
+
m += r * r;
|
|
1694
|
+
}
|
|
1695
|
+
let h = Math.sqrt(m / n), g = f * (n - 1) + p, _ = {
|
|
1696
|
+
middle: g,
|
|
1697
|
+
upper: g + r * h,
|
|
1698
|
+
lower: g - r * h,
|
|
1699
|
+
slope: f
|
|
1700
|
+
};
|
|
1701
|
+
i.set(e[t].time, _), a[t] = _;
|
|
1702
|
+
}
|
|
1703
|
+
return {
|
|
1704
|
+
values: i,
|
|
1705
|
+
series: a
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
render(e, t, n, r) {
|
|
1709
|
+
let i = t.series;
|
|
1710
|
+
if (!i) return;
|
|
1711
|
+
let { from: a, to: o } = n.visibleRange, s = [], c = [], l = [];
|
|
1712
|
+
for (let e = a; e <= o && e < i.length; e++) {
|
|
1713
|
+
let t = i[e];
|
|
1714
|
+
if (!t) continue;
|
|
1715
|
+
let r = w(e, n);
|
|
1716
|
+
t.middle !== void 0 && c.push({
|
|
1717
|
+
x: r,
|
|
1718
|
+
y: T(t.middle, n)
|
|
1719
|
+
}), t.upper !== void 0 && s.push({
|
|
1720
|
+
x: r,
|
|
1721
|
+
y: T(t.upper, n)
|
|
1722
|
+
}), t.lower !== void 0 && l.push({
|
|
1723
|
+
x: r,
|
|
1724
|
+
y: T(t.lower, n)
|
|
1725
|
+
});
|
|
1726
|
+
}
|
|
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]);
|
|
1728
|
+
}
|
|
1729
|
+
}, Le = class extends j {
|
|
1730
|
+
descriptor = {
|
|
1731
|
+
id: "hma",
|
|
1732
|
+
name: "Hull Moving Average",
|
|
1733
|
+
placement: "overlay",
|
|
1734
|
+
defaultConfig: { period: 21 }
|
|
1735
|
+
};
|
|
1736
|
+
calculate(e, t) {
|
|
1737
|
+
let n = N(t, "period", 21, 2), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1738
|
+
if (e.length < n) return {
|
|
1739
|
+
values: r,
|
|
1740
|
+
series: i
|
|
1741
|
+
};
|
|
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);
|
|
1743
|
+
for (let t = 0; t < e.length; t++) {
|
|
1744
|
+
if (u[t] === null) continue;
|
|
1745
|
+
let n = { value: u[t] };
|
|
1746
|
+
r.set(e[t].time, n), i[t] = n;
|
|
1747
|
+
}
|
|
1748
|
+
return {
|
|
1749
|
+
values: r,
|
|
1750
|
+
series: i
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
render(e, t, n, r) {
|
|
1754
|
+
let i = t.series;
|
|
1755
|
+
if (!i) return;
|
|
1756
|
+
let { from: a, to: o } = n.visibleRange;
|
|
1757
|
+
e.beginPath(), e.strokeStyle = r.colors[0], e.lineWidth = r.lineWidths[0], e.lineJoin = "round";
|
|
1758
|
+
let s = !1;
|
|
1759
|
+
for (let t = a; t <= o && t < i.length; t++) {
|
|
1760
|
+
let r = i[t];
|
|
1761
|
+
if (!r || r.value === void 0) continue;
|
|
1762
|
+
let a = w(t, n), o = T(r.value, n);
|
|
1763
|
+
s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
|
|
1764
|
+
}
|
|
1765
|
+
e.stroke();
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
function Re(e, t) {
|
|
1769
|
+
let n = Array(e.length).fill(null);
|
|
1770
|
+
if (e.length < t) return n;
|
|
1771
|
+
let r = t * (t + 1) / 2;
|
|
1772
|
+
for (let i = t - 1; i < e.length; i++) {
|
|
1773
|
+
let a = 0;
|
|
1774
|
+
for (let n = 0; n < t; n++) a += e[i - n] * (t - n);
|
|
1775
|
+
n[i] = a / r;
|
|
1776
|
+
}
|
|
1777
|
+
return n;
|
|
1778
|
+
}
|
|
1779
|
+
function ze(e, t) {
|
|
1780
|
+
let n = Array(e.length).fill(null), r = t * (t + 1) / 2;
|
|
1781
|
+
for (let i = t - 1; i < e.length; i++) {
|
|
1782
|
+
let a = 0, o = !0;
|
|
1783
|
+
for (let n = 0; n < t; n++) {
|
|
1784
|
+
let r = e[i - n];
|
|
1785
|
+
if (r === null) {
|
|
1786
|
+
o = !1;
|
|
1787
|
+
break;
|
|
1788
|
+
}
|
|
1789
|
+
a += r * (t - n);
|
|
1790
|
+
}
|
|
1791
|
+
o && (n[i] = a / r);
|
|
1792
|
+
}
|
|
1793
|
+
return n;
|
|
1794
|
+
}
|
|
1795
|
+
//#endregion
|
|
1796
|
+
//#region src/indicators/panel/AwesomeOscillator.ts
|
|
1797
|
+
var Be = class extends j {
|
|
1798
|
+
descriptor = {
|
|
1799
|
+
id: "ao",
|
|
1800
|
+
name: "Awesome Oscillator",
|
|
1801
|
+
placement: "panel",
|
|
1802
|
+
defaultConfig: {
|
|
1803
|
+
fast: 5,
|
|
1804
|
+
slow: 34
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
calculate(e, t) {
|
|
1808
|
+
let n = N(t, "fast", 5, 1), r = N(t, "slow", 34, 1), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
|
|
1809
|
+
if (e.length < r) return {
|
|
1810
|
+
values: i,
|
|
1811
|
+
series: a
|
|
1812
|
+
};
|
|
1813
|
+
let o = Array(e.length);
|
|
1814
|
+
for (let t = 0; t < e.length; t++) o[t] = (e[t].high + e[t].low) / 2;
|
|
1815
|
+
let s = 0, c = 0, l;
|
|
1816
|
+
for (let t = 0; t < e.length; t++) if (c += o[t], t >= r && (c -= o[t - r]), s += o[t], t >= n && (s -= o[t - n]), t >= r - 1) {
|
|
1817
|
+
let o = s / n - c / r, u = {
|
|
1818
|
+
value: o,
|
|
1819
|
+
up: +(l === void 0 || o >= l)
|
|
1820
|
+
};
|
|
1821
|
+
i.set(e[t].time, u), a[t] = u, l = o;
|
|
1822
|
+
}
|
|
1823
|
+
return {
|
|
1824
|
+
values: i,
|
|
1825
|
+
series: a
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
render(e, t, n, r) {
|
|
1829
|
+
let i = t.series;
|
|
1830
|
+
if (!i) return;
|
|
1831
|
+
let { chartRect: a } = n, { from: o, to: s } = n.visibleRange, c = Infinity, l = -Infinity;
|
|
1832
|
+
for (let e = o; e <= s && e < i.length; e++) {
|
|
1833
|
+
let t = i[e]?.value;
|
|
1834
|
+
t !== void 0 && (t < c && (c = t), t > l && (l = t));
|
|
1835
|
+
}
|
|
1836
|
+
if (c === Infinity) return;
|
|
1837
|
+
let u = Math.max(Math.abs(c), Math.abs(l)) || 1, d = (e) => a.y + a.height * (1 - (e + u) / (2 * u)), f = d(0), p = n.barWidth / 2, m = r.colors[0] ?? "#26A69A", h = r.colors[1] ?? "#EF5350";
|
|
1838
|
+
for (let t = o; t <= s && t < i.length; t++) {
|
|
1839
|
+
let r = i[t];
|
|
1840
|
+
if (!r || r.value === void 0) continue;
|
|
1841
|
+
let a = w(t, n), o = d(r.value), s = Math.min(o, f), c = Math.max(Math.abs(o - f), 1);
|
|
1842
|
+
e.fillStyle = r.up ? m : h, e.fillRect(a - p, s, n.barWidth, c);
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
}, Ve = class extends j {
|
|
1846
|
+
descriptor = {
|
|
1847
|
+
id: "chaikinOsc",
|
|
1848
|
+
name: "Chaikin Oscillator",
|
|
1849
|
+
placement: "panel",
|
|
1850
|
+
defaultConfig: {
|
|
1851
|
+
fast: 3,
|
|
1852
|
+
slow: 10
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1855
|
+
calculate(e, t) {
|
|
1856
|
+
let n = N(t, "fast", 3, 1), r = N(t, "slow", 10, 1), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
|
|
1857
|
+
if (e.length < r) return {
|
|
1858
|
+
values: i,
|
|
1859
|
+
series: a
|
|
1860
|
+
};
|
|
1861
|
+
let o = 2 / (n + 1), s = 2 / (r + 1), c = 0, l = 0, u = 0;
|
|
1862
|
+
for (let t = 0; t < e.length; t++) {
|
|
1863
|
+
let { high: n, low: d, close: f, volume: p } = e[t], m = n - d, h = m === 0 ? 0 : (f - d - (n - f)) / m;
|
|
1864
|
+
if (c += h * p, t === 0 ? (l = c, u = c) : (l = (c - l) * o + l, u = (c - u) * s + u), t >= r - 1) {
|
|
1865
|
+
let n = {
|
|
1866
|
+
value: l - u,
|
|
1867
|
+
adl: c
|
|
1868
|
+
};
|
|
1869
|
+
i.set(e[t].time, n), a[t] = n;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
return {
|
|
1873
|
+
values: i,
|
|
1874
|
+
series: a
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
render(e, t, n, r) {
|
|
1878
|
+
let i = t.series;
|
|
1879
|
+
if (!i) return;
|
|
1880
|
+
let { chartRect: a } = n, { from: o, to: s } = n.visibleRange, c = Infinity, l = -Infinity;
|
|
1881
|
+
for (let e = o; e <= s && e < i.length; e++) {
|
|
1882
|
+
let t = i[e]?.value;
|
|
1883
|
+
t !== void 0 && (t < c && (c = t), t > l && (l = t));
|
|
1884
|
+
}
|
|
1885
|
+
if (c === Infinity) return;
|
|
1886
|
+
let u = Math.max(Math.abs(c), Math.abs(l)) || 1, d = (e) => a.y + a.height * (1 - (e + u) / (2 * u)), f = d(0), p = n.barWidth / 2, m = r.colors[0] ?? "#26A69A", h = r.colors[1] ?? "#EF5350";
|
|
1887
|
+
for (let t = o; t <= s && t < i.length; t++) {
|
|
1888
|
+
let r = i[t];
|
|
1889
|
+
if (!r || r.value === void 0) continue;
|
|
1890
|
+
let a = w(t, n), o = d(r.value), s = Math.min(o, f), c = Math.max(Math.abs(o - f), 1);
|
|
1891
|
+
e.fillStyle = r.value >= 0 ? m : h, e.fillRect(a - p, s, n.barWidth, c);
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
}, He = class extends j {
|
|
1376
1895
|
descriptor = {
|
|
1377
1896
|
id: "rsi",
|
|
1378
1897
|
name: "Relative Strength Index",
|
|
@@ -1380,7 +1899,7 @@ var j = class {
|
|
|
1380
1899
|
defaultConfig: { period: 14 }
|
|
1381
1900
|
};
|
|
1382
1901
|
calculate(e, t) {
|
|
1383
|
-
let n = t
|
|
1902
|
+
let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1384
1903
|
if (e.length < n + 1) return {
|
|
1385
1904
|
values: r,
|
|
1386
1905
|
series: i
|
|
@@ -1418,12 +1937,12 @@ var j = class {
|
|
|
1418
1937
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
1419
1938
|
let r = i[t];
|
|
1420
1939
|
if (!r || r.value === void 0) continue;
|
|
1421
|
-
let a =
|
|
1940
|
+
let a = w(t, n), o = c(r.value);
|
|
1422
1941
|
l ? e.lineTo(a, o) : (e.moveTo(a, o), l = !0);
|
|
1423
1942
|
}
|
|
1424
1943
|
e.stroke();
|
|
1425
1944
|
}
|
|
1426
|
-
},
|
|
1945
|
+
}, Ue = class extends j {
|
|
1427
1946
|
descriptor = {
|
|
1428
1947
|
id: "macd",
|
|
1429
1948
|
name: "MACD",
|
|
@@ -1435,7 +1954,7 @@ var j = class {
|
|
|
1435
1954
|
}
|
|
1436
1955
|
};
|
|
1437
1956
|
calculate(e, t) {
|
|
1438
|
-
let n = t
|
|
1957
|
+
let n = N(t, "fast", 12, 1), r = N(t, "slow", 26, 1), i = N(t, "signal", 9, 1), a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null);
|
|
1439
1958
|
if (e.length < r) return {
|
|
1440
1959
|
values: a,
|
|
1441
1960
|
series: o
|
|
@@ -1470,27 +1989,27 @@ var j = class {
|
|
|
1470
1989
|
if (c === Infinity) return;
|
|
1471
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";
|
|
1472
1991
|
e.beginPath();
|
|
1473
|
-
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();
|
|
1474
1993
|
for (let e = o; e <= s && e < i.length; e++) {
|
|
1475
1994
|
let t = i[e];
|
|
1476
1995
|
if (!t) continue;
|
|
1477
|
-
let r =
|
|
1996
|
+
let r = w(e, n);
|
|
1478
1997
|
if (t.histogram !== void 0) {
|
|
1479
1998
|
let e = d(t.histogram), i = Math.min(e, f), a = Math.max(Math.abs(e - f), 1);
|
|
1480
1999
|
t.histogram >= 0 ? v.rect(r - p, i, n.barWidth, a) : y.rect(r - p, i, n.barWidth, a);
|
|
1481
2000
|
}
|
|
1482
2001
|
if (t.macd !== void 0) {
|
|
1483
2002
|
let e = d(t.macd);
|
|
1484
|
-
b ?
|
|
2003
|
+
b ? S.lineTo(r, e) : (S.moveTo(r, e), b = !0);
|
|
1485
2004
|
}
|
|
1486
2005
|
if (t.signal !== void 0) {
|
|
1487
2006
|
let e = d(t.signal);
|
|
1488
|
-
x ?
|
|
2007
|
+
x ? C.lineTo(r, e) : (C.moveTo(r, e), x = !0);
|
|
1489
2008
|
}
|
|
1490
2009
|
}
|
|
1491
|
-
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);
|
|
1492
2011
|
}
|
|
1493
|
-
},
|
|
2012
|
+
}, We = class extends j {
|
|
1494
2013
|
descriptor = {
|
|
1495
2014
|
id: "stochastic",
|
|
1496
2015
|
name: "Stochastic Oscillator",
|
|
@@ -1502,7 +2021,7 @@ var j = class {
|
|
|
1502
2021
|
}
|
|
1503
2022
|
};
|
|
1504
2023
|
calculate(e, t) {
|
|
1505
|
-
let n = t
|
|
2024
|
+
let n = N(t, "kPeriod", 14, 1), r = N(t, "dPeriod", 3, 1), i = N(t, "smooth", 3, 1), a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null);
|
|
1506
2025
|
if (e.length < n) return {
|
|
1507
2026
|
values: a,
|
|
1508
2027
|
series: o
|
|
@@ -1558,14 +2077,14 @@ var j = class {
|
|
|
1558
2077
|
for (let r = o; r <= s && r < i.length; r++) {
|
|
1559
2078
|
let a = i[r];
|
|
1560
2079
|
if (!a || a[t] === void 0) continue;
|
|
1561
|
-
let o =
|
|
2080
|
+
let o = w(r, n), s = c(a[t]);
|
|
1562
2081
|
l ? e.lineTo(o, s) : (e.moveTo(o, s), l = !0);
|
|
1563
2082
|
}
|
|
1564
2083
|
e.stroke();
|
|
1565
2084
|
};
|
|
1566
2085
|
l("k", r.colors[0]), l("d", r.colors[1] ?? "#FF9800");
|
|
1567
2086
|
}
|
|
1568
|
-
},
|
|
2087
|
+
}, Ge = class extends j {
|
|
1569
2088
|
descriptor = {
|
|
1570
2089
|
id: "atr",
|
|
1571
2090
|
name: "Average True Range",
|
|
@@ -1573,7 +2092,7 @@ var j = class {
|
|
|
1573
2092
|
defaultConfig: { period: 14 }
|
|
1574
2093
|
};
|
|
1575
2094
|
calculate(e, t) {
|
|
1576
|
-
let n = t
|
|
2095
|
+
let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1577
2096
|
if (e.length < 2) return {
|
|
1578
2097
|
values: r,
|
|
1579
2098
|
series: i
|
|
@@ -1613,13 +2132,13 @@ var j = class {
|
|
|
1613
2132
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
1614
2133
|
let r = i[t];
|
|
1615
2134
|
if (r && r.value !== void 0) {
|
|
1616
|
-
let i =
|
|
2135
|
+
let i = w(t, n), a = p(r.value);
|
|
1617
2136
|
m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
|
|
1618
2137
|
}
|
|
1619
2138
|
}
|
|
1620
2139
|
e.stroke();
|
|
1621
2140
|
}
|
|
1622
|
-
},
|
|
2141
|
+
}, Ke = class extends j {
|
|
1623
2142
|
descriptor = {
|
|
1624
2143
|
id: "adx",
|
|
1625
2144
|
name: "Average Directional Index",
|
|
@@ -1627,7 +2146,7 @@ var j = class {
|
|
|
1627
2146
|
defaultConfig: { period: 14 }
|
|
1628
2147
|
};
|
|
1629
2148
|
calculate(e, t) {
|
|
1630
|
-
let n = t
|
|
2149
|
+
let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1631
2150
|
if (e.length < n * 2) return {
|
|
1632
2151
|
values: r,
|
|
1633
2152
|
series: i
|
|
@@ -1685,14 +2204,14 @@ var j = class {
|
|
|
1685
2204
|
for (let r = o; r <= s && r < i.length; r++) {
|
|
1686
2205
|
let a = i[r];
|
|
1687
2206
|
if (!a || a[t] === void 0) continue;
|
|
1688
|
-
let o =
|
|
2207
|
+
let o = w(r, n), s = c(a[t]);
|
|
1689
2208
|
l ? e.lineTo(o, s) : (e.moveTo(o, s), l = !0);
|
|
1690
2209
|
}
|
|
1691
2210
|
e.stroke();
|
|
1692
2211
|
};
|
|
1693
2212
|
l("adx", r.colors[0]), l("plusDI", r.colors[1] ?? "#26A69A"), l("minusDI", r.colors[2] ?? "#EF5350");
|
|
1694
2213
|
}
|
|
1695
|
-
},
|
|
2214
|
+
}, qe = class extends j {
|
|
1696
2215
|
descriptor = {
|
|
1697
2216
|
id: "obv",
|
|
1698
2217
|
name: "On Balance Volume",
|
|
@@ -1732,13 +2251,13 @@ var j = class {
|
|
|
1732
2251
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
1733
2252
|
let r = i[t];
|
|
1734
2253
|
if (r && r.value !== void 0) {
|
|
1735
|
-
let i =
|
|
2254
|
+
let i = w(t, n), a = p(r.value);
|
|
1736
2255
|
m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
|
|
1737
2256
|
}
|
|
1738
2257
|
}
|
|
1739
2258
|
e.stroke();
|
|
1740
2259
|
}
|
|
1741
|
-
},
|
|
2260
|
+
}, Je = class extends j {
|
|
1742
2261
|
descriptor = {
|
|
1743
2262
|
id: "williamsR",
|
|
1744
2263
|
name: "Williams %R",
|
|
@@ -1746,7 +2265,7 @@ var j = class {
|
|
|
1746
2265
|
defaultConfig: { period: 14 }
|
|
1747
2266
|
};
|
|
1748
2267
|
calculate(e, t) {
|
|
1749
|
-
let n = t
|
|
2268
|
+
let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1750
2269
|
for (let t = n - 1; t < e.length; t++) {
|
|
1751
2270
|
let a = -Infinity, o = Infinity;
|
|
1752
2271
|
for (let r = t - n + 1; r <= t; r++) e[r].high > a && (a = e[r].high), e[r].low < o && (o = e[r].low);
|
|
@@ -1772,13 +2291,13 @@ var j = class {
|
|
|
1772
2291
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
1773
2292
|
let r = i[t];
|
|
1774
2293
|
if (r && r.value !== void 0) {
|
|
1775
|
-
let i =
|
|
2294
|
+
let i = w(t, n), a = c(r.value);
|
|
1776
2295
|
l ? e.lineTo(i, a) : (e.moveTo(i, a), l = !0);
|
|
1777
2296
|
}
|
|
1778
2297
|
}
|
|
1779
2298
|
e.stroke();
|
|
1780
2299
|
}
|
|
1781
|
-
},
|
|
2300
|
+
}, Ye = class extends j {
|
|
1782
2301
|
descriptor = {
|
|
1783
2302
|
id: "cci",
|
|
1784
2303
|
name: "Commodity Channel Index",
|
|
@@ -1786,7 +2305,7 @@ var j = class {
|
|
|
1786
2305
|
defaultConfig: { period: 20 }
|
|
1787
2306
|
};
|
|
1788
2307
|
calculate(e, t) {
|
|
1789
|
-
let n = t
|
|
2308
|
+
let n = N(t, "period", 20, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1790
2309
|
for (let t = n - 1; t < e.length; t++) {
|
|
1791
2310
|
let a = 0;
|
|
1792
2311
|
for (let r = t - n + 1; r <= t; r++) a += (e[r].high + e[r].low + e[r].close) / 3;
|
|
@@ -1827,13 +2346,13 @@ var j = class {
|
|
|
1827
2346
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
1828
2347
|
let r = i[t];
|
|
1829
2348
|
if (r && r.value !== void 0) {
|
|
1830
|
-
let i =
|
|
2349
|
+
let i = w(t, n), a = m(r.value);
|
|
1831
2350
|
h ? e.lineTo(i, a) : (e.moveTo(i, a), h = !0);
|
|
1832
2351
|
}
|
|
1833
2352
|
}
|
|
1834
2353
|
e.stroke();
|
|
1835
2354
|
}
|
|
1836
|
-
},
|
|
2355
|
+
}, Xe = class extends j {
|
|
1837
2356
|
descriptor = {
|
|
1838
2357
|
id: "mfi",
|
|
1839
2358
|
name: "Money Flow Index",
|
|
@@ -1841,7 +2360,7 @@ var j = class {
|
|
|
1841
2360
|
defaultConfig: { period: 14 }
|
|
1842
2361
|
};
|
|
1843
2362
|
calculate(e, t) {
|
|
1844
|
-
let n = t
|
|
2363
|
+
let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1845
2364
|
if (e.length < n + 1) return {
|
|
1846
2365
|
values: r,
|
|
1847
2366
|
series: i
|
|
@@ -1872,13 +2391,13 @@ var j = class {
|
|
|
1872
2391
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
1873
2392
|
let r = i[t];
|
|
1874
2393
|
if (r && r.value !== void 0) {
|
|
1875
|
-
let i =
|
|
2394
|
+
let i = w(t, n), a = c(r.value);
|
|
1876
2395
|
l ? e.lineTo(i, a) : (e.moveTo(i, a), l = !0);
|
|
1877
2396
|
}
|
|
1878
2397
|
}
|
|
1879
2398
|
e.stroke();
|
|
1880
2399
|
}
|
|
1881
|
-
},
|
|
2400
|
+
}, Ze = class extends j {
|
|
1882
2401
|
descriptor = {
|
|
1883
2402
|
id: "aroon",
|
|
1884
2403
|
name: "Aroon",
|
|
@@ -1886,7 +2405,7 @@ var j = class {
|
|
|
1886
2405
|
defaultConfig: { period: 25 }
|
|
1887
2406
|
};
|
|
1888
2407
|
calculate(e, t) {
|
|
1889
|
-
let n = t
|
|
2408
|
+
let n = N(t, "period", 25, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1890
2409
|
for (let t = n; t < e.length; t++) {
|
|
1891
2410
|
let a = 0, o = 0, s = -Infinity, c = Infinity;
|
|
1892
2411
|
for (let r = 0; r <= n; r++) {
|
|
@@ -1913,14 +2432,14 @@ var j = class {
|
|
|
1913
2432
|
for (let r = o; r <= s && r < i.length; r++) {
|
|
1914
2433
|
let a = i[r];
|
|
1915
2434
|
if (!a || a[t] === void 0) continue;
|
|
1916
|
-
let o =
|
|
2435
|
+
let o = w(r, n), s = c(a[t]);
|
|
1917
2436
|
l ? e.lineTo(o, s) : (e.moveTo(o, s), l = !0);
|
|
1918
2437
|
}
|
|
1919
2438
|
e.stroke();
|
|
1920
2439
|
};
|
|
1921
2440
|
l("up", r.colors[0]), l("down", r.colors[1] ?? "#EF5350");
|
|
1922
2441
|
}
|
|
1923
|
-
},
|
|
2442
|
+
}, Qe = class extends j {
|
|
1924
2443
|
descriptor = {
|
|
1925
2444
|
id: "roc",
|
|
1926
2445
|
name: "Rate of Change",
|
|
@@ -1928,7 +2447,7 @@ var j = class {
|
|
|
1928
2447
|
defaultConfig: { period: 12 }
|
|
1929
2448
|
};
|
|
1930
2449
|
calculate(e, t) {
|
|
1931
|
-
let n = t
|
|
2450
|
+
let n = N(t, "period", 12, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
1932
2451
|
for (let t = n; t < e.length; t++) {
|
|
1933
2452
|
let a = e[t - n].close, o = { value: a === 0 ? 0 : (e[t].close - a) / a * 100 };
|
|
1934
2453
|
r.set(e[t].time, o), i[t] = o;
|
|
@@ -1958,13 +2477,13 @@ var j = class {
|
|
|
1958
2477
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
1959
2478
|
let r = i[t];
|
|
1960
2479
|
if (r && r.value !== void 0) {
|
|
1961
|
-
let i =
|
|
2480
|
+
let i = w(t, n), a = m(r.value);
|
|
1962
2481
|
h ? e.lineTo(i, a) : (e.moveTo(i, a), h = !0);
|
|
1963
2482
|
}
|
|
1964
2483
|
}
|
|
1965
2484
|
e.stroke();
|
|
1966
2485
|
}
|
|
1967
|
-
},
|
|
2486
|
+
}, $e = class extends j {
|
|
1968
2487
|
descriptor = {
|
|
1969
2488
|
id: "tsi",
|
|
1970
2489
|
name: "True Strength Index",
|
|
@@ -1981,7 +2500,7 @@ var j = class {
|
|
|
1981
2500
|
return r;
|
|
1982
2501
|
}
|
|
1983
2502
|
calculate(e, t) {
|
|
1984
|
-
let n = t
|
|
2503
|
+
let n = N(t, "longPeriod", 25, 1), r = N(t, "shortPeriod", 13, 1), i = N(t, "signalPeriod", 7, 1), a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null);
|
|
1985
2504
|
if (e.length < 2) return {
|
|
1986
2505
|
values: a,
|
|
1987
2506
|
series: o
|
|
@@ -2026,14 +2545,14 @@ var j = class {
|
|
|
2026
2545
|
for (let r = o; r <= s && r < i.length; r++) {
|
|
2027
2546
|
let a = i[r];
|
|
2028
2547
|
if (!a || a[t] === void 0) continue;
|
|
2029
|
-
let o =
|
|
2548
|
+
let o = w(r, n), s = m(a[t]);
|
|
2030
2549
|
c ? e.lineTo(o, s) : (e.moveTo(o, s), c = !0);
|
|
2031
2550
|
}
|
|
2032
2551
|
e.stroke();
|
|
2033
2552
|
};
|
|
2034
2553
|
h("tsi", r.colors[0]), h("signal", r.colors[1] ?? "#FF9800");
|
|
2035
2554
|
}
|
|
2036
|
-
},
|
|
2555
|
+
}, et = class extends j {
|
|
2037
2556
|
descriptor = {
|
|
2038
2557
|
id: "cmf",
|
|
2039
2558
|
name: "Chaikin Money Flow",
|
|
@@ -2041,7 +2560,7 @@ var j = class {
|
|
|
2041
2560
|
defaultConfig: { period: 20 }
|
|
2042
2561
|
};
|
|
2043
2562
|
calculate(e, t) {
|
|
2044
|
-
let n = t
|
|
2563
|
+
let n = N(t, "period", 20, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
2045
2564
|
for (let t = n - 1; t < e.length; t++) {
|
|
2046
2565
|
let a = 0, o = 0;
|
|
2047
2566
|
for (let r = t - n + 1; r <= t; r++) {
|
|
@@ -2071,14 +2590,14 @@ var j = class {
|
|
|
2071
2590
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2072
2591
|
let a = i[t];
|
|
2073
2592
|
if (a && a.value !== void 0) {
|
|
2074
|
-
let i =
|
|
2593
|
+
let i = w(t, n), o = m(a.value), s = m(0);
|
|
2075
2594
|
e.fillStyle = a.value >= 0 ? r.colors[0] : r.colors[1] ?? "#EF5350";
|
|
2076
2595
|
let c = Math.min(o, s);
|
|
2077
2596
|
e.fillRect(i - h, c, n.barWidth, Math.max(Math.abs(o - s), 1));
|
|
2078
2597
|
}
|
|
2079
2598
|
}
|
|
2080
2599
|
}
|
|
2081
|
-
},
|
|
2600
|
+
}, tt = class extends j {
|
|
2082
2601
|
descriptor = {
|
|
2083
2602
|
id: "stddev",
|
|
2084
2603
|
name: "Standard Deviation",
|
|
@@ -2086,7 +2605,7 @@ var j = class {
|
|
|
2086
2605
|
defaultConfig: { period: 20 }
|
|
2087
2606
|
};
|
|
2088
2607
|
calculate(e, t) {
|
|
2089
|
-
let n = t
|
|
2608
|
+
let n = N(t, "period", 20, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
2090
2609
|
for (let t = n - 1; t < e.length; t++) {
|
|
2091
2610
|
let a = 0;
|
|
2092
2611
|
for (let r = t - n + 1; r <= t; r++) a += e[r].close;
|
|
@@ -2118,13 +2637,13 @@ var j = class {
|
|
|
2118
2637
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2119
2638
|
let r = i[t];
|
|
2120
2639
|
if (r && r.value !== void 0) {
|
|
2121
|
-
let i =
|
|
2640
|
+
let i = w(t, n), a = p(r.value);
|
|
2122
2641
|
m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
|
|
2123
2642
|
}
|
|
2124
2643
|
}
|
|
2125
2644
|
e.stroke();
|
|
2126
2645
|
}
|
|
2127
|
-
},
|
|
2646
|
+
}, nt = class extends j {
|
|
2128
2647
|
descriptor = {
|
|
2129
2648
|
id: "volumeProfile",
|
|
2130
2649
|
name: "Volume Profile",
|
|
@@ -2132,7 +2651,7 @@ var j = class {
|
|
|
2132
2651
|
defaultConfig: { rows: 24 }
|
|
2133
2652
|
};
|
|
2134
2653
|
calculate(e, t) {
|
|
2135
|
-
let n = t
|
|
2654
|
+
let n = N(t, "rows", 24, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
2136
2655
|
if (e.length === 0) return {
|
|
2137
2656
|
values: r,
|
|
2138
2657
|
series: i
|
|
@@ -2174,7 +2693,7 @@ var j = class {
|
|
|
2174
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));
|
|
2175
2694
|
}
|
|
2176
2695
|
}
|
|
2177
|
-
},
|
|
2696
|
+
}, rt = class extends j {
|
|
2178
2697
|
descriptor = {
|
|
2179
2698
|
id: "ad",
|
|
2180
2699
|
name: "Accumulation/Distribution",
|
|
@@ -2214,13 +2733,13 @@ var j = class {
|
|
|
2214
2733
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2215
2734
|
let r = i[t];
|
|
2216
2735
|
if (r && r.value !== void 0) {
|
|
2217
|
-
let i =
|
|
2736
|
+
let i = w(t, n), a = p(r.value);
|
|
2218
2737
|
m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
|
|
2219
2738
|
}
|
|
2220
2739
|
}
|
|
2221
2740
|
e.stroke();
|
|
2222
2741
|
}
|
|
2223
|
-
},
|
|
2742
|
+
}, it = class extends j {
|
|
2224
2743
|
descriptor = {
|
|
2225
2744
|
id: "vroc",
|
|
2226
2745
|
name: "Volume Rate of Change",
|
|
@@ -2228,7 +2747,7 @@ var j = class {
|
|
|
2228
2747
|
defaultConfig: { period: 14 }
|
|
2229
2748
|
};
|
|
2230
2749
|
calculate(e, t) {
|
|
2231
|
-
let n = t
|
|
2750
|
+
let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
|
|
2232
2751
|
for (let t = n; t < e.length; t++) {
|
|
2233
2752
|
let a = e[t - n].volume, o = { value: a === 0 ? 0 : (e[t].volume - a) / a * 100 };
|
|
2234
2753
|
r.set(e[t].time, o), i[t] = o;
|
|
@@ -2253,7 +2772,7 @@ var j = class {
|
|
|
2253
2772
|
for (let t = o; t <= s && t < i.length; t++) {
|
|
2254
2773
|
let r = i[t];
|
|
2255
2774
|
if (r && r.value !== void 0) {
|
|
2256
|
-
let i =
|
|
2775
|
+
let i = w(t, n), a = m(r.value);
|
|
2257
2776
|
h ? e.lineTo(i, a) : (e.moveTo(i, a), h = !0);
|
|
2258
2777
|
}
|
|
2259
2778
|
}
|
|
@@ -2262,12 +2781,105 @@ var j = class {
|
|
|
2262
2781
|
};
|
|
2263
2782
|
//#endregion
|
|
2264
2783
|
//#region src/indicators/registry.ts
|
|
2265
|
-
function
|
|
2266
|
-
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());
|
|
2267
2786
|
}
|
|
2268
2787
|
//#endregion
|
|
2269
|
-
//#region src/
|
|
2270
|
-
|
|
2788
|
+
//#region src/indicators/worker/messages.ts
|
|
2789
|
+
function ot(e) {
|
|
2790
|
+
if (typeof e != "object" || !e) return !1;
|
|
2791
|
+
let t = e;
|
|
2792
|
+
return typeof t.requestId == "number" ? t.type === "result" || t.type === "pong" || t.type === "error" : !1;
|
|
2793
|
+
}
|
|
2794
|
+
//#endregion
|
|
2795
|
+
//#region src/indicators/worker/IndicatorWorkerHost.ts
|
|
2796
|
+
var st = class {
|
|
2797
|
+
worker;
|
|
2798
|
+
fallbackPlugins;
|
|
2799
|
+
timeoutMs;
|
|
2800
|
+
nextRequestId = 1;
|
|
2801
|
+
pending = /* @__PURE__ */ new Map();
|
|
2802
|
+
messageHandler;
|
|
2803
|
+
constructor(e, t = {}) {
|
|
2804
|
+
this.worker = e, this.fallbackPlugins = t.fallbackPlugins ?? /* @__PURE__ */ new Map(), this.timeoutMs = t.timeoutMs ?? 3e4, this.messageHandler = (e) => this.handleMessage(e), this.worker && (this.worker.addEventListener("message", this.messageHandler), this.worker.addEventListener("error", this.messageHandler));
|
|
2805
|
+
}
|
|
2806
|
+
hasWorker() {
|
|
2807
|
+
return this.worker !== null;
|
|
2808
|
+
}
|
|
2809
|
+
registerFallbackPlugin(e) {
|
|
2810
|
+
this.fallbackPlugins.set(e.descriptor.id, e);
|
|
2811
|
+
}
|
|
2812
|
+
async calculate(e, t, n) {
|
|
2813
|
+
if (!this.worker) {
|
|
2814
|
+
let r = this.fallbackPlugins.get(e);
|
|
2815
|
+
if (!r) throw Error(`Unknown indicator: ${e}`);
|
|
2816
|
+
return r.calculate(n, t);
|
|
2817
|
+
}
|
|
2818
|
+
let r = this.nextRequestId++, i = {
|
|
2819
|
+
type: "calculate",
|
|
2820
|
+
requestId: r,
|
|
2821
|
+
indicatorId: e,
|
|
2822
|
+
config: t,
|
|
2823
|
+
data: n
|
|
2824
|
+
};
|
|
2825
|
+
return new Promise((t, n) => {
|
|
2826
|
+
let a = {
|
|
2827
|
+
resolve: t,
|
|
2828
|
+
reject: n,
|
|
2829
|
+
timer: null
|
|
2830
|
+
};
|
|
2831
|
+
this.timeoutMs > 0 && (a.timer = setTimeout(() => {
|
|
2832
|
+
this.pending.delete(r), n(/* @__PURE__ */ Error(`Indicator worker timeout (${this.timeoutMs}ms): ${e}`));
|
|
2833
|
+
}, this.timeoutMs)), this.pending.set(r, a), this.worker.postMessage(i);
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2836
|
+
ping() {
|
|
2837
|
+
if (!this.worker) return Promise.resolve();
|
|
2838
|
+
let e = this.nextRequestId++;
|
|
2839
|
+
return new Promise((t, n) => {
|
|
2840
|
+
let r = {
|
|
2841
|
+
resolve: () => t(),
|
|
2842
|
+
reject: n,
|
|
2843
|
+
timer: this.timeoutMs > 0 ? setTimeout(() => {
|
|
2844
|
+
this.pending.delete(e), n(/* @__PURE__ */ Error("Indicator worker ping timeout"));
|
|
2845
|
+
}, this.timeoutMs) : null
|
|
2846
|
+
};
|
|
2847
|
+
this.pending.set(e, r), this.worker.postMessage({
|
|
2848
|
+
type: "ping",
|
|
2849
|
+
requestId: e
|
|
2850
|
+
});
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2853
|
+
terminate() {
|
|
2854
|
+
this.worker &&= (this.worker.removeEventListener("message", this.messageHandler), this.worker.removeEventListener("error", this.messageHandler), this.worker.terminate(), null);
|
|
2855
|
+
for (let e of this.pending.values()) e.timer && clearTimeout(e.timer), e.reject(/* @__PURE__ */ Error("Indicator worker terminated"));
|
|
2856
|
+
this.pending.clear();
|
|
2857
|
+
}
|
|
2858
|
+
handleMessage(e) {
|
|
2859
|
+
let t = e.data;
|
|
2860
|
+
if (t !== void 0) {
|
|
2861
|
+
if (!ot(t)) return;
|
|
2862
|
+
this.dispatchResponse(t);
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2865
|
+
let n = e.message ?? "Indicator worker error";
|
|
2866
|
+
for (let [e, t] of this.pending) t.timer && clearTimeout(t.timer), t.reject(Error(n)), this.pending.delete(e);
|
|
2867
|
+
}
|
|
2868
|
+
dispatchResponse(e) {
|
|
2869
|
+
let t = this.pending.get(e.requestId);
|
|
2870
|
+
if (t) {
|
|
2871
|
+
if (this.pending.delete(e.requestId), t.timer && clearTimeout(t.timer), e.type === "error") {
|
|
2872
|
+
t.reject(Error(e.message));
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2875
|
+
if (e.type === "pong") {
|
|
2876
|
+
t.resolve(void 0);
|
|
2877
|
+
return;
|
|
2878
|
+
}
|
|
2879
|
+
t.resolve(e.output);
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
}, ct = class {
|
|
2271
2883
|
visible = !0;
|
|
2272
2884
|
setVisible(e) {
|
|
2273
2885
|
this.visible = e;
|
|
@@ -2283,20 +2895,20 @@ var Le = class {
|
|
|
2283
2895
|
if (a <= 0) return;
|
|
2284
2896
|
let o = 1 / a;
|
|
2285
2897
|
e.beginPath();
|
|
2286
|
-
let s =
|
|
2898
|
+
let s = m(i.min, i.max, 8), c = Math.ceil(i.min / s) * s;
|
|
2287
2899
|
for (let t = c; t <= i.max; t += s) {
|
|
2288
2900
|
let n = Math.round(r.y + r.height * (1 - (t - i.min) * o)) + .5;
|
|
2289
2901
|
e.moveTo(r.x, n), e.lineTo(r.x + r.width, n);
|
|
2290
2902
|
}
|
|
2291
|
-
let l = t.barWidth + t.barSpacing, u = Math.max(1, Math.ceil(80 / l)), { from: d, to:
|
|
2292
|
-
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++) {
|
|
2293
2905
|
if (t % u !== 0) continue;
|
|
2294
|
-
let n = Math.round(t * l +
|
|
2906
|
+
let n = Math.round(t * l + p) + .5;
|
|
2295
2907
|
e.moveTo(n, r.y), e.lineTo(n, r.y + r.height);
|
|
2296
2908
|
}
|
|
2297
2909
|
e.stroke();
|
|
2298
2910
|
}
|
|
2299
|
-
},
|
|
2911
|
+
}, lt = class {
|
|
2300
2912
|
locale = "en-US";
|
|
2301
2913
|
setLocale(e) {
|
|
2302
2914
|
this.locale = e;
|
|
@@ -2306,20 +2918,20 @@ var Le = class {
|
|
|
2306
2918
|
if (o <= 0) return;
|
|
2307
2919
|
let s = 1 / o;
|
|
2308
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();
|
|
2309
|
-
let
|
|
2310
|
-
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) {
|
|
2311
2923
|
let t = r.y + r.height * (1 - (e - i.min) * s);
|
|
2312
|
-
|
|
2924
|
+
p.push({
|
|
2313
2925
|
y: t,
|
|
2314
|
-
text:
|
|
2926
|
+
text: h(e, d, this.locale)
|
|
2315
2927
|
});
|
|
2316
2928
|
}
|
|
2317
|
-
e.font =
|
|
2318
|
-
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);
|
|
2319
2931
|
e.fillStyle = n.axisLabel;
|
|
2320
|
-
for (let { y: t, text: n } of
|
|
2932
|
+
for (let { y: t, text: n } of p) e.fillText(n, a + 5, t);
|
|
2321
2933
|
}
|
|
2322
|
-
},
|
|
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 {
|
|
2323
2935
|
render(e, t, n, r, i) {
|
|
2324
2936
|
let { chartRect: a } = t, o = i ?? a.y + a.height;
|
|
2325
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();
|
|
@@ -2329,14 +2941,14 @@ var Le = class {
|
|
|
2329
2941
|
for (let t = l; t <= u && t < r.length; t++) {
|
|
2330
2942
|
if (t % c !== 0) continue;
|
|
2331
2943
|
let n = t * s + d, i = r[t].time, a = i > 0xe8d4a51000 ? i : i * 1e3;
|
|
2332
|
-
|
|
2333
|
-
let l =
|
|
2334
|
-
l === f ? h = `${
|
|
2944
|
+
I.setTime(a);
|
|
2945
|
+
let l = I.getDate(), u = I.getMonth() + 1, p = I.getHours(), m = I.getMinutes(), h;
|
|
2946
|
+
l === f ? h = `${ut(p)}:${ut(m)}` : (h = `${u}/${l}`, f = l), e.fillText(h, n, o + 5);
|
|
2335
2947
|
}
|
|
2336
2948
|
let p = a.x + a.width - 4, m = o + 4;
|
|
2337
|
-
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);
|
|
2338
2950
|
}
|
|
2339
|
-
},
|
|
2951
|
+
}, mt = class {
|
|
2340
2952
|
panHandler = null;
|
|
2341
2953
|
zoomHandler = null;
|
|
2342
2954
|
crosshairHandler = null;
|
|
@@ -2464,7 +3076,7 @@ var Le = class {
|
|
|
2464
3076
|
y: (e.clientY + t.clientY) / 2 - n.top
|
|
2465
3077
|
};
|
|
2466
3078
|
}
|
|
2467
|
-
},
|
|
3079
|
+
}, ht = class {
|
|
2468
3080
|
dragging = !1;
|
|
2469
3081
|
lastX = 0;
|
|
2470
3082
|
lastTime = 0;
|
|
@@ -2500,7 +3112,7 @@ var Le = class {
|
|
|
2500
3112
|
stopMomentum() {
|
|
2501
3113
|
this.momentumId &&= (cancelAnimationFrame(this.momentumId), 0);
|
|
2502
3114
|
}
|
|
2503
|
-
},
|
|
3115
|
+
}, gt = class {
|
|
2504
3116
|
callback;
|
|
2505
3117
|
sensitivity;
|
|
2506
3118
|
pendingDelta = 0;
|
|
@@ -2519,7 +3131,7 @@ var Le = class {
|
|
|
2519
3131
|
dispose() {
|
|
2520
3132
|
this.rafId &&= (cancelAnimationFrame(this.rafId), 0);
|
|
2521
3133
|
}
|
|
2522
|
-
},
|
|
3134
|
+
}, _t = class {
|
|
2523
3135
|
position = null;
|
|
2524
3136
|
callback = null;
|
|
2525
3137
|
data = [];
|
|
@@ -2565,13 +3177,13 @@ var Le = class {
|
|
|
2565
3177
|
if (!this.position || this.mode === "hidden") return;
|
|
2566
3178
|
let { chartRect: r } = t, { x: i, y: a } = this.position;
|
|
2567
3179
|
if (i < r.x || i > r.x + r.width || a < r.y || a > r.y + r.height) return;
|
|
2568
|
-
let o =
|
|
2569
|
-
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 = {
|
|
2570
3182
|
x: i,
|
|
2571
3183
|
y: a
|
|
2572
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([]);
|
|
2573
|
-
let s =
|
|
2574
|
-
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);
|
|
2575
3187
|
}
|
|
2576
3188
|
scheduleCallback() {
|
|
2577
3189
|
this.callbackScheduled || (this.callbackScheduled = !0, queueMicrotask(() => {
|
|
@@ -2581,7 +3193,7 @@ var Le = class {
|
|
|
2581
3193
|
flushCallback(e, t) {
|
|
2582
3194
|
this.callback?.(e, t);
|
|
2583
3195
|
}
|
|
2584
|
-
},
|
|
3196
|
+
}, vt = class {
|
|
2585
3197
|
callbacks;
|
|
2586
3198
|
enabled = !0;
|
|
2587
3199
|
constructor(e) {
|
|
@@ -2607,7 +3219,7 @@ var Le = class {
|
|
|
2607
3219
|
default: return !1;
|
|
2608
3220
|
}
|
|
2609
3221
|
}
|
|
2610
|
-
},
|
|
3222
|
+
}, yt = class {
|
|
2611
3223
|
el = null;
|
|
2612
3224
|
visible = !1;
|
|
2613
3225
|
timeEl;
|
|
@@ -2646,8 +3258,8 @@ var Le = class {
|
|
|
2646
3258
|
this.changeEl.textContent = `${l}${a(s)} (${l}${c.toFixed(2)}%)`, this.changeEl.style.color = i;
|
|
2647
3259
|
let u = t.volume;
|
|
2648
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;
|
|
2649
|
-
let d =
|
|
2650
|
-
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);
|
|
2651
3263
|
let f = e.x + 16, p = e.y - 40;
|
|
2652
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);
|
|
2653
3265
|
}
|
|
@@ -2672,7 +3284,7 @@ var Le = class {
|
|
|
2672
3284
|
return document.createElement("span");
|
|
2673
3285
|
}
|
|
2674
3286
|
};
|
|
2675
|
-
function
|
|
3287
|
+
function bt(e) {
|
|
2676
3288
|
if (e.startsWith("#")) {
|
|
2677
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);
|
|
2678
3290
|
return (.299 * r + .587 * i + .114 * a) / 255 < .5;
|
|
@@ -2684,7 +3296,7 @@ function Ye(e) {
|
|
|
2684
3296
|
}
|
|
2685
3297
|
return !0;
|
|
2686
3298
|
}
|
|
2687
|
-
function
|
|
3299
|
+
function xt(e, t) {
|
|
2688
3300
|
if (e.startsWith("#")) {
|
|
2689
3301
|
let n = e.slice(1), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n.slice(0, 6);
|
|
2690
3302
|
return `rgba(${parseInt(r.slice(0, 2), 16)}, ${parseInt(r.slice(2, 4), 16)}, ${parseInt(r.slice(4, 6), 16)}, ${t})`;
|
|
@@ -2693,7 +3305,7 @@ function Xe(e, t) {
|
|
|
2693
3305
|
}
|
|
2694
3306
|
//#endregion
|
|
2695
3307
|
//#region src/events/EventBus.ts
|
|
2696
|
-
var
|
|
3308
|
+
var St = class {
|
|
2697
3309
|
listeners = /* @__PURE__ */ new Map();
|
|
2698
3310
|
tauriBridge = null;
|
|
2699
3311
|
on(e, t) {
|
|
@@ -2724,7 +3336,7 @@ var Ze = class {
|
|
|
2724
3336
|
destroy() {
|
|
2725
3337
|
this.listeners.clear(), this.tauriBridge = null;
|
|
2726
3338
|
}
|
|
2727
|
-
},
|
|
3339
|
+
}, L = class {
|
|
2728
3340
|
hitTestAnchor(e, t, n, r) {
|
|
2729
3341
|
for (let i = 0; i < t.anchors.length; i++) {
|
|
2730
3342
|
let a = this.anchorToPixel(t.anchors[i], n);
|
|
@@ -2734,14 +3346,14 @@ var Ze = class {
|
|
|
2734
3346
|
}
|
|
2735
3347
|
anchorToPixel(e, t) {
|
|
2736
3348
|
return {
|
|
2737
|
-
x:
|
|
2738
|
-
y:
|
|
3349
|
+
x: w(e.time, t),
|
|
3350
|
+
y: T(e.price, t)
|
|
2739
3351
|
};
|
|
2740
3352
|
}
|
|
2741
3353
|
pixelToAnchor(e, t) {
|
|
2742
3354
|
return {
|
|
2743
|
-
time:
|
|
2744
|
-
price:
|
|
3355
|
+
time: E(e.x, t),
|
|
3356
|
+
price: D(e.y, t)
|
|
2745
3357
|
};
|
|
2746
3358
|
}
|
|
2747
3359
|
applyLineStyle(e, t) {
|
|
@@ -2779,8 +3391,8 @@ var Ze = class {
|
|
|
2779
3391
|
let r = n.x - t.x, i = n.y - t.y, a = Math.hypot(r, i);
|
|
2780
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;
|
|
2781
3393
|
}
|
|
2782
|
-
},
|
|
2783
|
-
function
|
|
3394
|
+
}, Ct = 1;
|
|
3395
|
+
function R(e) {
|
|
2784
3396
|
return {
|
|
2785
3397
|
...e,
|
|
2786
3398
|
anchors: e.anchors.map((e) => ({ ...e })),
|
|
@@ -2788,7 +3400,7 @@ function H(e) {
|
|
|
2788
3400
|
meta: e.meta ? { ...e.meta } : void 0
|
|
2789
3401
|
};
|
|
2790
3402
|
}
|
|
2791
|
-
var
|
|
3403
|
+
var wt = class {
|
|
2792
3404
|
registry = /* @__PURE__ */ new Map();
|
|
2793
3405
|
drawings = [];
|
|
2794
3406
|
state = "idle";
|
|
@@ -2947,7 +3559,7 @@ var $e = class {
|
|
|
2947
3559
|
if (this.state === "creating" && this.creatingDrawing) {
|
|
2948
3560
|
let n = this.registry.get(this.creatingDrawing.type);
|
|
2949
3561
|
if (n && this.committedAnchors < n.descriptor.requiredAnchors) {
|
|
2950
|
-
let n =
|
|
3562
|
+
let n = E(e.x, t), r = D(e.y, t);
|
|
2951
3563
|
return this.previewAnchor = this.snapToOHLC(n, r, t), this.requestRender?.(), !0;
|
|
2952
3564
|
}
|
|
2953
3565
|
}
|
|
@@ -2960,7 +3572,7 @@ var $e = class {
|
|
|
2960
3572
|
e && this.undoRedo?.push({
|
|
2961
3573
|
type: "drawingModify",
|
|
2962
3574
|
before: this.dragBeforeState,
|
|
2963
|
-
after:
|
|
3575
|
+
after: R(e)
|
|
2964
3576
|
});
|
|
2965
3577
|
}
|
|
2966
3578
|
return this.state = "selected", this.dragStartPoint = null, this.dragStartAnchors = [], this.dragAnchorIndex = -1, this.dragBeforeState = null, !0;
|
|
@@ -2993,7 +3605,7 @@ var $e = class {
|
|
|
2993
3605
|
let t = this.drawings.find((t) => t.id === e);
|
|
2994
3606
|
if (!t) return null;
|
|
2995
3607
|
let n = structuredClone(t);
|
|
2996
|
-
return n.id = `tc_drawing_${
|
|
3608
|
+
return n.id = `tc_drawing_${Ct++}`, n.anchors = n.anchors.map((e) => ({
|
|
2997
3609
|
...e,
|
|
2998
3610
|
time: e.time + 3
|
|
2999
3611
|
})), n.locked = !1, this.drawings.push(n), this.undoRedo?.push({
|
|
@@ -3033,9 +3645,9 @@ var $e = class {
|
|
|
3033
3645
|
if (!this.activeTool) return !1;
|
|
3034
3646
|
let n = this.registry.get(this.activeTool);
|
|
3035
3647
|
if (!n) return !1;
|
|
3036
|
-
let r =
|
|
3648
|
+
let r = E(e.x, t), i = D(e.y, t), a = this.snapToOHLC(r, i, t);
|
|
3037
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 = {
|
|
3038
|
-
id: `tc_drawing_${
|
|
3650
|
+
id: `tc_drawing_${Ct++}`,
|
|
3039
3651
|
type: this.activeTool,
|
|
3040
3652
|
anchors: [a],
|
|
3041
3653
|
style: { ...this.activeStyle },
|
|
@@ -3057,8 +3669,8 @@ var $e = class {
|
|
|
3057
3669
|
let r = this.registry.get(n.type);
|
|
3058
3670
|
if (r) {
|
|
3059
3671
|
let i = r.hitTestAnchor(e, n, t, 8);
|
|
3060
|
-
if (i >= 0) return this.state = "resizing", this.dragAnchorIndex = i, this.dragStartPoint = e, this.dragBeforeState =
|
|
3061
|
-
if (r.hitTest(e, n, t, 8)) return this.state = "moving", this.dragStartPoint = e, this.dragStartAnchors = n.anchors.map((e) => ({ ...e })), this.dragBeforeState =
|
|
3672
|
+
if (i >= 0) return this.state = "resizing", this.dragAnchorIndex = i, this.dragStartPoint = e, this.dragBeforeState = R(n), !0;
|
|
3673
|
+
if (r.hitTest(e, n, t, 8)) return this.state = "moving", this.dragStartPoint = e, this.dragStartAnchors = n.anchors.map((e) => ({ ...e })), this.dragBeforeState = R(n), !0;
|
|
3062
3674
|
}
|
|
3063
3675
|
}
|
|
3064
3676
|
}
|
|
@@ -3073,7 +3685,7 @@ var $e = class {
|
|
|
3073
3685
|
handleMove(e, t) {
|
|
3074
3686
|
let n = this.drawings.find((e) => e.id === this.selectedDrawingId);
|
|
3075
3687
|
if (!n || !this.dragStartPoint) return !1;
|
|
3076
|
-
let r =
|
|
3688
|
+
let r = E(e.x, t) - E(this.dragStartPoint.x, t), i = D(e.y, t) - D(this.dragStartPoint.y, t);
|
|
3077
3689
|
return n.anchors = this.dragStartAnchors.map((e) => ({
|
|
3078
3690
|
time: e.time + r,
|
|
3079
3691
|
price: e.price + i
|
|
@@ -3082,18 +3694,18 @@ var $e = class {
|
|
|
3082
3694
|
handleResize(e, t) {
|
|
3083
3695
|
let n = this.drawings.find((e) => e.id === this.selectedDrawingId);
|
|
3084
3696
|
return !n || this.dragAnchorIndex < 0 ? !1 : (n.anchors[this.dragAnchorIndex] = {
|
|
3085
|
-
time:
|
|
3086
|
-
price:
|
|
3697
|
+
time: E(e.x, t),
|
|
3698
|
+
price: D(e.y, t)
|
|
3087
3699
|
}, this.requestRender?.(), !0);
|
|
3088
3700
|
}
|
|
3089
|
-
},
|
|
3701
|
+
}, Tt = class {
|
|
3090
3702
|
constructor(e) {
|
|
3091
3703
|
this.manager = e;
|
|
3092
3704
|
}
|
|
3093
3705
|
render(e, t) {
|
|
3094
3706
|
this.manager.render(e, t);
|
|
3095
3707
|
}
|
|
3096
|
-
},
|
|
3708
|
+
}, Et = class extends L {
|
|
3097
3709
|
descriptor = {
|
|
3098
3710
|
type: "trendLine",
|
|
3099
3711
|
name: "Trend Line",
|
|
@@ -3109,7 +3721,7 @@ var $e = class {
|
|
|
3109
3721
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
|
|
3110
3722
|
return this.distanceToLine(e, i, a) <= r;
|
|
3111
3723
|
}
|
|
3112
|
-
},
|
|
3724
|
+
}, Dt = class extends L {
|
|
3113
3725
|
descriptor = {
|
|
3114
3726
|
type: "horizontalLine",
|
|
3115
3727
|
name: "Horizontal Line",
|
|
@@ -3117,15 +3729,15 @@ var $e = class {
|
|
|
3117
3729
|
};
|
|
3118
3730
|
render(e, t, n, r) {
|
|
3119
3731
|
if (t.anchors.length < 1) return;
|
|
3120
|
-
let i =
|
|
3732
|
+
let i = T(t.anchors[0].price, n), { chartRect: a } = n;
|
|
3121
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);
|
|
3122
3734
|
}
|
|
3123
3735
|
hitTest(e, t, n, r) {
|
|
3124
3736
|
if (t.anchors.length < 1) return !1;
|
|
3125
|
-
let i =
|
|
3737
|
+
let i = T(t.anchors[0].price, n);
|
|
3126
3738
|
return Math.abs(e.y - i) <= r && e.x >= n.chartRect.x && e.x <= n.chartRect.x + n.chartRect.width;
|
|
3127
3739
|
}
|
|
3128
|
-
},
|
|
3740
|
+
}, Ot = class extends L {
|
|
3129
3741
|
descriptor = {
|
|
3130
3742
|
type: "verticalLine",
|
|
3131
3743
|
name: "Vertical Line",
|
|
@@ -3141,7 +3753,7 @@ var $e = class {
|
|
|
3141
3753
|
let i = this.anchorToPixel(t.anchors[0], n), { chartRect: a } = n;
|
|
3142
3754
|
return Math.abs(e.x - i.x) <= r && e.y >= a.y && e.y <= a.y + a.height;
|
|
3143
3755
|
}
|
|
3144
|
-
},
|
|
3756
|
+
}, kt = class extends L {
|
|
3145
3757
|
descriptor = {
|
|
3146
3758
|
type: "ray",
|
|
3147
3759
|
name: "Ray",
|
|
@@ -3159,7 +3771,7 @@ var $e = class {
|
|
|
3159
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;
|
|
3160
3772
|
return ((e.x - i.x) * o + (e.y - i.y) * s) / (o * o + s * s) < 0 ? !1 : this.distanceToInfiniteLine(e, i, a) <= r;
|
|
3161
3773
|
}
|
|
3162
|
-
},
|
|
3774
|
+
}, At = class extends L {
|
|
3163
3775
|
descriptor = {
|
|
3164
3776
|
type: "extendedLine",
|
|
3165
3777
|
name: "Extended Line",
|
|
@@ -3177,7 +3789,7 @@ var $e = class {
|
|
|
3177
3789
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
|
|
3178
3790
|
return this.distanceToInfiniteLine(e, i, a) <= r;
|
|
3179
3791
|
}
|
|
3180
|
-
},
|
|
3792
|
+
}, jt = class extends L {
|
|
3181
3793
|
descriptor = {
|
|
3182
3794
|
type: "parallelChannel",
|
|
3183
3795
|
name: "Parallel Channel",
|
|
@@ -3214,7 +3826,7 @@ var $e = class {
|
|
|
3214
3826
|
}
|
|
3215
3827
|
return !1;
|
|
3216
3828
|
}
|
|
3217
|
-
},
|
|
3829
|
+
}, Mt = class extends L {
|
|
3218
3830
|
descriptor = {
|
|
3219
3831
|
type: "regressionChannel",
|
|
3220
3832
|
name: "Regression Channel",
|
|
@@ -3237,7 +3849,7 @@ var $e = class {
|
|
|
3237
3849
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = Math.hypot(a.x - i.x, a.y - i.y), s = Math.max(10, Math.min(o * .2, 100));
|
|
3238
3850
|
return this.distanceToLine(e, i, a) <= r + s;
|
|
3239
3851
|
}
|
|
3240
|
-
},
|
|
3852
|
+
}, z = [
|
|
3241
3853
|
0,
|
|
3242
3854
|
.236,
|
|
3243
3855
|
.382,
|
|
@@ -3245,7 +3857,7 @@ var $e = class {
|
|
|
3245
3857
|
.618,
|
|
3246
3858
|
.786,
|
|
3247
3859
|
1
|
|
3248
|
-
],
|
|
3860
|
+
], Nt = class extends L {
|
|
3249
3861
|
descriptor = {
|
|
3250
3862
|
type: "fibRetracement",
|
|
3251
3863
|
name: "Fibonacci Retracement",
|
|
@@ -3255,13 +3867,13 @@ var $e = class {
|
|
|
3255
3867
|
if (t.anchors.length < 2) return;
|
|
3256
3868
|
let { chartRect: i } = n, a = t.anchors[0].price, o = t.anchors[1].price, s = a - o;
|
|
3257
3869
|
e.font = "11px sans-serif", e.textBaseline = "middle";
|
|
3258
|
-
for (let r of
|
|
3259
|
-
let a = o + s * (1 - r), c =
|
|
3870
|
+
for (let r of z) {
|
|
3871
|
+
let a = o + s * (1 - r), c = T(a, n);
|
|
3260
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);
|
|
3261
3873
|
}
|
|
3262
3874
|
if (e.globalAlpha = 1, t.style.fillColor) {
|
|
3263
|
-
for (let r = 0; r <
|
|
3264
|
-
let a = o + s * (1 -
|
|
3875
|
+
for (let r = 0; r < z.length - 1; r++) {
|
|
3876
|
+
let a = o + s * (1 - z[r]), c = o + s * (1 - z[r + 1]), l = T(a, n), u = T(c, n);
|
|
3265
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));
|
|
3266
3878
|
}
|
|
3267
3879
|
e.globalAlpha = 1;
|
|
@@ -3273,13 +3885,13 @@ var $e = class {
|
|
|
3273
3885
|
let { chartRect: i } = n;
|
|
3274
3886
|
if (e.x < i.x - r || e.x > i.x + i.width + r) return !1;
|
|
3275
3887
|
let a = t.anchors[0].price, o = t.anchors[1].price, s = a - o;
|
|
3276
|
-
for (let t of
|
|
3277
|
-
let i =
|
|
3888
|
+
for (let t of z) {
|
|
3889
|
+
let i = T(o + s * (1 - t), n);
|
|
3278
3890
|
if (Math.abs(e.y - i) <= r) return !0;
|
|
3279
3891
|
}
|
|
3280
3892
|
return !1;
|
|
3281
3893
|
}
|
|
3282
|
-
},
|
|
3894
|
+
}, Pt = [
|
|
3283
3895
|
0,
|
|
3284
3896
|
.618,
|
|
3285
3897
|
1,
|
|
@@ -3288,7 +3900,7 @@ var $e = class {
|
|
|
3288
3900
|
2.618,
|
|
3289
3901
|
3.618,
|
|
3290
3902
|
4.236
|
|
3291
|
-
],
|
|
3903
|
+
], Ft = class extends L {
|
|
3292
3904
|
descriptor = {
|
|
3293
3905
|
type: "fibExtension",
|
|
3294
3906
|
name: "Fibonacci Extension",
|
|
@@ -3304,8 +3916,8 @@ var $e = class {
|
|
|
3304
3916
|
}
|
|
3305
3917
|
let { chartRect: i } = n, a = t.anchors[0].price, o = t.anchors[1].price, s = t.anchors[2].price, c = a - o;
|
|
3306
3918
|
e.font = "11px sans-serif", e.textBaseline = "middle", e.textAlign = "left";
|
|
3307
|
-
for (let r of
|
|
3308
|
-
let a =
|
|
3919
|
+
for (let r of Pt) {
|
|
3920
|
+
let a = T(s + c * r, n);
|
|
3309
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);
|
|
3310
3922
|
}
|
|
3311
3923
|
e.globalAlpha = 1, this.resetLineStyle(e), r && this.renderAnchorHandles(e, t, n);
|
|
@@ -3315,13 +3927,13 @@ var $e = class {
|
|
|
3315
3927
|
let { chartRect: i } = n;
|
|
3316
3928
|
if (e.x < i.x - r || e.x > i.x + i.width + r) return !1;
|
|
3317
3929
|
let a = t.anchors[0].price - t.anchors[1].price;
|
|
3318
|
-
for (let i of
|
|
3319
|
-
let o =
|
|
3930
|
+
for (let i of Pt) {
|
|
3931
|
+
let o = T(t.anchors[2].price + a * i, n);
|
|
3320
3932
|
if (Math.abs(e.y - o) <= r) return !0;
|
|
3321
3933
|
}
|
|
3322
3934
|
return !1;
|
|
3323
3935
|
}
|
|
3324
|
-
},
|
|
3936
|
+
}, It = class extends L {
|
|
3325
3937
|
descriptor = {
|
|
3326
3938
|
type: "rectangle",
|
|
3327
3939
|
name: "Rectangle",
|
|
@@ -3339,7 +3951,7 @@ var $e = class {
|
|
|
3339
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;
|
|
3340
3952
|
return !(e.x > u && e.x < f && e.y > d && e.y < p) || !!t.style.fillColor;
|
|
3341
3953
|
}
|
|
3342
|
-
},
|
|
3954
|
+
}, Lt = class extends L {
|
|
3343
3955
|
descriptor = {
|
|
3344
3956
|
type: "ellipse",
|
|
3345
3957
|
name: "Ellipse",
|
|
@@ -3355,7 +3967,7 @@ var $e = class {
|
|
|
3355
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);
|
|
3356
3968
|
return t.style.fillColor ? f <= 1 + p : Math.abs(f - 1) <= p;
|
|
3357
3969
|
}
|
|
3358
|
-
},
|
|
3970
|
+
}, Rt = class extends L {
|
|
3359
3971
|
descriptor = {
|
|
3360
3972
|
type: "triangle",
|
|
3361
3973
|
name: "Triangle",
|
|
@@ -3381,7 +3993,7 @@ var $e = class {
|
|
|
3381
3993
|
}
|
|
3382
3994
|
return !1;
|
|
3383
3995
|
}
|
|
3384
|
-
},
|
|
3996
|
+
}, zt = class extends L {
|
|
3385
3997
|
descriptor = {
|
|
3386
3998
|
type: "pitchfork",
|
|
3387
3999
|
name: "Andrews' Pitchfork",
|
|
@@ -3417,7 +4029,7 @@ var $e = class {
|
|
|
3417
4029
|
};
|
|
3418
4030
|
return this.distanceToInfiniteLine(e, a, u) <= r || this.distanceToInfiniteLine(e, o, d) <= r;
|
|
3419
4031
|
}
|
|
3420
|
-
},
|
|
4032
|
+
}, Bt = [
|
|
3421
4033
|
"1",
|
|
3422
4034
|
"2",
|
|
3423
4035
|
"3",
|
|
@@ -3426,7 +4038,7 @@ var $e = class {
|
|
|
3426
4038
|
"A",
|
|
3427
4039
|
"B",
|
|
3428
4040
|
"C"
|
|
3429
|
-
],
|
|
4041
|
+
], Vt = class extends L {
|
|
3430
4042
|
descriptor = {
|
|
3431
4043
|
type: "elliottWave",
|
|
3432
4044
|
name: "Elliott Wave",
|
|
@@ -3438,9 +4050,9 @@ var $e = class {
|
|
|
3438
4050
|
this.applyLineStyle(e, t.style), e.beginPath(), e.moveTo(i[0].x, i[0].y);
|
|
3439
4051
|
for (let t = 1; t < i.length; t++) e.lineTo(i[t].x, i[t].y);
|
|
3440
4052
|
e.stroke(), this.resetLineStyle(e), e.font = "bold 12px sans-serif", e.fillStyle = t.style.color, e.textAlign = "center";
|
|
3441
|
-
for (let t = 0; t < i.length && t <
|
|
4053
|
+
for (let t = 0; t < i.length && t < Bt.length; t++) {
|
|
3442
4054
|
let n = t % 2 == 0 ? -12 : 12;
|
|
3443
|
-
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);
|
|
3444
4056
|
}
|
|
3445
4057
|
r && this.renderAnchorHandles(e, t, n);
|
|
3446
4058
|
}
|
|
@@ -3450,7 +4062,7 @@ var $e = class {
|
|
|
3450
4062
|
for (let t = 0; t < i.length - 1; t++) if (this.distanceToLine(e, i[t], i[t + 1]) <= r) return !0;
|
|
3451
4063
|
return !1;
|
|
3452
4064
|
}
|
|
3453
|
-
},
|
|
4065
|
+
}, Ht = class extends L {
|
|
3454
4066
|
descriptor = {
|
|
3455
4067
|
type: "priceRange",
|
|
3456
4068
|
name: "Price Range",
|
|
@@ -3468,7 +4080,7 @@ var $e = class {
|
|
|
3468
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);
|
|
3469
4081
|
return e.x >= o - r && e.x <= s + r && e.y >= c - r && e.y <= l + r;
|
|
3470
4082
|
}
|
|
3471
|
-
},
|
|
4083
|
+
}, Ut = class extends L {
|
|
3472
4084
|
descriptor = {
|
|
3473
4085
|
type: "dateRange",
|
|
3474
4086
|
name: "Date Range",
|
|
@@ -3486,7 +4098,7 @@ var $e = class {
|
|
|
3486
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);
|
|
3487
4099
|
return e.x >= s - r && e.x <= c + r && e.y >= o.y && e.y <= o.y + o.height;
|
|
3488
4100
|
}
|
|
3489
|
-
},
|
|
4101
|
+
}, Wt = class extends L {
|
|
3490
4102
|
descriptor = {
|
|
3491
4103
|
type: "measure",
|
|
3492
4104
|
name: "Measure",
|
|
@@ -3508,7 +4120,15 @@ var $e = class {
|
|
|
3508
4120
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
|
|
3509
4121
|
return this.distanceToLine(e, i, a) <= r;
|
|
3510
4122
|
}
|
|
3511
|
-
}
|
|
4123
|
+
};
|
|
4124
|
+
//#endregion
|
|
4125
|
+
//#region src/drawings/tools/TextAnnotation.ts
|
|
4126
|
+
function Gt(e, t = "Text") {
|
|
4127
|
+
if (typeof e.style.text == "string" && e.style.text.length > 0) return e.style.text;
|
|
4128
|
+
let n = e.meta?.text;
|
|
4129
|
+
return typeof n == "string" && n.length > 0 ? n : t;
|
|
4130
|
+
}
|
|
4131
|
+
var Kt = class extends L {
|
|
3512
4132
|
descriptor = {
|
|
3513
4133
|
type: "text",
|
|
3514
4134
|
name: "Text",
|
|
@@ -3516,7 +4136,7 @@ var $e = class {
|
|
|
3516
4136
|
};
|
|
3517
4137
|
render(e, t, n, r) {
|
|
3518
4138
|
if (t.anchors.length < 1) return;
|
|
3519
|
-
let i = this.anchorToPixel(t.anchors[0], n), a = t
|
|
4139
|
+
let i = this.anchorToPixel(t.anchors[0], n), a = Gt(t), o = t.style.fontSize || 14;
|
|
3520
4140
|
if (e.font = `${o}px sans-serif`, e.fillStyle = t.style.color, e.textAlign = "left", e.textBaseline = "top", r) {
|
|
3521
4141
|
let n = e.measureText(a);
|
|
3522
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([]);
|
|
@@ -3528,7 +4148,7 @@ var $e = class {
|
|
|
3528
4148
|
let i = this.anchorToPixel(t.anchors[0], n), a = t.style.fontSize || 14;
|
|
3529
4149
|
return e.x >= i.x - r && e.x <= i.x + 80 + r && e.y >= i.y - r && e.y <= i.y + a + r;
|
|
3530
4150
|
}
|
|
3531
|
-
},
|
|
4151
|
+
}, qt = class extends L {
|
|
3532
4152
|
descriptor = {
|
|
3533
4153
|
type: "arrow",
|
|
3534
4154
|
name: "Arrow",
|
|
@@ -3546,7 +4166,7 @@ var $e = class {
|
|
|
3546
4166
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
|
|
3547
4167
|
return this.distanceToLine(e, i, a) <= r;
|
|
3548
4168
|
}
|
|
3549
|
-
},
|
|
4169
|
+
}, Jt = [
|
|
3550
4170
|
{
|
|
3551
4171
|
label: "8x1",
|
|
3552
4172
|
ratio: 8
|
|
@@ -3583,7 +4203,7 @@ var $e = class {
|
|
|
3583
4203
|
label: "1x8",
|
|
3584
4204
|
ratio: .125
|
|
3585
4205
|
}
|
|
3586
|
-
],
|
|
4206
|
+
], Yt = class extends L {
|
|
3587
4207
|
descriptor = {
|
|
3588
4208
|
type: "gannFan",
|
|
3589
4209
|
name: "Gann Fan",
|
|
@@ -3595,7 +4215,7 @@ var $e = class {
|
|
|
3595
4215
|
if (Math.abs(o) < 1) return;
|
|
3596
4216
|
let c = s / o, l = o > 0 ? 1 : -1, { chartRect: u } = n, d = l > 0 ? u.x + u.width : u.x;
|
|
3597
4217
|
this.applyLineStyle(e, t.style);
|
|
3598
|
-
for (let { label: n, ratio: r } of
|
|
4218
|
+
for (let { label: n, ratio: r } of Jt) {
|
|
3599
4219
|
let a = c * r, o = d, s = i.y + a * (o - i.x);
|
|
3600
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();
|
|
3601
4221
|
let f = o - l * 4, p = s;
|
|
@@ -3608,7 +4228,7 @@ var $e = class {
|
|
|
3608
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;
|
|
3609
4229
|
if (Math.abs(o) < 1) return !1;
|
|
3610
4230
|
let c = s / o, l = o > 0 ? 1 : -1, { chartRect: u } = n, d = l > 0 ? u.x + u.width : u.x;
|
|
3611
|
-
for (let { ratio: t } of
|
|
4231
|
+
for (let { ratio: t } of Jt) {
|
|
3612
4232
|
let n = c * t, a = d, o = i.y + n * (a - i.x);
|
|
3613
4233
|
if (this.distanceToLine(e, i, {
|
|
3614
4234
|
x: a,
|
|
@@ -3617,7 +4237,7 @@ var $e = class {
|
|
|
3617
4237
|
}
|
|
3618
4238
|
return !1;
|
|
3619
4239
|
}
|
|
3620
|
-
},
|
|
4240
|
+
}, B = [
|
|
3621
4241
|
0,
|
|
3622
4242
|
.25,
|
|
3623
4243
|
.333,
|
|
@@ -3625,7 +4245,7 @@ var $e = class {
|
|
|
3625
4245
|
.667,
|
|
3626
4246
|
.75,
|
|
3627
4247
|
1
|
|
3628
|
-
],
|
|
4248
|
+
], Xt = class extends L {
|
|
3629
4249
|
descriptor = {
|
|
3630
4250
|
type: "gannBox",
|
|
3631
4251
|
name: "Gann Box",
|
|
@@ -3636,18 +4256,18 @@ var $e = class {
|
|
|
3636
4256
|
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), u = s - o, d = l - c;
|
|
3637
4257
|
if (!(u < 2 || d < 2)) {
|
|
3638
4258
|
this.applyLineStyle(e, t.style), e.strokeRect(o, c, u, d), e.save(), e.globalAlpha = .35;
|
|
3639
|
-
for (let t of
|
|
4259
|
+
for (let t of B) {
|
|
3640
4260
|
if (t === 0 || t === 1) continue;
|
|
3641
4261
|
let n = c + d * t;
|
|
3642
4262
|
e.beginPath(), e.moveTo(o, n), e.lineTo(s, n), e.stroke();
|
|
3643
4263
|
}
|
|
3644
|
-
for (let t of
|
|
4264
|
+
for (let t of B) {
|
|
3645
4265
|
if (t === 0 || t === 1) continue;
|
|
3646
4266
|
let n = o + u * t;
|
|
3647
4267
|
e.beginPath(), e.moveTo(n, c), e.lineTo(n, l), e.stroke();
|
|
3648
4268
|
}
|
|
3649
4269
|
e.globalAlpha = .5, e.setLineDash([4, 3]), e.beginPath(), e.moveTo(o, c), e.lineTo(s, l), e.stroke(), e.beginPath(), e.moveTo(s, c), e.lineTo(o, l), e.stroke(), e.restore(), this.resetLineStyle(e), e.fillStyle = t.style.color, e.font = "8px sans-serif", e.globalAlpha = .6, e.textBaseline = "bottom", e.textAlign = "right";
|
|
3650
|
-
for (let t of
|
|
4270
|
+
for (let t of B) {
|
|
3651
4271
|
if (t === 0 || t === 1) continue;
|
|
3652
4272
|
let n = c + d * t;
|
|
3653
4273
|
e.fillText(`${(t * 100).toFixed(0)}%`, o - 3, n);
|
|
@@ -3672,7 +4292,7 @@ var $e = class {
|
|
|
3672
4292
|
y: l
|
|
3673
4293
|
}) <= r;
|
|
3674
4294
|
}
|
|
3675
|
-
},
|
|
4295
|
+
}, Zt = class extends L {
|
|
3676
4296
|
descriptor = {
|
|
3677
4297
|
type: "anchoredVWAP",
|
|
3678
4298
|
name: "Anchored VWAP",
|
|
@@ -3692,7 +4312,7 @@ var $e = class {
|
|
|
3692
4312
|
if (a >= i.length) return;
|
|
3693
4313
|
let { vwap: o, upper1: s, lower1: c, upper2: l, lower2: u } = this.computeVWAP(i, a), { chartRect: d } = n, f = n.barWidth + n.barSpacing;
|
|
3694
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) {
|
|
3695
|
-
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);
|
|
3696
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));
|
|
3697
4317
|
}
|
|
3698
4318
|
r && this.renderAnchorHandles(e, t, n);
|
|
@@ -3701,10 +4321,10 @@ var $e = class {
|
|
|
3701
4321
|
e.beginPath();
|
|
3702
4322
|
let o = !1;
|
|
3703
4323
|
for (let s = 0; s < t.length; s++) {
|
|
3704
|
-
let c =
|
|
4324
|
+
let c = w(n + s, r);
|
|
3705
4325
|
if (c < i.x - a) continue;
|
|
3706
4326
|
if (c > i.x + i.width + a) break;
|
|
3707
|
-
let l =
|
|
4327
|
+
let l = T(t[s], r);
|
|
3708
4328
|
o ? e.lineTo(c, l) : (e.moveTo(c, l), o = !0);
|
|
3709
4329
|
}
|
|
3710
4330
|
e.stroke();
|
|
@@ -3733,7 +4353,7 @@ var $e = class {
|
|
|
3733
4353
|
if (a >= i.length) return !1;
|
|
3734
4354
|
let { vwap: o } = this.computeVWAP(i, a);
|
|
3735
4355
|
for (let t = 1; t < o.length; t++) {
|
|
3736
|
-
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);
|
|
3737
4357
|
if (this.distanceToLine(e, {
|
|
3738
4358
|
x: i,
|
|
3739
4359
|
y: s
|
|
@@ -3744,7 +4364,7 @@ var $e = class {
|
|
|
3744
4364
|
}
|
|
3745
4365
|
return !1;
|
|
3746
4366
|
}
|
|
3747
|
-
},
|
|
4367
|
+
}, Qt = class extends L {
|
|
3748
4368
|
descriptor = {
|
|
3749
4369
|
type: "volumeProfileRange",
|
|
3750
4370
|
name: "Volume Profile (Range)",
|
|
@@ -3770,15 +4390,15 @@ var $e = class {
|
|
|
3770
4390
|
if (d === 0) return;
|
|
3771
4391
|
let f = 0;
|
|
3772
4392
|
for (let e = 1; e < this.numBins; e++) u[e] > u[f] && (f = e);
|
|
3773
|
-
let p =
|
|
4393
|
+
let p = w(o, n) + n.barWidth, m = t.style.color, h = t.style.fillColor ?? "#FF9800";
|
|
3774
4394
|
e.save();
|
|
3775
4395
|
for (let t = 0; t < this.numBins; t++) {
|
|
3776
|
-
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);
|
|
3777
4397
|
e.globalAlpha = .35, e.fillStyle = t === f ? h : m, e.fillRect(p, Math.min(o, c), r, Math.max(1, g - .5));
|
|
3778
4398
|
}
|
|
3779
|
-
let g = s + (f + .5) * l, _ =
|
|
4399
|
+
let g = s + (f + .5) * l, _ = T(g, n);
|
|
3780
4400
|
e.globalAlpha = .7, e.strokeStyle = h, e.lineWidth = 1, e.setLineDash([4, 3]), e.beginPath();
|
|
3781
|
-
let v =
|
|
4401
|
+
let v = w(a, n) - n.barWidth / 2;
|
|
3782
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);
|
|
3783
4403
|
}
|
|
3784
4404
|
hitTest(e, t, n, r) {
|
|
@@ -3789,16 +4409,16 @@ var $e = class {
|
|
|
3789
4409
|
};
|
|
3790
4410
|
//#endregion
|
|
3791
4411
|
//#region src/drawings/tools/index.ts
|
|
3792
|
-
function
|
|
3793
|
-
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());
|
|
3794
4414
|
}
|
|
3795
4415
|
//#endregion
|
|
3796
4416
|
//#region src/trading/OrderRenderer.ts
|
|
3797
|
-
var
|
|
4417
|
+
var en = class {
|
|
3798
4418
|
render(e, t, n, r, i, a) {
|
|
3799
4419
|
let o = i.orderColors?.buy ?? "#26A69A", s = i.orderColors?.sell ?? "#EF5350", { chartRect: c } = n;
|
|
3800
4420
|
for (let i of t) {
|
|
3801
|
-
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);
|
|
3802
4422
|
if (l < c.y || l > c.y + c.height) continue;
|
|
3803
4423
|
let u = i.side === "buy" ? o : s;
|
|
3804
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([]);
|
|
@@ -3808,64 +4428,113 @@ var Ot = class {
|
|
|
3808
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);
|
|
3809
4429
|
let p = c.x + 4 + f + 6;
|
|
3810
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) {
|
|
3811
|
-
let t =
|
|
4431
|
+
let t = T(a.startPrice, n);
|
|
3812
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([]);
|
|
3813
4433
|
}
|
|
3814
4434
|
}
|
|
3815
4435
|
}
|
|
3816
4436
|
renderAxisBadges(e, t, n, r, i, a) {
|
|
3817
|
-
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;
|
|
3818
4438
|
for (let i of t) {
|
|
3819
|
-
let t = a?.orderId === i.id && a.sourceType === "order" ? a.currentPrice : i.price, f =
|
|
3820
|
-
if (f <
|
|
3821
|
-
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}`;
|
|
3822
4442
|
e.font = `11px ${r.font.family}`;
|
|
3823
4443
|
let h = e.measureText(m).width + 10;
|
|
3824
|
-
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);
|
|
3825
4445
|
}
|
|
3826
4446
|
}
|
|
3827
4447
|
hitTest(e, t, n, r) {
|
|
3828
4448
|
for (let i of t) {
|
|
3829
4449
|
if (i.draggable === !1) continue;
|
|
3830
|
-
let t =
|
|
4450
|
+
let t = T(i.price, n);
|
|
3831
4451
|
if (Math.abs(e - t) <= r) return i;
|
|
3832
4452
|
}
|
|
3833
4453
|
return null;
|
|
3834
4454
|
}
|
|
3835
|
-
}
|
|
4455
|
+
};
|
|
4456
|
+
//#endregion
|
|
4457
|
+
//#region src/trading/positionFormat.ts
|
|
4458
|
+
function tn(e, t, n) {
|
|
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;
|
|
4460
|
+
return {
|
|
4461
|
+
side: e.side,
|
|
4462
|
+
quantity: e.quantity,
|
|
4463
|
+
closedQuantity: r,
|
|
4464
|
+
openQuantity: i,
|
|
4465
|
+
entryPrice: e.entryPrice,
|
|
4466
|
+
currentPrice: t,
|
|
4467
|
+
pnl: o,
|
|
4468
|
+
pnlPct: s,
|
|
4469
|
+
precision: n
|
|
4470
|
+
};
|
|
4471
|
+
}
|
|
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) => {
|
|
4475
|
+
switch (n) {
|
|
4476
|
+
case "side": return t.side.toUpperCase();
|
|
4477
|
+
case "qty": return String(t.quantity);
|
|
4478
|
+
case "closedQty": return String(t.closedQuantity);
|
|
4479
|
+
case "openQty": return String(t.openQuantity);
|
|
4480
|
+
case "entry": return t.entryPrice.toFixed(t.precision);
|
|
4481
|
+
case "price": return t.currentPrice.toFixed(t.precision);
|
|
4482
|
+
case "pnl": return t.pnl.toFixed(t.precision);
|
|
4483
|
+
case "pnlPct": return `${t.pnlPct.toFixed(2)}%`;
|
|
4484
|
+
case "pnlSign": return t.pnl >= 0 ? "+" : "";
|
|
4485
|
+
default: return "";
|
|
4486
|
+
}
|
|
4487
|
+
});
|
|
4488
|
+
}
|
|
4489
|
+
function an(e, t) {
|
|
4490
|
+
return typeof e == "function" ? e(t) : rn(e ?? "{side} {qty} | P&L: {pnlSign}{pnl}", t);
|
|
4491
|
+
}
|
|
4492
|
+
function on(e, t, n) {
|
|
4493
|
+
if (!t || t.length === 0) return n;
|
|
4494
|
+
let r = [...t].sort((e, t) => e.pnl - t.pnl), i;
|
|
4495
|
+
for (let t of r) if (e >= t.pnl) i = t.color;
|
|
4496
|
+
else break;
|
|
4497
|
+
return i ?? n;
|
|
4498
|
+
}
|
|
4499
|
+
//#endregion
|
|
4500
|
+
//#region src/trading/PositionRenderer.ts
|
|
4501
|
+
var sn = class {
|
|
3836
4502
|
render(e, t, n, r, i, a) {
|
|
3837
4503
|
let { chartRect: o } = r, s = a.positionColors?.profit ?? "#26A69A", c = a.positionColors?.loss ?? "#EF5350", l = a.positionColors?.entry ?? "#2196F3", u = a.pricePrecision ?? 2;
|
|
3838
|
-
for (let
|
|
3839
|
-
let t =
|
|
4504
|
+
for (let d of t) {
|
|
4505
|
+
let t = T(d.entryPrice, r);
|
|
3840
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) {
|
|
3841
|
-
let
|
|
3842
|
-
e.fillStyle =
|
|
3843
|
-
let
|
|
3844
|
-
e.fillRect(o.x,
|
|
3845
|
-
|
|
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);
|
|
4508
|
+
e.fillStyle = g, e.globalAlpha = .08;
|
|
4509
|
+
let _ = Math.min(t, f), v = Math.abs(f - t);
|
|
4510
|
+
if (e.fillRect(o.x, _, o.width, v), e.globalAlpha = 1, p.closedQuantity > 0 && d.quantity > 0) {
|
|
4511
|
+
let t = p.closedQuantity / d.quantity;
|
|
4512
|
+
e.fillStyle = l, e.globalAlpha = .25, e.fillRect(o.x, _, Math.max(2, o.width * t * .04) + 2, v), e.globalAlpha = 1;
|
|
4513
|
+
}
|
|
4514
|
+
let y = an(a.positionLabel, p);
|
|
3846
4515
|
e.font = `bold 11px ${i.font.family}`;
|
|
3847
|
-
let
|
|
3848
|
-
e.fillStyle =
|
|
4516
|
+
let b = e.measureText(y).width + 12, x = o.x + 8;
|
|
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);
|
|
3849
4518
|
}
|
|
3850
|
-
if (
|
|
3851
|
-
let t =
|
|
4519
|
+
if (d.stopLoss !== void 0) {
|
|
4520
|
+
let t = T(d.stopLoss, r);
|
|
3852
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);
|
|
3853
4522
|
}
|
|
3854
|
-
if (
|
|
3855
|
-
let t =
|
|
4523
|
+
if (d.takeProfit !== void 0) {
|
|
4524
|
+
let t = T(d.takeProfit, r);
|
|
3856
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);
|
|
3857
4526
|
}
|
|
3858
4527
|
e.setLineDash([]);
|
|
3859
4528
|
}
|
|
3860
4529
|
}
|
|
3861
4530
|
renderAxisBadges(e, t, n, r, i) {
|
|
3862
|
-
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;
|
|
3863
4532
|
for (let i of t) {
|
|
3864
|
-
let t =
|
|
3865
|
-
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);
|
|
3866
4535
|
}
|
|
3867
4536
|
}
|
|
3868
|
-
},
|
|
4537
|
+
}, V = class {
|
|
3869
4538
|
render(e, t, n, r) {
|
|
3870
4539
|
if (!r.depthOverlay?.enabled) return;
|
|
3871
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;
|
|
@@ -3880,23 +4549,23 @@ var Ot = class {
|
|
|
3880
4549
|
cumVol: u
|
|
3881
4550
|
}), u > c && (c = u);
|
|
3882
4551
|
if (c === 0) return;
|
|
3883
|
-
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;
|
|
3884
4553
|
e.fillStyle = a;
|
|
3885
4554
|
for (let { price: t, cumVol: r } of l) {
|
|
3886
|
-
let a =
|
|
4555
|
+
let a = T(t, n);
|
|
3887
4556
|
if (a < i.y || a > i.y + i.height) continue;
|
|
3888
4557
|
let o = r / c * s;
|
|
3889
4558
|
e.fillRect(p - o, a - f / 2, o, f);
|
|
3890
4559
|
}
|
|
3891
4560
|
e.fillStyle = o;
|
|
3892
4561
|
for (let { price: t, cumVol: r } of d) {
|
|
3893
|
-
let a =
|
|
4562
|
+
let a = T(t, n);
|
|
3894
4563
|
if (a < i.y || a > i.y + i.height) continue;
|
|
3895
4564
|
let o = r / c * s;
|
|
3896
4565
|
e.fillRect(p - o, a - f / 2, o, f);
|
|
3897
4566
|
}
|
|
3898
4567
|
}
|
|
3899
|
-
},
|
|
4568
|
+
}, cn = class {
|
|
3900
4569
|
dragState = null;
|
|
3901
4570
|
startY = 0;
|
|
3902
4571
|
dragging = !1;
|
|
@@ -3906,7 +4575,7 @@ var Ot = class {
|
|
|
3906
4575
|
onPointerDown(e, t, n, r, i) {
|
|
3907
4576
|
for (let n of t) {
|
|
3908
4577
|
if (n.draggable === !1) continue;
|
|
3909
|
-
let t =
|
|
4578
|
+
let t = T(n.price, r);
|
|
3910
4579
|
if (Math.abs(e.y - t) <= i) return this.dragState = {
|
|
3911
4580
|
orderId: n.id,
|
|
3912
4581
|
sourceType: "order",
|
|
@@ -3916,7 +4585,7 @@ var Ot = class {
|
|
|
3916
4585
|
}
|
|
3917
4586
|
for (let t of n) {
|
|
3918
4587
|
if (t.stopLoss !== void 0) {
|
|
3919
|
-
let n =
|
|
4588
|
+
let n = T(t.stopLoss, r);
|
|
3920
4589
|
if (Math.abs(e.y - n) <= i) return this.dragState = {
|
|
3921
4590
|
orderId: t.id,
|
|
3922
4591
|
sourceType: "stopLoss",
|
|
@@ -3925,7 +4594,7 @@ var Ot = class {
|
|
|
3925
4594
|
}, this.startY = e.y, this.dragging = !1, !0;
|
|
3926
4595
|
}
|
|
3927
4596
|
if (t.takeProfit !== void 0) {
|
|
3928
|
-
let n =
|
|
4597
|
+
let n = T(t.takeProfit, r);
|
|
3929
4598
|
if (Math.abs(e.y - n) <= i) return this.dragState = {
|
|
3930
4599
|
orderId: t.id,
|
|
3931
4600
|
sourceType: "takeProfit",
|
|
@@ -3942,7 +4611,7 @@ var Ot = class {
|
|
|
3942
4611
|
if (Math.abs(e.y - this.startY) < this.dragThreshold) return !0;
|
|
3943
4612
|
this.dragging = !0;
|
|
3944
4613
|
}
|
|
3945
|
-
return this.dragState.currentPrice =
|
|
4614
|
+
return this.dragState.currentPrice = D(e.y, t), !0;
|
|
3946
4615
|
}
|
|
3947
4616
|
onPointerUp() {
|
|
3948
4617
|
if (!this.dragState) return null;
|
|
@@ -3960,7 +4629,7 @@ var Ot = class {
|
|
|
3960
4629
|
isActive() {
|
|
3961
4630
|
return this.dragState !== null;
|
|
3962
4631
|
}
|
|
3963
|
-
},
|
|
4632
|
+
}, ln = class {
|
|
3964
4633
|
menuElement = null;
|
|
3965
4634
|
removeHandler = null;
|
|
3966
4635
|
onItemSelect = null;
|
|
@@ -4044,25 +4713,25 @@ var Ot = class {
|
|
|
4044
4713
|
destroy() {
|
|
4045
4714
|
this.hide(), this.onItemSelect = null;
|
|
4046
4715
|
}
|
|
4047
|
-
},
|
|
4716
|
+
}, un = class {
|
|
4048
4717
|
orders = [];
|
|
4049
4718
|
positions = [];
|
|
4050
4719
|
depthData = null;
|
|
4051
4720
|
currentPrice = null;
|
|
4052
4721
|
config;
|
|
4053
|
-
orderRenderer = new
|
|
4054
|
-
positionRenderer = new
|
|
4055
|
-
depthOverlay = new
|
|
4722
|
+
orderRenderer = new en();
|
|
4723
|
+
positionRenderer = new sn();
|
|
4724
|
+
depthOverlay = new V();
|
|
4056
4725
|
dragHandler;
|
|
4057
|
-
contextMenu = new
|
|
4726
|
+
contextMenu = new ln();
|
|
4058
4727
|
requestRender = null;
|
|
4059
4728
|
eventCallback = null;
|
|
4060
4729
|
container = null;
|
|
4061
4730
|
constructor(e) {
|
|
4062
4731
|
this.config = {
|
|
4063
|
-
...
|
|
4732
|
+
...s,
|
|
4064
4733
|
...e
|
|
4065
|
-
}, this.dragHandler = new
|
|
4734
|
+
}, this.dragHandler = new cn(this.config.dragThreshold), this.contextMenu.onItemSelect = (e) => {
|
|
4066
4735
|
this.eventCallback?.("orderPlace", e);
|
|
4067
4736
|
};
|
|
4068
4737
|
}
|
|
@@ -4111,7 +4780,7 @@ var Ot = class {
|
|
|
4111
4780
|
}
|
|
4112
4781
|
onContextMenu(e, t) {
|
|
4113
4782
|
if (!this.config.enabled || !this.config.contextMenu?.enabled || !this.container) return !1;
|
|
4114
|
-
let n =
|
|
4783
|
+
let n = D(e.y, t);
|
|
4115
4784
|
return this.contextMenu.show(e, n, this.container, this.config), !0;
|
|
4116
4785
|
}
|
|
4117
4786
|
render(e, t, n) {
|
|
@@ -4123,7 +4792,7 @@ var Ot = class {
|
|
|
4123
4792
|
destroy() {
|
|
4124
4793
|
this.contextMenu.destroy();
|
|
4125
4794
|
}
|
|
4126
|
-
},
|
|
4795
|
+
}, dn = class {
|
|
4127
4796
|
constructor(e) {
|
|
4128
4797
|
this.manager = e;
|
|
4129
4798
|
}
|
|
@@ -4133,7 +4802,7 @@ var Ot = class {
|
|
|
4133
4802
|
renderAxisBadges(e, t, n) {
|
|
4134
4803
|
this.manager.renderAxisBadges(e, t, n);
|
|
4135
4804
|
}
|
|
4136
|
-
},
|
|
4805
|
+
}, H = class {
|
|
4137
4806
|
listeners = /* @__PURE__ */ new Map();
|
|
4138
4807
|
on(e, t) {
|
|
4139
4808
|
let n = this.listeners.get(e);
|
|
@@ -4155,7 +4824,7 @@ var Ot = class {
|
|
|
4155
4824
|
removeAllListeners() {
|
|
4156
4825
|
this.listeners.clear();
|
|
4157
4826
|
}
|
|
4158
|
-
},
|
|
4827
|
+
}, fn = class extends H {
|
|
4159
4828
|
currentBar = null;
|
|
4160
4829
|
timeframeMs;
|
|
4161
4830
|
tickRing;
|
|
@@ -4163,10 +4832,10 @@ var Ot = class {
|
|
|
4163
4832
|
ringCount = 0;
|
|
4164
4833
|
ringCapacity;
|
|
4165
4834
|
constructor(e, t = 1e3) {
|
|
4166
|
-
super(), this.timeframeMs =
|
|
4835
|
+
super(), this.timeframeMs = v(e), this.ringCapacity = t, this.tickRing = Array(t);
|
|
4167
4836
|
}
|
|
4168
4837
|
setTimeframe(e) {
|
|
4169
|
-
this.timeframeMs =
|
|
4838
|
+
this.timeframeMs = v(e), this.currentBar = null, this.ringHead = 0, this.ringCount = 0;
|
|
4170
4839
|
}
|
|
4171
4840
|
processTick(e) {
|
|
4172
4841
|
let t = (this.ringHead + this.ringCount) % this.ringCapacity;
|
|
@@ -4217,7 +4886,7 @@ var Ot = class {
|
|
|
4217
4886
|
alignToTimeframe(e) {
|
|
4218
4887
|
return Math.floor(e / this.timeframeMs) * this.timeframeMs;
|
|
4219
4888
|
}
|
|
4220
|
-
},
|
|
4889
|
+
}, U = class extends H {
|
|
4221
4890
|
config;
|
|
4222
4891
|
attempt = 0;
|
|
4223
4892
|
timer = null;
|
|
@@ -4264,7 +4933,7 @@ var Ot = class {
|
|
|
4264
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);
|
|
4265
4934
|
return Math.max(0, Math.round(n + r));
|
|
4266
4935
|
}
|
|
4267
|
-
},
|
|
4936
|
+
}, pn = class {
|
|
4268
4937
|
price = null;
|
|
4269
4938
|
previousClose = null;
|
|
4270
4939
|
visible = !0;
|
|
@@ -4284,23 +4953,23 @@ var Ot = class {
|
|
|
4284
4953
|
}
|
|
4285
4954
|
render(e, t, n) {
|
|
4286
4955
|
if (!this.visible || this.price === null) return;
|
|
4287
|
-
let r =
|
|
4956
|
+
let r = T(this.price, t), { chartRect: i } = t;
|
|
4288
4957
|
if (r < i.y || r > i.y + i.height) return;
|
|
4289
4958
|
let a = this.previousClose === null || this.price >= this.previousClose ? n.candleUp ?? "#26A69A" : n.candleDown ?? "#EF5350", o = Date.now() < this.flashUntil;
|
|
4290
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;
|
|
4291
|
-
let s = i.x + i.width + 1,
|
|
4960
|
+
let s = i.x + i.width + 1, c = this.price.toFixed(this.pricePrecision);
|
|
4292
4961
|
e.font = `bold 11px ${n.font.family}`;
|
|
4293
|
-
let
|
|
4962
|
+
let l = e.measureText(c).width, d = Math.min(l + 12, u - 2);
|
|
4294
4963
|
e.fillStyle = a, e.fillRect(s, r - 10, d, 20);
|
|
4295
4964
|
let f = s - 5;
|
|
4296
|
-
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);
|
|
4297
4966
|
}
|
|
4298
|
-
},
|
|
4967
|
+
}, mn = class extends H {
|
|
4299
4968
|
config = null;
|
|
4300
4969
|
adapter = null;
|
|
4301
4970
|
aggregator = null;
|
|
4302
4971
|
reconnector;
|
|
4303
|
-
priceLine = new
|
|
4972
|
+
priceLine = new pn();
|
|
4304
4973
|
state = "disconnected";
|
|
4305
4974
|
lastPrice = null;
|
|
4306
4975
|
previousClose = null;
|
|
@@ -4308,13 +4977,13 @@ var Ot = class {
|
|
|
4308
4977
|
heartbeatTimer = null;
|
|
4309
4978
|
lastMessageTime = 0;
|
|
4310
4979
|
constructor() {
|
|
4311
|
-
super(), this.reconnector = new
|
|
4980
|
+
super(), this.reconnector = new U(), this.wireReconnector();
|
|
4312
4981
|
}
|
|
4313
4982
|
async connect(e) {
|
|
4314
4983
|
this.disconnect(), this.config = {
|
|
4315
|
-
...
|
|
4984
|
+
...a,
|
|
4316
4985
|
...e
|
|
4317
|
-
}, 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) => {
|
|
4318
4987
|
this.emit("barUpdate", e), this.updatePrice(e.close);
|
|
4319
4988
|
}), this.aggregator.on("barClose", (e) => {
|
|
4320
4989
|
this.previousClose = e.close, this.emit("barClose", e);
|
|
@@ -4424,7 +5093,56 @@ var Ot = class {
|
|
|
4424
5093
|
dispose() {
|
|
4425
5094
|
this.disconnect(), this.removeAllListeners();
|
|
4426
5095
|
}
|
|
4427
|
-
}
|
|
5096
|
+
};
|
|
5097
|
+
//#endregion
|
|
5098
|
+
//#region src/realtime/adapters/binanceTypes.ts
|
|
5099
|
+
function hn(e) {
|
|
5100
|
+
if (!Array.isArray(e) || e.length < 6) return null;
|
|
5101
|
+
let t = e[0];
|
|
5102
|
+
if (typeof t != "number" || !Number.isFinite(t)) return null;
|
|
5103
|
+
let n = W(e[1]), r = W(e[2]), i = W(e[3]), a = W(e[4]), o = W(e[5]);
|
|
5104
|
+
return n === null || r === null || i === null || a === null || o === null ? null : {
|
|
5105
|
+
time: t,
|
|
5106
|
+
open: n,
|
|
5107
|
+
high: r,
|
|
5108
|
+
low: i,
|
|
5109
|
+
close: a,
|
|
5110
|
+
volume: o
|
|
5111
|
+
};
|
|
5112
|
+
}
|
|
5113
|
+
function gn(e) {
|
|
5114
|
+
if (!_n(e)) return null;
|
|
5115
|
+
let t = e.t;
|
|
5116
|
+
if (typeof t != "number" || !Number.isFinite(t)) return null;
|
|
5117
|
+
let n = W(e.o), r = W(e.h), i = W(e.l), a = W(e.c), o = W(e.v);
|
|
5118
|
+
if (n === null || r === null || i === null || a === null || o === null) return null;
|
|
5119
|
+
let s = typeof e.x == "boolean" ? e.x : !1;
|
|
5120
|
+
return {
|
|
5121
|
+
bar: {
|
|
5122
|
+
time: t,
|
|
5123
|
+
open: n,
|
|
5124
|
+
high: r,
|
|
5125
|
+
low: i,
|
|
5126
|
+
close: a,
|
|
5127
|
+
volume: o
|
|
5128
|
+
},
|
|
5129
|
+
closed: s
|
|
5130
|
+
};
|
|
5131
|
+
}
|
|
5132
|
+
function W(e) {
|
|
5133
|
+
if (typeof e == "number") return Number.isFinite(e) ? e : null;
|
|
5134
|
+
if (typeof e == "string") {
|
|
5135
|
+
let t = parseFloat(e);
|
|
5136
|
+
return Number.isFinite(t) ? t : null;
|
|
5137
|
+
}
|
|
5138
|
+
return null;
|
|
5139
|
+
}
|
|
5140
|
+
function _n(e) {
|
|
5141
|
+
return typeof e == "object" && !!e;
|
|
5142
|
+
}
|
|
5143
|
+
//#endregion
|
|
5144
|
+
//#region src/realtime/adapters/BinanceAdapter.ts
|
|
5145
|
+
var vn = {
|
|
4428
5146
|
"1s": "1s",
|
|
4429
5147
|
"1m": "1m",
|
|
4430
5148
|
"3m": "3m",
|
|
@@ -4441,7 +5159,7 @@ var Ot = class {
|
|
|
4441
5159
|
"3d": "3d",
|
|
4442
5160
|
"1w": "1w",
|
|
4443
5161
|
"1M": "1M"
|
|
4444
|
-
},
|
|
5162
|
+
}, yn = class {
|
|
4445
5163
|
name = "binance";
|
|
4446
5164
|
ws = null;
|
|
4447
5165
|
state = "disconnected";
|
|
@@ -4462,16 +5180,16 @@ var Ot = class {
|
|
|
4462
5180
|
return this.state;
|
|
4463
5181
|
}
|
|
4464
5182
|
async fetchHistory(e, t, n = 500) {
|
|
4465
|
-
let r =
|
|
5183
|
+
let r = vn[t] ?? "15m", i = `${this.restBase}/klines?symbol=${e}&interval=${r}&limit=${n}`, a = await fetch(i);
|
|
4466
5184
|
if (!a.ok) throw Error(`Binance REST error: ${a.status}`);
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
5185
|
+
let o = await a.json();
|
|
5186
|
+
if (!Array.isArray(o)) return [];
|
|
5187
|
+
let s = [];
|
|
5188
|
+
for (let e of o) {
|
|
5189
|
+
let t = hn(e);
|
|
5190
|
+
t && s.push(t);
|
|
5191
|
+
}
|
|
5192
|
+
return s;
|
|
4475
5193
|
}
|
|
4476
5194
|
on(e, t) {
|
|
4477
5195
|
let n = this.listeners.get(e);
|
|
@@ -4485,7 +5203,7 @@ var Ot = class {
|
|
|
4485
5203
|
}
|
|
4486
5204
|
connectWs() {
|
|
4487
5205
|
if (!this.config) return;
|
|
4488
|
-
let e = `${this.config.symbol.toLowerCase()}@kline_${
|
|
5206
|
+
let e = `${this.config.symbol.toLowerCase()}@kline_${vn[this.config.timeframe] ?? "15m"}`, t = `${this.wsBase}/${e}`;
|
|
4489
5207
|
this.setState("connecting");
|
|
4490
5208
|
try {
|
|
4491
5209
|
this.ws = new WebSocket(t);
|
|
@@ -4496,10 +5214,13 @@ var Ot = class {
|
|
|
4496
5214
|
this.ws.onopen = () => {
|
|
4497
5215
|
this.setState("connected"), this.emitEvent("connectionChange", "connected");
|
|
4498
5216
|
}, this.ws.onmessage = (e) => {
|
|
5217
|
+
let t;
|
|
4499
5218
|
try {
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
5219
|
+
t = JSON.parse(typeof e.data == "string" ? e.data : "");
|
|
5220
|
+
} catch {
|
|
5221
|
+
return;
|
|
5222
|
+
}
|
|
5223
|
+
typeof t == "object" && t && t.e === "kline" && this.handleKline(t.k);
|
|
4503
5224
|
}, this.ws.onerror = () => {
|
|
4504
5225
|
this.setState("error"), this.emitEvent("error", { message: "WebSocket error" });
|
|
4505
5226
|
}, this.ws.onclose = () => {
|
|
@@ -4507,21 +5228,16 @@ var Ot = class {
|
|
|
4507
5228
|
};
|
|
4508
5229
|
}
|
|
4509
5230
|
handleKline(e) {
|
|
4510
|
-
let t =
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
high: parseFloat(e.h),
|
|
4514
|
-
low: parseFloat(e.l),
|
|
4515
|
-
close: parseFloat(e.c),
|
|
4516
|
-
volume: parseFloat(e.v)
|
|
4517
|
-
}, n = e.x;
|
|
5231
|
+
let t = gn(e);
|
|
5232
|
+
if (!t) return;
|
|
5233
|
+
let { bar: n, closed: r } = t;
|
|
4518
5234
|
this.emitEvent("bar", {
|
|
4519
|
-
bar:
|
|
4520
|
-
closed:
|
|
5235
|
+
bar: n,
|
|
5236
|
+
closed: r
|
|
4521
5237
|
}), this.emitEvent("tick", {
|
|
4522
5238
|
time: Date.now(),
|
|
4523
|
-
price:
|
|
4524
|
-
volume:
|
|
5239
|
+
price: n.close,
|
|
5240
|
+
volume: n.volume
|
|
4525
5241
|
});
|
|
4526
5242
|
}
|
|
4527
5243
|
setState(e) {
|
|
@@ -4538,7 +5254,7 @@ var Ot = class {
|
|
|
4538
5254
|
for (let e of n) e(r);
|
|
4539
5255
|
}
|
|
4540
5256
|
}
|
|
4541
|
-
},
|
|
5257
|
+
}, bn = class {
|
|
4542
5258
|
name = "mock";
|
|
4543
5259
|
state = "disconnected";
|
|
4544
5260
|
listeners = /* @__PURE__ */ new Map();
|
|
@@ -4578,7 +5294,7 @@ var Ot = class {
|
|
|
4578
5294
|
this.disconnect(), this.listeners.clear();
|
|
4579
5295
|
}
|
|
4580
5296
|
generateHistory(e, t) {
|
|
4581
|
-
let n = [], r = Date.now(), i =
|
|
5297
|
+
let n = [], r = Date.now(), i = v(e), a = this.options.basePrice, o = this.options.volatility / 100;
|
|
4582
5298
|
for (let e = t - 1; e >= 0; e--) {
|
|
4583
5299
|
let t = r - e * i, s = (Math.random() - .48) * a * o, c = a;
|
|
4584
5300
|
a += s;
|
|
@@ -4601,7 +5317,7 @@ var Ot = class {
|
|
|
4601
5317
|
if (this.state !== "connected" || !this.config) return;
|
|
4602
5318
|
let e = this.options.volatility / 100, t = (Math.random() - .48) * this.currentPrice * e * .3;
|
|
4603
5319
|
this.currentPrice += t;
|
|
4604
|
-
let n = Date.now(), r =
|
|
5320
|
+
let n = Date.now(), r = v(this.config.timeframe), i = {
|
|
4605
5321
|
time: Math.floor(n / r) * r,
|
|
4606
5322
|
open: this.currentPrice - t,
|
|
4607
5323
|
high: Math.max(this.currentPrice, this.currentPrice - t) + Math.abs(t) * .2,
|
|
@@ -4633,7 +5349,7 @@ var Ot = class {
|
|
|
4633
5349
|
for (let e of n) e(r);
|
|
4634
5350
|
}
|
|
4635
5351
|
}
|
|
4636
|
-
},
|
|
5352
|
+
}, xn = {
|
|
4637
5353
|
visible: !0,
|
|
4638
5354
|
showSymbol: !0,
|
|
4639
5355
|
showOHLC: !0,
|
|
@@ -4641,8 +5357,8 @@ var Ot = class {
|
|
|
4641
5357
|
showVolume: !0,
|
|
4642
5358
|
position: "top-left",
|
|
4643
5359
|
fontSize: 12
|
|
4644
|
-
},
|
|
4645
|
-
config = { ...
|
|
5360
|
+
}, Sn = class {
|
|
5361
|
+
config = { ...xn };
|
|
4646
5362
|
symbol = "";
|
|
4647
5363
|
timeframe = "";
|
|
4648
5364
|
hoverBar = null;
|
|
@@ -4733,7 +5449,7 @@ var Ot = class {
|
|
|
4733
5449
|
}
|
|
4734
5450
|
}
|
|
4735
5451
|
}
|
|
4736
|
-
},
|
|
5452
|
+
}, Cn = class {
|
|
4737
5453
|
static toDataURL(e, t) {
|
|
4738
5454
|
let n = e.querySelectorAll("canvas");
|
|
4739
5455
|
if (n.length === 0) return "";
|
|
@@ -4755,7 +5471,7 @@ var Ot = class {
|
|
|
4755
5471
|
let i = document.createElement("a");
|
|
4756
5472
|
i.href = r, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i);
|
|
4757
5473
|
}
|
|
4758
|
-
},
|
|
5474
|
+
}, wn = class {
|
|
4759
5475
|
config = null;
|
|
4760
5476
|
setConfig(e) {
|
|
4761
5477
|
this.config = e;
|
|
@@ -4765,7 +5481,7 @@ var Ot = class {
|
|
|
4765
5481
|
let { chartRect: r } = t, i = this.config.fontSize ?? 48, a = this.config.color ?? n.textSecondary;
|
|
4766
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();
|
|
4767
5483
|
}
|
|
4768
|
-
},
|
|
5484
|
+
}, Tn = class {
|
|
4769
5485
|
visible = !0;
|
|
4770
5486
|
timeframeMs = 0;
|
|
4771
5487
|
setVisible(e) {
|
|
@@ -4781,14 +5497,14 @@ var Ot = class {
|
|
|
4781
5497
|
if (!this.visible || this.timeframeMs <= 0 || r.length === 0) return;
|
|
4782
5498
|
let i = r[r.length - 1], a = (i.time > 0xe8d4a51000 ? i.time : i.time * 1e3) + this.timeframeMs - Date.now();
|
|
4783
5499
|
if (a <= 0) return;
|
|
4784
|
-
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;
|
|
4785
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));
|
|
4786
5502
|
}
|
|
4787
5503
|
formatRemaining(e) {
|
|
4788
5504
|
let t = Math.ceil(e / 1e3), n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), i = t % 60;
|
|
4789
5505
|
return n > 0 ? `${n}:${String(r).padStart(2, "0")}:${String(i).padStart(2, "0")}` : `${r}:${String(i).padStart(2, "0")}`;
|
|
4790
5506
|
}
|
|
4791
|
-
},
|
|
5507
|
+
}, En = class {
|
|
4792
5508
|
config = { visible: !1 };
|
|
4793
5509
|
cachedBreaks = [];
|
|
4794
5510
|
lastDataLength = 0;
|
|
@@ -4822,7 +5538,7 @@ var Ot = class {
|
|
|
4822
5538
|
let { chartRect: a } = t, o = this.config.color ?? n.axisLine, s = this.config.lineWidth ?? 1, c = this.config.lineStyle ?? "dashed";
|
|
4823
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();
|
|
4824
5540
|
for (let n of i) {
|
|
4825
|
-
let r =
|
|
5541
|
+
let r = w(n, t) - (t.barWidth + t.barSpacing) / 2;
|
|
4826
5542
|
if (r < a.x - 1 || r > a.x + a.width + 1) continue;
|
|
4827
5543
|
let i = Math.round(r) + .5;
|
|
4828
5544
|
e.moveTo(i, a.y), e.lineTo(i, a.y + a.height);
|
|
@@ -4832,7 +5548,7 @@ var Ot = class {
|
|
|
4832
5548
|
invalidateCache() {
|
|
4833
5549
|
this.lastDataLength = 0, this.cachedBreaks = [];
|
|
4834
5550
|
}
|
|
4835
|
-
},
|
|
5551
|
+
}, Dn = 1, On = class extends H {
|
|
4836
5552
|
alerts = [];
|
|
4837
5553
|
lastPrice = null;
|
|
4838
5554
|
requestRender = null;
|
|
@@ -4844,7 +5560,7 @@ var Ot = class {
|
|
|
4844
5560
|
this.pricePrecision = e;
|
|
4845
5561
|
}
|
|
4846
5562
|
addAlert(e, t = "crossing", n, r = !1) {
|
|
4847
|
-
let i = `tc_alert_${
|
|
5563
|
+
let i = `tc_alert_${Dn++}`, a = {
|
|
4848
5564
|
id: i,
|
|
4849
5565
|
price: e,
|
|
4850
5566
|
condition: t,
|
|
@@ -4916,7 +5632,7 @@ var Ot = class {
|
|
|
4916
5632
|
render(e, t, n) {
|
|
4917
5633
|
let { chartRect: r } = t;
|
|
4918
5634
|
for (let i of this.alerts) {
|
|
4919
|
-
let a =
|
|
5635
|
+
let a = T(i.price, t);
|
|
4920
5636
|
if (a < r.y || a > r.y + r.height) continue;
|
|
4921
5637
|
let o = i.triggered ? "#FF9800" : "#FFD700";
|
|
4922
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";
|
|
@@ -4924,7 +5640,7 @@ var Ot = class {
|
|
|
4924
5640
|
e.fillText(s, r.x + r.width - 4, a - 2);
|
|
4925
5641
|
}
|
|
4926
5642
|
}
|
|
4927
|
-
},
|
|
5643
|
+
}, kn = class extends H {
|
|
4928
5644
|
data = [];
|
|
4929
5645
|
currentIndex = 0;
|
|
4930
5646
|
timer = null;
|
|
@@ -4978,10 +5694,114 @@ var Ot = class {
|
|
|
4978
5694
|
dispose() {
|
|
4979
5695
|
this.stop(), this.removeAllListeners(), this.data = [];
|
|
4980
5696
|
}
|
|
4981
|
-
},
|
|
5697
|
+
}, G = 1;
|
|
5698
|
+
function K(e) {
|
|
5699
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
5700
|
+
}
|
|
5701
|
+
function q(e) {
|
|
5702
|
+
return Array.isArray(e) ? e : [];
|
|
5703
|
+
}
|
|
5704
|
+
function An(e, t) {
|
|
5705
|
+
return typeof e == "string" ? e : t;
|
|
5706
|
+
}
|
|
5707
|
+
function J(e, t) {
|
|
5708
|
+
return typeof e == "number" && Number.isFinite(e) ? e : t;
|
|
5709
|
+
}
|
|
5710
|
+
function jn(e) {
|
|
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;
|
|
5712
|
+
let t = [];
|
|
5713
|
+
for (let n of e.anchors) {
|
|
5714
|
+
if (!K(n) || typeof n.time != "number" || typeof n.price != "number" || !Number.isFinite(n.time) || !Number.isFinite(n.price)) return null;
|
|
5715
|
+
t.push({
|
|
5716
|
+
time: n.time,
|
|
5717
|
+
price: n.price
|
|
5718
|
+
});
|
|
5719
|
+
}
|
|
5720
|
+
let n = e.style;
|
|
5721
|
+
return typeof n.color != "string" || typeof n.lineWidth != "number" ? null : {
|
|
5722
|
+
id: e.id,
|
|
5723
|
+
type: e.type,
|
|
5724
|
+
anchors: t,
|
|
5725
|
+
style: n,
|
|
5726
|
+
visible: typeof e.visible == "boolean" ? e.visible : !0,
|
|
5727
|
+
locked: typeof e.locked == "boolean" ? e.locked : !1,
|
|
5728
|
+
meta: K(e.meta) ? e.meta : void 0
|
|
5729
|
+
};
|
|
5730
|
+
}
|
|
5731
|
+
function Mn(e) {
|
|
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;
|
|
5733
|
+
}
|
|
5734
|
+
function Nn(e) {
|
|
5735
|
+
return !K(e) || typeof e.id != "string" || typeof e.side != "string" || typeof e.entryPrice != "number" || typeof e.quantity != "number" ? null : e;
|
|
5736
|
+
}
|
|
5737
|
+
function Pn(e) {
|
|
5738
|
+
if (!K(e)) return Fn();
|
|
5739
|
+
typeof e.version == "number" && e.version !== G && console.warn(`Chart state version mismatch: ${e.version} vs ${G}`);
|
|
5740
|
+
let t = K(e.viewport) ? e.viewport : {}, n = [];
|
|
5741
|
+
for (let t of q(e.indicators)) K(t) && (typeof t.id != "string" || typeof t.instanceId != "string" || K(t.params) && n.push({
|
|
5742
|
+
id: t.id,
|
|
5743
|
+
instanceId: t.instanceId,
|
|
5744
|
+
params: t.params,
|
|
5745
|
+
position: typeof t.position == "string" ? t.position : void 0
|
|
5746
|
+
}));
|
|
5747
|
+
let r = [];
|
|
5748
|
+
for (let t of q(e.drawings)) {
|
|
5749
|
+
let e = jn(t);
|
|
5750
|
+
e && r.push(e);
|
|
5751
|
+
}
|
|
5752
|
+
let i = [];
|
|
5753
|
+
for (let t of q(e.orders)) {
|
|
5754
|
+
let e = Mn(t);
|
|
5755
|
+
e && i.push(e);
|
|
5756
|
+
}
|
|
5757
|
+
let a = [];
|
|
5758
|
+
for (let t of q(e.positions)) {
|
|
5759
|
+
let e = Nn(t);
|
|
5760
|
+
e && a.push(e);
|
|
5761
|
+
}
|
|
5762
|
+
let o = [];
|
|
5763
|
+
for (let t of q(e.alerts)) K(t) && typeof t.id == "string" && o.push(t);
|
|
5764
|
+
return {
|
|
5765
|
+
version: typeof e.version == "number" ? e.version : G,
|
|
5766
|
+
timestamp: J(e.timestamp, Date.now()),
|
|
5767
|
+
symbol: typeof e.symbol == "string" ? e.symbol : void 0,
|
|
5768
|
+
timeframe: typeof e.timeframe == "string" ? e.timeframe : void 0,
|
|
5769
|
+
chartType: An(e.chartType, "candlestick"),
|
|
5770
|
+
viewport: {
|
|
5771
|
+
barWidth: J(t.barWidth, 8),
|
|
5772
|
+
barSpacing: J(t.barSpacing, 2),
|
|
5773
|
+
offset: J(t.offset, 0)
|
|
5774
|
+
},
|
|
5775
|
+
theme: typeof e.theme == "string" ? e.theme : void 0,
|
|
5776
|
+
locale: typeof e.locale == "string" ? e.locale : void 0,
|
|
5777
|
+
indicators: n,
|
|
5778
|
+
drawings: r,
|
|
5779
|
+
orders: i,
|
|
5780
|
+
positions: a,
|
|
5781
|
+
alerts: o
|
|
5782
|
+
};
|
|
5783
|
+
}
|
|
5784
|
+
function Fn() {
|
|
5785
|
+
return {
|
|
5786
|
+
version: G,
|
|
5787
|
+
timestamp: Date.now(),
|
|
5788
|
+
chartType: "candlestick",
|
|
5789
|
+
viewport: {
|
|
5790
|
+
barWidth: 8,
|
|
5791
|
+
barSpacing: 2,
|
|
5792
|
+
offset: 0
|
|
5793
|
+
},
|
|
5794
|
+
indicators: [],
|
|
5795
|
+
drawings: [],
|
|
5796
|
+
orders: [],
|
|
5797
|
+
positions: [],
|
|
5798
|
+
alerts: []
|
|
5799
|
+
};
|
|
5800
|
+
}
|
|
5801
|
+
var In = class {
|
|
4982
5802
|
static capture(e, t) {
|
|
4983
5803
|
return {
|
|
4984
|
-
version:
|
|
5804
|
+
version: G,
|
|
4985
5805
|
timestamp: Date.now(),
|
|
4986
5806
|
chartType: t?.chartType ?? "candlestick",
|
|
4987
5807
|
symbol: t?.symbol,
|
|
@@ -5003,8 +5823,7 @@ var Ot = class {
|
|
|
5003
5823
|
return JSON.stringify(e);
|
|
5004
5824
|
}
|
|
5005
5825
|
static deserialize(e) {
|
|
5006
|
-
|
|
5007
|
-
return t.version !== q && console.warn(`Chart state version mismatch: ${t.version} vs ${q}`), t;
|
|
5826
|
+
return Pn(JSON.parse(e));
|
|
5008
5827
|
}
|
|
5009
5828
|
static saveToStorage(e, t) {
|
|
5010
5829
|
localStorage.setItem(e, this.serialize(t));
|
|
@@ -5031,7 +5850,7 @@ var Ot = class {
|
|
|
5031
5850
|
}, n.click();
|
|
5032
5851
|
});
|
|
5033
5852
|
}
|
|
5034
|
-
},
|
|
5853
|
+
}, Ln = class {
|
|
5035
5854
|
undoStack = [];
|
|
5036
5855
|
redoStack = [];
|
|
5037
5856
|
maxHistory = 50;
|
|
@@ -5067,7 +5886,7 @@ var Ot = class {
|
|
|
5067
5886
|
redoCount: this.redoStack.length
|
|
5068
5887
|
};
|
|
5069
5888
|
}
|
|
5070
|
-
},
|
|
5889
|
+
}, Rn = class {
|
|
5071
5890
|
static toCSV(e) {
|
|
5072
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");
|
|
5073
5892
|
}
|
|
@@ -5085,7 +5904,158 @@ var Ot = class {
|
|
|
5085
5904
|
let r = new Blob([e], { type: n }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
5086
5905
|
a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
5087
5906
|
}
|
|
5088
|
-
},
|
|
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 = {
|
|
5089
6059
|
linear: (e) => e,
|
|
5090
6060
|
easeOutCubic: (e) => 1 - (1 - e) ** 3,
|
|
5091
6061
|
easeOutQuart: (e) => 1 - (1 - e) ** 4,
|
|
@@ -5093,7 +6063,7 @@ var Ot = class {
|
|
|
5093
6063
|
easeOutExpo: (e) => e === 1 ? 1 : 1 - 2 ** (-10 * e),
|
|
5094
6064
|
easeOutElastic: (e) => e === 0 || e === 1 ? e : 2 ** (-10 * e) * Math.sin((e * 10 - .75) * (2 * Math.PI / 3)) + 1,
|
|
5095
6065
|
spring: (e) => 1 - Math.E ** (-6 * e) * Math.cos(8 * e)
|
|
5096
|
-
},
|
|
6066
|
+
}, Wn = class {
|
|
5097
6067
|
animations = /* @__PURE__ */ new Map();
|
|
5098
6068
|
frameId = 0;
|
|
5099
6069
|
running = !1;
|
|
@@ -5101,7 +6071,7 @@ var Ot = class {
|
|
|
5101
6071
|
this.animations.set(e, {
|
|
5102
6072
|
startTime: -1,
|
|
5103
6073
|
duration: t.duration,
|
|
5104
|
-
easing: t.easing ??
|
|
6074
|
+
easing: t.easing ?? Un.easeOutCubic,
|
|
5105
6075
|
onUpdate: t.onUpdate,
|
|
5106
6076
|
onComplete: t.onComplete
|
|
5107
6077
|
}), this.running || (this.running = !0, this.tick());
|
|
@@ -5136,10 +6106,10 @@ var Ot = class {
|
|
|
5136
6106
|
};
|
|
5137
6107
|
//#endregion
|
|
5138
6108
|
//#region src/finance/BaseFinanceChart.ts
|
|
5139
|
-
function
|
|
5140
|
-
return !t || t === "dark" ? e : t === "light" ?
|
|
6109
|
+
function Gn(t) {
|
|
6110
|
+
return !t || t === "dark" ? e : t === "light" ? c : t;
|
|
5141
6111
|
}
|
|
5142
|
-
var
|
|
6112
|
+
var Kn = class {
|
|
5143
6113
|
canvas;
|
|
5144
6114
|
ctx;
|
|
5145
6115
|
container;
|
|
@@ -5150,7 +6120,7 @@ var nn = class {
|
|
|
5150
6120
|
frameId = null;
|
|
5151
6121
|
resizeObserver;
|
|
5152
6122
|
constructor(e, t) {
|
|
5153
|
-
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(() => {
|
|
5154
6124
|
this.updateSize(), this.requestRender();
|
|
5155
6125
|
}), this.resizeObserver.observe(e);
|
|
5156
6126
|
}
|
|
@@ -5165,12 +6135,12 @@ var nn = class {
|
|
|
5165
6135
|
}));
|
|
5166
6136
|
}
|
|
5167
6137
|
setTheme(e) {
|
|
5168
|
-
this.theme =
|
|
6138
|
+
this.theme = Gn(e), this.requestRender();
|
|
5169
6139
|
}
|
|
5170
6140
|
destroy() {
|
|
5171
6141
|
this.frameId !== null && cancelAnimationFrame(this.frameId), this.resizeObserver.disconnect(), this.canvas.remove();
|
|
5172
6142
|
}
|
|
5173
|
-
},
|
|
6143
|
+
}, qn = class {
|
|
5174
6144
|
pos = null;
|
|
5175
6145
|
canvas;
|
|
5176
6146
|
onUpdate;
|
|
@@ -5202,7 +6172,7 @@ var nn = class {
|
|
|
5202
6172
|
};
|
|
5203
6173
|
//#endregion
|
|
5204
6174
|
//#region src/finance/SparklineRenderer.ts
|
|
5205
|
-
function
|
|
6175
|
+
function Jn(e, t, n, r, i) {
|
|
5206
6176
|
let { data: a, mode: o = "area", lineWidth: s = 1.5, showLastPoint: c = !1, showMinMax: l = !1 } = r;
|
|
5207
6177
|
if (a.length < 2 || t <= 0 || n <= 0) return;
|
|
5208
6178
|
let u = r.color ?? i.lineColor, d = r.fillColor ?? u, f = t - 4, p = n - 4, m = Infinity, h = -Infinity, g = 0, _ = 0;
|
|
@@ -5227,8 +6197,8 @@ function an(e, t, n, r, i) {
|
|
|
5227
6197
|
}
|
|
5228
6198
|
//#endregion
|
|
5229
6199
|
//#region src/finance/DepthChartRenderer.ts
|
|
5230
|
-
var
|
|
5231
|
-
function
|
|
6200
|
+
var Yn = 50, Xn = 60, Y = 20, Zn = .2;
|
|
6201
|
+
function Qn(e) {
|
|
5232
6202
|
let t = [...e].sort((e, t) => t.price - e.price), n = [], r = 0;
|
|
5233
6203
|
for (let e of t) r += e.volume, n.push({
|
|
5234
6204
|
price: e.price,
|
|
@@ -5236,7 +6206,7 @@ function ln(e) {
|
|
|
5236
6206
|
});
|
|
5237
6207
|
return n;
|
|
5238
6208
|
}
|
|
5239
|
-
function
|
|
6209
|
+
function $n(e) {
|
|
5240
6210
|
let t = [...e].sort((e, t) => e.price - t.price), n = [], r = 0;
|
|
5241
6211
|
for (let e of t) r += e.volume, n.push({
|
|
5242
6212
|
price: e.price,
|
|
@@ -5244,35 +6214,35 @@ function un(e) {
|
|
|
5244
6214
|
});
|
|
5245
6215
|
return n;
|
|
5246
6216
|
}
|
|
5247
|
-
function
|
|
6217
|
+
function er(e, t) {
|
|
5248
6218
|
return {
|
|
5249
|
-
left:
|
|
5250
|
-
right: e -
|
|
5251
|
-
top:
|
|
5252
|
-
bottom: t -
|
|
5253
|
-
plotWidth: e -
|
|
5254
|
-
plotHeight: t -
|
|
6219
|
+
left: Yn,
|
|
6220
|
+
right: e - Xn,
|
|
6221
|
+
top: Y,
|
|
6222
|
+
bottom: t - Y,
|
|
6223
|
+
plotWidth: e - Yn - Xn,
|
|
6224
|
+
plotHeight: t - Y * 2
|
|
5255
6225
|
};
|
|
5256
6226
|
}
|
|
5257
|
-
function
|
|
6227
|
+
function tr(e, t, n, r) {
|
|
5258
6228
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
5259
6229
|
}
|
|
5260
|
-
function
|
|
5261
|
-
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;
|
|
5262
6232
|
e.save(), e.strokeStyle = a.grid, e.lineWidth = .5, e.fillStyle = a.axisLabel, e.font = `${a.font.sizeSmall}px ${a.font.family}`;
|
|
5263
|
-
let h =
|
|
6233
|
+
let h = m(0, i, 5);
|
|
5264
6234
|
for (let t = 0; t <= i; t += h) {
|
|
5265
|
-
let n = d - t / i *
|
|
6235
|
+
let n = d - t / i * p;
|
|
5266
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);
|
|
5267
6237
|
}
|
|
5268
|
-
let g = r - n, _ =
|
|
6238
|
+
let g = r - n, _ = m(n, r, 6), v = Math.ceil(n / _) * _;
|
|
5269
6239
|
for (let t = v; t <= r; t += _) {
|
|
5270
|
-
let r = c + (t - n) / g *
|
|
6240
|
+
let r = c + (t - n) / g * f;
|
|
5271
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);
|
|
5272
6242
|
}
|
|
5273
6243
|
e.restore();
|
|
5274
6244
|
}
|
|
5275
|
-
function
|
|
6245
|
+
function rr(e, t, n, r, i, a, o, s, c) {
|
|
5276
6246
|
if (t.length === 0) return;
|
|
5277
6247
|
let { left: l, bottom: u, plotWidth: d, plotHeight: f } = n, p = (e) => l + (e - r) / i * d, m = (e) => u - e / a * f;
|
|
5278
6248
|
if (e.beginPath(), c === "bid") {
|
|
@@ -5305,14 +6275,14 @@ function mn(e, t, n, r, i, a, o, s, c) {
|
|
|
5305
6275
|
}
|
|
5306
6276
|
e.strokeStyle = s, e.lineWidth = 1.5, e.stroke();
|
|
5307
6277
|
}
|
|
5308
|
-
function
|
|
6278
|
+
function ir(e, t, n, r, i, a, o, s, c) {
|
|
5309
6279
|
let { left: l, top: u, bottom: d, plotWidth: f } = r, p = l + (t - i) / a * f;
|
|
5310
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) {
|
|
5311
6281
|
let t = `Spread: ${c(n)}`;
|
|
5312
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();
|
|
5313
6283
|
}
|
|
5314
6284
|
}
|
|
5315
|
-
function
|
|
6285
|
+
function ar(e, t, n, r, i, a, o, s, c, l, u) {
|
|
5316
6286
|
let { left: d, top: f, bottom: p, plotWidth: m, plotHeight: h } = i, g = t.x;
|
|
5317
6287
|
if (g < d || g > i.right) return;
|
|
5318
6288
|
let _ = a + (g - d) / m * o, v = 0, y = "";
|
|
@@ -5338,47 +6308,47 @@ function gn(e, t, n, r, i, a, o, s, c, l, u) {
|
|
|
5338
6308
|
for (let t = 0; t < b.length; t++) e.fillText(b[t], C + 8, w + 6 + t * (c.font.sizeSmall + 4));
|
|
5339
6309
|
e.restore();
|
|
5340
6310
|
}
|
|
5341
|
-
function
|
|
6311
|
+
function or(e) {
|
|
5342
6312
|
return e.toFixed(2);
|
|
5343
6313
|
}
|
|
5344
|
-
function
|
|
6314
|
+
function sr(e) {
|
|
5345
6315
|
return e >= 1e6 ? (e / 1e6).toFixed(2) + "M" : e >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(0);
|
|
5346
6316
|
}
|
|
5347
|
-
function
|
|
6317
|
+
function cr(e, t, n, r, i, a) {
|
|
5348
6318
|
let { data: o } = r;
|
|
5349
6319
|
if (o.bids.length === 0 && o.asks.length === 0 || t <= 0 || n <= 0) return;
|
|
5350
|
-
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 ??
|
|
5351
|
-
|
|
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);
|
|
5352
6322
|
}
|
|
5353
6323
|
//#endregion
|
|
5354
6324
|
//#region src/finance/EquityCurveRenderer.ts
|
|
5355
|
-
var
|
|
5356
|
-
function
|
|
6325
|
+
var lr = 70, ur = 30, dr = 20, fr = 20, pr = .05;
|
|
6326
|
+
function mr(e, t) {
|
|
5357
6327
|
return {
|
|
5358
|
-
left:
|
|
5359
|
-
right: e -
|
|
5360
|
-
top:
|
|
5361
|
-
bottom: t -
|
|
5362
|
-
plotWidth: e -
|
|
5363
|
-
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
|
|
5364
6334
|
};
|
|
5365
6335
|
}
|
|
5366
|
-
function
|
|
6336
|
+
function hr(e, t) {
|
|
5367
6337
|
let n = Infinity, r = -Infinity;
|
|
5368
6338
|
for (let t of e) t.value < n && (n = t.value), t.value > r && (r = t.value);
|
|
5369
6339
|
if (t) for (let e of t) e.value < n && (n = e.value), e.value > r && (r = e.value);
|
|
5370
|
-
let i = (r - n) *
|
|
6340
|
+
let i = (r - n) * pr;
|
|
5371
6341
|
return {
|
|
5372
6342
|
valMin: n - i,
|
|
5373
6343
|
valMax: r + i
|
|
5374
6344
|
};
|
|
5375
6345
|
}
|
|
5376
|
-
function
|
|
6346
|
+
function gr(e) {
|
|
5377
6347
|
let t = [], n = -Infinity;
|
|
5378
6348
|
for (let r of e) r.value > n && (n = r.value), t.push(n);
|
|
5379
6349
|
return t;
|
|
5380
6350
|
}
|
|
5381
|
-
function
|
|
6351
|
+
function _r(e) {
|
|
5382
6352
|
let t = 864e5;
|
|
5383
6353
|
if (365.25 * t, e < 7 * t) {
|
|
5384
6354
|
let e = new Intl.DateTimeFormat(void 0, {
|
|
@@ -5400,42 +6370,42 @@ function On(e) {
|
|
|
5400
6370
|
});
|
|
5401
6371
|
return (e) => n.format(new Date(e));
|
|
5402
6372
|
}
|
|
5403
|
-
function
|
|
6373
|
+
function vr(e) {
|
|
5404
6374
|
return Math.abs(e) >= 1e6 ? (e / 1e6).toFixed(2) + "M" : Math.abs(e) >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(2);
|
|
5405
6375
|
}
|
|
5406
|
-
function
|
|
6376
|
+
function yr(e, t, n, r) {
|
|
5407
6377
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
5408
6378
|
}
|
|
5409
|
-
function
|
|
5410
|
-
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;
|
|
5411
6381
|
e.save(), e.strokeStyle = o.grid, e.lineWidth = .5, e.fillStyle = o.axisLabel, e.font = `${o.font.sizeSmall}px ${o.font.family}`;
|
|
5412
|
-
let g =
|
|
6382
|
+
let g = m(n, r, 6), _ = Math.ceil(n / g) * g;
|
|
5413
6383
|
for (let t = _; t <= r; t += g) {
|
|
5414
|
-
let i =
|
|
6384
|
+
let i = f - (t - n) / (r - n) * h;
|
|
5415
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);
|
|
5416
6386
|
}
|
|
5417
|
-
let v = a - i, y =
|
|
6387
|
+
let v = a - i, y = m(i, a, 6), b = Math.ceil(i / y) * y;
|
|
5418
6388
|
for (let t = b; t <= a; t += y) {
|
|
5419
|
-
let n = l + (t - i) / v *
|
|
5420
|
-
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);
|
|
5421
6391
|
}
|
|
5422
6392
|
e.restore();
|
|
5423
6393
|
}
|
|
5424
|
-
function
|
|
6394
|
+
function xr(e, t, n, r, i, a, o, s, c) {
|
|
5425
6395
|
if (t.length < 2) return;
|
|
5426
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;
|
|
5427
6397
|
e.save(), e.beginPath(), e.moveTo(p(t[0].time), m(t[0].value));
|
|
5428
6398
|
for (let n = 1; n < t.length; n++) e.lineTo(p(t[n].time), m(t[n].value));
|
|
5429
6399
|
e.strokeStyle = s, e.lineWidth = c, e.lineJoin = "round", e.stroke(), e.restore();
|
|
5430
6400
|
}
|
|
5431
|
-
function
|
|
6401
|
+
function Sr(e, t, n, r, i, a, o, s) {
|
|
5432
6402
|
if (t.length < 2) return;
|
|
5433
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);
|
|
5434
6404
|
m.addColorStop(0, s + "40"), m.addColorStop(1, "transparent"), e.save(), e.beginPath(), e.moveTo(f(t[0].time), p(t[0].value));
|
|
5435
6405
|
for (let n = 1; n < t.length; n++) e.lineTo(f(t[n].time), p(t[n].value));
|
|
5436
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();
|
|
5437
6407
|
}
|
|
5438
|
-
function
|
|
6408
|
+
function Cr(e, t, n, r, i, a, o, s, c) {
|
|
5439
6409
|
if (t.length < 2) return;
|
|
5440
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;
|
|
5441
6411
|
e.save(), e.fillStyle = c, e.beginPath(), e.moveTo(p(t[0].time), m(n[0]));
|
|
@@ -5443,12 +6413,12 @@ function Pn(e, t, n, r, i, a, o, s, c) {
|
|
|
5443
6413
|
for (let n = t.length - 1; n >= 0; n--) e.lineTo(p(t[n].time), m(t[n].value));
|
|
5444
6414
|
e.closePath(), e.fill(), e.restore();
|
|
5445
6415
|
}
|
|
5446
|
-
function
|
|
6416
|
+
function wr(e, t, n, r, i, a, o, s, c, l) {
|
|
5447
6417
|
if (t.length === 0) return;
|
|
5448
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;
|
|
5449
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();
|
|
5450
6420
|
}
|
|
5451
|
-
function
|
|
6421
|
+
function Tr(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
5452
6422
|
let { left: f, top: p, bottom: m, plotWidth: h, plotHeight: g } = i, _ = t.x;
|
|
5453
6423
|
if (_ < f || _ > i.right) return;
|
|
5454
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();
|
|
@@ -5466,15 +6436,15 @@ function In(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
5466
6436
|
for (let t = 0; t < S.length; t++) e.fillText(S[t], D + 8, O + 6 + t * (l.font.sizeSmall + 4));
|
|
5467
6437
|
e.restore();
|
|
5468
6438
|
}
|
|
5469
|
-
function
|
|
6439
|
+
function Er(e, t, n, r, i, a) {
|
|
5470
6440
|
let { data: o } = r;
|
|
5471
6441
|
if (o.length < 2 || t <= 0 || n <= 0) return;
|
|
5472
|
-
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 ??
|
|
5473
|
-
|
|
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);
|
|
5474
6444
|
}
|
|
5475
6445
|
//#endregion
|
|
5476
6446
|
//#region src/finance/HeatmapLayout.ts
|
|
5477
|
-
function
|
|
6447
|
+
function Dr(e, t, n) {
|
|
5478
6448
|
if (e.length === 0) return [];
|
|
5479
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 = [];
|
|
5480
6450
|
for (let a = 0; a < r; a++) {
|
|
@@ -5491,7 +6461,7 @@ function Rn(e, t, n) {
|
|
|
5491
6461
|
}
|
|
5492
6462
|
return c;
|
|
5493
6463
|
}
|
|
5494
|
-
function
|
|
6464
|
+
function Or(e, t) {
|
|
5495
6465
|
let n = e.reduce((e, t) => e + t, 0);
|
|
5496
6466
|
if (n === 0 || t === 0) return Infinity;
|
|
5497
6467
|
let r = 0;
|
|
@@ -5501,7 +6471,7 @@ function zn(e, t) {
|
|
|
5501
6471
|
}
|
|
5502
6472
|
return r;
|
|
5503
6473
|
}
|
|
5504
|
-
function
|
|
6474
|
+
function X(e, t, n, r, i, a) {
|
|
5505
6475
|
let o = r ? n.height : n.width, s = e.reduce((e, t) => e + t, 0), c = o > 0 ? s / o : 0, l = 0;
|
|
5506
6476
|
for (let o = 0; o < e.length; o++) {
|
|
5507
6477
|
let s = c > 0 ? e[o] / c : 0, u;
|
|
@@ -5521,19 +6491,19 @@ function Y(e, t, n, r, i, a) {
|
|
|
5521
6491
|
}), l += s;
|
|
5522
6492
|
}
|
|
5523
6493
|
}
|
|
5524
|
-
function
|
|
6494
|
+
function kr(e, t, n, r, i) {
|
|
5525
6495
|
if (e.length === 0) return;
|
|
5526
6496
|
let a = n.width >= n.height, o = a ? n.height : n.width;
|
|
5527
6497
|
if (e.length === 1) {
|
|
5528
|
-
|
|
6498
|
+
X(e, t, n, a, r, i);
|
|
5529
6499
|
return;
|
|
5530
6500
|
}
|
|
5531
6501
|
let s = [], c = [], l = 0;
|
|
5532
6502
|
for (; l < e.length;) {
|
|
5533
6503
|
let u = [...s, e[l]];
|
|
5534
|
-
if (s.length === 0 ||
|
|
6504
|
+
if (s.length === 0 || Or(u, o) <= Or(s, o)) s.push(e[l]), c.push(t[l]), l++;
|
|
5535
6505
|
else {
|
|
5536
|
-
|
|
6506
|
+
X(s, c, n, a, r, i);
|
|
5537
6507
|
let u = s.reduce((e, t) => e + t, 0), d = o > 0 ? u / o : 0;
|
|
5538
6508
|
n = a ? {
|
|
5539
6509
|
x: n.x + d,
|
|
@@ -5545,43 +6515,43 @@ function Bn(e, t, n, r, i) {
|
|
|
5545
6515
|
y: n.y + d,
|
|
5546
6516
|
width: n.width,
|
|
5547
6517
|
height: n.height - d
|
|
5548
|
-
},
|
|
6518
|
+
}, kr(e.slice(l), t.slice(l), n, r, i);
|
|
5549
6519
|
return;
|
|
5550
6520
|
}
|
|
5551
6521
|
}
|
|
5552
|
-
s.length > 0 &&
|
|
6522
|
+
s.length > 0 && X(s, c, n, a, r, i);
|
|
5553
6523
|
}
|
|
5554
|
-
function
|
|
6524
|
+
function Ar(e, t, n) {
|
|
5555
6525
|
if (e.length === 0) return [];
|
|
5556
6526
|
let r = [...e].sort((e, t) => t.weight - e.weight), i = r.reduce((e, t) => e + Math.max(0, t.weight), 0);
|
|
5557
6527
|
if (i === 0) return [];
|
|
5558
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 = [];
|
|
5559
|
-
return
|
|
6529
|
+
return kr(o, s, { ...t }, n, c), c;
|
|
5560
6530
|
}
|
|
5561
6531
|
//#endregion
|
|
5562
6532
|
//#region src/finance/HeatmapRenderer.ts
|
|
5563
|
-
function
|
|
6533
|
+
function jr(e) {
|
|
5564
6534
|
return (e >= 0 ? "+" : "") + e.toFixed(2) + "%";
|
|
5565
6535
|
}
|
|
5566
|
-
function
|
|
6536
|
+
function Mr(e) {
|
|
5567
6537
|
return e.label;
|
|
5568
6538
|
}
|
|
5569
|
-
function
|
|
6539
|
+
function Nr(e, t) {
|
|
5570
6540
|
let n = t.min ?? -5, r = t.max ?? 5;
|
|
5571
6541
|
if (e <= n) return t.negative;
|
|
5572
6542
|
if (e >= r) return t.positive;
|
|
5573
6543
|
if (e < 0) {
|
|
5574
6544
|
let r = 1 - e / n;
|
|
5575
|
-
return
|
|
6545
|
+
return g(t.negative, t.zero, r);
|
|
5576
6546
|
}
|
|
5577
6547
|
let i = e / r;
|
|
5578
|
-
return
|
|
6548
|
+
return g(t.zero, t.positive, i);
|
|
5579
6549
|
}
|
|
5580
|
-
function
|
|
6550
|
+
function Z(e, t, n, r, i, a) {
|
|
5581
6551
|
let o = Math.min(a, r / 2, i / 2);
|
|
5582
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();
|
|
5583
6553
|
}
|
|
5584
|
-
function
|
|
6554
|
+
function Pr(e, t, n, r, i, a, o, s, c, l, u) {
|
|
5585
6555
|
if (i < 40 || a < 30) return;
|
|
5586
6556
|
let d = n + i / 2, f = r + a / 2;
|
|
5587
6557
|
if (e.save(), e.shadowColor = "rgba(0,0,0,0.6)", e.shadowBlur = 2, e.fillStyle = "#FFFFFF", e.textAlign = "center", s) {
|
|
@@ -5594,22 +6564,22 @@ function Gn(e, t, n, r, i, a, o, s, c, l, u) {
|
|
|
5594
6564
|
}
|
|
5595
6565
|
e.restore();
|
|
5596
6566
|
}
|
|
5597
|
-
function
|
|
6567
|
+
function Fr(e, t, n, r, i, a, o, s) {
|
|
5598
6568
|
let c = [o(t), s(t.value)];
|
|
5599
6569
|
if (t.meta) for (let [e, n] of Object.entries(t.meta)) c.push(e + ": " + String(n));
|
|
5600
6570
|
e.save(), e.font = a.font.sizeSmall + "px " + a.font.family;
|
|
5601
6571
|
let l = Math.max(...c.map((t) => e.measureText(t).width)) + 16, u = a.font.sizeSmall + 4, d = c.length * u + 12, f = n.x + 14, p = n.y - d / 2;
|
|
5602
|
-
f + l > r && (f = n.x - l - 14), p < 0 && (p = 0), p + d > i && (p = i - d), e.fillStyle = a.axisLabelBackground, e.globalAlpha = .92,
|
|
6572
|
+
f + l > r && (f = n.x - l - 14), p < 0 && (p = 0), p + d > i && (p = i - d), e.fillStyle = a.axisLabelBackground, e.globalAlpha = .92, Z(e, f, p, l, d, 4), e.fill(), e.globalAlpha = 1, e.fillStyle = a.text, e.textBaseline = "top", e.textAlign = "left";
|
|
5603
6573
|
for (let t = 0; t < c.length; t++) e.fillText(c[t], f + 8, p + 6 + t * u);
|
|
5604
6574
|
e.restore();
|
|
5605
6575
|
}
|
|
5606
|
-
function
|
|
6576
|
+
function Ir(e, t, n, r, i, a, o, s) {
|
|
5607
6577
|
if (r.length === 0 || i.length === 0 || t <= 0 || n <= 0) return null;
|
|
5608
6578
|
let c = a.colorScale ?? {
|
|
5609
6579
|
negative: "#EF5350",
|
|
5610
6580
|
zero: "#424242",
|
|
5611
6581
|
positive: "#26A69A"
|
|
5612
|
-
}, 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();
|
|
5613
6583
|
for (let e of r) m.set(e.id, e);
|
|
5614
6584
|
let h = null, g = null;
|
|
5615
6585
|
if (s) for (let e of i) {
|
|
@@ -5630,37 +6600,37 @@ function qn(e, t, n, r, i, a, o, s) {
|
|
|
5630
6600
|
if (!n) continue;
|
|
5631
6601
|
let { x: r, y: i, width: a, height: s } = t.rect;
|
|
5632
6602
|
if (a <= 0 || s <= 0) continue;
|
|
5633
|
-
let g =
|
|
5634
|
-
|
|
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());
|
|
5635
6605
|
}
|
|
5636
|
-
return g && s &&
|
|
6606
|
+
return g && s && Fr(e, g.cell, s, t, n, o, p, f), g;
|
|
5637
6607
|
}
|
|
5638
6608
|
//#endregion
|
|
5639
6609
|
//#region src/finance/WaterfallRenderer.ts
|
|
5640
|
-
var
|
|
5641
|
-
function
|
|
6610
|
+
var Lr = 60, Rr = 12, zr = 24, Br = 40, Vr = .7, Hr = 1;
|
|
6611
|
+
function Ur(e) {
|
|
5642
6612
|
return e.type ? e.type : e.value > 0 ? "positive" : e.value < 0 ? "negative" : "subtotal";
|
|
5643
6613
|
}
|
|
5644
|
-
function
|
|
6614
|
+
function Wr(e) {
|
|
5645
6615
|
let t = Math.abs(e);
|
|
5646
6616
|
return t >= 1e6 ? (e / 1e6).toFixed(2) + "M" : t >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(2);
|
|
5647
6617
|
}
|
|
5648
|
-
function
|
|
6618
|
+
function Gr(e, t) {
|
|
5649
6619
|
return {
|
|
5650
|
-
left:
|
|
5651
|
-
right: e -
|
|
5652
|
-
top:
|
|
5653
|
-
bottom: t -
|
|
5654
|
-
plotWidth: e -
|
|
5655
|
-
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
|
|
5656
6626
|
};
|
|
5657
6627
|
}
|
|
5658
|
-
function
|
|
6628
|
+
function Kr(e, t, n, r, i) {
|
|
5659
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;
|
|
5660
6630
|
for (let t = 0; t < e.length; t++) {
|
|
5661
|
-
let n = e[t], m =
|
|
6631
|
+
let n = e[t], m = Ur(n), h, g;
|
|
5662
6632
|
m === "total" || m === "subtotal" ? (h = 0, g = n.value, p = n.value) : (h = p, g = p + n.value, p = g);
|
|
5663
|
-
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;
|
|
5664
6634
|
a[t] = {
|
|
5665
6635
|
label: n.label,
|
|
5666
6636
|
value: n.value,
|
|
@@ -5680,14 +6650,14 @@ function nr(e, t, n, r, i) {
|
|
|
5680
6650
|
cumulatives: o
|
|
5681
6651
|
};
|
|
5682
6652
|
}
|
|
5683
|
-
function
|
|
6653
|
+
function qr(e) {
|
|
5684
6654
|
if (e.length === 0) return {
|
|
5685
6655
|
valMin: 0,
|
|
5686
6656
|
valMax: 1
|
|
5687
6657
|
};
|
|
5688
6658
|
let t = 0, n = 0, r = 0;
|
|
5689
6659
|
for (let i = 0; i < e.length; i++) {
|
|
5690
|
-
let a = e[i], o =
|
|
6660
|
+
let a = e[i], o = Ur(a), s, c;
|
|
5691
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);
|
|
5692
6662
|
}
|
|
5693
6663
|
let i = (n - t || 1) * .1;
|
|
@@ -5696,20 +6666,20 @@ function rr(e) {
|
|
|
5696
6666
|
valMax: n + i
|
|
5697
6667
|
};
|
|
5698
6668
|
}
|
|
5699
|
-
function
|
|
6669
|
+
function Jr(e, t, n, r) {
|
|
5700
6670
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
5701
6671
|
}
|
|
5702
|
-
function
|
|
6672
|
+
function Yr(e, t, n, r, i, a) {
|
|
5703
6673
|
let { left: o, right: s, top: c, bottom: l, plotHeight: u } = t, d = r - n || 1;
|
|
5704
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";
|
|
5705
|
-
let
|
|
6675
|
+
let f = m(n, r, 5), p = Math.ceil(n / f) * f;
|
|
5706
6676
|
e.beginPath();
|
|
5707
|
-
for (let t =
|
|
6677
|
+
for (let t = p; t <= r; t += f) {
|
|
5708
6678
|
let r = Math.round(l - (t - n) / d * u) + .5;
|
|
5709
6679
|
r < c || r > l || (e.moveTo(o, r), e.lineTo(s, r));
|
|
5710
6680
|
}
|
|
5711
6681
|
e.stroke();
|
|
5712
|
-
for (let t =
|
|
6682
|
+
for (let t = p; t <= r; t += f) {
|
|
5713
6683
|
let r = l - (t - n) / d * u;
|
|
5714
6684
|
r < c - 1 || r > l + 1 || e.fillText(a(t), o - 6, r);
|
|
5715
6685
|
}
|
|
@@ -5718,7 +6688,7 @@ function ar(e, t, n, r, i, a) {
|
|
|
5718
6688
|
e.strokeStyle = i.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(o, t), e.lineTo(s, t), e.stroke();
|
|
5719
6689
|
}
|
|
5720
6690
|
}
|
|
5721
|
-
function
|
|
6691
|
+
function Xr(e, t, n) {
|
|
5722
6692
|
let r = [
|
|
5723
6693
|
"positive",
|
|
5724
6694
|
"negative",
|
|
@@ -5737,7 +6707,7 @@ function or(e, t, n) {
|
|
|
5737
6707
|
s && (e.fillStyle = o, e.fill());
|
|
5738
6708
|
}
|
|
5739
6709
|
}
|
|
5740
|
-
function
|
|
6710
|
+
function Zr(e, t, n, r, i, a, o) {
|
|
5741
6711
|
if (o === "none" || t.length < 2) return;
|
|
5742
6712
|
let { bottom: s, plotHeight: c } = n;
|
|
5743
6713
|
e.strokeStyle = a, e.lineWidth = 1, o === "dashed" ? e.setLineDash([4, 4]) : e.setLineDash([]), e.beginPath();
|
|
@@ -5747,7 +6717,7 @@ function sr(e, t, n, r, i, a, o) {
|
|
|
5747
6717
|
}
|
|
5748
6718
|
e.stroke(), e.setLineDash([]);
|
|
5749
6719
|
}
|
|
5750
|
-
function
|
|
6720
|
+
function Qr(e, t, n, r, i, a) {
|
|
5751
6721
|
e.fillStyle = r.text, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center";
|
|
5752
6722
|
for (let r = 0; r < t.length; r++) {
|
|
5753
6723
|
let o = t[r], s;
|
|
@@ -5756,7 +6726,7 @@ function cr(e, t, n, r, i, a) {
|
|
|
5756
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));
|
|
5757
6727
|
}
|
|
5758
6728
|
}
|
|
5759
|
-
function
|
|
6729
|
+
function $r(e, t, n, r, i) {
|
|
5760
6730
|
e.fillStyle = r.axisLabel, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center", e.textBaseline = "top";
|
|
5761
6731
|
let a = n.bottom + 6, o = t.length > 0 ? t[0].slotW - 4 : 0, s = !1;
|
|
5762
6732
|
for (let n = 0; n < t.length; n++) if (e.measureText(i(t[n].label)).width > o) {
|
|
@@ -5777,7 +6747,7 @@ function lr(e, t, n, r, i) {
|
|
|
5777
6747
|
}
|
|
5778
6748
|
e.setTransform(1, 0, 0, 1, 0, 0), e.restore();
|
|
5779
6749
|
}
|
|
5780
|
-
function
|
|
6750
|
+
function ei(e, t, n) {
|
|
5781
6751
|
if (t < n.left || t > n.right) return null;
|
|
5782
6752
|
for (let n = 0; n < e.length; n++) {
|
|
5783
6753
|
let r = e[n];
|
|
@@ -5785,7 +6755,7 @@ function ur(e, t, n) {
|
|
|
5785
6755
|
}
|
|
5786
6756
|
return null;
|
|
5787
6757
|
}
|
|
5788
|
-
function
|
|
6758
|
+
function ti(e, t, n, r, i, a, o, s) {
|
|
5789
6759
|
let c = t[r], l = n[r], u = Math.round(c.slotX + c.slotW / 2) + .5;
|
|
5790
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([]);
|
|
5791
6761
|
let d = [
|
|
@@ -5804,31 +6774,31 @@ function dr(e, t, n, r, i, a, o, s) {
|
|
|
5804
6774
|
let _ = o.font.sizeSmall + 4;
|
|
5805
6775
|
for (let t = 0; t < d.length; t++) e.fillText(d[t], h + 8, g + 6 + t * _);
|
|
5806
6776
|
}
|
|
5807
|
-
function
|
|
6777
|
+
function ni(e, t, n, r, i, a) {
|
|
5808
6778
|
let { data: o } = r;
|
|
5809
6779
|
if (!o || o.length === 0 || t <= 0 || n <= 0) return { hitBar: null };
|
|
5810
|
-
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 ??
|
|
5811
|
-
|
|
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, {
|
|
5812
6782
|
positive: s,
|
|
5813
6783
|
negative: c,
|
|
5814
6784
|
total: l,
|
|
5815
6785
|
subtotal: u
|
|
5816
|
-
}), m &&
|
|
5817
|
-
let w = a ?
|
|
5818
|
-
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 };
|
|
5819
6789
|
}
|
|
5820
6790
|
//#endregion
|
|
5821
6791
|
//#region src/finance/GaugeRenderer.ts
|
|
5822
|
-
var
|
|
5823
|
-
function
|
|
6792
|
+
var ri = Math.PI / 180, ii = 135, ai = 405, oi = .25;
|
|
6793
|
+
function si(e) {
|
|
5824
6794
|
let t = Math.abs(e);
|
|
5825
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);
|
|
5826
6796
|
}
|
|
5827
6797
|
function Q(e, t, n) {
|
|
5828
6798
|
return e < t ? t : e > n ? n : e;
|
|
5829
6799
|
}
|
|
5830
|
-
function
|
|
5831
|
-
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);
|
|
5832
6802
|
return {
|
|
5833
6803
|
cx: l,
|
|
5834
6804
|
cy: u,
|
|
@@ -5846,38 +6816,38 @@ function $(e, t) {
|
|
|
5846
6816
|
let n = Q((e - t.min) / t.range, 0, 1);
|
|
5847
6817
|
return t.startAngle + t.angleRange * n;
|
|
5848
6818
|
}
|
|
5849
|
-
function
|
|
6819
|
+
function li(e, t, n, r) {
|
|
5850
6820
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
5851
6821
|
}
|
|
5852
|
-
function
|
|
6822
|
+
function ui(e, t, n) {
|
|
5853
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();
|
|
5854
6824
|
}
|
|
5855
|
-
function
|
|
6825
|
+
function di(e, t, n) {
|
|
5856
6826
|
let r = Q(n.from, t.min, t.max), i = Q(n.to, t.min, t.max);
|
|
5857
6827
|
if (i <= r) return;
|
|
5858
6828
|
let a = $(r, t), o = $(i, t);
|
|
5859
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();
|
|
5860
6830
|
}
|
|
5861
|
-
function
|
|
6831
|
+
function fi(e, t, n, r, i) {
|
|
5862
6832
|
let a = $(n, t);
|
|
5863
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);
|
|
5864
6834
|
}
|
|
5865
|
-
function
|
|
6835
|
+
function pi(e, t, n, r) {
|
|
5866
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;
|
|
5867
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();
|
|
5868
6838
|
}
|
|
5869
|
-
function
|
|
6839
|
+
function mi(e, t, n, r, i) {
|
|
5870
6840
|
let a = Math.round(t.innerRadius * .55), o = Math.round(i.font.sizeMedium);
|
|
5871
6841
|
e.fillStyle = i.text, e.textAlign = "center", e.textBaseline = "middle", e.font = `600 ${a}px ${i.font.family}`;
|
|
5872
6842
|
let s = !!r, c = s ? t.cy - o * .6 : t.cy - a * .1;
|
|
5873
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));
|
|
5874
6844
|
}
|
|
5875
|
-
function
|
|
6845
|
+
function hi(e, t, n, r) {
|
|
5876
6846
|
e.fillStyle = r.textSecondary, e.font = `${r.font.sizeSmall}px ${r.font.family}`;
|
|
5877
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;
|
|
5878
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);
|
|
5879
6849
|
}
|
|
5880
|
-
function
|
|
6850
|
+
function gi(e, t, n, r) {
|
|
5881
6851
|
e.fillStyle = r.textSecondary, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
5882
6852
|
let i = (t.radius + t.innerRadius) / 2;
|
|
5883
6853
|
for (let r = 0; r < n.length; r++) {
|
|
@@ -5887,15 +6857,15 @@ function Er(e, t, n, r) {
|
|
|
5887
6857
|
e.fillText(a.label, s, c);
|
|
5888
6858
|
}
|
|
5889
6859
|
}
|
|
5890
|
-
function
|
|
6860
|
+
function _i(e, t, n, r, i, a) {
|
|
5891
6861
|
if (t <= 0 || n <= 0) return;
|
|
5892
|
-
let o =
|
|
5893
|
-
|
|
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);
|
|
5894
6864
|
let p = r.zones;
|
|
5895
|
-
if (p && p.length > 0) for (let t = 0; t < p.length; t++)
|
|
5896
|
-
|
|
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);
|
|
5897
6867
|
}
|
|
5898
6868
|
//#endregion
|
|
5899
|
-
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 };
|
|
5900
6870
|
|
|
5901
6871
|
//# sourceMappingURL=index.js.map
|