@lilt-ui/charts 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cards/cartesian-card.d.ts +7 -1
- package/dist/chart-context.d.ts +8 -1
- package/dist/chart.d.ts +1 -1
- package/dist/engine/decimate.d.ts +25 -0
- package/dist/finance.js +99 -98
- package/dist/index.js +642 -642
- package/dist/primitives/runoff.d.ts +6 -7
- package/dist/{report-context-Cz0AYdV2.js → report-context-CkzH-r8B.js} +130 -129
- package/dist/{skeleton-block-Uf1lywJi.js → skeleton-block-C110l-2a.js} +1811 -1669
- package/dist/types.d.ts +6 -0
- package/dist/watch.js +1 -1
- package/package.json +1 -1
package/dist/finance.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { A as e, C as t, G as n, I as r, K as i, L as a, P as o, R as s, S as c, T as l, X as u, _ as d, a as f, b as p, et as m, f as h, i as g, it as _, n as v, pt as y, t as b, u as x, v as S, w as C, x as w, y as T, z as E } from "./skeleton-block-
|
|
3
|
-
import { S as D, d as O, g as k, h as A, p as j, u as ee } from "./report-context-
|
|
2
|
+
import { A as e, C as t, G as n, I as r, K as i, L as a, P as o, R as s, S as c, T as l, X as u, _ as d, a as f, b as p, et as m, f as h, i as g, it as _, n as v, pt as y, t as b, u as x, v as S, w as C, x as w, y as T, z as E } from "./skeleton-block-C110l-2a.js";
|
|
3
|
+
import { S as D, d as O, g as k, h as A, p as j, u as ee } from "./report-context-CkzH-r8B.js";
|
|
4
4
|
import { useEffect as M, useMemo as N, useRef as P, useState as F } from "react";
|
|
5
5
|
import { Fragment as I, jsx as L, jsxs as R } from "react/jsx-runtime";
|
|
6
|
+
import { min as z } from "d3-array";
|
|
6
7
|
//#region src/finance/candle-geometry.ts
|
|
7
|
-
var
|
|
8
|
-
function
|
|
8
|
+
var B = "var(--lilt-candle-up)", V = "var(--lilt-candle-down)";
|
|
9
|
+
function H(e) {
|
|
9
10
|
return Math.round(e * 100) / 100;
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
+
function U(e, t, n) {
|
|
12
13
|
let r = e.fields[t], i = r?.[n.open], a = r?.[n.high], o = r?.[n.low], s = e.values[t];
|
|
13
14
|
return i == null || a == null || o == null || s == null ? null : {
|
|
14
15
|
open: i,
|
|
@@ -18,22 +19,22 @@ function H(e, t, n) {
|
|
|
18
19
|
up: s >= i
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
+
function W(e, t, n) {
|
|
22
23
|
for (let r of e) {
|
|
23
|
-
let e =
|
|
24
|
+
let e = U(r, t, n);
|
|
24
25
|
if (!e) continue;
|
|
25
26
|
let i = Math.max(e.open, e.close), a = Math.min(e.open, e.close);
|
|
26
27
|
if (e.high < i || e.low > a) throw Error(`Lilt Candles on series "${t}" expects low ≤ open, close ≤ high at row ${r.sourceIndex + 1}.`);
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
let a = Math.max(1, n.columnWidth), s = a / 2, c =
|
|
30
|
+
function G(e, t, n, r, i = !1) {
|
|
31
|
+
let a = Math.max(1, n.columnWidth), s = a / 2, c = H(e), l = H(n.y(t.high)), u = H(n.y(t.low));
|
|
31
32
|
if (r === "ohlc") {
|
|
32
|
-
let r =
|
|
33
|
+
let r = H(n.y(t.open)), i = H(n.y(t.close)), a = H(Math.max(2, s));
|
|
33
34
|
return {
|
|
34
35
|
body: null,
|
|
35
36
|
hollow: null,
|
|
36
|
-
stroke: `M${c},${l}V${u}M${
|
|
37
|
+
stroke: `M${c},${l}V${u}M${H(e - a)},${r}H${c}M${c},${i}H${H(e + a)}`,
|
|
37
38
|
side: null,
|
|
38
39
|
top: null
|
|
39
40
|
};
|
|
@@ -43,7 +44,7 @@ function W(e, t, n, r, i = !1) {
|
|
|
43
44
|
let e = (d + f) / 2;
|
|
44
45
|
d = e - .5, f = e + .5;
|
|
45
46
|
}
|
|
46
|
-
let p = r === "hollow" && t.up && a >= 3, h = p ? .5 : 0, g = i ? m(e, d, a, f - d) : null, _ = g ? e - g.frontWidth / 2 : e - s, v = o(_ + h, d + h, Math.max(1, (g ? g.frontWidth : a) - h * 2), Math.max(1, f - d - h * 2), !g && a >= 6 ? 1.5 : 0), y = (l < d ? `M${c},${l}V${
|
|
47
|
+
let p = r === "hollow" && t.up && a >= 3, h = p ? .5 : 0, g = i ? m(e, d, a, f - d) : null, _ = g ? e - g.frontWidth / 2 : e - s, v = o(_ + h, d + h, Math.max(1, (g ? g.frontWidth : a) - h * 2), Math.max(1, f - d - h * 2), !g && a >= 6 ? 1.5 : 0), y = (l < d ? `M${c},${l}V${H(d)}` : "") + (u > f ? `M${c},${H(f)}V${u}` : "");
|
|
47
48
|
return {
|
|
48
49
|
body: p ? null : v,
|
|
49
50
|
hollow: p ? v : null,
|
|
@@ -52,12 +53,12 @@ function W(e, t, n, r, i = !1) {
|
|
|
52
53
|
top: g?.top ?? null
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function K(t, n, r, i, a, o, s = !1) {
|
|
56
57
|
let c = new l(), u = new l(), d = new l(), f = new l(), p = new l();
|
|
57
58
|
for (let { row: l, cx: m } of e(t, i)) {
|
|
58
|
-
let e =
|
|
59
|
+
let e = U(l, n, r);
|
|
59
60
|
if (!e) continue;
|
|
60
|
-
let t = o(l, e), h =
|
|
61
|
+
let t = o(l, e), h = G(m, e, i, a, s);
|
|
61
62
|
h.side && f.add(t, h.side), h.top && p.add(t, h.top), h.body && c.add(t, h.body), h.hollow && u.add(t, h.hollow), h.stroke && d.add(t, h.stroke);
|
|
62
63
|
}
|
|
63
64
|
return {
|
|
@@ -70,8 +71,8 @@ function te(t, n, r, i, a, o, s = !1) {
|
|
|
70
71
|
}
|
|
71
72
|
//#endregion
|
|
72
73
|
//#region src/finance/candles.tsx
|
|
73
|
-
function
|
|
74
|
-
return E(e, t, n.up ?
|
|
74
|
+
function te(e, t, n) {
|
|
75
|
+
return E(e, t, n.up ? B : V);
|
|
75
76
|
}
|
|
76
77
|
function ne({ paths: e, display: t }) {
|
|
77
78
|
let n = t === "ohlc" ? 1.5 : 1;
|
|
@@ -116,7 +117,7 @@ var re = s(function({ series: e, open: t, high: n, low: r, display: a = "candle"
|
|
|
116
117
|
high: n,
|
|
117
118
|
low: r
|
|
118
119
|
};
|
|
119
|
-
return
|
|
120
|
+
return W(l.data.rows, e, i), K(l.data.rows, e, i, d, a, (e, t) => te(u, e, t), o);
|
|
120
121
|
}, [
|
|
121
122
|
l,
|
|
122
123
|
e,
|
|
@@ -150,7 +151,7 @@ var re = s(function({ series: e, open: t, high: n, low: r, display: a = "candle"
|
|
|
150
151
|
kind: e.display === "ohlc" ? "ohlc" : "candle",
|
|
151
152
|
depth: e.depth && e.display !== "ohlc",
|
|
152
153
|
render: ({ cx: t, low: n, high: r, scales: i, mask: a }) => {
|
|
153
|
-
let o = a ? "white" : "color-mix(in srgb, var(--lilt-skeleton) 64%, var(--lilt-surface))", s =
|
|
154
|
+
let o = a ? "white" : "color-mix(in srgb, var(--lilt-skeleton) 64%, var(--lilt-surface))", s = G(t, {
|
|
154
155
|
low: n,
|
|
155
156
|
high: r,
|
|
156
157
|
open: n + (r - n) * .28,
|
|
@@ -191,9 +192,9 @@ var re = s(function({ series: e, open: t, high: n, low: r, display: a = "candle"
|
|
|
191
192
|
e.low
|
|
192
193
|
],
|
|
193
194
|
highlight: (e, { row: n, snapshot: r, descriptor: i }) => {
|
|
194
|
-
let a =
|
|
195
|
+
let a = U(n, e.series, e);
|
|
195
196
|
if (!a) return null;
|
|
196
|
-
let o = e.display ?? "candle", s = t(r, e.series), c =
|
|
197
|
+
let o = e.display ?? "candle", s = t(r, e.series), c = G(s.x(n.x), a, s, o, e.depth), l = te(i, n, a);
|
|
197
198
|
return /* @__PURE__ */ L("g", {
|
|
198
199
|
className: "lilt-chart__candle-highlight",
|
|
199
200
|
children: /* @__PURE__ */ L(ne, {
|
|
@@ -226,7 +227,7 @@ var re = s(function({ series: e, open: t, high: n, low: r, display: a = "candle"
|
|
|
226
227
|
});
|
|
227
228
|
//#endregion
|
|
228
229
|
//#region src/finance/cards/pane.tsx
|
|
229
|
-
function
|
|
230
|
+
function q({ context: e, label: t, caption: n, readout: r, series: i, height: o, y: s, bars: c, xAxis: l = !1, children: u }) {
|
|
230
231
|
let [f, p] = F(null), m = f ?? e.data.at(-1) ?? null;
|
|
231
232
|
return /* @__PURE__ */ R("div", {
|
|
232
233
|
className: "lilt-card__pane",
|
|
@@ -269,12 +270,12 @@ function K({ context: e, label: t, caption: n, readout: r, series: i, height: o,
|
|
|
269
270
|
}
|
|
270
271
|
//#endregion
|
|
271
272
|
//#region src/finance/cards/candlestick-chart-card.tsx
|
|
272
|
-
function
|
|
273
|
+
function J(e, t) {
|
|
273
274
|
let n = e[t];
|
|
274
275
|
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
275
276
|
}
|
|
276
|
-
function
|
|
277
|
-
let r = e.length ?
|
|
277
|
+
function Y(e, t, n) {
|
|
278
|
+
let r = e.length ? J(e[0], t) : null, i = e.length ? J(e.at(-1), n) : null;
|
|
278
279
|
return r && i !== null ? i / r - 1 : void 0;
|
|
279
280
|
}
|
|
280
281
|
function ie(e) {
|
|
@@ -290,23 +291,23 @@ var ae = {
|
|
|
290
291
|
function oe({ open: e, high: t, low: n, close: i, volume: a, display: o = "candle", depth: s = !1, scale: c = "linear", label: l = "Price", live: u = !1, data: d, ranges: f, delta: m, valueFormat: h = ae, locale: _ = "en-US", volumeHeight: y = 64, ...b }) {
|
|
291
292
|
let x = N(() => g(_, h).full, [_, JSON.stringify(h)]), S = N(() => g(_).compact, [_]), C = N(() => f?.map((t) => ({
|
|
292
293
|
...t,
|
|
293
|
-
delta: t.delta ??
|
|
294
|
+
delta: t.delta ?? Y(t.data, e, i)
|
|
294
295
|
})), [
|
|
295
296
|
f,
|
|
296
297
|
e,
|
|
297
298
|
i
|
|
298
|
-
]), T = (
|
|
299
|
+
]), T = (Y(d ?? f?.[0]?.data ?? [], e, i) ?? 0) >= 0, E = (t) => (J(t, i) ?? 0) >= (J(t, e) ?? 0), D = o === "area", O = {
|
|
299
300
|
open: {
|
|
300
301
|
label: "Open",
|
|
301
|
-
accessor: (t) =>
|
|
302
|
+
accessor: (t) => J(t, e)
|
|
302
303
|
},
|
|
303
304
|
high: {
|
|
304
305
|
label: "High",
|
|
305
|
-
accessor: (e) =>
|
|
306
|
+
accessor: (e) => J(e, t)
|
|
306
307
|
},
|
|
307
308
|
low: {
|
|
308
309
|
label: "Low",
|
|
309
|
-
accessor: (e) =>
|
|
310
|
+
accessor: (e) => J(e, n)
|
|
310
311
|
}
|
|
311
312
|
};
|
|
312
313
|
return /* @__PURE__ */ L(v, {
|
|
@@ -314,7 +315,7 @@ function oe({ open: e, high: t, low: n, close: i, volume: a, display: o = "candl
|
|
|
314
315
|
depth: s,
|
|
315
316
|
data: d,
|
|
316
317
|
ranges: C,
|
|
317
|
-
delta: m ?? (d ?
|
|
318
|
+
delta: m ?? (d ? Y(d, e, i) : void 0),
|
|
318
319
|
valueFormat: h,
|
|
319
320
|
locale: _,
|
|
320
321
|
aggregate: "last",
|
|
@@ -323,7 +324,7 @@ function oe({ open: e, high: t, low: n, close: i, volume: a, display: o = "candl
|
|
|
323
324
|
series: [{
|
|
324
325
|
key: i,
|
|
325
326
|
label: l,
|
|
326
|
-
color: D ? T ?
|
|
327
|
+
color: D ? T ? B : V : void 0
|
|
327
328
|
}],
|
|
328
329
|
shape: {
|
|
329
330
|
kind: "marks",
|
|
@@ -350,7 +351,7 @@ function oe({ open: e, high: t, low: n, close: i, volume: a, display: o = "candl
|
|
|
350
351
|
depth: s
|
|
351
352
|
}, e))
|
|
352
353
|
},
|
|
353
|
-
panes: a ? (e) => /* @__PURE__ */ L(
|
|
354
|
+
panes: a ? (e) => /* @__PURE__ */ L(q, {
|
|
354
355
|
context: e,
|
|
355
356
|
label: `${b.title} volume`,
|
|
356
357
|
caption: "Volume",
|
|
@@ -365,7 +366,7 @@ function oe({ open: e, high: t, low: n, close: i, volume: a, display: o = "candl
|
|
|
365
366
|
series: [{
|
|
366
367
|
id: "volume",
|
|
367
368
|
label: "Volume",
|
|
368
|
-
accessor: (e) =>
|
|
369
|
+
accessor: (e) => J(e, a),
|
|
369
370
|
formatValue: S,
|
|
370
371
|
colorAt: (e) => E(e) ? "color-mix(in srgb, var(--lilt-candle-up) 42%, transparent)" : "color-mix(in srgb, var(--lilt-candle-down) 42%, transparent)",
|
|
371
372
|
bar: { radius: 1 }
|
|
@@ -376,7 +377,7 @@ function oe({ open: e, high: t, low: n, close: i, volume: a, display: o = "candl
|
|
|
376
377
|
}
|
|
377
378
|
//#endregion
|
|
378
379
|
//#region src/finance/indicators.ts
|
|
379
|
-
function
|
|
380
|
+
function X(e) {
|
|
380
381
|
return typeof e == "number" && Number.isFinite(e);
|
|
381
382
|
}
|
|
382
383
|
function se(e, t) {
|
|
@@ -387,17 +388,17 @@ function ce(e, t) {
|
|
|
387
388
|
let n = [], r = 0, i = 0;
|
|
388
389
|
for (let a = 0; a < e.length; a += 1) {
|
|
389
390
|
let o = e[a];
|
|
390
|
-
|
|
391
|
+
X(o) && (r += o, i += 1);
|
|
391
392
|
let s = a - t >= 0 ? e[a - t] : void 0;
|
|
392
|
-
a - t >= 0 &&
|
|
393
|
+
a - t >= 0 && X(s) && (r -= s, --i), n.push(a >= t - 1 && i === t ? r / t : null);
|
|
393
394
|
}
|
|
394
395
|
return n;
|
|
395
396
|
}
|
|
396
|
-
function
|
|
397
|
+
function Z(e, t) {
|
|
397
398
|
se("ema", t);
|
|
398
399
|
let n = 2 / (t + 1), r = [], i = null, a = [];
|
|
399
400
|
for (let o of e) {
|
|
400
|
-
if (!
|
|
401
|
+
if (!X(o)) {
|
|
401
402
|
r.push(null);
|
|
402
403
|
continue;
|
|
403
404
|
}
|
|
@@ -413,7 +414,7 @@ function le(e, t = 14) {
|
|
|
413
414
|
se("rsi", t);
|
|
414
415
|
let n = e.map(() => null), r = null, i = 0, a = 0, o = 0, s = 0, c = 0;
|
|
415
416
|
return e.forEach((e, l) => {
|
|
416
|
-
if (!
|
|
417
|
+
if (!X(e)) return;
|
|
417
418
|
if (r === null) {
|
|
418
419
|
r = e;
|
|
419
420
|
return;
|
|
@@ -430,10 +431,10 @@ function le(e, t = 14) {
|
|
|
430
431
|
}
|
|
431
432
|
function ue(e, t = 12, n = 26, r = 9) {
|
|
432
433
|
if (t >= n) throw Error("Lilt macd needs a fast period shorter than the slow period.");
|
|
433
|
-
let i =
|
|
434
|
+
let i = Z(e, t), a = Z(e, n), o = e.map((e, t) => {
|
|
434
435
|
let n = i[t], r = a[t];
|
|
435
436
|
return n === null || r === null ? null : n - r;
|
|
436
|
-
}), s =
|
|
437
|
+
}), s = Z(o, r);
|
|
437
438
|
return {
|
|
438
439
|
macd: o,
|
|
439
440
|
signal: s,
|
|
@@ -462,14 +463,14 @@ function de(e, t = 20, n = 2) {
|
|
|
462
463
|
}
|
|
463
464
|
function fe(e) {
|
|
464
465
|
let t = -Infinity;
|
|
465
|
-
return e.map((e) =>
|
|
466
|
+
return e.map((e) => X(e) ? (t = Math.max(t, e), t > 0 ? e / t - 1 : 0) : null);
|
|
466
467
|
}
|
|
467
468
|
function pe(e) {
|
|
468
|
-
let t = e.find(
|
|
469
|
-
return e.map((e) =>
|
|
469
|
+
let t = e.find(X);
|
|
470
|
+
return e.map((e) => X(e) && t !== void 0 && t !== 0 ? e / t - 1 : null);
|
|
470
471
|
}
|
|
471
472
|
function me(e, t) {
|
|
472
|
-
for (let n of t) if (!
|
|
473
|
+
for (let n of t) if (!X(n.price) || !X(n.size) || n.size < 0) throw Error(`Lilt order book ${e} need finite prices and non-negative sizes; received ${n.price} × ${n.size}.`);
|
|
473
474
|
}
|
|
474
475
|
function he(e, t) {
|
|
475
476
|
me("bids", e), me("asks", t);
|
|
@@ -532,17 +533,17 @@ function _e(e) {
|
|
|
532
533
|
};
|
|
533
534
|
});
|
|
534
535
|
}
|
|
535
|
-
function
|
|
536
|
+
function Q(e, t) {
|
|
536
537
|
if (!t) return null;
|
|
537
538
|
let n = e[t];
|
|
538
539
|
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
539
540
|
}
|
|
540
541
|
function ve(e, t, n, r) {
|
|
541
|
-
let i = e.map((e) =>
|
|
542
|
+
let i = e.map((e) => Q(e, t)), a = e.map((e) => ({ ...e })), o = (e, t) => t.forEach((t, n) => a[n][e] = t);
|
|
542
543
|
for (let e of n) if (e.kind === "bollinger") {
|
|
543
544
|
let t = de(i, e.period, e.deviations);
|
|
544
545
|
o(e.id, t.middle), o(`${e.id}Upper`, t.upper), o(`${e.id}Lower`, t.lower);
|
|
545
|
-
} else o(e.id, (e.kind === "sma" ? ce :
|
|
546
|
+
} else o(e.id, (e.kind === "sma" ? ce : Z)(i, e.period));
|
|
546
547
|
for (let e of r) if (e.kind === "rsi" && o(e.id, le(i, e.period)), e.kind === "macd") {
|
|
547
548
|
let t = ue(i, e.fast, e.slow, e.signal);
|
|
548
549
|
o(`${e.id}Macd`, t.macd), o(`${e.id}Signal`, t.signal), o(`${e.id}Histogram`, t.histogram);
|
|
@@ -570,41 +571,41 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
570
571
|
]), ee = N(() => m?.map((n) => ({
|
|
571
572
|
...n,
|
|
572
573
|
data: ve(n.data, e, k, A),
|
|
573
|
-
delta: n.delta ?? (t ?
|
|
574
|
+
delta: n.delta ?? (t ? Y(n.data, t, e) : void 0)
|
|
574
575
|
})), [
|
|
575
576
|
m,
|
|
576
577
|
e,
|
|
577
578
|
t,
|
|
578
579
|
k,
|
|
579
580
|
A
|
|
580
|
-
]), M = N(() => g(b, y).full, [b, JSON.stringify(y)]), P = N(() => g(b, { maximumFractionDigits: 2 }).full, [b]), F = N(() => g(b).compact, [b]),
|
|
581
|
+
]), M = N(() => g(b, y).full, [b, JSON.stringify(y)]), P = N(() => g(b, { maximumFractionDigits: 2 }).full, [b]), F = N(() => g(b).compact, [b]), z = T ? {
|
|
581
582
|
open: {
|
|
582
583
|
label: "Open",
|
|
583
|
-
accessor: (e) =>
|
|
584
|
+
accessor: (e) => Q(e, t)
|
|
584
585
|
},
|
|
585
586
|
high: {
|
|
586
587
|
label: "High",
|
|
587
|
-
accessor: (e) =>
|
|
588
|
+
accessor: (e) => Q(e, n)
|
|
588
589
|
},
|
|
589
590
|
low: {
|
|
590
591
|
label: "Low",
|
|
591
|
-
accessor: (e) =>
|
|
592
|
+
accessor: (e) => Q(e, r)
|
|
592
593
|
}
|
|
593
|
-
} : void 0, H = new Map(k.map((e) => [e.id, e])), U = f?.length ?
|
|
594
|
-
let a = n.id ===
|
|
595
|
-
let r =
|
|
594
|
+
} : void 0, H = new Map(k.map((e) => [e.id, e])), U = f?.length ? Q(f[0], e) : null, W = f?.length ? Q(f.at(-1), e) : null, G = U === null || W === null || W >= U, K = A.at(-1)?.id, te = (n, r) => {
|
|
595
|
+
let a = n.id === K, o = (e) => (t) => Q(t, e), s = (e, t, n) => {
|
|
596
|
+
let r = Q(e, t);
|
|
596
597
|
return /* @__PURE__ */ R("span", {
|
|
597
598
|
className: "lilt-card__pane-value",
|
|
598
599
|
children: [n ? `${n} ` : "", r === null ? "—" : P(r)]
|
|
599
600
|
}, t);
|
|
600
601
|
};
|
|
601
|
-
if (n.kind === "volume") return /* @__PURE__ */ L(
|
|
602
|
+
if (n.kind === "volume") return /* @__PURE__ */ L(q, {
|
|
602
603
|
context: r,
|
|
603
604
|
label: `${C.title} volume`,
|
|
604
605
|
caption: "Volume",
|
|
605
606
|
readout: (e) => /* @__PURE__ */ L("span", {
|
|
606
607
|
className: "lilt-card__pane-value",
|
|
607
|
-
children:
|
|
608
|
+
children: Q(e, i) === null ? "—" : F(Q(e, i))
|
|
608
609
|
}),
|
|
609
610
|
height: S,
|
|
610
611
|
xAxis: a,
|
|
@@ -619,12 +620,12 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
619
620
|
label: "Volume",
|
|
620
621
|
accessor: o(i),
|
|
621
622
|
formatValue: F,
|
|
622
|
-
colorAt: (n) => (
|
|
623
|
+
colorAt: (n) => (Q(n, e) ?? 0) >= (Q(n, t) ?? Q(n, e) ?? 0) ? "color-mix(in srgb, var(--lilt-candle-up) 42%, transparent)" : "color-mix(in srgb, var(--lilt-candle-down) 42%, transparent)",
|
|
623
624
|
bar: { radius: 1 }
|
|
624
625
|
}],
|
|
625
626
|
children: /* @__PURE__ */ L(p, { series: "volume" })
|
|
626
627
|
}, n.id);
|
|
627
|
-
if (n.kind === "rsi") return /* @__PURE__ */ R(
|
|
628
|
+
if (n.kind === "rsi") return /* @__PURE__ */ R(q, {
|
|
628
629
|
context: r,
|
|
629
630
|
label: `${C.title} RSI ${n.period}`,
|
|
630
631
|
caption: `RSI ${n.period}`,
|
|
@@ -666,7 +667,7 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
666
667
|
]
|
|
667
668
|
}, n.id);
|
|
668
669
|
let c = `${n.id}Macd`, l = `${n.id}Signal`, u = `${n.id}Histogram`;
|
|
669
|
-
return /* @__PURE__ */ R(
|
|
670
|
+
return /* @__PURE__ */ R(q, {
|
|
670
671
|
context: r,
|
|
671
672
|
label: `${C.title} MACD`,
|
|
672
673
|
caption: `MACD ${n.fast} · ${n.slow} · ${n.signal}`,
|
|
@@ -685,7 +686,7 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
685
686
|
label: "Histogram",
|
|
686
687
|
accessor: o(u),
|
|
687
688
|
formatValue: P,
|
|
688
|
-
colorAt: (e) => (
|
|
689
|
+
colorAt: (e) => (Q(e, u) ?? 0) >= 0 ? "color-mix(in srgb, var(--lilt-candle-up) 55%, transparent)" : "color-mix(in srgb, var(--lilt-candle-down) 55%, transparent)",
|
|
689
690
|
bar: { radius: 1 }
|
|
690
691
|
},
|
|
691
692
|
{
|
|
@@ -722,7 +723,7 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
722
723
|
...C,
|
|
723
724
|
data: j,
|
|
724
725
|
ranges: ee,
|
|
725
|
-
delta: _ ?? (f && t ?
|
|
726
|
+
delta: _ ?? (f && t ? Y(f, t, e) : void 0),
|
|
726
727
|
valueFormat: y,
|
|
727
728
|
locale: b,
|
|
728
729
|
aggregate: "last",
|
|
@@ -733,7 +734,7 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
733
734
|
series: [{
|
|
734
735
|
key: e,
|
|
735
736
|
label: l,
|
|
736
|
-
color: E === "line" ?
|
|
737
|
+
color: E === "line" ? G ? B : V : void 0
|
|
737
738
|
}, ...k.map((e, t) => ({
|
|
738
739
|
key: e.id,
|
|
739
740
|
label: e.label,
|
|
@@ -758,21 +759,21 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
758
759
|
...t.kind === "bollinger" ? { fields: {
|
|
759
760
|
upper: {
|
|
760
761
|
label: "Upper",
|
|
761
|
-
accessor: (e) =>
|
|
762
|
+
accessor: (e) => Q(e, `${t.id}Upper`)
|
|
762
763
|
},
|
|
763
764
|
lower: {
|
|
764
765
|
label: "Lower",
|
|
765
|
-
accessor: (e) =>
|
|
766
|
+
accessor: (e) => Q(e, `${t.id}Lower`)
|
|
766
767
|
}
|
|
767
768
|
} } : {}
|
|
768
769
|
} : E === "line" ? {
|
|
769
|
-
fields:
|
|
770
|
+
fields: z,
|
|
770
771
|
curve: "linear",
|
|
771
772
|
line: {
|
|
772
773
|
width: 2,
|
|
773
774
|
depth: C.depth
|
|
774
775
|
}
|
|
775
|
-
} : { fields:
|
|
776
|
+
} : { fields: z };
|
|
776
777
|
},
|
|
777
778
|
describe: T ? ie(M) : void 0,
|
|
778
779
|
draw: (e) => e.map((e) => {
|
|
@@ -791,7 +792,7 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
791
792
|
}, e);
|
|
792
793
|
})
|
|
793
794
|
},
|
|
794
|
-
panes: A.length ? (e) => /* @__PURE__ */ L(I, { children: A.map((t) =>
|
|
795
|
+
panes: A.length ? (e) => /* @__PURE__ */ L(I, { children: A.map((t) => te(t, e)) }) : void 0
|
|
795
796
|
});
|
|
796
797
|
}
|
|
797
798
|
//#endregion
|
|
@@ -825,14 +826,14 @@ var Ce = {
|
|
|
825
826
|
maximumFractionDigits: 2
|
|
826
827
|
};
|
|
827
828
|
function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, locale: s = "en-US", height: c = 220, axis: l = "minimal", background: u = "dots", hoverStyle: f = "soft", surface: p, numberStyle: m, loading: h = !1, loadingStyle: _ = "shimmer", motion: v, className: b, style: x, depth: C = !1 }) {
|
|
828
|
-
let E = N(() => he(t, n), [t, n]), D = JSON.stringify(i), M = JSON.stringify(o ?? null), P = N(() => g(s, i), [s, D]), I = N(() => g(s, o), [s, M]),
|
|
829
|
+
let E = N(() => he(t, n), [t, n]), D = JSON.stringify(i), M = JSON.stringify(o ?? null), P = N(() => g(s, i), [s, D]), I = N(() => g(s, o), [s, M]), z = N(() => g(s, {
|
|
829
830
|
style: "percent",
|
|
830
831
|
maximumFractionDigits: 3
|
|
831
832
|
}).full, [s]), [H, U] = F(null), W = N(() => [{
|
|
832
833
|
id: "bid",
|
|
833
834
|
label: "Bids",
|
|
834
835
|
accessor: (e) => e.bid,
|
|
835
|
-
color:
|
|
836
|
+
color: B,
|
|
836
837
|
curve: "step-before",
|
|
837
838
|
area: { treatment: "fade" },
|
|
838
839
|
line: {
|
|
@@ -844,7 +845,7 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
|
|
|
844
845
|
id: "ask",
|
|
845
846
|
label: "Asks",
|
|
846
847
|
accessor: (e) => e.ask,
|
|
847
|
-
color:
|
|
848
|
+
color: V,
|
|
848
849
|
curve: "step-after",
|
|
849
850
|
area: { treatment: "fade" },
|
|
850
851
|
line: {
|
|
@@ -852,7 +853,7 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
|
|
|
852
853
|
depth: C
|
|
853
854
|
},
|
|
854
855
|
formatValue: I.full
|
|
855
|
-
}], [I, C]),
|
|
856
|
+
}], [I, C]), G = E.spread !== null && E.mid ? `${P.full(E.spread)} (${z(E.spread / E.mid)})` : "—", K = H ? H.bid ?? H.ask : null;
|
|
856
857
|
return /* @__PURE__ */ R(ee, {
|
|
857
858
|
"aria-label": e,
|
|
858
859
|
surface: p,
|
|
@@ -866,8 +867,8 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
|
|
|
866
867
|
format: P.full,
|
|
867
868
|
loading: h,
|
|
868
869
|
motion: v,
|
|
869
|
-
children: h ? null : H &&
|
|
870
|
-
I.full(
|
|
870
|
+
children: h ? null : H && K !== null ? /* @__PURE__ */ R(O, { children: [
|
|
871
|
+
I.full(K),
|
|
871
872
|
" ",
|
|
872
873
|
H.side === "bid" ? "bid" : "ask",
|
|
873
874
|
" depth at",
|
|
@@ -878,7 +879,7 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
|
|
|
878
879
|
/* @__PURE__ */ R("dl", {
|
|
879
880
|
className: "lilt-card__stats",
|
|
880
881
|
children: [
|
|
881
|
-
/* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("dt", { children: "Spread" }), /* @__PURE__ */ L("dd", { children: h ? "—" :
|
|
882
|
+
/* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("dt", { children: "Spread" }), /* @__PURE__ */ L("dd", { children: h ? "—" : G })] }),
|
|
882
883
|
/* @__PURE__ */ R("div", {
|
|
883
884
|
"data-side": "bid",
|
|
884
885
|
children: [/* @__PURE__ */ L("dt", { children: "Bid depth" }), /* @__PURE__ */ L("dd", { children: h ? "—" : I.compact(E.bidDepth) })]
|
|
@@ -939,13 +940,13 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
|
|
|
939
940
|
}
|
|
940
941
|
//#endregion
|
|
941
942
|
//#region src/finance/cards/portfolio-chart-card.tsx
|
|
942
|
-
function
|
|
943
|
+
function $(e, t) {
|
|
943
944
|
if (!t) return null;
|
|
944
945
|
let n = e[t];
|
|
945
946
|
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
946
947
|
}
|
|
947
948
|
function Te(e, t, n) {
|
|
948
|
-
let r = e.at(-1), i =
|
|
949
|
+
let r = e.at(-1), i = $(r, t), a = $(r, n);
|
|
949
950
|
return i !== null && a ? i / a - 1 : void 0;
|
|
950
951
|
}
|
|
951
952
|
function Ee({ value: e, basis: t, label: n = "Value", drawdown: i = !0, drawdownHeight: a = 64, data: o, ranges: s, delta: c, locale: l = "en-US", ...u }) {
|
|
@@ -961,8 +962,8 @@ function Ee({ value: e, basis: t, label: n = "Value", drawdown: i = !0, drawdown
|
|
|
961
962
|
minimumFractionDigits: 1,
|
|
962
963
|
maximumFractionDigits: 1
|
|
963
964
|
}).full, [l]), m = N(() => {
|
|
964
|
-
let t = fe(d.map((t) =>
|
|
965
|
-
return
|
|
965
|
+
let t = fe(d.map((t) => $(t, e))).filter((e) => e !== null);
|
|
966
|
+
return z(t) ?? null;
|
|
966
967
|
}, [d, e]);
|
|
967
968
|
return /* @__PURE__ */ L(v, {
|
|
968
969
|
...u,
|
|
@@ -998,8 +999,8 @@ function Ee({ value: e, basis: t, label: n = "Value", drawdown: i = !0, drawdown
|
|
|
998
999
|
draw: (e) => e.map((e) => [/* @__PURE__ */ L(r, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, e)])
|
|
999
1000
|
},
|
|
1000
1001
|
panes: i ? (t) => {
|
|
1001
|
-
let n = fe(t.data.map((t) =>
|
|
1002
|
-
return /* @__PURE__ */ R(
|
|
1002
|
+
let n = fe(t.data.map((t) => $(t, e))), i = new Map(t.data.map((e, t) => [e, n[t] ?? null]));
|
|
1003
|
+
return /* @__PURE__ */ R(q, {
|
|
1003
1004
|
context: t,
|
|
1004
1005
|
label: `${u.title} drawdown`,
|
|
1005
1006
|
caption: "Drawdown",
|
|
@@ -1038,34 +1039,34 @@ function De(e, t) {
|
|
|
1038
1039
|
let n = e[t];
|
|
1039
1040
|
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
1040
1041
|
}
|
|
1041
|
-
function
|
|
1042
|
+
function Oe(e, t) {
|
|
1042
1043
|
let n = e.map((e) => De(e, t)).filter((e) => e !== null);
|
|
1043
1044
|
return n.length > 1 ? {
|
|
1044
1045
|
first: n[0],
|
|
1045
1046
|
last: n.at(-1)
|
|
1046
1047
|
} : null;
|
|
1047
1048
|
}
|
|
1048
|
-
function
|
|
1049
|
+
function ke(e, t) {
|
|
1049
1050
|
let n = e.map((e) => ({ ...e }));
|
|
1050
1051
|
for (let r of t) pe(e.map((e) => De(e, r))).forEach((e, t) => n[t][`__rebased${r}`] = e);
|
|
1051
1052
|
return n;
|
|
1052
1053
|
}
|
|
1053
|
-
var
|
|
1054
|
+
var Ae = {
|
|
1054
1055
|
style: "currency",
|
|
1055
1056
|
currency: "USD",
|
|
1056
1057
|
minimumFractionDigits: 2,
|
|
1057
1058
|
maximumFractionDigits: 2
|
|
1058
1059
|
};
|
|
1059
|
-
function
|
|
1060
|
-
let h = !!o?.length, _ = N(() => [e, ...(o ?? []).map((e) => e.key)], [e, o]), y = N(() => s ? h ?
|
|
1060
|
+
function je({ price: e, symbol: t, name: n, icon: i, display: a = "area", versus: o, data: s, ranges: c, delta: l, valueFormat: u = Ae, locale: d = "en-US", title: p, ...m }) {
|
|
1061
|
+
let h = !!o?.length, _ = N(() => [e, ...(o ?? []).map((e) => e.key)], [e, o]), y = N(() => s ? h ? ke(s, _) : s : void 0, [
|
|
1061
1062
|
s,
|
|
1062
1063
|
h,
|
|
1063
1064
|
_
|
|
1064
1065
|
]), b = N(() => c?.map((t) => {
|
|
1065
|
-
let n =
|
|
1066
|
+
let n = Oe(t.data, e);
|
|
1066
1067
|
return {
|
|
1067
1068
|
...t,
|
|
1068
|
-
data: h ?
|
|
1069
|
+
data: h ? ke(t.data, _) : t.data,
|
|
1069
1070
|
delta: t.delta ?? (n && n.first ? n.last / n.first - 1 : void 0)
|
|
1070
1071
|
};
|
|
1071
1072
|
}), [
|
|
@@ -1073,7 +1074,7 @@ function Ae({ price: e, symbol: t, name: n, icon: i, display: a = "area", versus
|
|
|
1073
1074
|
h,
|
|
1074
1075
|
_,
|
|
1075
1076
|
e
|
|
1076
|
-
]), x =
|
|
1077
|
+
]), x = Oe(s ?? c?.[0]?.data ?? [], e), S = !x || x.last >= x.first, C = N(() => g(d, u).full, [d, JSON.stringify(u)]), T = N(() => g(d, {
|
|
1077
1078
|
style: "percent",
|
|
1078
1079
|
minimumFractionDigits: 1,
|
|
1079
1080
|
maximumFractionDigits: 1
|
|
@@ -1112,13 +1113,13 @@ function Ae({ price: e, symbol: t, name: n, icon: i, display: a = "area", versus
|
|
|
1112
1113
|
pillSeries: h ? "nearest" : E(e),
|
|
1113
1114
|
tiles: h,
|
|
1114
1115
|
restCaption: h ? void 0 : (t) => {
|
|
1115
|
-
let n =
|
|
1116
|
+
let n = Oe(t, e);
|
|
1116
1117
|
return n ? f(C)(n.last - n.first) : null;
|
|
1117
1118
|
},
|
|
1118
1119
|
series: [{
|
|
1119
1120
|
key: E(e),
|
|
1120
1121
|
label: t ?? p,
|
|
1121
|
-
color: h ? void 0 : S ?
|
|
1122
|
+
color: h ? void 0 : S ? B : V
|
|
1122
1123
|
}, ...(o ?? []).map((e) => ({
|
|
1123
1124
|
...e,
|
|
1124
1125
|
key: E(e.key)
|
|
@@ -1138,7 +1139,7 @@ function Ae({ price: e, symbol: t, name: n, icon: i, display: a = "area", versus
|
|
|
1138
1139
|
}
|
|
1139
1140
|
//#endregion
|
|
1140
1141
|
//#region src/finance/order-book.tsx
|
|
1141
|
-
function
|
|
1142
|
+
function Me(e, t, n) {
|
|
1142
1143
|
let r = /* @__PURE__ */ new Map();
|
|
1143
1144
|
for (let t of e) Number.isFinite(t.price) && Number.isFinite(t.size) && t.size > 0 && r.set(t.price, (r.get(t.price) ?? 0) + t.size);
|
|
1144
1145
|
let i = [...r].map(([e, t]) => ({
|
|
@@ -1151,7 +1152,7 @@ function je(e, t, n) {
|
|
|
1151
1152
|
side: t
|
|
1152
1153
|
}));
|
|
1153
1154
|
}
|
|
1154
|
-
function
|
|
1155
|
+
function Ne(e, t) {
|
|
1155
1156
|
let n = P(null), [r, i] = F(/* @__PURE__ */ new Set());
|
|
1156
1157
|
return M(() => {
|
|
1157
1158
|
let r = new Map(e.map((e) => [`${e.side}:${e.price}`, e.size])), a = n.current;
|
|
@@ -1163,14 +1164,14 @@ function Me(e, t) {
|
|
|
1163
1164
|
return () => window.clearTimeout(s);
|
|
1164
1165
|
}, [e, t]), r;
|
|
1165
1166
|
}
|
|
1166
|
-
function
|
|
1167
|
+
function Pe({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFormat: o = {
|
|
1167
1168
|
minimumFractionDigits: 2,
|
|
1168
1169
|
maximumFractionDigits: 2
|
|
1169
1170
|
}, sizeFormat: s, locale: c = "en-US", flash: l = !0, surface: u, loading: d = !1, loadingStyle: f = "shimmer", motion: p, className: m, style: h }) {
|
|
1170
1171
|
let _ = D(p ?? "auto"), v = n(d, f), y = JSON.stringify(o), x = JSON.stringify(s ?? null), S = N(() => g(c, o).full, [c, y]), C = N(() => g(c, s).compact, [c, x]), w = N(() => g(c, {
|
|
1171
1172
|
style: "percent",
|
|
1172
1173
|
maximumFractionDigits: 3
|
|
1173
|
-
}).full, [c]), T = N(() =>
|
|
1174
|
+
}).full, [c]), T = N(() => Me(t, "bid", i), [t, i]), E = N(() => Me(r, "ask", i), [r, i]), O = Ne(N(() => [...E, ...T], [E, T]), l && !_ && !d), k = Math.max(1, E.at(-1)?.total ?? 0, T.at(-1)?.total ?? 0), A = T[0]?.price, j = E[0]?.price, M = A !== void 0 && j !== void 0 ? {
|
|
1174
1175
|
value: j - A,
|
|
1175
1176
|
mid: (j + A) / 2
|
|
1176
1177
|
} : null, P = (e) => /* @__PURE__ */ R("tr", {
|
|
@@ -1262,4 +1263,4 @@ function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFor
|
|
|
1262
1263
|
});
|
|
1263
1264
|
}
|
|
1264
1265
|
//#endregion
|
|
1265
|
-
export { re as Candles, oe as CandlestickChartCard, we as DepthChartCard, xe as IndicatorChartCard,
|
|
1266
|
+
export { re as Candles, oe as CandlestickChartCard, we as DepthChartCard, xe as IndicatorChartCard, Pe as OrderBook, Ee as PortfolioChartCard, je as PriceChartCard, de as bollinger, he as depthLevels, fe as drawdown, Z as ema, ue as macd, pe as rebase, le as rsi, ce as sma };
|