@tradecanvas/core 0.3.0 → 0.4.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/dist/axis/PriceAxis.d.ts +2 -0
- package/dist/axis/PriceAxis.d.ts.map +1 -1
- package/dist/drawings/DrawingManager.d.ts.map +1 -1
- package/dist/engine/RenderEngine.d.ts +2 -0
- package/dist/engine/RenderEngine.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +327 -294
- package/dist/index.js.map +1 -1
- package/dist/interaction/CrosshairHandler.d.ts +2 -0
- package/dist/interaction/CrosshairHandler.d.ts.map +1 -1
- package/dist/interaction/InteractionManager.d.ts +4 -0
- package/dist/interaction/InteractionManager.d.ts.map +1 -1
- package/dist/realtime/StreamManager.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -200,7 +200,7 @@ var D = class {
|
|
|
200
200
|
render(e) {
|
|
201
201
|
let t = this.renderCtx;
|
|
202
202
|
if (!t) return;
|
|
203
|
-
let { viewport: n, theme: r, data: i } = t;
|
|
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
205
|
if (e.has(s.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(s.Main) && this.mainLayer) {
|
|
206
206
|
this.mainLayer.clear();
|
|
@@ -236,42 +236,42 @@ var D = class {
|
|
|
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(),
|
|
240
|
-
if (
|
|
241
|
-
let e =
|
|
242
|
-
|
|
243
|
-
for (let t of e)
|
|
239
|
+
let n = t.crosshairHandler?.getPosition(), o = t.indicatorEngine, s = `${r.font.sizeSmall}px ${r.font.family}`, l;
|
|
240
|
+
if (o) {
|
|
241
|
+
let e = o.getPanelIndicators();
|
|
242
|
+
l = /* @__PURE__ */ new Map();
|
|
243
|
+
for (let t of e) l.set(t.instanceId, t);
|
|
244
244
|
}
|
|
245
|
-
for (let
|
|
246
|
-
let t =
|
|
247
|
-
if (
|
|
248
|
-
let
|
|
249
|
-
e.strokeStyle = r.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(
|
|
250
|
-
let
|
|
251
|
-
e.font =
|
|
252
|
-
for (let n =
|
|
245
|
+
for (let u of t.panels) {
|
|
246
|
+
let t = u.viewport, d = u.rect, { min: m, max: h } = t.priceRange;
|
|
247
|
+
if (h - m <= 0 || d.height <= 0) continue;
|
|
248
|
+
let g = d.x + d.width, _ = t.chartRect;
|
|
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(m, h, 4), y = Math.ceil(m / v) * v, b = v < 1 ? Math.ceil(-Math.log10(v)) + 1 : +(v < 10);
|
|
251
|
+
e.font = s, e.textBaseline = "middle", e.textAlign = "left";
|
|
252
|
+
for (let n = y; n <= h; n += v) {
|
|
253
253
|
let i = C(n, t);
|
|
254
|
-
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(p(n, b, a), g + 6, i));
|
|
255
255
|
}
|
|
256
|
-
if (n && n.x >=
|
|
257
|
-
let i = p(T(n.y, t),
|
|
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 = p(T(n.y, t), b, a);
|
|
258
258
|
e.font = `bold ${r.font.sizeSmall}px ${r.font.family}`;
|
|
259
|
-
let
|
|
260
|
-
e.fillStyle = r.crosshair, e.fillRect(
|
|
259
|
+
let o = e.measureText(i).width, s = Math.min(o + 10, c - 2);
|
|
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
|
-
if (n &&
|
|
263
|
-
let
|
|
264
|
-
if (f?.series &&
|
|
265
|
-
let t = f.series[
|
|
262
|
+
if (n && o) {
|
|
263
|
+
let a = w(n.x, t), c = Math.max(0, Math.min((i?.length ?? 1) - 1, Math.round(a))), f = o.getOutput(u.instanceId);
|
|
264
|
+
if (f?.series && c < f.series.length) {
|
|
265
|
+
let t = f.series[c];
|
|
266
266
|
if (t) {
|
|
267
267
|
let n = [];
|
|
268
268
|
for (let e in t) {
|
|
269
269
|
let r = t[e];
|
|
270
|
-
r !== void 0 && n.push(`${e}: ${r.toFixed(
|
|
270
|
+
r !== void 0 && n.push(`${e}: ${r.toFixed(b)}`);
|
|
271
271
|
}
|
|
272
272
|
if (n.length > 0) {
|
|
273
|
-
let t =
|
|
274
|
-
e.font =
|
|
273
|
+
let t = l?.get(u.instanceId), i = t ? e.measureText(t.descriptor.name).width + 14 : 10;
|
|
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
|
}
|
|
277
277
|
}
|
|
@@ -957,7 +957,7 @@ var j = class {
|
|
|
957
957
|
});
|
|
958
958
|
return e;
|
|
959
959
|
}
|
|
960
|
-
},
|
|
960
|
+
}, ve = class extends j {
|
|
961
961
|
descriptor = {
|
|
962
962
|
id: "sma",
|
|
963
963
|
name: "Simple Moving Average",
|
|
@@ -989,7 +989,7 @@ var j = class {
|
|
|
989
989
|
}
|
|
990
990
|
e.stroke();
|
|
991
991
|
}
|
|
992
|
-
},
|
|
992
|
+
}, ye = class extends j {
|
|
993
993
|
descriptor = {
|
|
994
994
|
id: "ema",
|
|
995
995
|
name: "Exponential Moving Average",
|
|
@@ -1026,7 +1026,7 @@ var j = class {
|
|
|
1026
1026
|
}
|
|
1027
1027
|
e.stroke();
|
|
1028
1028
|
}
|
|
1029
|
-
},
|
|
1029
|
+
}, be = class extends j {
|
|
1030
1030
|
descriptor = {
|
|
1031
1031
|
id: "bb",
|
|
1032
1032
|
name: "Bollinger Bands",
|
|
@@ -1081,7 +1081,7 @@ var j = class {
|
|
|
1081
1081
|
e.stroke();
|
|
1082
1082
|
}
|
|
1083
1083
|
}
|
|
1084
|
-
},
|
|
1084
|
+
}, xe = class extends j {
|
|
1085
1085
|
descriptor = {
|
|
1086
1086
|
id: "vwap",
|
|
1087
1087
|
name: "Volume Weighted Average Price",
|
|
@@ -1116,7 +1116,7 @@ var j = class {
|
|
|
1116
1116
|
}
|
|
1117
1117
|
e.stroke();
|
|
1118
1118
|
}
|
|
1119
|
-
},
|
|
1119
|
+
}, Se = class extends j {
|
|
1120
1120
|
descriptor = {
|
|
1121
1121
|
id: "ichimoku",
|
|
1122
1122
|
name: "Ichimoku Cloud",
|
|
@@ -1176,7 +1176,7 @@ var j = class {
|
|
|
1176
1176
|
};
|
|
1177
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(v, y, b, r.colors[3] ?? "#EF5350", 1);
|
|
1178
1178
|
}
|
|
1179
|
-
},
|
|
1179
|
+
}, Ce = class extends j {
|
|
1180
1180
|
descriptor = {
|
|
1181
1181
|
id: "psar",
|
|
1182
1182
|
name: "Parabolic SAR",
|
|
@@ -1222,7 +1222,7 @@ var j = class {
|
|
|
1222
1222
|
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
1223
|
}
|
|
1224
1224
|
}
|
|
1225
|
-
},
|
|
1225
|
+
}, we = class extends j {
|
|
1226
1226
|
descriptor = {
|
|
1227
1227
|
id: "supertrend",
|
|
1228
1228
|
name: "Supertrend",
|
|
@@ -1270,7 +1270,7 @@ var j = class {
|
|
|
1270
1270
|
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
1271
|
}
|
|
1272
1272
|
}
|
|
1273
|
-
},
|
|
1273
|
+
}, Te = class extends j {
|
|
1274
1274
|
descriptor = {
|
|
1275
1275
|
id: "keltner",
|
|
1276
1276
|
name: "Keltner Channel",
|
|
@@ -1327,7 +1327,7 @@ var j = class {
|
|
|
1327
1327
|
}
|
|
1328
1328
|
this.drawBand(e, s, l, _(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
1329
|
}
|
|
1330
|
-
},
|
|
1330
|
+
}, Ee = class extends j {
|
|
1331
1331
|
descriptor = {
|
|
1332
1332
|
id: "donchian",
|
|
1333
1333
|
name: "Donchian Channel",
|
|
@@ -1372,7 +1372,7 @@ var j = class {
|
|
|
1372
1372
|
}
|
|
1373
1373
|
this.drawBand(e, s, l, _(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]);
|
|
1374
1374
|
}
|
|
1375
|
-
},
|
|
1375
|
+
}, De = class extends j {
|
|
1376
1376
|
descriptor = {
|
|
1377
1377
|
id: "rsi",
|
|
1378
1378
|
name: "Relative Strength Index",
|
|
@@ -1423,7 +1423,7 @@ var j = class {
|
|
|
1423
1423
|
}
|
|
1424
1424
|
e.stroke();
|
|
1425
1425
|
}
|
|
1426
|
-
},
|
|
1426
|
+
}, Oe = class extends j {
|
|
1427
1427
|
descriptor = {
|
|
1428
1428
|
id: "macd",
|
|
1429
1429
|
name: "MACD",
|
|
@@ -1490,7 +1490,7 @@ var j = class {
|
|
|
1490
1490
|
}
|
|
1491
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(C), e.strokeStyle = _, e.stroke(w);
|
|
1492
1492
|
}
|
|
1493
|
-
},
|
|
1493
|
+
}, ke = class extends j {
|
|
1494
1494
|
descriptor = {
|
|
1495
1495
|
id: "stochastic",
|
|
1496
1496
|
name: "Stochastic Oscillator",
|
|
@@ -1565,7 +1565,7 @@ var j = class {
|
|
|
1565
1565
|
};
|
|
1566
1566
|
l("k", r.colors[0]), l("d", r.colors[1] ?? "#FF9800");
|
|
1567
1567
|
}
|
|
1568
|
-
},
|
|
1568
|
+
}, Ae = class extends j {
|
|
1569
1569
|
descriptor = {
|
|
1570
1570
|
id: "atr",
|
|
1571
1571
|
name: "Average True Range",
|
|
@@ -1619,7 +1619,7 @@ var j = class {
|
|
|
1619
1619
|
}
|
|
1620
1620
|
e.stroke();
|
|
1621
1621
|
}
|
|
1622
|
-
},
|
|
1622
|
+
}, je = class extends j {
|
|
1623
1623
|
descriptor = {
|
|
1624
1624
|
id: "adx",
|
|
1625
1625
|
name: "Average Directional Index",
|
|
@@ -1692,7 +1692,7 @@ var j = class {
|
|
|
1692
1692
|
};
|
|
1693
1693
|
l("adx", r.colors[0]), l("plusDI", r.colors[1] ?? "#26A69A"), l("minusDI", r.colors[2] ?? "#EF5350");
|
|
1694
1694
|
}
|
|
1695
|
-
},
|
|
1695
|
+
}, Me = class extends j {
|
|
1696
1696
|
descriptor = {
|
|
1697
1697
|
id: "obv",
|
|
1698
1698
|
name: "On Balance Volume",
|
|
@@ -1738,7 +1738,7 @@ var j = class {
|
|
|
1738
1738
|
}
|
|
1739
1739
|
e.stroke();
|
|
1740
1740
|
}
|
|
1741
|
-
},
|
|
1741
|
+
}, Ne = class extends j {
|
|
1742
1742
|
descriptor = {
|
|
1743
1743
|
id: "williamsR",
|
|
1744
1744
|
name: "Williams %R",
|
|
@@ -1778,7 +1778,7 @@ var j = class {
|
|
|
1778
1778
|
}
|
|
1779
1779
|
e.stroke();
|
|
1780
1780
|
}
|
|
1781
|
-
},
|
|
1781
|
+
}, M = class extends j {
|
|
1782
1782
|
descriptor = {
|
|
1783
1783
|
id: "cci",
|
|
1784
1784
|
name: "Commodity Channel Index",
|
|
@@ -1833,7 +1833,7 @@ var j = class {
|
|
|
1833
1833
|
}
|
|
1834
1834
|
e.stroke();
|
|
1835
1835
|
}
|
|
1836
|
-
},
|
|
1836
|
+
}, N = class extends j {
|
|
1837
1837
|
descriptor = {
|
|
1838
1838
|
id: "mfi",
|
|
1839
1839
|
name: "Money Flow Index",
|
|
@@ -1878,7 +1878,7 @@ var j = class {
|
|
|
1878
1878
|
}
|
|
1879
1879
|
e.stroke();
|
|
1880
1880
|
}
|
|
1881
|
-
},
|
|
1881
|
+
}, P = class extends j {
|
|
1882
1882
|
descriptor = {
|
|
1883
1883
|
id: "aroon",
|
|
1884
1884
|
name: "Aroon",
|
|
@@ -1920,7 +1920,7 @@ var j = class {
|
|
|
1920
1920
|
};
|
|
1921
1921
|
l("up", r.colors[0]), l("down", r.colors[1] ?? "#EF5350");
|
|
1922
1922
|
}
|
|
1923
|
-
},
|
|
1923
|
+
}, F = class extends j {
|
|
1924
1924
|
descriptor = {
|
|
1925
1925
|
id: "roc",
|
|
1926
1926
|
name: "Rate of Change",
|
|
@@ -1964,7 +1964,7 @@ var j = class {
|
|
|
1964
1964
|
}
|
|
1965
1965
|
e.stroke();
|
|
1966
1966
|
}
|
|
1967
|
-
},
|
|
1967
|
+
}, I = class extends j {
|
|
1968
1968
|
descriptor = {
|
|
1969
1969
|
id: "tsi",
|
|
1970
1970
|
name: "True Strength Index",
|
|
@@ -2033,7 +2033,7 @@ var j = class {
|
|
|
2033
2033
|
};
|
|
2034
2034
|
h("tsi", r.colors[0]), h("signal", r.colors[1] ?? "#FF9800");
|
|
2035
2035
|
}
|
|
2036
|
-
},
|
|
2036
|
+
}, L = class extends j {
|
|
2037
2037
|
descriptor = {
|
|
2038
2038
|
id: "cmf",
|
|
2039
2039
|
name: "Chaikin Money Flow",
|
|
@@ -2078,7 +2078,7 @@ var j = class {
|
|
|
2078
2078
|
}
|
|
2079
2079
|
}
|
|
2080
2080
|
}
|
|
2081
|
-
},
|
|
2081
|
+
}, R = class extends j {
|
|
2082
2082
|
descriptor = {
|
|
2083
2083
|
id: "stddev",
|
|
2084
2084
|
name: "Standard Deviation",
|
|
@@ -2124,7 +2124,7 @@ var j = class {
|
|
|
2124
2124
|
}
|
|
2125
2125
|
e.stroke();
|
|
2126
2126
|
}
|
|
2127
|
-
},
|
|
2127
|
+
}, z = class extends j {
|
|
2128
2128
|
descriptor = {
|
|
2129
2129
|
id: "volumeProfile",
|
|
2130
2130
|
name: "Volume Profile",
|
|
@@ -2174,7 +2174,7 @@ var j = class {
|
|
|
2174
2174
|
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
2175
|
}
|
|
2176
2176
|
}
|
|
2177
|
-
},
|
|
2177
|
+
}, Pe = class extends j {
|
|
2178
2178
|
descriptor = {
|
|
2179
2179
|
id: "ad",
|
|
2180
2180
|
name: "Accumulation/Distribution",
|
|
@@ -2220,7 +2220,7 @@ var j = class {
|
|
|
2220
2220
|
}
|
|
2221
2221
|
e.stroke();
|
|
2222
2222
|
}
|
|
2223
|
-
},
|
|
2223
|
+
}, Fe = class extends j {
|
|
2224
2224
|
descriptor = {
|
|
2225
2225
|
id: "vroc",
|
|
2226
2226
|
name: "Volume Rate of Change",
|
|
@@ -2262,12 +2262,12 @@ var j = class {
|
|
|
2262
2262
|
};
|
|
2263
2263
|
//#endregion
|
|
2264
2264
|
//#region src/indicators/registry.ts
|
|
2265
|
-
function
|
|
2266
|
-
e.register(new
|
|
2265
|
+
function Ie(e) {
|
|
2266
|
+
e.register(new ve()), e.register(new ye()), e.register(new be()), e.register(new xe()), e.register(new Se()), e.register(new Ce()), e.register(new we()), 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 Me()), e.register(new Ne()), e.register(new M()), e.register(new N()), e.register(new P()), e.register(new F()), e.register(new I()), e.register(new L()), e.register(new R()), e.register(new z()), e.register(new Pe()), e.register(new Fe());
|
|
2267
2267
|
}
|
|
2268
2268
|
//#endregion
|
|
2269
2269
|
//#region src/axis/GridRenderer.ts
|
|
2270
|
-
var
|
|
2270
|
+
var Le = class {
|
|
2271
2271
|
visible = !0;
|
|
2272
2272
|
setVisible(e) {
|
|
2273
2273
|
this.visible = e;
|
|
@@ -2296,7 +2296,11 @@ var Ie = class {
|
|
|
2296
2296
|
}
|
|
2297
2297
|
e.stroke();
|
|
2298
2298
|
}
|
|
2299
|
-
},
|
|
2299
|
+
}, Re = class {
|
|
2300
|
+
locale = "en-US";
|
|
2301
|
+
setLocale(e) {
|
|
2302
|
+
this.locale = e;
|
|
2303
|
+
}
|
|
2300
2304
|
render(e, t, n) {
|
|
2301
2305
|
let { chartRect: r, priceRange: i } = t, a = r.x + r.width, o = i.max - i.min;
|
|
2302
2306
|
if (o <= 0) return;
|
|
@@ -2307,7 +2311,7 @@ var Ie = class {
|
|
|
2307
2311
|
let t = r.y + r.height * (1 - (e - i.min) * s);
|
|
2308
2312
|
h.push({
|
|
2309
2313
|
y: t,
|
|
2310
|
-
text: p(e, d)
|
|
2314
|
+
text: p(e, d, this.locale)
|
|
2311
2315
|
});
|
|
2312
2316
|
}
|
|
2313
2317
|
e.font = m, e.textBaseline = "middle", e.textAlign = "left", e.fillStyle = n.axisLabelBackground;
|
|
@@ -2315,7 +2319,7 @@ var Ie = class {
|
|
|
2315
2319
|
e.fillStyle = n.axisLabel;
|
|
2316
2320
|
for (let { y: t, text: n } of h) e.fillText(n, a + 5, t);
|
|
2317
2321
|
}
|
|
2318
|
-
},
|
|
2322
|
+
}, B = /* @__PURE__ */ new Date(), ze = (e) => e < 10 ? "0" + e : "" + e, Be = -(/* @__PURE__ */ new Date()).getTimezoneOffset() / 60, Ve = `UTC${Be >= 0 ? "+" : ""}${Be}`, He = class {
|
|
2319
2323
|
render(e, t, n, r, i) {
|
|
2320
2324
|
let { chartRect: a } = t, o = i ?? a.y + a.height;
|
|
2321
2325
|
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();
|
|
@@ -2325,14 +2329,14 @@ var Ie = class {
|
|
|
2325
2329
|
for (let t = l; t <= u && t < r.length; t++) {
|
|
2326
2330
|
if (t % c !== 0) continue;
|
|
2327
2331
|
let n = t * s + d, i = r[t].time, a = i > 0xe8d4a51000 ? i : i * 1e3;
|
|
2328
|
-
|
|
2329
|
-
let l =
|
|
2330
|
-
l === f ? h = `${
|
|
2332
|
+
B.setTime(a);
|
|
2333
|
+
let l = B.getDate(), u = B.getMonth() + 1, p = B.getHours(), m = B.getMinutes(), h;
|
|
2334
|
+
l === f ? h = `${ze(p)}:${ze(m)}` : (h = `${u}/${l}`, f = l), e.fillText(h, n, o + 5);
|
|
2331
2335
|
}
|
|
2332
2336
|
let p = a.x + a.width - 4, m = o + 4;
|
|
2333
|
-
e.font = `${n.font.sizeSmall - 1}px ${n.font.family}`, e.textAlign = "right", e.textBaseline = "top", e.fillStyle = n.textSecondary, e.fillText(
|
|
2337
|
+
e.font = `${n.font.sizeSmall - 1}px ${n.font.family}`, e.textAlign = "right", e.textBaseline = "top", e.fillStyle = n.textSecondary, e.fillText(Ve, p, m);
|
|
2334
2338
|
}
|
|
2335
|
-
},
|
|
2339
|
+
}, Ue = class {
|
|
2336
2340
|
panHandler = null;
|
|
2337
2341
|
zoomHandler = null;
|
|
2338
2342
|
crosshairHandler = null;
|
|
@@ -2347,6 +2351,7 @@ var Ie = class {
|
|
|
2347
2351
|
y: 0
|
|
2348
2352
|
};
|
|
2349
2353
|
touchActive = !1;
|
|
2354
|
+
cachedRect = null;
|
|
2350
2355
|
constructor(e) {
|
|
2351
2356
|
this.element = e;
|
|
2352
2357
|
}
|
|
@@ -2370,6 +2375,7 @@ var Ie = class {
|
|
|
2370
2375
|
}
|
|
2371
2376
|
attach() {
|
|
2372
2377
|
let e = () => this.viewportGetter?.() ?? null, t = (t) => {
|
|
2378
|
+
this.invalidateRect();
|
|
2373
2379
|
let n = this.getMousePos(t), r = e();
|
|
2374
2380
|
this.tradingManager && r && this.tradingManager.onPointerDown(n, r) || this.drawingManager && r && this.drawingManager.onPointerDown(n, r) || this.panHandler?.onPointerDown(n);
|
|
2375
2381
|
}, n = (t) => {
|
|
@@ -2397,7 +2403,7 @@ var Ie = class {
|
|
|
2397
2403
|
let n = e();
|
|
2398
2404
|
this.tradingManager && n && (t.preventDefault(), this.tradingManager.onContextMenu(this.getMousePos(t), n));
|
|
2399
2405
|
}, c = (e) => {
|
|
2400
|
-
if (e.preventDefault(), e.touches.length === 1) {
|
|
2406
|
+
if (e.preventDefault(), this.invalidateRect(), e.touches.length === 1) {
|
|
2401
2407
|
let t = this.getTouchPos(e.touches[0]);
|
|
2402
2408
|
this.panHandler?.onPointerDown(t), this.crosshairHandler?.onPointerMove(t), this.touchActive = !0;
|
|
2403
2409
|
} else e.touches.length === 2 && (this.panHandler?.onPointerUp(), this.lastTouchDist = this.getTouchDistance(e.touches[0], e.touches[1]), this.lastTouchMid = this.getTouchMidpoint(e.touches[0], e.touches[1]), this.touchActive = !0);
|
|
@@ -2421,22 +2427,28 @@ var Ie = class {
|
|
|
2421
2427
|
let t = this.getTouchPos(e.touches[0]);
|
|
2422
2428
|
this.panHandler?.onPointerDown(t);
|
|
2423
2429
|
}
|
|
2424
|
-
};
|
|
2425
|
-
this.element.addEventListener("mousedown", t), this.element.addEventListener("mousemove", n), document.addEventListener("mouseup", r), this.element.addEventListener("mouseleave", i), this.element.addEventListener("wheel", a, { passive: !1 }), this.element.addEventListener("contextmenu", s), this.element.addEventListener("touchstart", c, { passive: !1 }), this.element.addEventListener("touchmove", l, { passive: !1 }), this.element.addEventListener("touchend", u), document.addEventListener("keydown", o), this.boundHandlers.push(() => this.element.removeEventListener("mousedown", t), () => this.element.removeEventListener("mousemove", n), () => document.removeEventListener("mouseup", r), () => this.element.removeEventListener("mouseleave", i), () => this.element.removeEventListener("wheel", a), () => this.element.removeEventListener("contextmenu", s), () => this.element.removeEventListener("touchstart", c), () => this.element.removeEventListener("touchmove", l), () => this.element.removeEventListener("touchend", u), () => document.removeEventListener("keydown", o));
|
|
2430
|
+
}, d = () => this.invalidateRect(), f = () => this.invalidateRect();
|
|
2431
|
+
this.element.addEventListener("mousedown", t), this.element.addEventListener("mousemove", n), document.addEventListener("mouseup", r), this.element.addEventListener("mouseleave", i), this.element.addEventListener("wheel", a, { passive: !1 }), this.element.addEventListener("contextmenu", s), this.element.addEventListener("touchstart", c, { passive: !1 }), this.element.addEventListener("touchmove", l, { passive: !1 }), this.element.addEventListener("touchend", u), document.addEventListener("keydown", o), window.addEventListener("resize", d), this.element.addEventListener("scroll", f, { passive: !0 }), this.boundHandlers.push(() => this.element.removeEventListener("mousedown", t), () => this.element.removeEventListener("mousemove", n), () => document.removeEventListener("mouseup", r), () => this.element.removeEventListener("mouseleave", i), () => this.element.removeEventListener("wheel", a), () => this.element.removeEventListener("contextmenu", s), () => this.element.removeEventListener("touchstart", c), () => this.element.removeEventListener("touchmove", l), () => this.element.removeEventListener("touchend", u), () => document.removeEventListener("keydown", o), () => window.removeEventListener("resize", d), () => this.element.removeEventListener("scroll", f));
|
|
2426
2432
|
}
|
|
2427
2433
|
detach() {
|
|
2428
2434
|
for (let e of this.boundHandlers) e();
|
|
2429
|
-
this.boundHandlers = [];
|
|
2435
|
+
this.boundHandlers = [], this.cachedRect = null;
|
|
2436
|
+
}
|
|
2437
|
+
invalidateRect() {
|
|
2438
|
+
this.cachedRect = null;
|
|
2439
|
+
}
|
|
2440
|
+
getRect() {
|
|
2441
|
+
return this.cachedRect ||= this.element.getBoundingClientRect(), this.cachedRect;
|
|
2430
2442
|
}
|
|
2431
2443
|
getMousePos(e) {
|
|
2432
|
-
let t = this.
|
|
2444
|
+
let t = this.getRect();
|
|
2433
2445
|
return {
|
|
2434
2446
|
x: e.clientX - t.left,
|
|
2435
2447
|
y: e.clientY - t.top
|
|
2436
2448
|
};
|
|
2437
2449
|
}
|
|
2438
2450
|
getTouchPos(e) {
|
|
2439
|
-
let t = this.
|
|
2451
|
+
let t = this.getRect();
|
|
2440
2452
|
return {
|
|
2441
2453
|
x: e.clientX - t.left,
|
|
2442
2454
|
y: e.clientY - t.top
|
|
@@ -2446,13 +2458,13 @@ var Ie = class {
|
|
|
2446
2458
|
return Math.hypot(t.clientX - e.clientX, t.clientY - e.clientY);
|
|
2447
2459
|
}
|
|
2448
2460
|
getTouchMidpoint(e, t) {
|
|
2449
|
-
let n = this.
|
|
2461
|
+
let n = this.getRect();
|
|
2450
2462
|
return {
|
|
2451
2463
|
x: (e.clientX + t.clientX) / 2 - n.left,
|
|
2452
2464
|
y: (e.clientY + t.clientY) / 2 - n.top
|
|
2453
2465
|
};
|
|
2454
2466
|
}
|
|
2455
|
-
},
|
|
2467
|
+
}, We = class {
|
|
2456
2468
|
dragging = !1;
|
|
2457
2469
|
lastX = 0;
|
|
2458
2470
|
lastTime = 0;
|
|
@@ -2488,7 +2500,7 @@ var Ie = class {
|
|
|
2488
2500
|
stopMomentum() {
|
|
2489
2501
|
this.momentumId &&= (cancelAnimationFrame(this.momentumId), 0);
|
|
2490
2502
|
}
|
|
2491
|
-
},
|
|
2503
|
+
}, Ge = class {
|
|
2492
2504
|
callback;
|
|
2493
2505
|
sensitivity;
|
|
2494
2506
|
pendingDelta = 0;
|
|
@@ -2507,13 +2519,14 @@ var Ie = class {
|
|
|
2507
2519
|
dispose() {
|
|
2508
2520
|
this.rafId &&= (cancelAnimationFrame(this.rafId), 0);
|
|
2509
2521
|
}
|
|
2510
|
-
},
|
|
2522
|
+
}, Ke = class {
|
|
2511
2523
|
position = null;
|
|
2512
2524
|
callback = null;
|
|
2513
2525
|
data = [];
|
|
2514
2526
|
magnetMode = !0;
|
|
2515
2527
|
mode = "magnet";
|
|
2516
2528
|
pricePrecision = 2;
|
|
2529
|
+
locale = "en-US";
|
|
2517
2530
|
pendingBarIndex = null;
|
|
2518
2531
|
pendingPoint = null;
|
|
2519
2532
|
callbackScheduled = !1;
|
|
@@ -2536,6 +2549,9 @@ var Ie = class {
|
|
|
2536
2549
|
setPricePrecision(e) {
|
|
2537
2550
|
this.pricePrecision = e;
|
|
2538
2551
|
}
|
|
2552
|
+
setLocale(e) {
|
|
2553
|
+
this.locale = e;
|
|
2554
|
+
}
|
|
2539
2555
|
getPosition() {
|
|
2540
2556
|
return this.position;
|
|
2541
2557
|
}
|
|
@@ -2554,7 +2570,7 @@ var Ie = class {
|
|
|
2554
2570
|
x: i,
|
|
2555
2571
|
y: a
|
|
2556
2572
|
}, 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([]);
|
|
2557
|
-
let s = p(T(a, t), this.pricePrecision), l = r.x + r.width + 1;
|
|
2573
|
+
let s = p(T(a, t), this.pricePrecision, this.locale), l = r.x + r.width + 1;
|
|
2558
2574
|
e.fillStyle = n.axisLabelBackground, e.fillRect(l, a - 10, c - 2, 20), e.fillStyle = n.axisLabel, e.font = `${n.font.sizeSmall}px ${n.font.family}`, e.textBaseline = "middle", e.textAlign = "left", e.fillText(s, l + 5, a);
|
|
2559
2575
|
}
|
|
2560
2576
|
scheduleCallback() {
|
|
@@ -2565,7 +2581,7 @@ var Ie = class {
|
|
|
2565
2581
|
flushCallback(e, t) {
|
|
2566
2582
|
this.callback?.(e, t);
|
|
2567
2583
|
}
|
|
2568
|
-
},
|
|
2584
|
+
}, qe = class {
|
|
2569
2585
|
callbacks;
|
|
2570
2586
|
enabled = !0;
|
|
2571
2587
|
constructor(e) {
|
|
@@ -2591,7 +2607,7 @@ var Ie = class {
|
|
|
2591
2607
|
default: return !1;
|
|
2592
2608
|
}
|
|
2593
2609
|
}
|
|
2594
|
-
},
|
|
2610
|
+
}, Je = class {
|
|
2595
2611
|
el = null;
|
|
2596
2612
|
visible = !1;
|
|
2597
2613
|
timeEl;
|
|
@@ -2630,8 +2646,8 @@ var Ie = class {
|
|
|
2630
2646
|
this.changeEl.textContent = `${l}${a(s)} (${l}${c.toFixed(2)}%)`, this.changeEl.style.color = i;
|
|
2631
2647
|
let u = t.volume;
|
|
2632
2648
|
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;
|
|
2633
|
-
let d =
|
|
2634
|
-
this.el.style.background = d ?
|
|
2649
|
+
let d = Ye(n.background);
|
|
2650
|
+
this.el.style.background = d ? Xe(n.background, .95) : Xe(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);
|
|
2635
2651
|
let f = e.x + 16, p = e.y - 40;
|
|
2636
2652
|
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);
|
|
2637
2653
|
}
|
|
@@ -2656,7 +2672,7 @@ var Ie = class {
|
|
|
2656
2672
|
return document.createElement("span");
|
|
2657
2673
|
}
|
|
2658
2674
|
};
|
|
2659
|
-
function
|
|
2675
|
+
function Ye(e) {
|
|
2660
2676
|
if (e.startsWith("#")) {
|
|
2661
2677
|
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);
|
|
2662
2678
|
return (.299 * r + .587 * i + .114 * a) / 255 < .5;
|
|
@@ -2668,7 +2684,7 @@ function Je(e) {
|
|
|
2668
2684
|
}
|
|
2669
2685
|
return !0;
|
|
2670
2686
|
}
|
|
2671
|
-
function
|
|
2687
|
+
function Xe(e, t) {
|
|
2672
2688
|
if (e.startsWith("#")) {
|
|
2673
2689
|
let n = e.slice(1), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n.slice(0, 6);
|
|
2674
2690
|
return `rgba(${parseInt(r.slice(0, 2), 16)}, ${parseInt(r.slice(2, 4), 16)}, ${parseInt(r.slice(4, 6), 16)}, ${t})`;
|
|
@@ -2677,7 +2693,7 @@ function Ye(e, t) {
|
|
|
2677
2693
|
}
|
|
2678
2694
|
//#endregion
|
|
2679
2695
|
//#region src/events/EventBus.ts
|
|
2680
|
-
var
|
|
2696
|
+
var Ze = class {
|
|
2681
2697
|
listeners = /* @__PURE__ */ new Map();
|
|
2682
2698
|
tauriBridge = null;
|
|
2683
2699
|
on(e, t) {
|
|
@@ -2708,7 +2724,7 @@ var Xe = class {
|
|
|
2708
2724
|
destroy() {
|
|
2709
2725
|
this.listeners.clear(), this.tauriBridge = null;
|
|
2710
2726
|
}
|
|
2711
|
-
},
|
|
2727
|
+
}, V = class {
|
|
2712
2728
|
hitTestAnchor(e, t, n, r) {
|
|
2713
2729
|
for (let i = 0; i < t.anchors.length; i++) {
|
|
2714
2730
|
let a = this.anchorToPixel(t.anchors[i], n);
|
|
@@ -2763,7 +2779,16 @@ var Xe = class {
|
|
|
2763
2779
|
let r = n.x - t.x, i = n.y - t.y, a = Math.hypot(r, i);
|
|
2764
2780
|
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;
|
|
2765
2781
|
}
|
|
2766
|
-
},
|
|
2782
|
+
}, Qe = 1;
|
|
2783
|
+
function H(e) {
|
|
2784
|
+
return {
|
|
2785
|
+
...e,
|
|
2786
|
+
anchors: e.anchors.map((e) => ({ ...e })),
|
|
2787
|
+
style: { ...e.style },
|
|
2788
|
+
meta: e.meta ? { ...e.meta } : void 0
|
|
2789
|
+
};
|
|
2790
|
+
}
|
|
2791
|
+
var $e = class {
|
|
2767
2792
|
registry = /* @__PURE__ */ new Map();
|
|
2768
2793
|
drawings = [];
|
|
2769
2794
|
state = "idle";
|
|
@@ -2935,7 +2960,7 @@ var Xe = class {
|
|
|
2935
2960
|
e && this.undoRedo?.push({
|
|
2936
2961
|
type: "drawingModify",
|
|
2937
2962
|
before: this.dragBeforeState,
|
|
2938
|
-
after:
|
|
2963
|
+
after: H(e)
|
|
2939
2964
|
});
|
|
2940
2965
|
}
|
|
2941
2966
|
return this.state = "selected", this.dragStartPoint = null, this.dragStartAnchors = [], this.dragAnchorIndex = -1, this.dragBeforeState = null, !0;
|
|
@@ -2968,7 +2993,7 @@ var Xe = class {
|
|
|
2968
2993
|
let t = this.drawings.find((t) => t.id === e);
|
|
2969
2994
|
if (!t) return null;
|
|
2970
2995
|
let n = structuredClone(t);
|
|
2971
|
-
return n.id = `tc_drawing_${
|
|
2996
|
+
return n.id = `tc_drawing_${Qe++}`, n.anchors = n.anchors.map((e) => ({
|
|
2972
2997
|
...e,
|
|
2973
2998
|
time: e.time + 3
|
|
2974
2999
|
})), n.locked = !1, this.drawings.push(n), this.undoRedo?.push({
|
|
@@ -3010,7 +3035,7 @@ var Xe = class {
|
|
|
3010
3035
|
if (!n) return !1;
|
|
3011
3036
|
let r = w(e.x, t), i = T(e.y, t), a = this.snapToOHLC(r, i, t);
|
|
3012
3037
|
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 = {
|
|
3013
|
-
id: `tc_drawing_${
|
|
3038
|
+
id: `tc_drawing_${Qe++}`,
|
|
3014
3039
|
type: this.activeTool,
|
|
3015
3040
|
anchors: [a],
|
|
3016
3041
|
style: { ...this.activeStyle },
|
|
@@ -3032,8 +3057,8 @@ var Xe = class {
|
|
|
3032
3057
|
let r = this.registry.get(n.type);
|
|
3033
3058
|
if (r) {
|
|
3034
3059
|
let i = r.hitTestAnchor(e, n, t, 8);
|
|
3035
|
-
if (i >= 0) return this.state = "resizing", this.dragAnchorIndex = i, this.dragStartPoint = e, this.dragBeforeState =
|
|
3036
|
-
if (r.hitTest(e, n, t, 8)) return this.state = "moving", this.dragStartPoint = e, this.dragStartAnchors = n.anchors.map((e) => ({ ...e })), this.dragBeforeState =
|
|
3060
|
+
if (i >= 0) return this.state = "resizing", this.dragAnchorIndex = i, this.dragStartPoint = e, this.dragBeforeState = H(n), !0;
|
|
3061
|
+
if (r.hitTest(e, n, t, 8)) return this.state = "moving", this.dragStartPoint = e, this.dragStartAnchors = n.anchors.map((e) => ({ ...e })), this.dragBeforeState = H(n), !0;
|
|
3037
3062
|
}
|
|
3038
3063
|
}
|
|
3039
3064
|
}
|
|
@@ -3061,14 +3086,14 @@ var Xe = class {
|
|
|
3061
3086
|
price: T(e.y, t)
|
|
3062
3087
|
}, this.requestRender?.(), !0);
|
|
3063
3088
|
}
|
|
3064
|
-
},
|
|
3089
|
+
}, et = class {
|
|
3065
3090
|
constructor(e) {
|
|
3066
3091
|
this.manager = e;
|
|
3067
3092
|
}
|
|
3068
3093
|
render(e, t) {
|
|
3069
3094
|
this.manager.render(e, t);
|
|
3070
3095
|
}
|
|
3071
|
-
},
|
|
3096
|
+
}, tt = class extends V {
|
|
3072
3097
|
descriptor = {
|
|
3073
3098
|
type: "trendLine",
|
|
3074
3099
|
name: "Trend Line",
|
|
@@ -3084,7 +3109,7 @@ var Xe = class {
|
|
|
3084
3109
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
|
|
3085
3110
|
return this.distanceToLine(e, i, a) <= r;
|
|
3086
3111
|
}
|
|
3087
|
-
},
|
|
3112
|
+
}, nt = class extends V {
|
|
3088
3113
|
descriptor = {
|
|
3089
3114
|
type: "horizontalLine",
|
|
3090
3115
|
name: "Horizontal Line",
|
|
@@ -3100,7 +3125,7 @@ var Xe = class {
|
|
|
3100
3125
|
let i = C(t.anchors[0].price, n);
|
|
3101
3126
|
return Math.abs(e.y - i) <= r && e.x >= n.chartRect.x && e.x <= n.chartRect.x + n.chartRect.width;
|
|
3102
3127
|
}
|
|
3103
|
-
},
|
|
3128
|
+
}, rt = class extends V {
|
|
3104
3129
|
descriptor = {
|
|
3105
3130
|
type: "verticalLine",
|
|
3106
3131
|
name: "Vertical Line",
|
|
@@ -3116,7 +3141,7 @@ var Xe = class {
|
|
|
3116
3141
|
let i = this.anchorToPixel(t.anchors[0], n), { chartRect: a } = n;
|
|
3117
3142
|
return Math.abs(e.x - i.x) <= r && e.y >= a.y && e.y <= a.y + a.height;
|
|
3118
3143
|
}
|
|
3119
|
-
},
|
|
3144
|
+
}, it = class extends V {
|
|
3120
3145
|
descriptor = {
|
|
3121
3146
|
type: "ray",
|
|
3122
3147
|
name: "Ray",
|
|
@@ -3134,7 +3159,7 @@ var Xe = class {
|
|
|
3134
3159
|
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;
|
|
3135
3160
|
return ((e.x - i.x) * o + (e.y - i.y) * s) / (o * o + s * s) < 0 ? !1 : this.distanceToInfiniteLine(e, i, a) <= r;
|
|
3136
3161
|
}
|
|
3137
|
-
},
|
|
3162
|
+
}, at = class extends V {
|
|
3138
3163
|
descriptor = {
|
|
3139
3164
|
type: "extendedLine",
|
|
3140
3165
|
name: "Extended Line",
|
|
@@ -3152,7 +3177,7 @@ var Xe = class {
|
|
|
3152
3177
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
|
|
3153
3178
|
return this.distanceToInfiniteLine(e, i, a) <= r;
|
|
3154
3179
|
}
|
|
3155
|
-
},
|
|
3180
|
+
}, ot = class extends V {
|
|
3156
3181
|
descriptor = {
|
|
3157
3182
|
type: "parallelChannel",
|
|
3158
3183
|
name: "Parallel Channel",
|
|
@@ -3189,7 +3214,7 @@ var Xe = class {
|
|
|
3189
3214
|
}
|
|
3190
3215
|
return !1;
|
|
3191
3216
|
}
|
|
3192
|
-
},
|
|
3217
|
+
}, st = class extends V {
|
|
3193
3218
|
descriptor = {
|
|
3194
3219
|
type: "regressionChannel",
|
|
3195
3220
|
name: "Regression Channel",
|
|
@@ -3220,7 +3245,7 @@ var Xe = class {
|
|
|
3220
3245
|
.618,
|
|
3221
3246
|
.786,
|
|
3222
3247
|
1
|
|
3223
|
-
],
|
|
3248
|
+
], ct = class extends V {
|
|
3224
3249
|
descriptor = {
|
|
3225
3250
|
type: "fibRetracement",
|
|
3226
3251
|
name: "Fibonacci Retracement",
|
|
@@ -3254,7 +3279,7 @@ var Xe = class {
|
|
|
3254
3279
|
}
|
|
3255
3280
|
return !1;
|
|
3256
3281
|
}
|
|
3257
|
-
},
|
|
3282
|
+
}, lt = [
|
|
3258
3283
|
0,
|
|
3259
3284
|
.618,
|
|
3260
3285
|
1,
|
|
@@ -3263,7 +3288,7 @@ var Xe = class {
|
|
|
3263
3288
|
2.618,
|
|
3264
3289
|
3.618,
|
|
3265
3290
|
4.236
|
|
3266
|
-
],
|
|
3291
|
+
], ut = class extends V {
|
|
3267
3292
|
descriptor = {
|
|
3268
3293
|
type: "fibExtension",
|
|
3269
3294
|
name: "Fibonacci Extension",
|
|
@@ -3279,7 +3304,7 @@ var Xe = class {
|
|
|
3279
3304
|
}
|
|
3280
3305
|
let { chartRect: i } = n, a = t.anchors[0].price, o = t.anchors[1].price, s = t.anchors[2].price, c = a - o;
|
|
3281
3306
|
e.font = "11px sans-serif", e.textBaseline = "middle", e.textAlign = "left";
|
|
3282
|
-
for (let r of
|
|
3307
|
+
for (let r of lt) {
|
|
3283
3308
|
let a = C(s + c * r, n);
|
|
3284
3309
|
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);
|
|
3285
3310
|
}
|
|
@@ -3290,13 +3315,13 @@ var Xe = class {
|
|
|
3290
3315
|
let { chartRect: i } = n;
|
|
3291
3316
|
if (e.x < i.x - r || e.x > i.x + i.width + r) return !1;
|
|
3292
3317
|
let a = t.anchors[0].price - t.anchors[1].price;
|
|
3293
|
-
for (let i of
|
|
3318
|
+
for (let i of lt) {
|
|
3294
3319
|
let o = C(t.anchors[2].price + a * i, n);
|
|
3295
3320
|
if (Math.abs(e.y - o) <= r) return !0;
|
|
3296
3321
|
}
|
|
3297
3322
|
return !1;
|
|
3298
3323
|
}
|
|
3299
|
-
},
|
|
3324
|
+
}, dt = class extends V {
|
|
3300
3325
|
descriptor = {
|
|
3301
3326
|
type: "rectangle",
|
|
3302
3327
|
name: "Rectangle",
|
|
@@ -3314,7 +3339,7 @@ var Xe = class {
|
|
|
3314
3339
|
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;
|
|
3315
3340
|
return !(e.x > u && e.x < f && e.y > d && e.y < p) || !!t.style.fillColor;
|
|
3316
3341
|
}
|
|
3317
|
-
},
|
|
3342
|
+
}, ft = class extends V {
|
|
3318
3343
|
descriptor = {
|
|
3319
3344
|
type: "ellipse",
|
|
3320
3345
|
name: "Ellipse",
|
|
@@ -3330,7 +3355,7 @@ var Xe = class {
|
|
|
3330
3355
|
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);
|
|
3331
3356
|
return t.style.fillColor ? f <= 1 + p : Math.abs(f - 1) <= p;
|
|
3332
3357
|
}
|
|
3333
|
-
},
|
|
3358
|
+
}, pt = class extends V {
|
|
3334
3359
|
descriptor = {
|
|
3335
3360
|
type: "triangle",
|
|
3336
3361
|
name: "Triangle",
|
|
@@ -3356,7 +3381,7 @@ var Xe = class {
|
|
|
3356
3381
|
}
|
|
3357
3382
|
return !1;
|
|
3358
3383
|
}
|
|
3359
|
-
},
|
|
3384
|
+
}, mt = class extends V {
|
|
3360
3385
|
descriptor = {
|
|
3361
3386
|
type: "pitchfork",
|
|
3362
3387
|
name: "Andrews' Pitchfork",
|
|
@@ -3392,7 +3417,7 @@ var Xe = class {
|
|
|
3392
3417
|
};
|
|
3393
3418
|
return this.distanceToInfiniteLine(e, a, u) <= r || this.distanceToInfiniteLine(e, o, d) <= r;
|
|
3394
3419
|
}
|
|
3395
|
-
},
|
|
3420
|
+
}, ht = [
|
|
3396
3421
|
"1",
|
|
3397
3422
|
"2",
|
|
3398
3423
|
"3",
|
|
@@ -3401,7 +3426,7 @@ var Xe = class {
|
|
|
3401
3426
|
"A",
|
|
3402
3427
|
"B",
|
|
3403
3428
|
"C"
|
|
3404
|
-
],
|
|
3429
|
+
], gt = class extends V {
|
|
3405
3430
|
descriptor = {
|
|
3406
3431
|
type: "elliottWave",
|
|
3407
3432
|
name: "Elliott Wave",
|
|
@@ -3413,9 +3438,9 @@ var Xe = class {
|
|
|
3413
3438
|
this.applyLineStyle(e, t.style), e.beginPath(), e.moveTo(i[0].x, i[0].y);
|
|
3414
3439
|
for (let t = 1; t < i.length; t++) e.lineTo(i[t].x, i[t].y);
|
|
3415
3440
|
e.stroke(), this.resetLineStyle(e), e.font = "bold 12px sans-serif", e.fillStyle = t.style.color, e.textAlign = "center";
|
|
3416
|
-
for (let t = 0; t < i.length && t <
|
|
3441
|
+
for (let t = 0; t < i.length && t < ht.length; t++) {
|
|
3417
3442
|
let n = t % 2 == 0 ? -12 : 12;
|
|
3418
|
-
e.textBaseline = n < 0 ? "bottom" : "top", e.fillText(
|
|
3443
|
+
e.textBaseline = n < 0 ? "bottom" : "top", e.fillText(ht[t], i[t].x, i[t].y + n);
|
|
3419
3444
|
}
|
|
3420
3445
|
r && this.renderAnchorHandles(e, t, n);
|
|
3421
3446
|
}
|
|
@@ -3425,7 +3450,7 @@ var Xe = class {
|
|
|
3425
3450
|
for (let t = 0; t < i.length - 1; t++) if (this.distanceToLine(e, i[t], i[t + 1]) <= r) return !0;
|
|
3426
3451
|
return !1;
|
|
3427
3452
|
}
|
|
3428
|
-
},
|
|
3453
|
+
}, _t = class extends V {
|
|
3429
3454
|
descriptor = {
|
|
3430
3455
|
type: "priceRange",
|
|
3431
3456
|
name: "Price Range",
|
|
@@ -3443,7 +3468,7 @@ var Xe = class {
|
|
|
3443
3468
|
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);
|
|
3444
3469
|
return e.x >= o - r && e.x <= s + r && e.y >= c - r && e.y <= l + r;
|
|
3445
3470
|
}
|
|
3446
|
-
},
|
|
3471
|
+
}, vt = class extends V {
|
|
3447
3472
|
descriptor = {
|
|
3448
3473
|
type: "dateRange",
|
|
3449
3474
|
name: "Date Range",
|
|
@@ -3461,7 +3486,7 @@ var Xe = class {
|
|
|
3461
3486
|
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);
|
|
3462
3487
|
return e.x >= s - r && e.x <= c + r && e.y >= o.y && e.y <= o.y + o.height;
|
|
3463
3488
|
}
|
|
3464
|
-
},
|
|
3489
|
+
}, yt = class extends V {
|
|
3465
3490
|
descriptor = {
|
|
3466
3491
|
type: "measure",
|
|
3467
3492
|
name: "Measure",
|
|
@@ -3483,7 +3508,7 @@ var Xe = class {
|
|
|
3483
3508
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
|
|
3484
3509
|
return this.distanceToLine(e, i, a) <= r;
|
|
3485
3510
|
}
|
|
3486
|
-
},
|
|
3511
|
+
}, bt = class extends V {
|
|
3487
3512
|
descriptor = {
|
|
3488
3513
|
type: "text",
|
|
3489
3514
|
name: "Text",
|
|
@@ -3503,7 +3528,7 @@ var Xe = class {
|
|
|
3503
3528
|
let i = this.anchorToPixel(t.anchors[0], n), a = t.style.fontSize || 14;
|
|
3504
3529
|
return e.x >= i.x - r && e.x <= i.x + 80 + r && e.y >= i.y - r && e.y <= i.y + a + r;
|
|
3505
3530
|
}
|
|
3506
|
-
},
|
|
3531
|
+
}, xt = class extends V {
|
|
3507
3532
|
descriptor = {
|
|
3508
3533
|
type: "arrow",
|
|
3509
3534
|
name: "Arrow",
|
|
@@ -3521,7 +3546,7 @@ var Xe = class {
|
|
|
3521
3546
|
let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
|
|
3522
3547
|
return this.distanceToLine(e, i, a) <= r;
|
|
3523
3548
|
}
|
|
3524
|
-
},
|
|
3549
|
+
}, St = [
|
|
3525
3550
|
{
|
|
3526
3551
|
label: "8x1",
|
|
3527
3552
|
ratio: 8
|
|
@@ -3558,7 +3583,7 @@ var Xe = class {
|
|
|
3558
3583
|
label: "1x8",
|
|
3559
3584
|
ratio: .125
|
|
3560
3585
|
}
|
|
3561
|
-
],
|
|
3586
|
+
], Ct = class extends V {
|
|
3562
3587
|
descriptor = {
|
|
3563
3588
|
type: "gannFan",
|
|
3564
3589
|
name: "Gann Fan",
|
|
@@ -3570,7 +3595,7 @@ var Xe = class {
|
|
|
3570
3595
|
if (Math.abs(o) < 1) return;
|
|
3571
3596
|
let c = s / o, l = o > 0 ? 1 : -1, { chartRect: u } = n, d = l > 0 ? u.x + u.width : u.x;
|
|
3572
3597
|
this.applyLineStyle(e, t.style);
|
|
3573
|
-
for (let { label: n, ratio: r } of
|
|
3598
|
+
for (let { label: n, ratio: r } of St) {
|
|
3574
3599
|
let a = c * r, o = d, s = i.y + a * (o - i.x);
|
|
3575
3600
|
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();
|
|
3576
3601
|
let f = o - l * 4, p = s;
|
|
@@ -3583,7 +3608,7 @@ var Xe = class {
|
|
|
3583
3608
|
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;
|
|
3584
3609
|
if (Math.abs(o) < 1) return !1;
|
|
3585
3610
|
let c = s / o, l = o > 0 ? 1 : -1, { chartRect: u } = n, d = l > 0 ? u.x + u.width : u.x;
|
|
3586
|
-
for (let { ratio: t } of
|
|
3611
|
+
for (let { ratio: t } of St) {
|
|
3587
3612
|
let n = c * t, a = d, o = i.y + n * (a - i.x);
|
|
3588
3613
|
if (this.distanceToLine(e, i, {
|
|
3589
3614
|
x: a,
|
|
@@ -3592,7 +3617,7 @@ var Xe = class {
|
|
|
3592
3617
|
}
|
|
3593
3618
|
return !1;
|
|
3594
3619
|
}
|
|
3595
|
-
},
|
|
3620
|
+
}, W = [
|
|
3596
3621
|
0,
|
|
3597
3622
|
.25,
|
|
3598
3623
|
.333,
|
|
@@ -3600,7 +3625,7 @@ var Xe = class {
|
|
|
3600
3625
|
.667,
|
|
3601
3626
|
.75,
|
|
3602
3627
|
1
|
|
3603
|
-
],
|
|
3628
|
+
], wt = class extends V {
|
|
3604
3629
|
descriptor = {
|
|
3605
3630
|
type: "gannBox",
|
|
3606
3631
|
name: "Gann Box",
|
|
@@ -3611,18 +3636,18 @@ var Xe = class {
|
|
|
3611
3636
|
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;
|
|
3612
3637
|
if (!(u < 2 || d < 2)) {
|
|
3613
3638
|
this.applyLineStyle(e, t.style), e.strokeRect(o, c, u, d), e.save(), e.globalAlpha = .35;
|
|
3614
|
-
for (let t of
|
|
3639
|
+
for (let t of W) {
|
|
3615
3640
|
if (t === 0 || t === 1) continue;
|
|
3616
3641
|
let n = c + d * t;
|
|
3617
3642
|
e.beginPath(), e.moveTo(o, n), e.lineTo(s, n), e.stroke();
|
|
3618
3643
|
}
|
|
3619
|
-
for (let t of
|
|
3644
|
+
for (let t of W) {
|
|
3620
3645
|
if (t === 0 || t === 1) continue;
|
|
3621
3646
|
let n = o + u * t;
|
|
3622
3647
|
e.beginPath(), e.moveTo(n, c), e.lineTo(n, l), e.stroke();
|
|
3623
3648
|
}
|
|
3624
3649
|
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";
|
|
3625
|
-
for (let t of
|
|
3650
|
+
for (let t of W) {
|
|
3626
3651
|
if (t === 0 || t === 1) continue;
|
|
3627
3652
|
let n = c + d * t;
|
|
3628
3653
|
e.fillText(`${(t * 100).toFixed(0)}%`, o - 3, n);
|
|
@@ -3647,7 +3672,7 @@ var Xe = class {
|
|
|
3647
3672
|
y: l
|
|
3648
3673
|
}) <= r;
|
|
3649
3674
|
}
|
|
3650
|
-
},
|
|
3675
|
+
}, Tt = class extends V {
|
|
3651
3676
|
descriptor = {
|
|
3652
3677
|
type: "anchoredVWAP",
|
|
3653
3678
|
name: "Anchored VWAP",
|
|
@@ -3719,7 +3744,7 @@ var Xe = class {
|
|
|
3719
3744
|
}
|
|
3720
3745
|
return !1;
|
|
3721
3746
|
}
|
|
3722
|
-
},
|
|
3747
|
+
}, Et = class extends V {
|
|
3723
3748
|
descriptor = {
|
|
3724
3749
|
type: "volumeProfileRange",
|
|
3725
3750
|
name: "Volume Profile (Range)",
|
|
@@ -3764,12 +3789,12 @@ var Xe = class {
|
|
|
3764
3789
|
};
|
|
3765
3790
|
//#endregion
|
|
3766
3791
|
//#region src/drawings/tools/index.ts
|
|
3767
|
-
function
|
|
3768
|
-
e.register(new
|
|
3792
|
+
function Dt(e) {
|
|
3793
|
+
e.register(new tt()), e.register(new nt()), e.register(new rt()), e.register(new it()), e.register(new at()), e.register(new ot()), e.register(new st()), e.register(new ct()), e.register(new ut()), e.register(new dt()), e.register(new ft()), e.register(new pt()), e.register(new mt()), e.register(new gt()), e.register(new _t()), e.register(new vt()), e.register(new yt()), e.register(new bt()), e.register(new xt()), e.register(new Ct()), e.register(new wt()), e.register(new Tt()), e.register(new Et());
|
|
3769
3794
|
}
|
|
3770
3795
|
//#endregion
|
|
3771
3796
|
//#region src/trading/OrderRenderer.ts
|
|
3772
|
-
var
|
|
3797
|
+
var Ot = class {
|
|
3773
3798
|
render(e, t, n, r, i, a) {
|
|
3774
3799
|
let o = i.orderColors?.buy ?? "#26A69A", s = i.orderColors?.sell ?? "#EF5350", { chartRect: c } = n;
|
|
3775
3800
|
for (let i of t) {
|
|
@@ -3807,7 +3832,7 @@ var Et = class {
|
|
|
3807
3832
|
}
|
|
3808
3833
|
return null;
|
|
3809
3834
|
}
|
|
3810
|
-
},
|
|
3835
|
+
}, kt = class {
|
|
3811
3836
|
render(e, t, n, r, i, a) {
|
|
3812
3837
|
let { chartRect: o } = r, s = a.positionColors?.profit ?? "#26A69A", c = a.positionColors?.loss ?? "#EF5350", l = a.positionColors?.entry ?? "#2196F3", u = a.pricePrecision ?? 2;
|
|
3813
3838
|
for (let a of t) {
|
|
@@ -3840,7 +3865,7 @@ var Et = class {
|
|
|
3840
3865
|
e.fillStyle = o, e.fillRect(l, t - 9, c - 2, 18), e.fillStyle = "#FFFFFF", e.font = `11px ${r.font.family}`, e.textAlign = "left", e.textBaseline = "middle", e.fillText(i.entryPrice.toFixed(s), l + 5, t);
|
|
3841
3866
|
}
|
|
3842
3867
|
}
|
|
3843
|
-
},
|
|
3868
|
+
}, At = class {
|
|
3844
3869
|
render(e, t, n, r) {
|
|
3845
3870
|
if (!r.depthOverlay?.enabled) return;
|
|
3846
3871
|
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;
|
|
@@ -3871,7 +3896,7 @@ var Et = class {
|
|
|
3871
3896
|
e.fillRect(p - o, a - f / 2, o, f);
|
|
3872
3897
|
}
|
|
3873
3898
|
}
|
|
3874
|
-
},
|
|
3899
|
+
}, jt = class {
|
|
3875
3900
|
dragState = null;
|
|
3876
3901
|
startY = 0;
|
|
3877
3902
|
dragging = !1;
|
|
@@ -3935,7 +3960,7 @@ var Et = class {
|
|
|
3935
3960
|
isActive() {
|
|
3936
3961
|
return this.dragState !== null;
|
|
3937
3962
|
}
|
|
3938
|
-
},
|
|
3963
|
+
}, Mt = class {
|
|
3939
3964
|
menuElement = null;
|
|
3940
3965
|
removeHandler = null;
|
|
3941
3966
|
onItemSelect = null;
|
|
@@ -4019,17 +4044,17 @@ var Et = class {
|
|
|
4019
4044
|
destroy() {
|
|
4020
4045
|
this.hide(), this.onItemSelect = null;
|
|
4021
4046
|
}
|
|
4022
|
-
},
|
|
4047
|
+
}, Nt = class {
|
|
4023
4048
|
orders = [];
|
|
4024
4049
|
positions = [];
|
|
4025
4050
|
depthData = null;
|
|
4026
4051
|
currentPrice = null;
|
|
4027
4052
|
config;
|
|
4028
|
-
orderRenderer = new
|
|
4029
|
-
positionRenderer = new
|
|
4030
|
-
depthOverlay = new
|
|
4053
|
+
orderRenderer = new Ot();
|
|
4054
|
+
positionRenderer = new kt();
|
|
4055
|
+
depthOverlay = new At();
|
|
4031
4056
|
dragHandler;
|
|
4032
|
-
contextMenu = new
|
|
4057
|
+
contextMenu = new Mt();
|
|
4033
4058
|
requestRender = null;
|
|
4034
4059
|
eventCallback = null;
|
|
4035
4060
|
container = null;
|
|
@@ -4037,7 +4062,7 @@ var Et = class {
|
|
|
4037
4062
|
this.config = {
|
|
4038
4063
|
...a,
|
|
4039
4064
|
...e
|
|
4040
|
-
}, this.dragHandler = new
|
|
4065
|
+
}, this.dragHandler = new jt(this.config.dragThreshold), this.contextMenu.onItemSelect = (e) => {
|
|
4041
4066
|
this.eventCallback?.("orderPlace", e);
|
|
4042
4067
|
};
|
|
4043
4068
|
}
|
|
@@ -4098,7 +4123,7 @@ var Et = class {
|
|
|
4098
4123
|
destroy() {
|
|
4099
4124
|
this.contextMenu.destroy();
|
|
4100
4125
|
}
|
|
4101
|
-
},
|
|
4126
|
+
}, Pt = class {
|
|
4102
4127
|
constructor(e) {
|
|
4103
4128
|
this.manager = e;
|
|
4104
4129
|
}
|
|
@@ -4108,7 +4133,7 @@ var Et = class {
|
|
|
4108
4133
|
renderAxisBadges(e, t, n) {
|
|
4109
4134
|
this.manager.renderAxisBadges(e, t, n);
|
|
4110
4135
|
}
|
|
4111
|
-
},
|
|
4136
|
+
}, G = class {
|
|
4112
4137
|
listeners = /* @__PURE__ */ new Map();
|
|
4113
4138
|
on(e, t) {
|
|
4114
4139
|
let n = this.listeners.get(e);
|
|
@@ -4130,7 +4155,7 @@ var Et = class {
|
|
|
4130
4155
|
removeAllListeners() {
|
|
4131
4156
|
this.listeners.clear();
|
|
4132
4157
|
}
|
|
4133
|
-
},
|
|
4158
|
+
}, Ft = class extends G {
|
|
4134
4159
|
currentBar = null;
|
|
4135
4160
|
timeframeMs;
|
|
4136
4161
|
tickRing;
|
|
@@ -4192,7 +4217,7 @@ var Et = class {
|
|
|
4192
4217
|
alignToTimeframe(e) {
|
|
4193
4218
|
return Math.floor(e / this.timeframeMs) * this.timeframeMs;
|
|
4194
4219
|
}
|
|
4195
|
-
},
|
|
4220
|
+
}, K = class extends G {
|
|
4196
4221
|
config;
|
|
4197
4222
|
attempt = 0;
|
|
4198
4223
|
timer = null;
|
|
@@ -4239,7 +4264,7 @@ var Et = class {
|
|
|
4239
4264
|
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);
|
|
4240
4265
|
return Math.max(0, Math.round(n + r));
|
|
4241
4266
|
}
|
|
4242
|
-
},
|
|
4267
|
+
}, It = class {
|
|
4243
4268
|
price = null;
|
|
4244
4269
|
previousClose = null;
|
|
4245
4270
|
visible = !0;
|
|
@@ -4270,12 +4295,12 @@ var Et = class {
|
|
|
4270
4295
|
let f = s - 5;
|
|
4271
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(l, s + 5, r);
|
|
4272
4297
|
}
|
|
4273
|
-
},
|
|
4298
|
+
}, Lt = class extends G {
|
|
4274
4299
|
config = null;
|
|
4275
4300
|
adapter = null;
|
|
4276
4301
|
aggregator = null;
|
|
4277
4302
|
reconnector;
|
|
4278
|
-
priceLine = new
|
|
4303
|
+
priceLine = new It();
|
|
4279
4304
|
state = "disconnected";
|
|
4280
4305
|
lastPrice = null;
|
|
4281
4306
|
previousClose = null;
|
|
@@ -4283,13 +4308,13 @@ var Et = class {
|
|
|
4283
4308
|
heartbeatTimer = null;
|
|
4284
4309
|
lastMessageTime = 0;
|
|
4285
4310
|
constructor() {
|
|
4286
|
-
super(), this.reconnector = new
|
|
4311
|
+
super(), this.reconnector = new K(), this.wireReconnector();
|
|
4287
4312
|
}
|
|
4288
4313
|
async connect(e) {
|
|
4289
4314
|
this.disconnect(), this.config = {
|
|
4290
4315
|
...i,
|
|
4291
4316
|
...e
|
|
4292
|
-
}, this.adapter = e.adapter, this.aggregator = new
|
|
4317
|
+
}, this.adapter = e.adapter, this.aggregator = new Ft(e.timeframe), this.reconnector.removeAllListeners(), this.reconnector.stop(), this.reconnector = new K(e.reconnect ?? r), this.wireReconnector(), this.aggregator.on("bar", (e) => {
|
|
4293
4318
|
this.emit("barUpdate", e), this.updatePrice(e.close);
|
|
4294
4319
|
}), this.aggregator.on("barClose", (e) => {
|
|
4295
4320
|
this.previousClose = e.close, this.emit("barClose", e);
|
|
@@ -4349,20 +4374,28 @@ var Et = class {
|
|
|
4349
4374
|
});
|
|
4350
4375
|
}
|
|
4351
4376
|
wireAdapter() {
|
|
4352
|
-
|
|
4377
|
+
if (!this.adapter) return;
|
|
4378
|
+
let e = this.adapter, t = (e) => {
|
|
4353
4379
|
let t = e.data;
|
|
4354
4380
|
this.lastMessageTime = Date.now(), t === "connected" ? (this.reconnector.onConnected(), this.setState("connected")) : (t === "disconnected" || t === "error") && this.reconnector.schedule(() => this.doConnect());
|
|
4355
|
-
}
|
|
4381
|
+
};
|
|
4382
|
+
e.on("connectionChange", t), this.unsubscribers.push(() => e.off("connectionChange", t));
|
|
4383
|
+
let n = (e) => {
|
|
4356
4384
|
this.lastMessageTime = Date.now();
|
|
4357
4385
|
let t = e.data;
|
|
4358
4386
|
this.emit("tick", t), this.config?.aggregateTicks && this.aggregator ? this.aggregator.processTick(t) : this.updatePrice(t.price);
|
|
4359
|
-
}
|
|
4387
|
+
};
|
|
4388
|
+
e.on("tick", n), this.unsubscribers.push(() => e.off("tick", n));
|
|
4389
|
+
let r = (e) => {
|
|
4360
4390
|
this.lastMessageTime = Date.now();
|
|
4361
4391
|
let { bar: t, closed: n } = e.data;
|
|
4362
4392
|
this.aggregator && this.aggregator.processBar(t, n);
|
|
4363
|
-
}
|
|
4393
|
+
};
|
|
4394
|
+
e.on("bar", r), this.unsubscribers.push(() => e.off("bar", r));
|
|
4395
|
+
let i = (e) => {
|
|
4364
4396
|
this.emit("error", { message: e.data?.message ?? "Adapter error" });
|
|
4365
|
-
}
|
|
4397
|
+
};
|
|
4398
|
+
e.on("error", i), this.unsubscribers.push(() => e.off("error", i));
|
|
4366
4399
|
}
|
|
4367
4400
|
updatePrice(e) {
|
|
4368
4401
|
e !== this.lastPrice && (this.lastPrice = e, this.priceLine.setPrice(e, this.previousClose ?? void 0), this.emit("priceChange", {
|
|
@@ -4391,7 +4424,7 @@ var Et = class {
|
|
|
4391
4424
|
dispose() {
|
|
4392
4425
|
this.disconnect(), this.removeAllListeners();
|
|
4393
4426
|
}
|
|
4394
|
-
},
|
|
4427
|
+
}, Rt = {
|
|
4395
4428
|
"1s": "1s",
|
|
4396
4429
|
"1m": "1m",
|
|
4397
4430
|
"3m": "3m",
|
|
@@ -4408,7 +4441,7 @@ var Et = class {
|
|
|
4408
4441
|
"3d": "3d",
|
|
4409
4442
|
"1w": "1w",
|
|
4410
4443
|
"1M": "1M"
|
|
4411
|
-
},
|
|
4444
|
+
}, zt = class {
|
|
4412
4445
|
name = "binance";
|
|
4413
4446
|
ws = null;
|
|
4414
4447
|
state = "disconnected";
|
|
@@ -4429,7 +4462,7 @@ var Et = class {
|
|
|
4429
4462
|
return this.state;
|
|
4430
4463
|
}
|
|
4431
4464
|
async fetchHistory(e, t, n = 500) {
|
|
4432
|
-
let r =
|
|
4465
|
+
let r = Rt[t] ?? "15m", i = `${this.restBase}/klines?symbol=${e}&interval=${r}&limit=${n}`, a = await fetch(i);
|
|
4433
4466
|
if (!a.ok) throw Error(`Binance REST error: ${a.status}`);
|
|
4434
4467
|
return (await a.json()).map((e) => ({
|
|
4435
4468
|
time: e[0],
|
|
@@ -4452,7 +4485,7 @@ var Et = class {
|
|
|
4452
4485
|
}
|
|
4453
4486
|
connectWs() {
|
|
4454
4487
|
if (!this.config) return;
|
|
4455
|
-
let e = `${this.config.symbol.toLowerCase()}@kline_${
|
|
4488
|
+
let e = `${this.config.symbol.toLowerCase()}@kline_${Rt[this.config.timeframe] ?? "15m"}`, t = `${this.wsBase}/${e}`;
|
|
4456
4489
|
this.setState("connecting");
|
|
4457
4490
|
try {
|
|
4458
4491
|
this.ws = new WebSocket(t);
|
|
@@ -4505,7 +4538,7 @@ var Et = class {
|
|
|
4505
4538
|
for (let e of n) e(r);
|
|
4506
4539
|
}
|
|
4507
4540
|
}
|
|
4508
|
-
},
|
|
4541
|
+
}, Bt = class {
|
|
4509
4542
|
name = "mock";
|
|
4510
4543
|
state = "disconnected";
|
|
4511
4544
|
listeners = /* @__PURE__ */ new Map();
|
|
@@ -4600,7 +4633,7 @@ var Et = class {
|
|
|
4600
4633
|
for (let e of n) e(r);
|
|
4601
4634
|
}
|
|
4602
4635
|
}
|
|
4603
|
-
},
|
|
4636
|
+
}, Vt = {
|
|
4604
4637
|
visible: !0,
|
|
4605
4638
|
showSymbol: !0,
|
|
4606
4639
|
showOHLC: !0,
|
|
@@ -4608,8 +4641,8 @@ var Et = class {
|
|
|
4608
4641
|
showVolume: !0,
|
|
4609
4642
|
position: "top-left",
|
|
4610
4643
|
fontSize: 12
|
|
4611
|
-
},
|
|
4612
|
-
config = { ...
|
|
4644
|
+
}, Ht = class {
|
|
4645
|
+
config = { ...Vt };
|
|
4613
4646
|
symbol = "";
|
|
4614
4647
|
timeframe = "";
|
|
4615
4648
|
hoverBar = null;
|
|
@@ -4696,7 +4729,7 @@ var Et = class {
|
|
|
4696
4729
|
}
|
|
4697
4730
|
}
|
|
4698
4731
|
}
|
|
4699
|
-
},
|
|
4732
|
+
}, Ut = class {
|
|
4700
4733
|
static toDataURL(e, t) {
|
|
4701
4734
|
let n = e.querySelectorAll("canvas");
|
|
4702
4735
|
if (n.length === 0) return "";
|
|
@@ -4718,7 +4751,7 @@ var Et = class {
|
|
|
4718
4751
|
let i = document.createElement("a");
|
|
4719
4752
|
i.href = r, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i);
|
|
4720
4753
|
}
|
|
4721
|
-
},
|
|
4754
|
+
}, Wt = class {
|
|
4722
4755
|
config = null;
|
|
4723
4756
|
setConfig(e) {
|
|
4724
4757
|
this.config = e;
|
|
@@ -4728,7 +4761,7 @@ var Et = class {
|
|
|
4728
4761
|
let { chartRect: r } = t, i = this.config.fontSize ?? 48, a = this.config.color ?? n.textSecondary;
|
|
4729
4762
|
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();
|
|
4730
4763
|
}
|
|
4731
|
-
},
|
|
4764
|
+
}, Gt = class {
|
|
4732
4765
|
visible = !0;
|
|
4733
4766
|
timeframeMs = 0;
|
|
4734
4767
|
setVisible(e) {
|
|
@@ -4751,7 +4784,7 @@ var Et = class {
|
|
|
4751
4784
|
let t = Math.ceil(e / 1e3), n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), i = t % 60;
|
|
4752
4785
|
return n > 0 ? `${n}:${String(r).padStart(2, "0")}:${String(i).padStart(2, "0")}` : `${r}:${String(i).padStart(2, "0")}`;
|
|
4753
4786
|
}
|
|
4754
|
-
},
|
|
4787
|
+
}, Kt = class {
|
|
4755
4788
|
config = { visible: !1 };
|
|
4756
4789
|
cachedBreaks = [];
|
|
4757
4790
|
lastDataLength = 0;
|
|
@@ -4795,7 +4828,7 @@ var Et = class {
|
|
|
4795
4828
|
invalidateCache() {
|
|
4796
4829
|
this.lastDataLength = 0, this.cachedBreaks = [];
|
|
4797
4830
|
}
|
|
4798
|
-
},
|
|
4831
|
+
}, qt = 1, Jt = class extends G {
|
|
4799
4832
|
alerts = [];
|
|
4800
4833
|
lastPrice = null;
|
|
4801
4834
|
requestRender = null;
|
|
@@ -4807,7 +4840,7 @@ var Et = class {
|
|
|
4807
4840
|
this.pricePrecision = e;
|
|
4808
4841
|
}
|
|
4809
4842
|
addAlert(e, t = "crossing", n, r = !1) {
|
|
4810
|
-
let i = `tc_alert_${
|
|
4843
|
+
let i = `tc_alert_${qt++}`, a = {
|
|
4811
4844
|
id: i,
|
|
4812
4845
|
price: e,
|
|
4813
4846
|
condition: t,
|
|
@@ -4887,7 +4920,7 @@ var Et = class {
|
|
|
4887
4920
|
e.fillText(s, r.x + r.width - 4, a - 2);
|
|
4888
4921
|
}
|
|
4889
4922
|
}
|
|
4890
|
-
},
|
|
4923
|
+
}, Yt = class extends G {
|
|
4891
4924
|
data = [];
|
|
4892
4925
|
currentIndex = 0;
|
|
4893
4926
|
timer = null;
|
|
@@ -4941,10 +4974,10 @@ var Et = class {
|
|
|
4941
4974
|
dispose() {
|
|
4942
4975
|
this.stop(), this.removeAllListeners(), this.data = [];
|
|
4943
4976
|
}
|
|
4944
|
-
},
|
|
4977
|
+
}, q = 1, Xt = class {
|
|
4945
4978
|
static capture(e, t) {
|
|
4946
4979
|
return {
|
|
4947
|
-
version:
|
|
4980
|
+
version: q,
|
|
4948
4981
|
timestamp: Date.now(),
|
|
4949
4982
|
chartType: t?.chartType ?? "candlestick",
|
|
4950
4983
|
symbol: t?.symbol,
|
|
@@ -4967,7 +5000,7 @@ var Et = class {
|
|
|
4967
5000
|
}
|
|
4968
5001
|
static deserialize(e) {
|
|
4969
5002
|
let t = JSON.parse(e);
|
|
4970
|
-
return t.version !==
|
|
5003
|
+
return t.version !== q && console.warn(`Chart state version mismatch: ${t.version} vs ${q}`), t;
|
|
4971
5004
|
}
|
|
4972
5005
|
static saveToStorage(e, t) {
|
|
4973
5006
|
localStorage.setItem(e, this.serialize(t));
|
|
@@ -4994,7 +5027,7 @@ var Et = class {
|
|
|
4994
5027
|
}, n.click();
|
|
4995
5028
|
});
|
|
4996
5029
|
}
|
|
4997
|
-
},
|
|
5030
|
+
}, Zt = class {
|
|
4998
5031
|
undoStack = [];
|
|
4999
5032
|
redoStack = [];
|
|
5000
5033
|
maxHistory = 50;
|
|
@@ -5030,7 +5063,7 @@ var Et = class {
|
|
|
5030
5063
|
redoCount: this.redoStack.length
|
|
5031
5064
|
};
|
|
5032
5065
|
}
|
|
5033
|
-
},
|
|
5066
|
+
}, Qt = class {
|
|
5034
5067
|
static toCSV(e) {
|
|
5035
5068
|
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");
|
|
5036
5069
|
}
|
|
@@ -5048,7 +5081,7 @@ var Et = class {
|
|
|
5048
5081
|
let r = new Blob([e], { type: n }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
5049
5082
|
a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
5050
5083
|
}
|
|
5051
|
-
},
|
|
5084
|
+
}, $t = {
|
|
5052
5085
|
linear: (e) => e,
|
|
5053
5086
|
easeOutCubic: (e) => 1 - (1 - e) ** 3,
|
|
5054
5087
|
easeOutQuart: (e) => 1 - (1 - e) ** 4,
|
|
@@ -5056,7 +5089,7 @@ var Et = class {
|
|
|
5056
5089
|
easeOutExpo: (e) => e === 1 ? 1 : 1 - 2 ** (-10 * e),
|
|
5057
5090
|
easeOutElastic: (e) => e === 0 || e === 1 ? e : 2 ** (-10 * e) * Math.sin((e * 10 - .75) * (2 * Math.PI / 3)) + 1,
|
|
5058
5091
|
spring: (e) => 1 - Math.E ** (-6 * e) * Math.cos(8 * e)
|
|
5059
|
-
},
|
|
5092
|
+
}, en = class {
|
|
5060
5093
|
animations = /* @__PURE__ */ new Map();
|
|
5061
5094
|
frameId = 0;
|
|
5062
5095
|
running = !1;
|
|
@@ -5064,7 +5097,7 @@ var Et = class {
|
|
|
5064
5097
|
this.animations.set(e, {
|
|
5065
5098
|
startTime: -1,
|
|
5066
5099
|
duration: t.duration,
|
|
5067
|
-
easing: t.easing ??
|
|
5100
|
+
easing: t.easing ?? $t.easeOutCubic,
|
|
5068
5101
|
onUpdate: t.onUpdate,
|
|
5069
5102
|
onComplete: t.onComplete
|
|
5070
5103
|
}), this.running || (this.running = !0, this.tick());
|
|
@@ -5099,10 +5132,10 @@ var Et = class {
|
|
|
5099
5132
|
};
|
|
5100
5133
|
//#endregion
|
|
5101
5134
|
//#region src/finance/BaseFinanceChart.ts
|
|
5102
|
-
function
|
|
5135
|
+
function tn(t) {
|
|
5103
5136
|
return !t || t === "dark" ? e : t === "light" ? o : t;
|
|
5104
5137
|
}
|
|
5105
|
-
var
|
|
5138
|
+
var nn = class {
|
|
5106
5139
|
canvas;
|
|
5107
5140
|
ctx;
|
|
5108
5141
|
container;
|
|
@@ -5113,7 +5146,7 @@ var en = class {
|
|
|
5113
5146
|
frameId = null;
|
|
5114
5147
|
resizeObserver;
|
|
5115
5148
|
constructor(e, t) {
|
|
5116
|
-
this.container = e, this.theme =
|
|
5149
|
+
this.container = e, this.theme = tn(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(() => {
|
|
5117
5150
|
this.updateSize(), this.requestRender();
|
|
5118
5151
|
}), this.resizeObserver.observe(e);
|
|
5119
5152
|
}
|
|
@@ -5128,12 +5161,12 @@ var en = class {
|
|
|
5128
5161
|
}));
|
|
5129
5162
|
}
|
|
5130
5163
|
setTheme(e) {
|
|
5131
|
-
this.theme =
|
|
5164
|
+
this.theme = tn(e), this.requestRender();
|
|
5132
5165
|
}
|
|
5133
5166
|
destroy() {
|
|
5134
5167
|
this.frameId !== null && cancelAnimationFrame(this.frameId), this.resizeObserver.disconnect(), this.canvas.remove();
|
|
5135
5168
|
}
|
|
5136
|
-
},
|
|
5169
|
+
}, rn = class {
|
|
5137
5170
|
pos = null;
|
|
5138
5171
|
canvas;
|
|
5139
5172
|
onUpdate;
|
|
@@ -5165,7 +5198,7 @@ var en = class {
|
|
|
5165
5198
|
};
|
|
5166
5199
|
//#endregion
|
|
5167
5200
|
//#region src/finance/SparklineRenderer.ts
|
|
5168
|
-
function
|
|
5201
|
+
function an(e, t, n, r, i) {
|
|
5169
5202
|
let { data: a, mode: o = "area", lineWidth: s = 1.5, showLastPoint: c = !1, showMinMax: l = !1 } = r;
|
|
5170
5203
|
if (a.length < 2 || t <= 0 || n <= 0) return;
|
|
5171
5204
|
let u = r.color ?? i.lineColor, d = r.fillColor ?? u, f = t - 4, p = n - 4, m = Infinity, h = -Infinity, g = 0, _ = 0;
|
|
@@ -5190,8 +5223,8 @@ function nn(e, t, n, r, i) {
|
|
|
5190
5223
|
}
|
|
5191
5224
|
//#endregion
|
|
5192
5225
|
//#region src/finance/DepthChartRenderer.ts
|
|
5193
|
-
var
|
|
5194
|
-
function
|
|
5226
|
+
var on = 50, sn = 60, J = 20, cn = .2;
|
|
5227
|
+
function ln(e) {
|
|
5195
5228
|
let t = [...e].sort((e, t) => t.price - e.price), n = [], r = 0;
|
|
5196
5229
|
for (let e of t) r += e.volume, n.push({
|
|
5197
5230
|
price: e.price,
|
|
@@ -5199,7 +5232,7 @@ function sn(e) {
|
|
|
5199
5232
|
});
|
|
5200
5233
|
return n;
|
|
5201
5234
|
}
|
|
5202
|
-
function
|
|
5235
|
+
function un(e) {
|
|
5203
5236
|
let t = [...e].sort((e, t) => e.price - t.price), n = [], r = 0;
|
|
5204
5237
|
for (let e of t) r += e.volume, n.push({
|
|
5205
5238
|
price: e.price,
|
|
@@ -5207,20 +5240,20 @@ function cn(e) {
|
|
|
5207
5240
|
});
|
|
5208
5241
|
return n;
|
|
5209
5242
|
}
|
|
5210
|
-
function
|
|
5243
|
+
function dn(e, t) {
|
|
5211
5244
|
return {
|
|
5212
|
-
left:
|
|
5213
|
-
right: e -
|
|
5214
|
-
top:
|
|
5215
|
-
bottom: t -
|
|
5216
|
-
plotWidth: e -
|
|
5217
|
-
plotHeight: t -
|
|
5245
|
+
left: on,
|
|
5246
|
+
right: e - sn,
|
|
5247
|
+
top: J,
|
|
5248
|
+
bottom: t - J,
|
|
5249
|
+
plotWidth: e - on - sn,
|
|
5250
|
+
plotHeight: t - J * 2
|
|
5218
5251
|
};
|
|
5219
5252
|
}
|
|
5220
|
-
function
|
|
5253
|
+
function fn(e, t, n, r) {
|
|
5221
5254
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
5222
5255
|
}
|
|
5223
|
-
function
|
|
5256
|
+
function pn(e, t, n, r, i, a, o, s) {
|
|
5224
5257
|
let { left: c, right: l, top: u, bottom: d, plotWidth: p, plotHeight: m } = t;
|
|
5225
5258
|
e.save(), e.strokeStyle = a.grid, e.lineWidth = .5, e.fillStyle = a.axisLabel, e.font = `${a.font.sizeSmall}px ${a.font.family}`;
|
|
5226
5259
|
let h = f(0, i, 5);
|
|
@@ -5235,7 +5268,7 @@ function dn(e, t, n, r, i, a, o, s) {
|
|
|
5235
5268
|
}
|
|
5236
5269
|
e.restore();
|
|
5237
5270
|
}
|
|
5238
|
-
function
|
|
5271
|
+
function mn(e, t, n, r, i, a, o, s, c) {
|
|
5239
5272
|
if (t.length === 0) return;
|
|
5240
5273
|
let { left: l, bottom: u, plotWidth: d, plotHeight: f } = n, p = (e) => l + (e - r) / i * d, m = (e) => u - e / a * f;
|
|
5241
5274
|
if (e.beginPath(), c === "bid") {
|
|
@@ -5268,14 +5301,14 @@ function fn(e, t, n, r, i, a, o, s, c) {
|
|
|
5268
5301
|
}
|
|
5269
5302
|
e.strokeStyle = s, e.lineWidth = 1.5, e.stroke();
|
|
5270
5303
|
}
|
|
5271
|
-
function
|
|
5304
|
+
function hn(e, t, n, r, i, a, o, s, c) {
|
|
5272
5305
|
let { left: l, top: u, bottom: d, plotWidth: f } = r, p = l + (t - i) / a * f;
|
|
5273
5306
|
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) {
|
|
5274
5307
|
let t = `Spread: ${c(n)}`;
|
|
5275
5308
|
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();
|
|
5276
5309
|
}
|
|
5277
5310
|
}
|
|
5278
|
-
function
|
|
5311
|
+
function gn(e, t, n, r, i, a, o, s, c, l, u) {
|
|
5279
5312
|
let { left: d, top: f, bottom: p, plotWidth: m, plotHeight: h } = i, g = t.x;
|
|
5280
5313
|
if (g < d || g > i.right) return;
|
|
5281
5314
|
let _ = a + (g - d) / m * o, v = 0, y = "";
|
|
@@ -5301,47 +5334,47 @@ function mn(e, t, n, r, i, a, o, s, c, l, u) {
|
|
|
5301
5334
|
for (let t = 0; t < b.length; t++) e.fillText(b[t], C + 8, w + 6 + t * (c.font.sizeSmall + 4));
|
|
5302
5335
|
e.restore();
|
|
5303
5336
|
}
|
|
5304
|
-
function
|
|
5337
|
+
function _n(e) {
|
|
5305
5338
|
return e.toFixed(2);
|
|
5306
5339
|
}
|
|
5307
|
-
function
|
|
5340
|
+
function vn(e) {
|
|
5308
5341
|
return e >= 1e6 ? (e / 1e6).toFixed(2) + "M" : e >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(0);
|
|
5309
5342
|
}
|
|
5310
|
-
function
|
|
5343
|
+
function yn(e, t, n, r, i, a) {
|
|
5311
5344
|
let { data: o } = r;
|
|
5312
5345
|
if (o.bids.length === 0 && o.asks.length === 0 || t <= 0 || n <= 0) return;
|
|
5313
|
-
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 ??
|
|
5314
|
-
|
|
5346
|
+
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 ?? _n, m = r.volumeFormat ?? vn, h = ln(o.bids), g = un(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 + cn), 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 = dn(t, n);
|
|
5347
|
+
fn(e, t, n, i.background), pn(e, A, w, T, k, i, p, m), mn(e, h, A, w, E, k, l, s, "bid"), mn(e, g, A, w, E, k, u, c, "ask"), d && hn(e, y, b, A, w, E, i, f, p), a && gn(e, a, h, g, A, w, E, k, i, p, m);
|
|
5315
5348
|
}
|
|
5316
5349
|
//#endregion
|
|
5317
5350
|
//#region src/finance/EquityCurveRenderer.ts
|
|
5318
|
-
var
|
|
5319
|
-
function
|
|
5351
|
+
var bn = 70, xn = 30, Sn = 20, Cn = 20, wn = .05;
|
|
5352
|
+
function Tn(e, t) {
|
|
5320
5353
|
return {
|
|
5321
|
-
left:
|
|
5322
|
-
right: e -
|
|
5323
|
-
top:
|
|
5324
|
-
bottom: t -
|
|
5325
|
-
plotWidth: e -
|
|
5326
|
-
plotHeight: t -
|
|
5354
|
+
left: bn,
|
|
5355
|
+
right: e - Sn,
|
|
5356
|
+
top: Cn,
|
|
5357
|
+
bottom: t - xn,
|
|
5358
|
+
plotWidth: e - bn - Sn,
|
|
5359
|
+
plotHeight: t - Cn - xn
|
|
5327
5360
|
};
|
|
5328
5361
|
}
|
|
5329
|
-
function
|
|
5362
|
+
function En(e, t) {
|
|
5330
5363
|
let n = Infinity, r = -Infinity;
|
|
5331
5364
|
for (let t of e) t.value < n && (n = t.value), t.value > r && (r = t.value);
|
|
5332
5365
|
if (t) for (let e of t) e.value < n && (n = e.value), e.value > r && (r = e.value);
|
|
5333
|
-
let i = (r - n) *
|
|
5366
|
+
let i = (r - n) * wn;
|
|
5334
5367
|
return {
|
|
5335
5368
|
valMin: n - i,
|
|
5336
5369
|
valMax: r + i
|
|
5337
5370
|
};
|
|
5338
5371
|
}
|
|
5339
|
-
function
|
|
5372
|
+
function Dn(e) {
|
|
5340
5373
|
let t = [], n = -Infinity;
|
|
5341
5374
|
for (let r of e) r.value > n && (n = r.value), t.push(n);
|
|
5342
5375
|
return t;
|
|
5343
5376
|
}
|
|
5344
|
-
function
|
|
5377
|
+
function On(e) {
|
|
5345
5378
|
let t = 864e5;
|
|
5346
5379
|
if (365.25 * t, e < 7 * t) {
|
|
5347
5380
|
let e = new Intl.DateTimeFormat(void 0, {
|
|
@@ -5363,13 +5396,13 @@ function En(e) {
|
|
|
5363
5396
|
});
|
|
5364
5397
|
return (e) => n.format(new Date(e));
|
|
5365
5398
|
}
|
|
5366
|
-
function
|
|
5399
|
+
function kn(e) {
|
|
5367
5400
|
return Math.abs(e) >= 1e6 ? (e / 1e6).toFixed(2) + "M" : Math.abs(e) >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(2);
|
|
5368
5401
|
}
|
|
5369
|
-
function
|
|
5402
|
+
function An(e, t, n, r) {
|
|
5370
5403
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
5371
5404
|
}
|
|
5372
|
-
function
|
|
5405
|
+
function jn(e, t, n, r, i, a, o, s, c) {
|
|
5373
5406
|
let { left: l, right: u, top: d, bottom: p, plotWidth: m, plotHeight: h } = t;
|
|
5374
5407
|
e.save(), e.strokeStyle = o.grid, e.lineWidth = .5, e.fillStyle = o.axisLabel, e.font = `${o.font.sizeSmall}px ${o.font.family}`;
|
|
5375
5408
|
let g = f(n, r, 6), _ = Math.ceil(n / g) * g;
|
|
@@ -5384,21 +5417,21 @@ function kn(e, t, n, r, i, a, o, s, c) {
|
|
|
5384
5417
|
}
|
|
5385
5418
|
e.restore();
|
|
5386
5419
|
}
|
|
5387
|
-
function
|
|
5420
|
+
function Mn(e, t, n, r, i, a, o, s, c) {
|
|
5388
5421
|
if (t.length < 2) return;
|
|
5389
5422
|
let { left: l, bottom: u, plotWidth: d, plotHeight: f } = n, p = (e) => l + (e - r) / i * d, m = (e) => u - (e - a) / o * f;
|
|
5390
5423
|
e.save(), e.beginPath(), e.moveTo(p(t[0].time), m(t[0].value));
|
|
5391
5424
|
for (let n = 1; n < t.length; n++) e.lineTo(p(t[n].time), m(t[n].value));
|
|
5392
5425
|
e.strokeStyle = s, e.lineWidth = c, e.lineJoin = "round", e.stroke(), e.restore();
|
|
5393
5426
|
}
|
|
5394
|
-
function
|
|
5427
|
+
function Nn(e, t, n, r, i, a, o, s) {
|
|
5395
5428
|
if (t.length < 2) return;
|
|
5396
5429
|
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);
|
|
5397
5430
|
m.addColorStop(0, s + "40"), m.addColorStop(1, "transparent"), e.save(), e.beginPath(), e.moveTo(f(t[0].time), p(t[0].value));
|
|
5398
5431
|
for (let n = 1; n < t.length; n++) e.lineTo(f(t[n].time), p(t[n].value));
|
|
5399
5432
|
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();
|
|
5400
5433
|
}
|
|
5401
|
-
function
|
|
5434
|
+
function Pn(e, t, n, r, i, a, o, s, c) {
|
|
5402
5435
|
if (t.length < 2) return;
|
|
5403
5436
|
let { left: l, bottom: u, plotWidth: d, plotHeight: f } = r, p = (e) => l + (e - i) / a * d, m = (e) => u - (e - o) / s * f;
|
|
5404
5437
|
e.save(), e.fillStyle = c, e.beginPath(), e.moveTo(p(t[0].time), m(n[0]));
|
|
@@ -5406,12 +5439,12 @@ function Mn(e, t, n, r, i, a, o, s, c) {
|
|
|
5406
5439
|
for (let n = t.length - 1; n >= 0; n--) e.lineTo(p(t[n].time), m(t[n].value));
|
|
5407
5440
|
e.closePath(), e.fill(), e.restore();
|
|
5408
5441
|
}
|
|
5409
|
-
function
|
|
5442
|
+
function Fn(e, t, n, r, i, a, o, s, c, l) {
|
|
5410
5443
|
if (t.length === 0) return;
|
|
5411
5444
|
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;
|
|
5412
5445
|
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();
|
|
5413
5446
|
}
|
|
5414
|
-
function
|
|
5447
|
+
function In(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
5415
5448
|
let { left: f, top: p, bottom: m, plotWidth: h, plotHeight: g } = i, _ = t.x;
|
|
5416
5449
|
if (_ < f || _ > i.right) return;
|
|
5417
5450
|
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();
|
|
@@ -5429,15 +5462,15 @@ function Pn(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
5429
5462
|
for (let t = 0; t < S.length; t++) e.fillText(S[t], D + 8, O + 6 + t * (l.font.sizeSmall + 4));
|
|
5430
5463
|
e.restore();
|
|
5431
5464
|
}
|
|
5432
|
-
function
|
|
5465
|
+
function Ln(e, t, n, r, i, a) {
|
|
5433
5466
|
let { data: o } = r;
|
|
5434
5467
|
if (o.length < 2 || t <= 0 || n <= 0) return;
|
|
5435
|
-
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 ??
|
|
5436
|
-
|
|
5468
|
+
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 ?? kn, { valMin: g, valMax: _ } = En(o, f), v = _ - g || 1, y = o[0].time, b = o[o.length - 1].time, x = b - y || 1, S = r.timeFormat ?? On(x), C = Tn(t, n);
|
|
5469
|
+
An(e, t, n, i.background), jn(e, C, g, _, y, b, i, h, S), l && Pn(e, o, Dn(o), C, y, x, g, v, u), d && Nn(e, o, C, y, x, g, v, s), Mn(e, o, C, y, x, g, v, s, c), f && f.length >= 2 && (Mn(e, f, C, y, x, g, v, p, 1), Fn(e, f, C, y, x, g, v, m, p, i)), a && In(e, a, o, f, C, y, x, g, v, i, S, h);
|
|
5437
5470
|
}
|
|
5438
5471
|
//#endregion
|
|
5439
5472
|
//#region src/finance/HeatmapLayout.ts
|
|
5440
|
-
function
|
|
5473
|
+
function Rn(e, t, n) {
|
|
5441
5474
|
if (e.length === 0) return [];
|
|
5442
5475
|
let r = e.length, i = Math.ceil(Math.sqrt(r)), a = Math.ceil(r / i), o = t.width / i, s = t.height / a, c = [];
|
|
5443
5476
|
for (let a = 0; a < r; a++) {
|
|
@@ -5454,7 +5487,7 @@ function In(e, t, n) {
|
|
|
5454
5487
|
}
|
|
5455
5488
|
return c;
|
|
5456
5489
|
}
|
|
5457
|
-
function
|
|
5490
|
+
function zn(e, t) {
|
|
5458
5491
|
let n = e.reduce((e, t) => e + t, 0);
|
|
5459
5492
|
if (n === 0 || t === 0) return Infinity;
|
|
5460
5493
|
let r = 0;
|
|
@@ -5464,7 +5497,7 @@ function Ln(e, t) {
|
|
|
5464
5497
|
}
|
|
5465
5498
|
return r;
|
|
5466
5499
|
}
|
|
5467
|
-
function
|
|
5500
|
+
function Y(e, t, n, r, i, a) {
|
|
5468
5501
|
let o = r ? n.height : n.width, s = e.reduce((e, t) => e + t, 0), c = o > 0 ? s / o : 0, l = 0;
|
|
5469
5502
|
for (let o = 0; o < e.length; o++) {
|
|
5470
5503
|
let s = c > 0 ? e[o] / c : 0, u;
|
|
@@ -5484,19 +5517,19 @@ function X(e, t, n, r, i, a) {
|
|
|
5484
5517
|
}), l += s;
|
|
5485
5518
|
}
|
|
5486
5519
|
}
|
|
5487
|
-
function
|
|
5520
|
+
function Bn(e, t, n, r, i) {
|
|
5488
5521
|
if (e.length === 0) return;
|
|
5489
5522
|
let a = n.width >= n.height, o = a ? n.height : n.width;
|
|
5490
5523
|
if (e.length === 1) {
|
|
5491
|
-
|
|
5524
|
+
Y(e, t, n, a, r, i);
|
|
5492
5525
|
return;
|
|
5493
5526
|
}
|
|
5494
5527
|
let s = [], c = [], l = 0;
|
|
5495
5528
|
for (; l < e.length;) {
|
|
5496
5529
|
let u = [...s, e[l]];
|
|
5497
|
-
if (s.length === 0 ||
|
|
5530
|
+
if (s.length === 0 || zn(u, o) <= zn(s, o)) s.push(e[l]), c.push(t[l]), l++;
|
|
5498
5531
|
else {
|
|
5499
|
-
|
|
5532
|
+
Y(s, c, n, a, r, i);
|
|
5500
5533
|
let u = s.reduce((e, t) => e + t, 0), d = o > 0 ? u / o : 0;
|
|
5501
5534
|
n = a ? {
|
|
5502
5535
|
x: n.x + d,
|
|
@@ -5508,28 +5541,28 @@ function Rn(e, t, n, r, i) {
|
|
|
5508
5541
|
y: n.y + d,
|
|
5509
5542
|
width: n.width,
|
|
5510
5543
|
height: n.height - d
|
|
5511
|
-
},
|
|
5544
|
+
}, Bn(e.slice(l), t.slice(l), n, r, i);
|
|
5512
5545
|
return;
|
|
5513
5546
|
}
|
|
5514
5547
|
}
|
|
5515
|
-
s.length > 0 &&
|
|
5548
|
+
s.length > 0 && Y(s, c, n, a, r, i);
|
|
5516
5549
|
}
|
|
5517
|
-
function
|
|
5550
|
+
function Vn(e, t, n) {
|
|
5518
5551
|
if (e.length === 0) return [];
|
|
5519
5552
|
let r = [...e].sort((e, t) => t.weight - e.weight), i = r.reduce((e, t) => e + Math.max(0, t.weight), 0);
|
|
5520
5553
|
if (i === 0) return [];
|
|
5521
5554
|
let a = t.width * t.height, o = r.map((e) => Math.max(0, e.weight) / i * a), s = r.map((e) => e.id), c = [];
|
|
5522
|
-
return
|
|
5555
|
+
return Bn(o, s, { ...t }, n, c), c;
|
|
5523
5556
|
}
|
|
5524
5557
|
//#endregion
|
|
5525
5558
|
//#region src/finance/HeatmapRenderer.ts
|
|
5526
|
-
function
|
|
5559
|
+
function Hn(e) {
|
|
5527
5560
|
return (e >= 0 ? "+" : "") + e.toFixed(2) + "%";
|
|
5528
5561
|
}
|
|
5529
|
-
function
|
|
5562
|
+
function Un(e) {
|
|
5530
5563
|
return e.label;
|
|
5531
5564
|
}
|
|
5532
|
-
function
|
|
5565
|
+
function Wn(e, t) {
|
|
5533
5566
|
let n = t.min ?? -5, r = t.max ?? 5;
|
|
5534
5567
|
if (e <= n) return t.negative;
|
|
5535
5568
|
if (e >= r) return t.positive;
|
|
@@ -5540,11 +5573,11 @@ function Hn(e, t) {
|
|
|
5540
5573
|
let i = e / r;
|
|
5541
5574
|
return m(t.zero, t.positive, i);
|
|
5542
5575
|
}
|
|
5543
|
-
function
|
|
5576
|
+
function X(e, t, n, r, i, a) {
|
|
5544
5577
|
let o = Math.min(a, r / 2, i / 2);
|
|
5545
5578
|
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();
|
|
5546
5579
|
}
|
|
5547
|
-
function
|
|
5580
|
+
function Gn(e, t, n, r, i, a, o, s, c, l, u) {
|
|
5548
5581
|
if (i < 40 || a < 30) return;
|
|
5549
5582
|
let d = n + i / 2, f = r + a / 2;
|
|
5550
5583
|
if (e.save(), e.shadowColor = "rgba(0,0,0,0.6)", e.shadowBlur = 2, e.fillStyle = "#FFFFFF", e.textAlign = "center", s) {
|
|
@@ -5557,22 +5590,22 @@ function Un(e, t, n, r, i, a, o, s, c, l, u) {
|
|
|
5557
5590
|
}
|
|
5558
5591
|
e.restore();
|
|
5559
5592
|
}
|
|
5560
|
-
function
|
|
5593
|
+
function Kn(e, t, n, r, i, a, o, s) {
|
|
5561
5594
|
let c = [o(t), s(t.value)];
|
|
5562
5595
|
if (t.meta) for (let [e, n] of Object.entries(t.meta)) c.push(e + ": " + String(n));
|
|
5563
5596
|
e.save(), e.font = a.font.sizeSmall + "px " + a.font.family;
|
|
5564
5597
|
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;
|
|
5565
|
-
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,
|
|
5598
|
+
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, X(e, f, p, l, d, 4), e.fill(), e.globalAlpha = 1, e.fillStyle = a.text, e.textBaseline = "top", e.textAlign = "left";
|
|
5566
5599
|
for (let t = 0; t < c.length; t++) e.fillText(c[t], f + 8, p + 6 + t * u);
|
|
5567
5600
|
e.restore();
|
|
5568
5601
|
}
|
|
5569
|
-
function
|
|
5602
|
+
function qn(e, t, n, r, i, a, o, s) {
|
|
5570
5603
|
if (r.length === 0 || i.length === 0 || t <= 0 || n <= 0) return null;
|
|
5571
5604
|
let c = a.colorScale ?? {
|
|
5572
5605
|
negative: "#EF5350",
|
|
5573
5606
|
zero: "#424242",
|
|
5574
5607
|
positive: "#26A69A"
|
|
5575
|
-
}, l = a.cellRadius ?? 4, u = a.showLabels !== !1, d = a.showValues !== !1, f = a.valueFormat ??
|
|
5608
|
+
}, l = a.cellRadius ?? 4, u = a.showLabels !== !1, d = a.showValues !== !1, f = a.valueFormat ?? Hn, p = a.labelFormat ?? Un, m = /* @__PURE__ */ new Map();
|
|
5576
5609
|
for (let e of r) m.set(e.id, e);
|
|
5577
5610
|
let h = null, g = null;
|
|
5578
5611
|
if (s) for (let e of i) {
|
|
@@ -5593,37 +5626,37 @@ function Gn(e, t, n, r, i, a, o, s) {
|
|
|
5593
5626
|
if (!n) continue;
|
|
5594
5627
|
let { x: r, y: i, width: a, height: s } = t.rect;
|
|
5595
5628
|
if (a <= 0 || s <= 0) continue;
|
|
5596
|
-
let g =
|
|
5597
|
-
|
|
5629
|
+
let g = Wn(n.value, c);
|
|
5630
|
+
X(e, r, i, a, s, l), e.fillStyle = g, e.fill(), Gn(e, n, r, i, a, s, o, u, d, p, f), t.id === h && (X(e, r, i, a, s, l), e.strokeStyle = "#FFFFFF", e.lineWidth = 1.5, e.stroke());
|
|
5598
5631
|
}
|
|
5599
|
-
return g && s &&
|
|
5632
|
+
return g && s && Kn(e, g.cell, s, t, n, o, p, f), g;
|
|
5600
5633
|
}
|
|
5601
5634
|
//#endregion
|
|
5602
5635
|
//#region src/finance/WaterfallRenderer.ts
|
|
5603
|
-
var
|
|
5604
|
-
function
|
|
5636
|
+
var Jn = 60, Z = 12, Yn = 24, Xn = 40, Zn = .7, Qn = 1;
|
|
5637
|
+
function $n(e) {
|
|
5605
5638
|
return e.type ? e.type : e.value > 0 ? "positive" : e.value < 0 ? "negative" : "subtotal";
|
|
5606
5639
|
}
|
|
5607
|
-
function
|
|
5640
|
+
function er(e) {
|
|
5608
5641
|
let t = Math.abs(e);
|
|
5609
5642
|
return t >= 1e6 ? (e / 1e6).toFixed(2) + "M" : t >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(2);
|
|
5610
5643
|
}
|
|
5611
|
-
function
|
|
5644
|
+
function tr(e, t) {
|
|
5612
5645
|
return {
|
|
5613
|
-
left:
|
|
5614
|
-
right: e -
|
|
5615
|
-
top:
|
|
5616
|
-
bottom: t -
|
|
5617
|
-
plotWidth: e -
|
|
5618
|
-
plotHeight: t -
|
|
5646
|
+
left: Jn,
|
|
5647
|
+
right: e - Z,
|
|
5648
|
+
top: Yn,
|
|
5649
|
+
bottom: t - Xn,
|
|
5650
|
+
plotWidth: e - Jn - Z,
|
|
5651
|
+
plotHeight: t - Yn - Xn
|
|
5619
5652
|
};
|
|
5620
5653
|
}
|
|
5621
|
-
function
|
|
5654
|
+
function nr(e, t, n, r, i) {
|
|
5622
5655
|
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;
|
|
5623
5656
|
for (let t = 0; t < e.length; t++) {
|
|
5624
|
-
let n = e[t], m =
|
|
5657
|
+
let n = e[t], m = $n(n), h, g;
|
|
5625
5658
|
m === "total" || m === "subtotal" ? (h = 0, g = n.value, p = n.value) : (h = p, g = p + n.value, p = g);
|
|
5626
|
-
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),
|
|
5659
|
+
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), Qn), C = u + t * s, w = C + l;
|
|
5627
5660
|
a[t] = {
|
|
5628
5661
|
label: n.label,
|
|
5629
5662
|
value: n.value,
|
|
@@ -5643,14 +5676,14 @@ function tr(e, t, n, r, i) {
|
|
|
5643
5676
|
cumulatives: o
|
|
5644
5677
|
};
|
|
5645
5678
|
}
|
|
5646
|
-
function
|
|
5679
|
+
function rr(e) {
|
|
5647
5680
|
if (e.length === 0) return {
|
|
5648
5681
|
valMin: 0,
|
|
5649
5682
|
valMax: 1
|
|
5650
5683
|
};
|
|
5651
5684
|
let t = 0, n = 0, r = 0;
|
|
5652
5685
|
for (let i = 0; i < e.length; i++) {
|
|
5653
|
-
let a = e[i], o =
|
|
5686
|
+
let a = e[i], o = $n(a), s, c;
|
|
5654
5687
|
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);
|
|
5655
5688
|
}
|
|
5656
5689
|
let i = (n - t || 1) * .1;
|
|
@@ -5659,10 +5692,10 @@ function nr(e) {
|
|
|
5659
5692
|
valMax: n + i
|
|
5660
5693
|
};
|
|
5661
5694
|
}
|
|
5662
|
-
function
|
|
5695
|
+
function ir(e, t, n, r) {
|
|
5663
5696
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
5664
5697
|
}
|
|
5665
|
-
function
|
|
5698
|
+
function ar(e, t, n, r, i, a) {
|
|
5666
5699
|
let { left: o, right: s, top: c, bottom: l, plotHeight: u } = t, d = r - n || 1;
|
|
5667
5700
|
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";
|
|
5668
5701
|
let p = f(n, r, 5), m = Math.ceil(n / p) * p;
|
|
@@ -5681,7 +5714,7 @@ function ir(e, t, n, r, i, a) {
|
|
|
5681
5714
|
e.strokeStyle = i.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(o, t), e.lineTo(s, t), e.stroke();
|
|
5682
5715
|
}
|
|
5683
5716
|
}
|
|
5684
|
-
function
|
|
5717
|
+
function or(e, t, n) {
|
|
5685
5718
|
let r = [
|
|
5686
5719
|
"positive",
|
|
5687
5720
|
"negative",
|
|
@@ -5700,7 +5733,7 @@ function ar(e, t, n) {
|
|
|
5700
5733
|
s && (e.fillStyle = o, e.fill());
|
|
5701
5734
|
}
|
|
5702
5735
|
}
|
|
5703
|
-
function
|
|
5736
|
+
function sr(e, t, n, r, i, a, o) {
|
|
5704
5737
|
if (o === "none" || t.length < 2) return;
|
|
5705
5738
|
let { bottom: s, plotHeight: c } = n;
|
|
5706
5739
|
e.strokeStyle = a, e.lineWidth = 1, o === "dashed" ? e.setLineDash([4, 4]) : e.setLineDash([]), e.beginPath();
|
|
@@ -5710,7 +5743,7 @@ function or(e, t, n, r, i, a, o) {
|
|
|
5710
5743
|
}
|
|
5711
5744
|
e.stroke(), e.setLineDash([]);
|
|
5712
5745
|
}
|
|
5713
|
-
function
|
|
5746
|
+
function cr(e, t, n, r, i, a) {
|
|
5714
5747
|
e.fillStyle = r.text, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center";
|
|
5715
5748
|
for (let r = 0; r < t.length; r++) {
|
|
5716
5749
|
let o = t[r], s;
|
|
@@ -5719,7 +5752,7 @@ function sr(e, t, n, r, i, a) {
|
|
|
5719
5752
|
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));
|
|
5720
5753
|
}
|
|
5721
5754
|
}
|
|
5722
|
-
function
|
|
5755
|
+
function lr(e, t, n, r, i) {
|
|
5723
5756
|
e.fillStyle = r.axisLabel, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center", e.textBaseline = "top";
|
|
5724
5757
|
let a = n.bottom + 6, o = t.length > 0 ? t[0].slotW - 4 : 0, s = !1;
|
|
5725
5758
|
for (let n = 0; n < t.length; n++) if (e.measureText(i(t[n].label)).width > o) {
|
|
@@ -5740,7 +5773,7 @@ function cr(e, t, n, r, i) {
|
|
|
5740
5773
|
}
|
|
5741
5774
|
e.setTransform(1, 0, 0, 1, 0, 0), e.restore();
|
|
5742
5775
|
}
|
|
5743
|
-
function
|
|
5776
|
+
function ur(e, t, n) {
|
|
5744
5777
|
if (t < n.left || t > n.right) return null;
|
|
5745
5778
|
for (let n = 0; n < e.length; n++) {
|
|
5746
5779
|
let r = e[n];
|
|
@@ -5748,7 +5781,7 @@ function lr(e, t, n) {
|
|
|
5748
5781
|
}
|
|
5749
5782
|
return null;
|
|
5750
5783
|
}
|
|
5751
|
-
function
|
|
5784
|
+
function dr(e, t, n, r, i, a, o, s) {
|
|
5752
5785
|
let c = t[r], l = n[r], u = Math.round(c.slotX + c.slotW / 2) + .5;
|
|
5753
5786
|
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([]);
|
|
5754
5787
|
let d = [
|
|
@@ -5767,31 +5800,31 @@ function ur(e, t, n, r, i, a, o, s) {
|
|
|
5767
5800
|
let _ = o.font.sizeSmall + 4;
|
|
5768
5801
|
for (let t = 0; t < d.length; t++) e.fillText(d[t], h + 8, g + 6 + t * _);
|
|
5769
5802
|
}
|
|
5770
|
-
function
|
|
5803
|
+
function fr(e, t, n, r, i, a) {
|
|
5771
5804
|
let { data: o } = r;
|
|
5772
5805
|
if (!o || o.length === 0 || t <= 0 || n <= 0) return { hitBar: null };
|
|
5773
|
-
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 ??
|
|
5774
|
-
|
|
5806
|
+
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 ?? Zn, m = r.showValues !== !1, h = r.showDelta !== !1, g = r.valueFormat ?? er, _ = r.labelFormat ?? ((e) => e), { valMin: v, valMax: y } = rr(o), b = y - v || 1, x = tr(t, n), { bars: S, cumulatives: C } = nr(o, x, p, v, b);
|
|
5807
|
+
ir(e, t, n, i.background), ar(e, x, v, y, i, g), sr(e, S, x, v, b, d, f), or(e, S, {
|
|
5775
5808
|
positive: s,
|
|
5776
5809
|
negative: c,
|
|
5777
5810
|
total: l,
|
|
5778
5811
|
subtotal: u
|
|
5779
|
-
}), m &&
|
|
5780
|
-
let w = a ?
|
|
5781
|
-
return a && w !== null &&
|
|
5812
|
+
}), m && cr(e, S, C, i, g, h), lr(e, S, x, i, _);
|
|
5813
|
+
let w = a ? ur(S, a.x, x) : null;
|
|
5814
|
+
return a && w !== null && dr(e, S, C, w, a, x, i, g), { hitBar: w };
|
|
5782
5815
|
}
|
|
5783
5816
|
//#endregion
|
|
5784
5817
|
//#region src/finance/GaugeRenderer.ts
|
|
5785
|
-
var
|
|
5786
|
-
function
|
|
5818
|
+
var pr = Math.PI / 180, mr = 135, hr = 405, gr = .25;
|
|
5819
|
+
function _r(e) {
|
|
5787
5820
|
let t = Math.abs(e);
|
|
5788
5821
|
return t >= 1e6 ? (e / 1e6).toFixed(2) + "M" : t >= 1e3 ? (e / 1e3).toFixed(1) + "K" : Number.isInteger(e) ? e.toFixed(0) : e.toFixed(1);
|
|
5789
5822
|
}
|
|
5790
5823
|
function Q(e, t, n) {
|
|
5791
5824
|
return e < t ? t : e > n ? n : e;
|
|
5792
5825
|
}
|
|
5793
|
-
function
|
|
5794
|
-
let r = n.min ?? 0, i = n.max ?? 100, a = i - r || 1, o = (n.startAngle ??
|
|
5826
|
+
function vr(e, t, n) {
|
|
5827
|
+
let r = n.min ?? 0, i = n.max ?? 100, a = i - r || 1, o = (n.startAngle ?? mr) * pr, s = (n.endAngle ?? hr) * pr, c = n.thickness ?? gr, l = e / 2, u = t / 2 + t * .05, d = Math.max(10, Math.min(e, t) / 2 - 24);
|
|
5795
5828
|
return {
|
|
5796
5829
|
cx: l,
|
|
5797
5830
|
cy: u,
|
|
@@ -5809,38 +5842,38 @@ function $(e, t) {
|
|
|
5809
5842
|
let n = Q((e - t.min) / t.range, 0, 1);
|
|
5810
5843
|
return t.startAngle + t.angleRange * n;
|
|
5811
5844
|
}
|
|
5812
|
-
function
|
|
5845
|
+
function yr(e, t, n, r) {
|
|
5813
5846
|
e.fillStyle = r, e.fillRect(0, 0, t, n);
|
|
5814
5847
|
}
|
|
5815
|
-
function
|
|
5848
|
+
function br(e, t, n) {
|
|
5816
5849
|
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();
|
|
5817
5850
|
}
|
|
5818
|
-
function
|
|
5851
|
+
function xr(e, t, n) {
|
|
5819
5852
|
let r = Q(n.from, t.min, t.max), i = Q(n.to, t.min, t.max);
|
|
5820
5853
|
if (i <= r) return;
|
|
5821
5854
|
let a = $(r, t), o = $(i, t);
|
|
5822
5855
|
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();
|
|
5823
5856
|
}
|
|
5824
|
-
function
|
|
5857
|
+
function Sr(e, t, n, r, i) {
|
|
5825
5858
|
let a = $(n, t);
|
|
5826
5859
|
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);
|
|
5827
5860
|
}
|
|
5828
|
-
function
|
|
5861
|
+
function Cr(e, t, n, r) {
|
|
5829
5862
|
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;
|
|
5830
5863
|
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();
|
|
5831
5864
|
}
|
|
5832
|
-
function
|
|
5865
|
+
function wr(e, t, n, r, i) {
|
|
5833
5866
|
let a = Math.round(t.innerRadius * .55), o = Math.round(i.font.sizeMedium);
|
|
5834
5867
|
e.fillStyle = i.text, e.textAlign = "center", e.textBaseline = "middle", e.font = `600 ${a}px ${i.font.family}`;
|
|
5835
5868
|
let s = !!r, c = s ? t.cy - o * .6 : t.cy - a * .1;
|
|
5836
5869
|
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));
|
|
5837
5870
|
}
|
|
5838
|
-
function
|
|
5871
|
+
function Tr(e, t, n, r) {
|
|
5839
5872
|
e.fillStyle = r.textSecondary, e.font = `${r.font.sizeSmall}px ${r.font.family}`;
|
|
5840
5873
|
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;
|
|
5841
5874
|
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);
|
|
5842
5875
|
}
|
|
5843
|
-
function
|
|
5876
|
+
function Er(e, t, n, r) {
|
|
5844
5877
|
e.fillStyle = r.textSecondary, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
5845
5878
|
let i = (t.radius + t.innerRadius) / 2;
|
|
5846
5879
|
for (let r = 0; r < n.length; r++) {
|
|
@@ -5850,15 +5883,15 @@ function Tr(e, t, n, r) {
|
|
|
5850
5883
|
e.fillText(a.label, s, c);
|
|
5851
5884
|
}
|
|
5852
5885
|
}
|
|
5853
|
-
function
|
|
5886
|
+
function Dr(e, t, n, r, i, a) {
|
|
5854
5887
|
if (t <= 0 || n <= 0) return;
|
|
5855
|
-
let o =
|
|
5856
|
-
|
|
5888
|
+
let o = vr(t, n, r), s = r.trackColor ?? i.grid, c = r.needleColor ?? i.text, l = r.showValue !== !1, u = r.showZoneLabels === !0, d = r.valueFormat ?? _r, f = Q(a, o.min, o.max);
|
|
5889
|
+
yr(e, t, n, i.background), br(e, o, s);
|
|
5857
5890
|
let p = r.zones;
|
|
5858
|
-
if (p && p.length > 0) for (let t = 0; t < p.length; t++)
|
|
5859
|
-
|
|
5891
|
+
if (p && p.length > 0) for (let t = 0; t < p.length; t++) xr(e, o, p[t]);
|
|
5892
|
+
Sr(e, o, f, c, .12), Cr(e, o, f, c), l && wr(e, o, d(f), r.label, i), Tr(e, o, d, i), u && p && p.length > 0 && Er(e, o, p, i);
|
|
5860
5893
|
}
|
|
5861
5894
|
//#endregion
|
|
5862
|
-
export {
|
|
5895
|
+
export { je as ADXIndicator, Ae as ATRIndicator, Pe as AccumulationDistributionIndicator, Jt as AlertManager, Tt as AnchoredVWAPTool, en as Animator, te as AreaRenderer, P as AroonIndicator, xt as ArrowTool, Gt as BarCountdown, ne as BarRenderer, nn as BaseFinanceChart, ie as BaselineRenderer, zt as BinanceAdapter, be as BollingerBandsIndicator, M as CCIIndicator, L as CMFIndicator, A as CandlestickRenderer, v as CanvasLayer, Ht as ChartLegend, Xt as ChartStateManager, le as CompareRenderer, Ke as CrosshairHandler, Je as CrosshairTooltip, It as CurrentPriceLine, Vt as DEFAULT_LEGEND_CONFIG, x as DPRManager, Qt as DataExporter, vt as DateRangeTool, At as DepthOverlay, Ee as DonchianChannelIndicator, V as DrawingBase, $e as DrawingManager, et as DrawingRenderer, ye as EMAIndicator, $t as Easing, gt as ElliottWaveTool, ft as EllipseTool, G as Emitter, Ze as EventBus, at as ExtendedLineTool, ut as FibExtensionTool, ct as FibRetracementTool, rn as FinanceCrosshair, wt as GannBoxTool, Ct as GannFanTool, Le as GridRenderer, re as HollowCandleRenderer, nt as HorizontalLineTool, Se as IchimokuIndicator, j as IndicatorBase, _e as IndicatorEngine, Ue as InteractionManager, oe as KagiRenderer, Te as KeltnerChannelIndicator, qe as KeyboardHandler, y as LayerManager, ee as LineRenderer, Oe as MACDIndicator, N as MFIIndicator, yt as MeasureTool, Bt as MockAdapter, Me as OBVIndicator, Ot as OrderRenderer, We as PanHandler, Ce as ParabolicSARIndicator, ot as ParallelChannelTool, mt as PitchforkTool, se as PointAndFigureRenderer, kt as PositionRenderer, Re as PriceAxis, _t as PriceRangeTool, F as ROCIndicator, De as RSIIndicator, it as RayTool, K as ReconnectManager, dt as RectangleTool, st as RegressionChannelTool, D as RenderEngine, b as RenderLoop, ae as RenkoRenderer, Yt as ReplayManager, ve as SMAIndicator, Ut as Screenshot, Kt as SessionBreaks, R as StdDevIndicator, ke as StochasticIndicator, Lt as StreamManager, we as SupertrendIndicator, I as TSIIndicator, bt as TextAnnotationTool, Ft as TickAggregator, He as TimeAxis, Mt as TradingContextMenu, jt as TradingDragHandler, Nt as TradingManager, Pt as TradingRenderer, tt as TrendLineTool, pt as TriangleTool, Zt as UndoRedoManager, Fe as VROCIndicator, xe as VWAPIndicator, rt as VerticalLineTool, O as Viewport, z as VolumeProfileIndicator, Et as VolumeProfileRangeTool, ce as VolumeRenderer, Wt as Watermark, Ne as WilliamsRIndicator, Ge as ZoomHandler, S as barIndexToX, k as getVisibleData, Vn as layoutSquarifiedTreemap, Rn as layoutUniformGrid, C as priceToY, Dt as registerBuiltInDrawingTools, Ie as registerBuiltInIndicators, yn as renderDepthChart, Ln as renderEquityCurve, Dr as renderGauge, qn as renderHeatmap, an as renderSparkline, fr as renderWaterfall, E as timestampToBarIndex, ue as toHeikinAshi, me as toKagi, pe as toLineBreak, he as toPointAndFigure, de as toRenko, w as xToBarIndex, T as yToPrice };
|
|
5863
5896
|
|
|
5864
5897
|
//# sourceMappingURL=index.js.map
|