@lilt-ui/charts 0.6.0 → 0.7.1
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 +22 -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 +209 -208
- package/dist/index.js +2048 -2064
- 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-DvtzSsgP.js} +1835 -1670
- package/dist/types.d.ts +6 -0
- package/dist/use-chart-width.d.ts +10 -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,
|
|
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, I as n, J as r, L as i, P as a, Q as o, R as s, S as c, T as l, _ as u, a as d, b as f, f as p, ht as m, i as h, n as g, nt as _, ot as v, q 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-DvtzSsgP.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
|
|
30
|
+
function G(e, t, n, r, i = !1) {
|
|
31
|
+
let o = Math.max(1, n.columnWidth), s = o / 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,21 +44,21 @@ 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 &&
|
|
47
|
+
let p = r === "hollow" && t.up && o >= 3, m = p ? .5 : 0, h = i ? _(e, d, o, f - d) : null, g = h ? e - h.frontWidth / 2 : e - s, v = a(g + m, d + m, Math.max(1, (h ? h.frontWidth : o) - m * 2), Math.max(1, f - d - m * 2), !h && o >= 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,
|
|
50
51
|
stroke: y,
|
|
51
|
-
side:
|
|
52
|
-
top:
|
|
52
|
+
side: h?.side ?? null,
|
|
53
|
+
top: h?.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;
|
|
@@ -85,11 +86,11 @@ function ne({ paths: e, display: t }) {
|
|
|
85
86
|
}, `stroke-${e}`)),
|
|
86
87
|
e.sides.map(({ color: e, d: t }) => /* @__PURE__ */ L("path", {
|
|
87
88
|
d: t,
|
|
88
|
-
style: { fill:
|
|
89
|
+
style: { fill: o(e).side }
|
|
89
90
|
}, `side-${e}`)),
|
|
90
91
|
e.tops.map(({ color: e, d: t }) => /* @__PURE__ */ L("path", {
|
|
91
92
|
d: t,
|
|
92
|
-
style: { fill:
|
|
93
|
+
style: { fill: o(e).top }
|
|
93
94
|
}, `top-${e}`)),
|
|
94
95
|
e.bodies.map(({ color: e, d: t }) => /* @__PURE__ */ L("path", {
|
|
95
96
|
d: t,
|
|
@@ -105,24 +106,24 @@ function ne({ paths: e, display: t }) {
|
|
|
105
106
|
}, `hollow-${e}`))
|
|
106
107
|
] });
|
|
107
108
|
}
|
|
108
|
-
var re = s(function({ series: e, open: t, high: n, low:
|
|
109
|
+
var re = s(function({ series: e, open: t, high: n, low: i, display: a = "candle", depth: o = !1, className: s }) {
|
|
109
110
|
let c = C("Candles", e, [
|
|
110
111
|
t,
|
|
111
112
|
n,
|
|
112
|
-
|
|
113
|
+
i
|
|
113
114
|
], "column"), { snapshot: l, descriptor: u, scales: d } = c, f = N(() => {
|
|
114
|
-
let
|
|
115
|
+
let r = {
|
|
115
116
|
open: t,
|
|
116
117
|
high: n,
|
|
117
|
-
low:
|
|
118
|
+
low: i
|
|
118
119
|
};
|
|
119
|
-
return
|
|
120
|
+
return W(l.data.rows, e, r), K(l.data.rows, e, r, d, a, (e, t) => te(u, e, t), o);
|
|
120
121
|
}, [
|
|
121
122
|
l,
|
|
122
123
|
e,
|
|
123
124
|
t,
|
|
124
125
|
n,
|
|
125
|
-
|
|
126
|
+
i,
|
|
126
127
|
d,
|
|
127
128
|
a,
|
|
128
129
|
u,
|
|
@@ -139,7 +140,7 @@ var re = s(function({ series: e, open: t, high: n, low: r, display: a = "candle"
|
|
|
139
140
|
opacity: c.opacity,
|
|
140
141
|
transition: c.reducedMotion ? void 0 : "opacity 160ms ease-out"
|
|
141
142
|
},
|
|
142
|
-
children: [o ? /* @__PURE__ */ L(
|
|
143
|
+
children: [o ? /* @__PURE__ */ L(r, { clip: c.depthClip }) : null, /* @__PURE__ */ L(ne, {
|
|
143
144
|
paths: f,
|
|
144
145
|
display: a
|
|
145
146
|
})]
|
|
@@ -150,36 +151,36 @@ 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
|
|
154
|
+
let s = a ? "white" : "color-mix(in srgb, var(--lilt-skeleton) 64%, var(--lilt-surface))", c = G(t, {
|
|
154
155
|
low: n,
|
|
155
156
|
high: r,
|
|
156
157
|
open: n + (r - n) * .28,
|
|
157
158
|
close: r - (r - n) * .23,
|
|
158
159
|
up: !0
|
|
159
|
-
}, i, e.display ?? "candle", e.depth),
|
|
160
|
+
}, i, e.display ?? "candle", e.depth), l = o(s);
|
|
160
161
|
return /* @__PURE__ */ R(I, { children: [
|
|
161
|
-
|
|
162
|
-
d:
|
|
162
|
+
c.stroke ? /* @__PURE__ */ L("path", {
|
|
163
|
+
d: c.stroke,
|
|
163
164
|
fill: "none",
|
|
164
|
-
stroke:
|
|
165
|
+
stroke: s,
|
|
165
166
|
strokeWidth: 1.5
|
|
166
167
|
}) : null,
|
|
167
|
-
|
|
168
|
-
d:
|
|
169
|
-
fill: a ?
|
|
168
|
+
c.side ? /* @__PURE__ */ L("path", {
|
|
169
|
+
d: c.side,
|
|
170
|
+
fill: a ? s : l.side
|
|
170
171
|
}) : null,
|
|
171
|
-
|
|
172
|
-
d:
|
|
173
|
-
fill: a ?
|
|
172
|
+
c.top ? /* @__PURE__ */ L("path", {
|
|
173
|
+
d: c.top,
|
|
174
|
+
fill: a ? s : l.top
|
|
174
175
|
}) : null,
|
|
175
|
-
|
|
176
|
-
d:
|
|
177
|
-
fill:
|
|
176
|
+
c.body ? /* @__PURE__ */ L("path", {
|
|
177
|
+
d: c.body,
|
|
178
|
+
fill: s
|
|
178
179
|
}) : null,
|
|
179
|
-
|
|
180
|
-
d:
|
|
180
|
+
c.hollow ? /* @__PURE__ */ L("path", {
|
|
181
|
+
d: c.hollow,
|
|
181
182
|
fill: a ? "black" : "var(--lilt-surface)",
|
|
182
|
-
stroke:
|
|
183
|
+
stroke: s
|
|
183
184
|
}) : null
|
|
184
185
|
] });
|
|
185
186
|
}
|
|
@@ -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,8 +227,8 @@ 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
|
-
let [f, p] = F(null),
|
|
230
|
+
function q({ context: e, label: t, caption: n, readout: r, series: a, height: o, y: s, bars: c, xAxis: l = !1, children: d }) {
|
|
231
|
+
let [f, p] = F(null), h = f ?? e.data.at(-1) ?? null;
|
|
231
232
|
return /* @__PURE__ */ R("div", {
|
|
232
233
|
className: "lilt-card__pane",
|
|
233
234
|
children: [n ? /* @__PURE__ */ R("span", {
|
|
@@ -236,20 +237,20 @@ function K({ context: e, label: t, caption: n, readout: r, series: i, height: o,
|
|
|
236
237
|
children: [/* @__PURE__ */ L("span", {
|
|
237
238
|
className: "lilt-card__pane-name",
|
|
238
239
|
children: n
|
|
239
|
-
}), r &&
|
|
240
|
-
}) : null, /* @__PURE__ */ L(
|
|
240
|
+
}), r && h && !e.loading ? r(h) : null]
|
|
241
|
+
}) : null, /* @__PURE__ */ L(m, {
|
|
241
242
|
className: "lilt-card__chart",
|
|
242
243
|
"aria-label": t,
|
|
243
244
|
data: e.data,
|
|
244
245
|
x: e.x,
|
|
245
246
|
y: s,
|
|
246
|
-
series:
|
|
247
|
+
series: a,
|
|
247
248
|
controller: e.controller,
|
|
248
249
|
onSelectionChange: r ? (e) => p(e?.row ?? null) : void 0,
|
|
249
250
|
motion: e.motion,
|
|
250
251
|
status: e.loading ? "loading" : "ready",
|
|
251
252
|
loadingStyle: e.loadingStyle,
|
|
252
|
-
children: /* @__PURE__ */ R(
|
|
253
|
+
children: /* @__PURE__ */ R(i, {
|
|
253
254
|
height: o,
|
|
254
255
|
margins: {
|
|
255
256
|
...e.margins,
|
|
@@ -262,19 +263,19 @@ function K({ context: e, label: t, caption: n, readout: r, series: i, height: o,
|
|
|
262
263
|
slots: e.slots || !!c,
|
|
263
264
|
bars: c,
|
|
264
265
|
background: "none",
|
|
265
|
-
children: [
|
|
266
|
+
children: [d, l ? /* @__PURE__ */ L(u, { labels: "fit" }) : null]
|
|
266
267
|
})
|
|
267
268
|
})]
|
|
268
269
|
});
|
|
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) {
|
|
@@ -287,47 +288,47 @@ var ae = {
|
|
|
287
288
|
minimumFractionDigits: 2,
|
|
288
289
|
maximumFractionDigits: 2
|
|
289
290
|
};
|
|
290
|
-
function oe({ open: e, high: t, low:
|
|
291
|
-
let x = N(() =>
|
|
291
|
+
function oe({ open: e, high: t, low: r, close: i, volume: a, display: o = "candle", depth: s = !1, scale: c = "linear", label: l = "Price", live: u = !1, data: d, ranges: p, delta: m, valueFormat: _ = ae, locale: v = "en-US", volumeHeight: y = 64, ...b }) {
|
|
292
|
+
let x = N(() => h(v, _).full, [v, JSON.stringify(_)]), S = N(() => h(v).compact, [v]), C = N(() => p?.map((t) => ({
|
|
292
293
|
...t,
|
|
293
|
-
delta: t.delta ??
|
|
294
|
+
delta: t.delta ?? Y(t.data, e, i)
|
|
294
295
|
})), [
|
|
295
|
-
|
|
296
|
+
p,
|
|
296
297
|
e,
|
|
297
298
|
i
|
|
298
|
-
]), T = (
|
|
299
|
+
]), T = (Y(d ?? p?.[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, r)
|
|
310
311
|
}
|
|
311
312
|
};
|
|
312
|
-
return /* @__PURE__ */ L(
|
|
313
|
+
return /* @__PURE__ */ L(g, {
|
|
313
314
|
...b,
|
|
314
315
|
depth: s,
|
|
315
316
|
data: d,
|
|
316
317
|
ranges: C,
|
|
317
|
-
delta: m ?? (d ?
|
|
318
|
-
valueFormat:
|
|
319
|
-
locale:
|
|
318
|
+
delta: m ?? (d ? Y(d, e, i) : void 0),
|
|
319
|
+
valueFormat: _,
|
|
320
|
+
locale: v,
|
|
320
321
|
aggregate: "last",
|
|
321
322
|
tiles: !1,
|
|
322
323
|
live: u,
|
|
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",
|
|
330
|
-
id: `candles:${o}:${s}:${c}:${e}:${t}:${
|
|
331
|
+
id: `candles:${o}:${s}:${c}:${e}:${t}:${r}:${!!a}`,
|
|
331
332
|
includeZero: !1,
|
|
332
333
|
scale: c,
|
|
333
334
|
slots: !0,
|
|
@@ -341,7 +342,7 @@ function oe({ open: e, high: t, low: n, close: i, volume: a, display: o = "candl
|
|
|
341
342
|
line: { showInspectionPoint: !1 }
|
|
342
343
|
},
|
|
343
344
|
describe: ie(x),
|
|
344
|
-
draw: (e) => e.map((e) => D ? [/* @__PURE__ */ L(
|
|
345
|
+
draw: (e) => e.map((e) => D ? [/* @__PURE__ */ L(n, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, `line-${e}`)] : /* @__PURE__ */ L(re, {
|
|
345
346
|
series: e,
|
|
346
347
|
open: "open",
|
|
347
348
|
high: "high",
|
|
@@ -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,18 +366,18 @@ 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 }
|
|
372
373
|
}],
|
|
373
|
-
children: /* @__PURE__ */ L(
|
|
374
|
+
children: /* @__PURE__ */ L(f, { series: "volume" })
|
|
374
375
|
}) : void 0
|
|
375
376
|
});
|
|
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);
|
|
@@ -557,54 +558,54 @@ var ye = {
|
|
|
557
558
|
"var(--lilt-series-3)",
|
|
558
559
|
"var(--lilt-series-5)"
|
|
559
560
|
];
|
|
560
|
-
function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlays: o = [], panes: s = ["rsi", "macd"], label: l = "Price", scale: u = "linear", live: d = !1, data:
|
|
561
|
+
function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlays: o = [], panes: s = ["rsi", "macd"], label: l = "Price", scale: u = "linear", live: d = !1, data: m, ranges: _, delta: v, valueFormat: y = ye, locale: b = "en-US", paneHeight: S = 72, ...C }) {
|
|
561
562
|
let T = !!(t && n && r), E = a ?? (T ? "candle" : "line");
|
|
562
563
|
if (E !== "line" && !T) throw Error("Lilt IndicatorChartCard candles need open, high and low fields.");
|
|
563
564
|
let D = JSON.stringify(o), O = JSON.stringify(s), k = N(() => ge(o), [D]), A = N(() => _e(s), [O]);
|
|
564
565
|
if (A.some((e) => e.kind === "volume") && !i) throw Error("Lilt IndicatorChartCard needs a `volume` field for a volume pane.");
|
|
565
|
-
let j = N(() =>
|
|
566
|
-
|
|
566
|
+
let j = N(() => m ? ve(m, e, k, A) : void 0, [
|
|
567
|
+
m,
|
|
567
568
|
e,
|
|
568
569
|
k,
|
|
569
570
|
A
|
|
570
|
-
]), ee = N(() =>
|
|
571
|
+
]), ee = N(() => _?.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
|
+
_,
|
|
576
577
|
e,
|
|
577
578
|
t,
|
|
578
579
|
k,
|
|
579
580
|
A
|
|
580
|
-
]), M = N(() =>
|
|
581
|
+
]), M = N(() => h(b, y).full, [b, JSON.stringify(y)]), P = N(() => h(b, { maximumFractionDigits: 2 }).full, [b]), F = N(() => h(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 =
|
|
594
|
-
let a = n.id ===
|
|
595
|
-
let r =
|
|
594
|
+
} : void 0, H = new Map(k.map((e) => [e.id, e])), U = m?.length ? Q(m[0], e) : null, W = m?.length ? Q(m.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
|
-
children: /* @__PURE__ */ L(
|
|
626
|
+
children: /* @__PURE__ */ L(f, { 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}`,
|
|
@@ -648,7 +649,7 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
648
649
|
}
|
|
649
650
|
}],
|
|
650
651
|
children: [
|
|
651
|
-
/* @__PURE__ */ L(
|
|
652
|
+
/* @__PURE__ */ L(p, {
|
|
652
653
|
axis: "y",
|
|
653
654
|
from: 30,
|
|
654
655
|
to: 70,
|
|
@@ -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
|
{
|
|
@@ -712,17 +713,17 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
712
713
|
}
|
|
713
714
|
],
|
|
714
715
|
children: [
|
|
715
|
-
/* @__PURE__ */ L(
|
|
716
|
+
/* @__PURE__ */ L(f, { series: u }),
|
|
716
717
|
/* @__PURE__ */ L(w, { series: c }),
|
|
717
718
|
/* @__PURE__ */ L(w, { series: l })
|
|
718
719
|
]
|
|
719
720
|
}, n.id);
|
|
720
721
|
};
|
|
721
|
-
return /* @__PURE__ */ L(
|
|
722
|
+
return /* @__PURE__ */ L(g, {
|
|
722
723
|
...C,
|
|
723
724
|
data: j,
|
|
724
725
|
ranges: ee,
|
|
725
|
-
delta:
|
|
726
|
+
delta: v ?? (m && t ? Y(m, 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,13 +792,13 @@ 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
|
|
798
799
|
//#region src/finance/cards/depth-chart-card.tsx
|
|
799
800
|
function Se({ price: e, label: t }) {
|
|
800
|
-
let { snapshot: n } =
|
|
801
|
+
let { snapshot: n } = v();
|
|
801
802
|
if (e < n.xDomain[0] || e > n.xDomain[1]) return null;
|
|
802
803
|
let r = n.xToPixel(e);
|
|
803
804
|
return /* @__PURE__ */ R("g", {
|
|
@@ -824,15 +825,15 @@ var Ce = {
|
|
|
824
825
|
minimumFractionDigits: 2,
|
|
825
826
|
maximumFractionDigits: 2
|
|
826
827
|
};
|
|
827
|
-
function we({ title: e, bids: t, asks:
|
|
828
|
-
let E = N(() => he(t,
|
|
828
|
+
function we({ title: e, bids: t, asks: r, valueFormat: a = Ce, sizeFormat: o, locale: s = "en-US", height: c = 220, axis: l = "minimal", background: d = "dots", hoverStyle: f = "soft", surface: p, numberStyle: g, loading: _ = !1, loadingStyle: v = "shimmer", motion: y, className: b, style: x, depth: C = !1 }) {
|
|
829
|
+
let E = N(() => he(t, r), [t, r]), D = JSON.stringify(a), M = JSON.stringify(o ?? null), P = N(() => h(s, a), [s, D]), I = N(() => h(s, o), [s, M]), z = N(() => h(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,22 +853,22 @@ 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,
|
|
859
|
-
numberStyle:
|
|
860
|
-
motion:
|
|
860
|
+
numberStyle: g,
|
|
861
|
+
motion: y,
|
|
861
862
|
className: ["lilt-card--depth", b].filter(Boolean).join(" "),
|
|
862
863
|
style: x,
|
|
863
864
|
children: [
|
|
864
865
|
/* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(A, { children: e }), /* @__PURE__ */ L(k, {
|
|
865
866
|
value: E.mid,
|
|
866
867
|
format: P.full,
|
|
867
|
-
loading:
|
|
868
|
-
motion:
|
|
869
|
-
children:
|
|
870
|
-
I.full(
|
|
868
|
+
loading: _,
|
|
869
|
+
motion: y,
|
|
870
|
+
children: _ ? 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,18 +879,18 @@ 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:
|
|
882
|
+
/* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("dt", { children: "Spread" }), /* @__PURE__ */ L("dd", { children: _ ? "—" : G })] }),
|
|
882
883
|
/* @__PURE__ */ R("div", {
|
|
883
884
|
"data-side": "bid",
|
|
884
|
-
children: [/* @__PURE__ */ L("dt", { children: "Bid depth" }), /* @__PURE__ */ L("dd", { children:
|
|
885
|
+
children: [/* @__PURE__ */ L("dt", { children: "Bid depth" }), /* @__PURE__ */ L("dd", { children: _ ? "—" : I.compact(E.bidDepth) })]
|
|
885
886
|
}),
|
|
886
887
|
/* @__PURE__ */ R("div", {
|
|
887
888
|
"data-side": "ask",
|
|
888
|
-
children: [/* @__PURE__ */ L("dt", { children: "Ask depth" }), /* @__PURE__ */ L("dd", { children:
|
|
889
|
+
children: [/* @__PURE__ */ L("dt", { children: "Ask depth" }), /* @__PURE__ */ L("dd", { children: _ ? "—" : I.compact(E.askDepth) })]
|
|
889
890
|
})
|
|
890
891
|
]
|
|
891
892
|
}),
|
|
892
|
-
/* @__PURE__ */ L(
|
|
893
|
+
/* @__PURE__ */ L(m, {
|
|
893
894
|
className: "lilt-card__chart",
|
|
894
895
|
"aria-label": `${e} depth by price`,
|
|
895
896
|
data: E.levels,
|
|
@@ -905,13 +906,13 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
|
|
|
905
906
|
},
|
|
906
907
|
series: W,
|
|
907
908
|
onSelectionChange: (e) => U(e?.row ?? null),
|
|
908
|
-
motion:
|
|
909
|
-
status:
|
|
910
|
-
loadingStyle:
|
|
911
|
-
children: /* @__PURE__ */ R(
|
|
909
|
+
motion: y,
|
|
910
|
+
status: _ ? "loading" : "ready",
|
|
911
|
+
loadingStyle: v,
|
|
912
|
+
children: /* @__PURE__ */ R(i, {
|
|
912
913
|
height: c,
|
|
913
914
|
axis: l,
|
|
914
|
-
background:
|
|
915
|
+
background: d,
|
|
915
916
|
pill: f,
|
|
916
917
|
margins: {
|
|
917
918
|
top: 8,
|
|
@@ -921,15 +922,15 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
|
|
|
921
922
|
},
|
|
922
923
|
children: [
|
|
923
924
|
/* @__PURE__ */ L(T, { pattern: "lines" }),
|
|
924
|
-
/* @__PURE__ */ L(
|
|
925
|
-
/* @__PURE__ */ L(
|
|
925
|
+
/* @__PURE__ */ L(n, { series: "bid" }),
|
|
926
|
+
/* @__PURE__ */ L(n, { series: "ask" }),
|
|
926
927
|
/* @__PURE__ */ L(w, { series: "bid" }),
|
|
927
928
|
/* @__PURE__ */ L(w, { series: "ask" }),
|
|
928
929
|
E.mid === null ? null : /* @__PURE__ */ L(Se, {
|
|
929
930
|
price: E.mid,
|
|
930
931
|
label: `Mid ${P.full(E.mid)}`
|
|
931
932
|
}),
|
|
932
|
-
/* @__PURE__ */ L(
|
|
933
|
+
/* @__PURE__ */ L(u, { labels: "fit" }),
|
|
933
934
|
/* @__PURE__ */ L(S, {})
|
|
934
935
|
]
|
|
935
936
|
})
|
|
@@ -939,16 +940,16 @@ 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
|
-
function Ee({ value: e, basis: t, label:
|
|
952
|
+
function Ee({ value: e, basis: t, label: r = "Value", drawdown: i = !0, drawdownHeight: a = 64, data: o, ranges: s, delta: c, locale: l = "en-US", ...u }) {
|
|
952
953
|
let d = o ?? s?.[0]?.data ?? [], f = N(() => s?.map((n) => ({
|
|
953
954
|
...n,
|
|
954
955
|
delta: n.delta ?? Te(n.data, e, t)
|
|
@@ -956,15 +957,15 @@ function Ee({ value: e, basis: t, label: n = "Value", drawdown: i = !0, drawdown
|
|
|
956
957
|
s,
|
|
957
958
|
e,
|
|
958
959
|
t
|
|
959
|
-
]), p = N(() =>
|
|
960
|
+
]), p = N(() => h(l, {
|
|
960
961
|
style: "percent",
|
|
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
|
-
return /* @__PURE__ */ L(
|
|
968
|
+
return /* @__PURE__ */ L(g, {
|
|
968
969
|
...u,
|
|
969
970
|
data: o,
|
|
970
971
|
ranges: f,
|
|
@@ -977,7 +978,7 @@ function Ee({ value: e, basis: t, label: n = "Value", drawdown: i = !0, drawdown
|
|
|
977
978
|
restCaption: t ? () => "over basis" : void 0,
|
|
978
979
|
series: [{
|
|
979
980
|
key: e,
|
|
980
|
-
label:
|
|
981
|
+
label: r
|
|
981
982
|
}, ...t ? [{
|
|
982
983
|
key: t,
|
|
983
984
|
label: "Basis",
|
|
@@ -995,11 +996,11 @@ function Ee({ value: e, basis: t, label: n = "Value", drawdown: i = !0, drawdown
|
|
|
995
996
|
area: { treatment: "fade" },
|
|
996
997
|
curve: "monotone"
|
|
997
998
|
},
|
|
998
|
-
draw: (e) => e.map((e) => [/* @__PURE__ */ L(
|
|
999
|
+
draw: (e) => e.map((e) => [/* @__PURE__ */ L(n, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, e)])
|
|
999
1000
|
},
|
|
1000
1001
|
panes: i ? (t) => {
|
|
1001
|
-
let
|
|
1002
|
-
return /* @__PURE__ */ R(
|
|
1002
|
+
let r = fe(t.data.map((t) => $(t, e))), i = new Map(t.data.map((e, t) => [e, r[t] ?? null]));
|
|
1003
|
+
return /* @__PURE__ */ R(q, {
|
|
1003
1004
|
context: t,
|
|
1004
1005
|
label: `${u.title} drawdown`,
|
|
1005
1006
|
caption: "Drawdown",
|
|
@@ -1027,7 +1028,7 @@ function Ee({ value: e, basis: t, label: n = "Value", drawdown: i = !0, drawdown
|
|
|
1027
1028
|
line: { width: 1.5 },
|
|
1028
1029
|
curve: "monotone"
|
|
1029
1030
|
}],
|
|
1030
|
-
children: [/* @__PURE__ */ L(
|
|
1031
|
+
children: [/* @__PURE__ */ L(n, { series: "drawdown" }), /* @__PURE__ */ L(w, { series: "drawdown" })]
|
|
1031
1032
|
});
|
|
1032
1033
|
} : void 0
|
|
1033
1034
|
});
|
|
@@ -1038,46 +1039,46 @@ 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
|
|
1060
|
+
function je({ price: e, symbol: t, name: r, icon: i, display: a = "area", versus: o, data: s, ranges: c, delta: l, valueFormat: u = Ae, locale: f = "en-US", title: p, ...m }) {
|
|
1061
|
+
let _ = !!o?.length, v = N(() => [e, ...(o ?? []).map((e) => e.key)], [e, o]), y = N(() => s ? _ ? ke(s, v) : s : void 0, [
|
|
1061
1062
|
s,
|
|
1062
|
-
|
|
1063
|
-
|
|
1063
|
+
_,
|
|
1064
|
+
v
|
|
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:
|
|
1069
|
+
data: _ ? ke(t.data, v) : t.data,
|
|
1069
1070
|
delta: t.delta ?? (n && n.first ? n.last / n.first - 1 : void 0)
|
|
1070
1071
|
};
|
|
1071
1072
|
}), [
|
|
1072
1073
|
c,
|
|
1073
|
-
h,
|
|
1074
1074
|
_,
|
|
1075
|
+
v,
|
|
1075
1076
|
e
|
|
1076
|
-
]), x =
|
|
1077
|
+
]), x = Oe(s ?? c?.[0]?.data ?? [], e), S = !x || x.last >= x.first, C = N(() => h(f, u).full, [f, JSON.stringify(u)]), T = N(() => h(f, {
|
|
1077
1078
|
style: "percent",
|
|
1078
1079
|
minimumFractionDigits: 1,
|
|
1079
1080
|
maximumFractionDigits: 1
|
|
1080
|
-
}).full, [
|
|
1081
|
+
}).full, [f]), E = (e) => _ ? `__rebased${e}` : e, D = /* @__PURE__ */ R("span", {
|
|
1081
1082
|
className: "lilt-card__ticker",
|
|
1082
1083
|
children: [
|
|
1083
1084
|
i ? /* @__PURE__ */ L("span", {
|
|
@@ -1088,57 +1089,57 @@ function Ae({ price: e, symbol: t, name: n, icon: i, display: a = "area", versus
|
|
|
1088
1089
|
className: "lilt-card__ticker-symbol",
|
|
1089
1090
|
children: t ?? p
|
|
1090
1091
|
}),
|
|
1091
|
-
|
|
1092
|
+
r ? /* @__PURE__ */ L("span", {
|
|
1092
1093
|
className: "lilt-card__ticker-name",
|
|
1093
|
-
children:
|
|
1094
|
+
children: r
|
|
1094
1095
|
}) : null
|
|
1095
1096
|
]
|
|
1096
1097
|
});
|
|
1097
|
-
return /* @__PURE__ */ L(
|
|
1098
|
+
return /* @__PURE__ */ L(g, {
|
|
1098
1099
|
...m,
|
|
1099
1100
|
title: p,
|
|
1100
1101
|
heading: D,
|
|
1101
1102
|
data: y,
|
|
1102
1103
|
ranges: b,
|
|
1103
|
-
delta:
|
|
1104
|
-
valueFormat:
|
|
1104
|
+
delta: _ ? void 0 : l ?? (s && x && x.first ? x.last / x.first - 1 : void 0),
|
|
1105
|
+
valueFormat: _ ? {
|
|
1105
1106
|
style: "percent",
|
|
1106
1107
|
maximumFractionDigits: 1
|
|
1107
1108
|
} : u,
|
|
1108
|
-
formatValue:
|
|
1109
|
-
locale:
|
|
1109
|
+
formatValue: _ ? (e) => d(T)(e) : void 0,
|
|
1110
|
+
locale: f,
|
|
1110
1111
|
aggregate: "last",
|
|
1111
1112
|
headlineSeries: E(e),
|
|
1112
|
-
pillSeries:
|
|
1113
|
-
tiles:
|
|
1114
|
-
restCaption:
|
|
1115
|
-
let n =
|
|
1116
|
-
return n ?
|
|
1113
|
+
pillSeries: _ ? "nearest" : E(e),
|
|
1114
|
+
tiles: _,
|
|
1115
|
+
restCaption: _ ? void 0 : (t) => {
|
|
1116
|
+
let n = Oe(t, e);
|
|
1117
|
+
return n ? d(C)(n.last - n.first) : null;
|
|
1117
1118
|
},
|
|
1118
1119
|
series: [{
|
|
1119
1120
|
key: E(e),
|
|
1120
1121
|
label: t ?? p,
|
|
1121
|
-
color:
|
|
1122
|
+
color: _ ? void 0 : S ? B : V
|
|
1122
1123
|
}, ...(o ?? []).map((e) => ({
|
|
1123
1124
|
...e,
|
|
1124
1125
|
key: E(e.key)
|
|
1125
1126
|
}))],
|
|
1126
1127
|
shape: {
|
|
1127
1128
|
kind: "marks",
|
|
1128
|
-
id: `price:${a}:${
|
|
1129
|
-
includeZero:
|
|
1130
|
-
series: () => a === "area" && !
|
|
1129
|
+
id: `price:${a}:${v.join()}:${_}`,
|
|
1130
|
+
includeZero: _,
|
|
1131
|
+
series: () => a === "area" && !_ ? {
|
|
1131
1132
|
area: { treatment: "fade" },
|
|
1132
1133
|
curve: "monotone"
|
|
1133
1134
|
} : { curve: "monotone" },
|
|
1134
|
-
draw: (e) => e.map((e) => a === "area" && !
|
|
1135
|
+
draw: (e) => e.map((e) => a === "area" && !_ ? [/* @__PURE__ */ L(n, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, e)] : /* @__PURE__ */ L(w, { series: e }, e))
|
|
1135
1136
|
},
|
|
1136
1137
|
bleed: m.bleed ?? !0
|
|
1137
1138
|
});
|
|
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: n, levels: r = 8, depth: i = !1, valueFormat: a = {
|
|
1167
1168
|
minimumFractionDigits: 2,
|
|
1168
1169
|
maximumFractionDigits: 2
|
|
1169
|
-
}, sizeFormat:
|
|
1170
|
-
let
|
|
1170
|
+
}, sizeFormat: o, locale: s = "en-US", flash: c = !0, surface: l, loading: u = !1, loadingStyle: d = "shimmer", motion: f, className: p, style: m }) {
|
|
1171
|
+
let g = D(f ?? "auto"), _ = y(u, d), v = JSON.stringify(a), x = JSON.stringify(o ?? null), S = N(() => h(s, a).full, [s, v]), C = N(() => h(s, o).compact, [s, x]), w = N(() => h(s, {
|
|
1171
1172
|
style: "percent",
|
|
1172
1173
|
maximumFractionDigits: 3
|
|
1173
|
-
}).full, [
|
|
1174
|
+
}).full, [s]), T = N(() => Me(t, "bid", r), [t, r]), E = N(() => Me(n, "ask", r), [n, r]), O = Ne(N(() => [...E, ...T], [E, T]), c && !g && !u), 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", {
|
|
@@ -1181,7 +1182,7 @@ function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFor
|
|
|
1181
1182
|
children: [
|
|
1182
1183
|
/* @__PURE__ */ R("th", {
|
|
1183
1184
|
scope: "row",
|
|
1184
|
-
children: [
|
|
1185
|
+
children: [i ? /* @__PURE__ */ L("span", {
|
|
1185
1186
|
className: "lilt-order-book__bar",
|
|
1186
1187
|
"aria-hidden": "true"
|
|
1187
1188
|
}) : null, S(e.price)]
|
|
@@ -1189,7 +1190,7 @@ function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFor
|
|
|
1189
1190
|
/* @__PURE__ */ L("td", { children: C(e.size) }),
|
|
1190
1191
|
/* @__PURE__ */ L("td", { children: C(e.total) })
|
|
1191
1192
|
]
|
|
1192
|
-
}, `${e.side}:${e.price}`), F = (e) => Array.from({ length: Math.max(1, Math.min(50,
|
|
1193
|
+
}, `${e.side}:${e.price}`), F = (e) => Array.from({ length: Math.max(1, Math.min(50, r)) }, (t, n) => /* @__PURE__ */ R("tr", {
|
|
1193
1194
|
className: "lilt-order-book__placeholder",
|
|
1194
1195
|
"aria-hidden": "true",
|
|
1195
1196
|
children: [
|
|
@@ -1209,17 +1210,17 @@ function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFor
|
|
|
1209
1210
|
}, `${e}-${n}`));
|
|
1210
1211
|
return /* @__PURE__ */ L(ee, {
|
|
1211
1212
|
"aria-label": e,
|
|
1212
|
-
surface:
|
|
1213
|
-
motion:
|
|
1214
|
-
className: ["lilt-card--order-book",
|
|
1215
|
-
style:
|
|
1213
|
+
surface: l,
|
|
1214
|
+
motion: f,
|
|
1215
|
+
className: ["lilt-card--order-book", p].filter(Boolean).join(" "),
|
|
1216
|
+
style: m,
|
|
1216
1217
|
children: /* @__PURE__ */ R("table", {
|
|
1217
|
-
ref:
|
|
1218
|
-
className:
|
|
1219
|
-
"data-depth":
|
|
1220
|
-
"data-style":
|
|
1221
|
-
"data-reduced-motion":
|
|
1222
|
-
"aria-busy":
|
|
1218
|
+
ref: _,
|
|
1219
|
+
className: u ? "lilt-order-book lilt-skeleton" : "lilt-order-book",
|
|
1220
|
+
"data-depth": i || void 0,
|
|
1221
|
+
"data-style": u ? d : void 0,
|
|
1222
|
+
"data-reduced-motion": g || void 0,
|
|
1223
|
+
"aria-busy": u,
|
|
1223
1224
|
children: [
|
|
1224
1225
|
/* @__PURE__ */ L("caption", { children: e }),
|
|
1225
1226
|
/* @__PURE__ */ L("thead", { children: /* @__PURE__ */ R("tr", { children: [
|
|
@@ -1238,7 +1239,7 @@ function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFor
|
|
|
1238
1239
|
] }) }),
|
|
1239
1240
|
/* @__PURE__ */ L("tbody", {
|
|
1240
1241
|
"aria-label": "Asks",
|
|
1241
|
-
children:
|
|
1242
|
+
children: u ? F("ask") : [...E].reverse().map(P)
|
|
1242
1243
|
}),
|
|
1243
1244
|
/* @__PURE__ */ L("tbody", {
|
|
1244
1245
|
"aria-label": "Spread",
|
|
@@ -1246,20 +1247,20 @@ function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFor
|
|
|
1246
1247
|
className: "lilt-order-book__spread",
|
|
1247
1248
|
children: [/* @__PURE__ */ L("th", {
|
|
1248
1249
|
scope: "row",
|
|
1249
|
-
children:
|
|
1250
|
+
children: u ? "—" : M ? S(M.mid) : "—"
|
|
1250
1251
|
}), /* @__PURE__ */ L("td", {
|
|
1251
1252
|
colSpan: 2,
|
|
1252
|
-
children:
|
|
1253
|
+
children: u ? "Loading order book" : M ? `Spread ${S(M.value)} · ${w(M.value / M.mid)}` : "No spread"
|
|
1253
1254
|
})]
|
|
1254
1255
|
})
|
|
1255
1256
|
}),
|
|
1256
1257
|
/* @__PURE__ */ L("tbody", {
|
|
1257
1258
|
"aria-label": "Bids",
|
|
1258
|
-
children:
|
|
1259
|
+
children: u ? F("bid") : T.map(P)
|
|
1259
1260
|
})
|
|
1260
1261
|
]
|
|
1261
1262
|
})
|
|
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 };
|