@lilt-ui/charts 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/activity-ring.d.ts +3 -2
- package/dist/cards/activity-ring-card.d.ts +3 -2
- package/dist/cards/cartesian-card.d.ts +15 -2
- package/dist/cards/funnel-chart-card.d.ts +3 -2
- package/dist/cards/heatmap-chart-card.d.ts +3 -2
- package/dist/cards/horizontal-bar-chart-card.d.ts +3 -2
- package/dist/cards/progress-card.d.ts +3 -2
- package/dist/cards/radar-chart-card.d.ts +3 -2
- package/dist/cards/radial-chart-card.d.ts +4 -2
- package/dist/cards/sankey-chart-card.d.ts +3 -2
- package/dist/cards/scatter-chart-card.d.ts +3 -2
- package/dist/cards/slope-chart-card.d.ts +3 -2
- package/dist/cards/stat-card.d.ts +3 -2
- 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/cards/depth-chart-card.d.ts +3 -2
- package/dist/finance/order-book.d.ts +4 -2
- package/dist/finance.js +467 -404
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2488 -2080
- package/dist/lifecycle/loading-layer.d.ts +14 -3
- package/dist/lifecycle/skeleton-block.d.ts +6 -0
- package/dist/lifecycle/skeleton-sheen.d.ts +15 -2
- package/dist/lifecycle/use-skeleton-clock.d.ts +5 -0
- package/dist/marks/contract.d.ts +15 -0
- package/dist/marks/range-loading-mark.d.ts +3 -0
- package/dist/primitives/depth-paint.d.ts +5 -1
- package/dist/primitives/runoff.d.ts +6 -7
- package/dist/{report-context-Cz0AYdV2.js → report-context-CkzH-r8B.js} +130 -129
- package/dist/{cartesian-card-7DAiMU3w.js → skeleton-block-C110l-2a.js} +2223 -1856
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +14 -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 {
|
|
3
|
-
import { S as
|
|
4
|
-
import { useEffect as
|
|
5
|
-
import { Fragment as
|
|
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
|
+
import { useEffect as M, useMemo as N, useRef as P, useState as F } from "react";
|
|
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,84 +19,84 @@ function z(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 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${
|
|
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
|
};
|
|
40
41
|
}
|
|
41
|
-
let
|
|
42
|
-
if (
|
|
43
|
-
let e = (
|
|
44
|
-
|
|
42
|
+
let d = n.y(Math.max(t.open, t.close)), f = n.y(Math.min(t.open, t.close));
|
|
43
|
+
if (f - d < 1) {
|
|
44
|
+
let e = (d + f) / 2;
|
|
45
|
+
d = e - .5, f = e + .5;
|
|
45
46
|
}
|
|
46
|
-
let
|
|
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
|
-
body:
|
|
49
|
-
hollow:
|
|
49
|
+
body: p ? null : v,
|
|
50
|
+
hollow: p ? v : null,
|
|
50
51
|
stroke: y,
|
|
51
52
|
side: g?.side ?? null,
|
|
52
53
|
top: g?.top ?? null
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
-
let
|
|
57
|
-
for (let { row:
|
|
58
|
-
let e =
|
|
56
|
+
function K(t, n, r, i, a, o, s = !1) {
|
|
57
|
+
let c = new l(), u = new l(), d = new l(), f = new l(), p = new l();
|
|
58
|
+
for (let { row: l, cx: m } of e(t, i)) {
|
|
59
|
+
let e = U(l, n, r);
|
|
59
60
|
if (!e) continue;
|
|
60
|
-
let
|
|
61
|
-
h.side &&
|
|
61
|
+
let t = o(l, e), h = G(m, e, i, a, s);
|
|
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 {
|
|
64
|
-
bodies:
|
|
65
|
-
hollow:
|
|
66
|
-
strokes:
|
|
67
|
-
sides:
|
|
68
|
-
tops:
|
|
65
|
+
bodies: c.entries(),
|
|
66
|
+
hollow: u.entries(),
|
|
67
|
+
strokes: d.entries(),
|
|
68
|
+
sides: f.entries(),
|
|
69
|
+
tops: p.entries()
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
//#endregion
|
|
72
73
|
//#region src/finance/candles.tsx
|
|
73
|
-
function
|
|
74
|
-
return
|
|
74
|
+
function te(e, t, n) {
|
|
75
|
+
return E(e, t, n.up ? B : V);
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
+
function ne({ paths: e, display: t }) {
|
|
77
78
|
let n = t === "ohlc" ? 1.5 : 1;
|
|
78
|
-
return /* @__PURE__ */
|
|
79
|
-
e.strokes.map(({ color: e, d: r }) => /* @__PURE__ */
|
|
79
|
+
return /* @__PURE__ */ R(I, { children: [
|
|
80
|
+
e.strokes.map(({ color: e, d: r }) => /* @__PURE__ */ L("path", {
|
|
80
81
|
d: r,
|
|
81
82
|
fill: "none",
|
|
82
83
|
strokeWidth: n,
|
|
83
84
|
strokeLinecap: t === "ohlc" ? "round" : "butt",
|
|
84
85
|
style: { stroke: e }
|
|
85
86
|
}, `stroke-${e}`)),
|
|
86
|
-
e.sides.map(({ color: e, d: t }) => /* @__PURE__ */
|
|
87
|
+
e.sides.map(({ color: e, d: t }) => /* @__PURE__ */ L("path", {
|
|
87
88
|
d: t,
|
|
88
|
-
style: { fill:
|
|
89
|
+
style: { fill: u(e).side }
|
|
89
90
|
}, `side-${e}`)),
|
|
90
|
-
e.tops.map(({ color: e, d: t }) => /* @__PURE__ */
|
|
91
|
+
e.tops.map(({ color: e, d: t }) => /* @__PURE__ */ L("path", {
|
|
91
92
|
d: t,
|
|
92
|
-
style: { fill:
|
|
93
|
+
style: { fill: u(e).top }
|
|
93
94
|
}, `top-${e}`)),
|
|
94
|
-
e.bodies.map(({ color: e, d: t }) => /* @__PURE__ */
|
|
95
|
+
e.bodies.map(({ color: e, d: t }) => /* @__PURE__ */ L("path", {
|
|
95
96
|
d: t,
|
|
96
97
|
style: { fill: e }
|
|
97
98
|
}, `body-${e}`)),
|
|
98
|
-
e.hollow.map(({ color: e, d: t }) => /* @__PURE__ */
|
|
99
|
+
e.hollow.map(({ color: e, d: t }) => /* @__PURE__ */ L("path", {
|
|
99
100
|
d: t,
|
|
100
101
|
strokeWidth: 1,
|
|
101
102
|
style: {
|
|
@@ -105,61 +106,99 @@ function W({ paths: e, display: t }) {
|
|
|
105
106
|
}, `hollow-${e}`))
|
|
106
107
|
] });
|
|
107
108
|
}
|
|
108
|
-
var
|
|
109
|
-
let
|
|
109
|
+
var re = s(function({ series: e, open: t, high: n, low: r, display: a = "candle", depth: o = !1, className: s }) {
|
|
110
|
+
let c = C("Candles", e, [
|
|
111
|
+
t,
|
|
110
112
|
n,
|
|
111
|
-
r
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
low: i
|
|
113
|
+
r
|
|
114
|
+
], "column"), { snapshot: l, descriptor: u, scales: d } = c, f = N(() => {
|
|
115
|
+
let i = {
|
|
116
|
+
open: t,
|
|
117
|
+
high: n,
|
|
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,
|
|
123
|
+
e,
|
|
122
124
|
t,
|
|
123
125
|
n,
|
|
124
126
|
r,
|
|
125
|
-
i,
|
|
126
|
-
f,
|
|
127
|
-
a,
|
|
128
127
|
d,
|
|
128
|
+
a,
|
|
129
|
+
u,
|
|
129
130
|
o
|
|
130
131
|
]);
|
|
131
|
-
return /* @__PURE__ */
|
|
132
|
+
return /* @__PURE__ */ R("g", {
|
|
132
133
|
"aria-hidden": "true",
|
|
133
|
-
className: ["lilt-chart__candles",
|
|
134
|
-
"data-series":
|
|
134
|
+
className: ["lilt-chart__candles", s].filter(Boolean).join(" "),
|
|
135
|
+
"data-series": e,
|
|
135
136
|
"data-display": a,
|
|
136
|
-
clipPath: o ? `url(#${
|
|
137
|
-
mask:
|
|
137
|
+
clipPath: o ? `url(#${c.depthClip.id})` : c.clipPath,
|
|
138
|
+
mask: c.mask,
|
|
138
139
|
style: {
|
|
139
|
-
opacity:
|
|
140
|
-
transition:
|
|
140
|
+
opacity: c.opacity,
|
|
141
|
+
transition: c.reducedMotion ? void 0 : "opacity 160ms ease-out"
|
|
141
142
|
},
|
|
142
|
-
children: [o ? /* @__PURE__ */
|
|
143
|
-
paths:
|
|
143
|
+
children: [o ? /* @__PURE__ */ L(i, { clip: c.depthClip }) : null, /* @__PURE__ */ L(ne, {
|
|
144
|
+
paths: f,
|
|
144
145
|
display: a
|
|
145
146
|
})]
|
|
146
147
|
});
|
|
147
148
|
}, {
|
|
148
149
|
layout: "column",
|
|
150
|
+
loading: (e) => ({
|
|
151
|
+
kind: e.display === "ohlc" ? "ohlc" : "candle",
|
|
152
|
+
depth: e.depth && e.display !== "ohlc",
|
|
153
|
+
render: ({ cx: t, low: n, high: r, scales: i, mask: a }) => {
|
|
154
|
+
let o = a ? "white" : "color-mix(in srgb, var(--lilt-skeleton) 64%, var(--lilt-surface))", s = G(t, {
|
|
155
|
+
low: n,
|
|
156
|
+
high: r,
|
|
157
|
+
open: n + (r - n) * .28,
|
|
158
|
+
close: r - (r - n) * .23,
|
|
159
|
+
up: !0
|
|
160
|
+
}, i, e.display ?? "candle", e.depth), c = u(o);
|
|
161
|
+
return /* @__PURE__ */ R(I, { children: [
|
|
162
|
+
s.stroke ? /* @__PURE__ */ L("path", {
|
|
163
|
+
d: s.stroke,
|
|
164
|
+
fill: "none",
|
|
165
|
+
stroke: o,
|
|
166
|
+
strokeWidth: 1.5
|
|
167
|
+
}) : null,
|
|
168
|
+
s.side ? /* @__PURE__ */ L("path", {
|
|
169
|
+
d: s.side,
|
|
170
|
+
fill: a ? o : c.side
|
|
171
|
+
}) : null,
|
|
172
|
+
s.top ? /* @__PURE__ */ L("path", {
|
|
173
|
+
d: s.top,
|
|
174
|
+
fill: a ? o : c.top
|
|
175
|
+
}) : null,
|
|
176
|
+
s.body ? /* @__PURE__ */ L("path", {
|
|
177
|
+
d: s.body,
|
|
178
|
+
fill: o
|
|
179
|
+
}) : null,
|
|
180
|
+
s.hollow ? /* @__PURE__ */ L("path", {
|
|
181
|
+
d: s.hollow,
|
|
182
|
+
fill: a ? "black" : "var(--lilt-surface)",
|
|
183
|
+
stroke: o
|
|
184
|
+
}) : null
|
|
185
|
+
] });
|
|
186
|
+
}
|
|
187
|
+
}),
|
|
149
188
|
series: (e) => e.series,
|
|
150
189
|
fields: (e) => [
|
|
151
190
|
e.open,
|
|
152
191
|
e.high,
|
|
153
192
|
e.low
|
|
154
193
|
],
|
|
155
|
-
highlight: (e, { row:
|
|
156
|
-
let
|
|
157
|
-
if (!
|
|
158
|
-
let
|
|
159
|
-
return /* @__PURE__ */
|
|
194
|
+
highlight: (e, { row: n, snapshot: r, descriptor: i }) => {
|
|
195
|
+
let a = U(n, e.series, e);
|
|
196
|
+
if (!a) return null;
|
|
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);
|
|
198
|
+
return /* @__PURE__ */ L("g", {
|
|
160
199
|
className: "lilt-chart__candle-highlight",
|
|
161
|
-
children: /* @__PURE__ */
|
|
162
|
-
display:
|
|
200
|
+
children: /* @__PURE__ */ L(ne, {
|
|
201
|
+
display: o,
|
|
163
202
|
paths: {
|
|
164
203
|
bodies: c.body ? [{
|
|
165
204
|
color: l,
|
|
@@ -188,29 +227,30 @@ var G = r(function({ series: t, open: n, high: r, low: i, display: a = "candle",
|
|
|
188
227
|
});
|
|
189
228
|
//#endregion
|
|
190
229
|
//#region src/finance/cards/pane.tsx
|
|
191
|
-
function
|
|
192
|
-
let [
|
|
193
|
-
return /* @__PURE__ */
|
|
230
|
+
function q({ context: e, label: t, caption: n, readout: r, series: i, height: o, y: s, bars: c, xAxis: l = !1, children: u }) {
|
|
231
|
+
let [f, p] = F(null), m = f ?? e.data.at(-1) ?? null;
|
|
232
|
+
return /* @__PURE__ */ R("div", {
|
|
194
233
|
className: "lilt-card__pane",
|
|
195
|
-
children: [
|
|
234
|
+
children: [n ? /* @__PURE__ */ R("span", {
|
|
196
235
|
className: "lilt-card__pane-caption",
|
|
197
236
|
"aria-hidden": "true",
|
|
198
|
-
children: [/* @__PURE__ */
|
|
237
|
+
children: [/* @__PURE__ */ L("span", {
|
|
199
238
|
className: "lilt-card__pane-name",
|
|
200
|
-
children:
|
|
201
|
-
}),
|
|
202
|
-
}) : null, /* @__PURE__ */
|
|
239
|
+
children: n
|
|
240
|
+
}), r && m && !e.loading ? r(m) : null]
|
|
241
|
+
}) : null, /* @__PURE__ */ L(y, {
|
|
203
242
|
className: "lilt-card__chart",
|
|
204
243
|
"aria-label": t,
|
|
205
244
|
data: e.data,
|
|
206
245
|
x: e.x,
|
|
207
246
|
y: s,
|
|
208
|
-
series:
|
|
247
|
+
series: i,
|
|
209
248
|
controller: e.controller,
|
|
210
|
-
onSelectionChange:
|
|
249
|
+
onSelectionChange: r ? (e) => p(e?.row ?? null) : void 0,
|
|
211
250
|
motion: e.motion,
|
|
212
251
|
status: e.loading ? "loading" : "ready",
|
|
213
|
-
|
|
252
|
+
loadingStyle: e.loadingStyle,
|
|
253
|
+
children: /* @__PURE__ */ R(a, {
|
|
214
254
|
height: o,
|
|
215
255
|
margins: {
|
|
216
256
|
...e.margins,
|
|
@@ -223,72 +263,72 @@ function K({ context: e, label: t, caption: r, readout: i, series: a, height: o,
|
|
|
223
263
|
slots: e.slots || !!c,
|
|
224
264
|
bars: c,
|
|
225
265
|
background: "none",
|
|
226
|
-
children: [u, l ? /* @__PURE__ */
|
|
266
|
+
children: [u, l ? /* @__PURE__ */ L(d, { labels: "fit" }) : null]
|
|
227
267
|
})
|
|
228
268
|
})]
|
|
229
269
|
});
|
|
230
270
|
}
|
|
231
271
|
//#endregion
|
|
232
272
|
//#region src/finance/cards/candlestick-chart-card.tsx
|
|
233
|
-
function
|
|
273
|
+
function J(e, t) {
|
|
234
274
|
let n = e[t];
|
|
235
275
|
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
236
276
|
}
|
|
237
|
-
function
|
|
238
|
-
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;
|
|
239
279
|
return r && i !== null ? i / r - 1 : void 0;
|
|
240
280
|
}
|
|
241
|
-
function
|
|
281
|
+
function ie(e) {
|
|
242
282
|
return (t) => {
|
|
243
283
|
let n = t.series[0]?.fields;
|
|
244
284
|
return !n?.length || n.some((e) => e.value === null) ? null : n.map((t) => `${t.label[0]} ${e(t.value)}`).join(" ");
|
|
245
285
|
};
|
|
246
286
|
}
|
|
247
|
-
var
|
|
287
|
+
var ae = {
|
|
248
288
|
minimumFractionDigits: 2,
|
|
249
289
|
maximumFractionDigits: 2
|
|
250
290
|
};
|
|
251
|
-
function
|
|
252
|
-
let x =
|
|
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 }) {
|
|
292
|
+
let x = N(() => g(_, h).full, [_, JSON.stringify(h)]), S = N(() => g(_).compact, [_]), C = N(() => f?.map((t) => ({
|
|
253
293
|
...t,
|
|
254
|
-
delta: t.delta ??
|
|
294
|
+
delta: t.delta ?? Y(t.data, e, i)
|
|
255
295
|
})), [
|
|
256
|
-
|
|
296
|
+
f,
|
|
257
297
|
e,
|
|
258
298
|
i
|
|
259
|
-
]), 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 = {
|
|
260
300
|
open: {
|
|
261
301
|
label: "Open",
|
|
262
|
-
accessor: (t) =>
|
|
302
|
+
accessor: (t) => J(t, e)
|
|
263
303
|
},
|
|
264
304
|
high: {
|
|
265
305
|
label: "High",
|
|
266
|
-
accessor: (e) =>
|
|
306
|
+
accessor: (e) => J(e, t)
|
|
267
307
|
},
|
|
268
308
|
low: {
|
|
269
309
|
label: "Low",
|
|
270
|
-
accessor: (e) =>
|
|
310
|
+
accessor: (e) => J(e, n)
|
|
271
311
|
}
|
|
272
312
|
};
|
|
273
|
-
return /* @__PURE__ */
|
|
274
|
-
...
|
|
313
|
+
return /* @__PURE__ */ L(v, {
|
|
314
|
+
...b,
|
|
275
315
|
depth: s,
|
|
276
|
-
data:
|
|
316
|
+
data: d,
|
|
277
317
|
ranges: C,
|
|
278
|
-
delta: m ?? (
|
|
318
|
+
delta: m ?? (d ? Y(d, e, i) : void 0),
|
|
279
319
|
valueFormat: h,
|
|
280
|
-
locale:
|
|
320
|
+
locale: _,
|
|
281
321
|
aggregate: "last",
|
|
282
322
|
tiles: !1,
|
|
283
|
-
live:
|
|
323
|
+
live: u,
|
|
284
324
|
series: [{
|
|
285
325
|
key: i,
|
|
286
326
|
label: l,
|
|
287
|
-
color: D ? T ?
|
|
327
|
+
color: D ? T ? B : V : void 0
|
|
288
328
|
}],
|
|
289
329
|
shape: {
|
|
290
330
|
kind: "marks",
|
|
291
|
-
id: `candles:${o}:${s}:${c}:${e}:${
|
|
331
|
+
id: `candles:${o}:${s}:${c}:${e}:${t}:${n}:${!!a}`,
|
|
292
332
|
includeZero: !1,
|
|
293
333
|
scale: c,
|
|
294
334
|
slots: !0,
|
|
@@ -301,8 +341,8 @@ function ie({ open: e, high: n, low: r, close: i, volume: a, display: o = "candl
|
|
|
301
341
|
fields: O,
|
|
302
342
|
line: { showInspectionPoint: !1 }
|
|
303
343
|
},
|
|
304
|
-
describe:
|
|
305
|
-
draw: (e) => e.map((e) => D ? [/* @__PURE__ */
|
|
344
|
+
describe: ie(x),
|
|
345
|
+
draw: (e) => e.map((e) => D ? [/* @__PURE__ */ L(r, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, `line-${e}`)] : /* @__PURE__ */ L(re, {
|
|
306
346
|
series: e,
|
|
307
347
|
open: "open",
|
|
308
348
|
high: "high",
|
|
@@ -311,11 +351,11 @@ function ie({ open: e, high: n, low: r, close: i, volume: a, display: o = "candl
|
|
|
311
351
|
depth: s
|
|
312
352
|
}, e))
|
|
313
353
|
},
|
|
314
|
-
panes: a ? (e) => /* @__PURE__ */
|
|
354
|
+
panes: a ? (e) => /* @__PURE__ */ L(q, {
|
|
315
355
|
context: e,
|
|
316
|
-
label: `${
|
|
356
|
+
label: `${b.title} volume`,
|
|
317
357
|
caption: "Volume",
|
|
318
|
-
height:
|
|
358
|
+
height: y,
|
|
319
359
|
xAxis: !0,
|
|
320
360
|
y: {
|
|
321
361
|
includeZero: !0,
|
|
@@ -326,39 +366,39 @@ function ie({ open: e, high: n, low: r, close: i, volume: a, display: o = "candl
|
|
|
326
366
|
series: [{
|
|
327
367
|
id: "volume",
|
|
328
368
|
label: "Volume",
|
|
329
|
-
accessor: (e) =>
|
|
369
|
+
accessor: (e) => J(e, a),
|
|
330
370
|
formatValue: S,
|
|
331
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)",
|
|
332
372
|
bar: { radius: 1 }
|
|
333
373
|
}],
|
|
334
|
-
children: /* @__PURE__ */
|
|
374
|
+
children: /* @__PURE__ */ L(p, { series: "volume" })
|
|
335
375
|
}) : void 0
|
|
336
376
|
});
|
|
337
377
|
}
|
|
338
378
|
//#endregion
|
|
339
379
|
//#region src/finance/indicators.ts
|
|
340
|
-
function
|
|
380
|
+
function X(e) {
|
|
341
381
|
return typeof e == "number" && Number.isFinite(e);
|
|
342
382
|
}
|
|
343
|
-
function
|
|
383
|
+
function se(e, t) {
|
|
344
384
|
if (!Number.isInteger(t) || t < 1) throw Error(`Lilt ${e} period must be a positive integer; received ${t}.`);
|
|
345
385
|
}
|
|
346
|
-
function
|
|
347
|
-
|
|
386
|
+
function ce(e, t) {
|
|
387
|
+
se("sma", t);
|
|
348
388
|
let n = [], r = 0, i = 0;
|
|
349
389
|
for (let a = 0; a < e.length; a += 1) {
|
|
350
390
|
let o = e[a];
|
|
351
|
-
|
|
391
|
+
X(o) && (r += o, i += 1);
|
|
352
392
|
let s = a - t >= 0 ? e[a - t] : void 0;
|
|
353
|
-
a - t >= 0 &&
|
|
393
|
+
a - t >= 0 && X(s) && (r -= s, --i), n.push(a >= t - 1 && i === t ? r / t : null);
|
|
354
394
|
}
|
|
355
395
|
return n;
|
|
356
396
|
}
|
|
357
|
-
function
|
|
358
|
-
|
|
397
|
+
function Z(e, t) {
|
|
398
|
+
se("ema", t);
|
|
359
399
|
let n = 2 / (t + 1), r = [], i = null, a = [];
|
|
360
400
|
for (let o of e) {
|
|
361
|
-
if (!
|
|
401
|
+
if (!X(o)) {
|
|
362
402
|
r.push(null);
|
|
363
403
|
continue;
|
|
364
404
|
}
|
|
@@ -370,11 +410,11 @@ function X(e, t) {
|
|
|
370
410
|
}
|
|
371
411
|
return r;
|
|
372
412
|
}
|
|
373
|
-
function
|
|
374
|
-
|
|
413
|
+
function le(e, t = 14) {
|
|
414
|
+
se("rsi", t);
|
|
375
415
|
let n = e.map(() => null), r = null, i = 0, a = 0, o = 0, s = 0, c = 0;
|
|
376
416
|
return e.forEach((e, l) => {
|
|
377
|
-
if (!
|
|
417
|
+
if (!X(e)) return;
|
|
378
418
|
if (r === null) {
|
|
379
419
|
r = e;
|
|
380
420
|
return;
|
|
@@ -389,12 +429,12 @@ function se(e, t = 14) {
|
|
|
389
429
|
n[l] = c === 0 ? s === 0 ? 50 : 100 : 100 - 100 / (1 + s / c);
|
|
390
430
|
}), n;
|
|
391
431
|
}
|
|
392
|
-
function
|
|
432
|
+
function ue(e, t = 12, n = 26, r = 9) {
|
|
393
433
|
if (t >= n) throw Error("Lilt macd needs a fast period shorter than the slow period.");
|
|
394
|
-
let i =
|
|
434
|
+
let i = Z(e, t), a = Z(e, n), o = e.map((e, t) => {
|
|
395
435
|
let n = i[t], r = a[t];
|
|
396
436
|
return n === null || r === null ? null : n - r;
|
|
397
|
-
}), s =
|
|
437
|
+
}), s = Z(o, r);
|
|
398
438
|
return {
|
|
399
439
|
macd: o,
|
|
400
440
|
signal: s,
|
|
@@ -404,8 +444,8 @@ function ce(e, t = 12, n = 26, r = 9) {
|
|
|
404
444
|
})
|
|
405
445
|
};
|
|
406
446
|
}
|
|
407
|
-
function
|
|
408
|
-
let r =
|
|
447
|
+
function de(e, t = 20, n = 2) {
|
|
448
|
+
let r = ce(e, t), i = [], a = [];
|
|
409
449
|
return r.forEach((r, o) => {
|
|
410
450
|
if (r === null) {
|
|
411
451
|
i.push(null), a.push(null);
|
|
@@ -421,19 +461,19 @@ function le(e, t = 20, n = 2) {
|
|
|
421
461
|
lower: a
|
|
422
462
|
};
|
|
423
463
|
}
|
|
424
|
-
function
|
|
464
|
+
function fe(e) {
|
|
425
465
|
let t = -Infinity;
|
|
426
|
-
return e.map((e) =>
|
|
466
|
+
return e.map((e) => X(e) ? (t = Math.max(t, e), t > 0 ? e / t - 1 : 0) : null);
|
|
427
467
|
}
|
|
428
|
-
function
|
|
429
|
-
let t = e.find(
|
|
430
|
-
return e.map((e) =>
|
|
468
|
+
function pe(e) {
|
|
469
|
+
let t = e.find(X);
|
|
470
|
+
return e.map((e) => X(e) && t !== void 0 && t !== 0 ? e / t - 1 : null);
|
|
431
471
|
}
|
|
432
|
-
function
|
|
433
|
-
for (let n of t) if (!
|
|
472
|
+
function me(e, t) {
|
|
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}.`);
|
|
434
474
|
}
|
|
435
|
-
function
|
|
436
|
-
|
|
475
|
+
function he(e, t) {
|
|
476
|
+
me("bids", e), me("asks", t);
|
|
437
477
|
let n = (e) => {
|
|
438
478
|
let t = /* @__PURE__ */ new Map();
|
|
439
479
|
for (let n of e) t.set(n.price, (t.get(n.price) ?? 0) + n.size);
|
|
@@ -468,7 +508,7 @@ function pe(e, t) {
|
|
|
468
508
|
}
|
|
469
509
|
//#endregion
|
|
470
510
|
//#region src/finance/cards/indicator-chart-card.tsx
|
|
471
|
-
function
|
|
511
|
+
function ge(e) {
|
|
472
512
|
return e.map((e, t) => {
|
|
473
513
|
let n = typeof e == "string" ? { kind: e } : e, r = "period" in n && n.period !== void 0 ? n.period : (n.kind, 20), i = "deviations" in n && n.deviations !== void 0 ? n.deviations : 2, a = n.kind === "bollinger" ? "BB" : n.kind.toUpperCase();
|
|
474
514
|
return {
|
|
@@ -480,7 +520,7 @@ function me(e) {
|
|
|
480
520
|
};
|
|
481
521
|
});
|
|
482
522
|
}
|
|
483
|
-
function
|
|
523
|
+
function _e(e) {
|
|
484
524
|
return e.map((e, t) => {
|
|
485
525
|
let n = typeof e == "string" ? { kind: e } : e;
|
|
486
526
|
return {
|
|
@@ -493,104 +533,104 @@ function he(e) {
|
|
|
493
533
|
};
|
|
494
534
|
});
|
|
495
535
|
}
|
|
496
|
-
function
|
|
536
|
+
function Q(e, t) {
|
|
497
537
|
if (!t) return null;
|
|
498
538
|
let n = e[t];
|
|
499
539
|
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
500
540
|
}
|
|
501
|
-
function
|
|
502
|
-
let i = e.map((e) =>
|
|
541
|
+
function ve(e, t, n, r) {
|
|
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);
|
|
503
543
|
for (let e of n) if (e.kind === "bollinger") {
|
|
504
|
-
let t =
|
|
544
|
+
let t = de(i, e.period, e.deviations);
|
|
505
545
|
o(e.id, t.middle), o(`${e.id}Upper`, t.upper), o(`${e.id}Lower`, t.lower);
|
|
506
|
-
} else o(e.id, (e.kind === "sma" ?
|
|
507
|
-
for (let e of r) if (e.kind === "rsi" && o(e.id,
|
|
508
|
-
let t =
|
|
546
|
+
} else o(e.id, (e.kind === "sma" ? ce : Z)(i, e.period));
|
|
547
|
+
for (let e of r) if (e.kind === "rsi" && o(e.id, le(i, e.period)), e.kind === "macd") {
|
|
548
|
+
let t = ue(i, e.fast, e.slow, e.signal);
|
|
509
549
|
o(`${e.id}Macd`, t.macd), o(`${e.id}Signal`, t.signal), o(`${e.id}Histogram`, t.histogram);
|
|
510
550
|
}
|
|
511
551
|
return a;
|
|
512
552
|
}
|
|
513
|
-
var
|
|
553
|
+
var ye = {
|
|
514
554
|
minimumFractionDigits: 2,
|
|
515
555
|
maximumFractionDigits: 2
|
|
516
|
-
},
|
|
556
|
+
}, be = [
|
|
517
557
|
"var(--lilt-series-4)",
|
|
518
558
|
"var(--lilt-series-3)",
|
|
519
559
|
"var(--lilt-series-5)"
|
|
520
560
|
];
|
|
521
|
-
function
|
|
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: f, ranges: m, delta: _, valueFormat: y = ye, locale: b = "en-US", paneHeight: S = 72, ...C }) {
|
|
522
562
|
let T = !!(t && n && r), E = a ?? (T ? "candle" : "line");
|
|
523
563
|
if (E !== "line" && !T) throw Error("Lilt IndicatorChartCard candles need open, high and low fields.");
|
|
524
|
-
let D = JSON.stringify(o), O = JSON.stringify(s), k =
|
|
564
|
+
let D = JSON.stringify(o), O = JSON.stringify(s), k = N(() => ge(o), [D]), A = N(() => _e(s), [O]);
|
|
525
565
|
if (A.some((e) => e.kind === "volume") && !i) throw Error("Lilt IndicatorChartCard needs a `volume` field for a volume pane.");
|
|
526
|
-
let
|
|
527
|
-
|
|
566
|
+
let j = N(() => f ? ve(f, e, k, A) : void 0, [
|
|
567
|
+
f,
|
|
528
568
|
e,
|
|
529
569
|
k,
|
|
530
570
|
A
|
|
531
|
-
]),
|
|
571
|
+
]), ee = N(() => m?.map((n) => ({
|
|
532
572
|
...n,
|
|
533
|
-
data:
|
|
534
|
-
delta: n.delta ?? (t ?
|
|
573
|
+
data: ve(n.data, e, k, A),
|
|
574
|
+
delta: n.delta ?? (t ? Y(n.data, t, e) : void 0)
|
|
535
575
|
})), [
|
|
536
576
|
m,
|
|
537
577
|
e,
|
|
538
578
|
t,
|
|
539
579
|
k,
|
|
540
580
|
A
|
|
541
|
-
]), M =
|
|
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 ? {
|
|
542
582
|
open: {
|
|
543
583
|
label: "Open",
|
|
544
|
-
accessor: (e) =>
|
|
584
|
+
accessor: (e) => Q(e, t)
|
|
545
585
|
},
|
|
546
586
|
high: {
|
|
547
587
|
label: "High",
|
|
548
|
-
accessor: (e) =>
|
|
588
|
+
accessor: (e) => Q(e, n)
|
|
549
589
|
},
|
|
550
590
|
low: {
|
|
551
591
|
label: "Low",
|
|
552
|
-
accessor: (e) =>
|
|
592
|
+
accessor: (e) => Q(e, r)
|
|
553
593
|
}
|
|
554
|
-
} : void 0,
|
|
555
|
-
let a = n.id ===
|
|
556
|
-
let r =
|
|
557
|
-
return /* @__PURE__ */
|
|
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);
|
|
597
|
+
return /* @__PURE__ */ R("span", {
|
|
558
598
|
className: "lilt-card__pane-value",
|
|
559
|
-
children: [n ? `${n} ` : "", r === null ? "—" :
|
|
599
|
+
children: [n ? `${n} ` : "", r === null ? "—" : P(r)]
|
|
560
600
|
}, t);
|
|
561
601
|
};
|
|
562
|
-
if (n.kind === "volume") return /* @__PURE__ */
|
|
602
|
+
if (n.kind === "volume") return /* @__PURE__ */ L(q, {
|
|
563
603
|
context: r,
|
|
564
|
-
label: `${
|
|
604
|
+
label: `${C.title} volume`,
|
|
565
605
|
caption: "Volume",
|
|
566
|
-
readout: (e) => /* @__PURE__ */
|
|
606
|
+
readout: (e) => /* @__PURE__ */ L("span", {
|
|
567
607
|
className: "lilt-card__pane-value",
|
|
568
|
-
children:
|
|
608
|
+
children: Q(e, i) === null ? "—" : F(Q(e, i))
|
|
569
609
|
}),
|
|
570
|
-
height:
|
|
610
|
+
height: S,
|
|
571
611
|
xAxis: a,
|
|
572
612
|
y: {
|
|
573
613
|
includeZero: !0,
|
|
574
614
|
ticks: 2,
|
|
575
|
-
format:
|
|
615
|
+
format: F
|
|
576
616
|
},
|
|
577
617
|
bars: { series: ["volume"] },
|
|
578
618
|
series: [{
|
|
579
619
|
id: "volume",
|
|
580
620
|
label: "Volume",
|
|
581
621
|
accessor: o(i),
|
|
582
|
-
formatValue:
|
|
583
|
-
colorAt: (n) => (
|
|
622
|
+
formatValue: F,
|
|
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)",
|
|
584
624
|
bar: { radius: 1 }
|
|
585
625
|
}],
|
|
586
|
-
children: /* @__PURE__ */
|
|
626
|
+
children: /* @__PURE__ */ L(p, { series: "volume" })
|
|
587
627
|
}, n.id);
|
|
588
|
-
if (n.kind === "rsi") return /* @__PURE__ */
|
|
628
|
+
if (n.kind === "rsi") return /* @__PURE__ */ R(q, {
|
|
589
629
|
context: r,
|
|
590
|
-
label: `${
|
|
630
|
+
label: `${C.title} RSI ${n.period}`,
|
|
591
631
|
caption: `RSI ${n.period}`,
|
|
592
632
|
readout: (e) => s(e, n.id),
|
|
593
|
-
height:
|
|
633
|
+
height: S,
|
|
594
634
|
xAxis: a,
|
|
595
635
|
y: {
|
|
596
636
|
domain: [0, 100],
|
|
@@ -602,51 +642,51 @@ function ye({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
602
642
|
label: `RSI ${n.period}`,
|
|
603
643
|
accessor: o(n.id),
|
|
604
644
|
color: "var(--lilt-series-1)",
|
|
605
|
-
formatValue:
|
|
645
|
+
formatValue: P,
|
|
606
646
|
line: {
|
|
607
647
|
width: 1.5,
|
|
608
|
-
depth:
|
|
648
|
+
depth: C.depth
|
|
609
649
|
}
|
|
610
650
|
}],
|
|
611
651
|
children: [
|
|
612
|
-
/* @__PURE__ */
|
|
652
|
+
/* @__PURE__ */ L(h, {
|
|
613
653
|
axis: "y",
|
|
614
654
|
from: 30,
|
|
615
655
|
to: 70,
|
|
616
656
|
color: "var(--lilt-series-1)"
|
|
617
657
|
}),
|
|
618
|
-
/* @__PURE__ */
|
|
658
|
+
/* @__PURE__ */ L(x, {
|
|
619
659
|
value: 70,
|
|
620
660
|
color: "var(--lilt-muted)"
|
|
621
661
|
}),
|
|
622
|
-
/* @__PURE__ */
|
|
662
|
+
/* @__PURE__ */ L(x, {
|
|
623
663
|
value: 30,
|
|
624
664
|
color: "var(--lilt-muted)"
|
|
625
665
|
}),
|
|
626
|
-
/* @__PURE__ */
|
|
666
|
+
/* @__PURE__ */ L(w, { series: n.id })
|
|
627
667
|
]
|
|
628
668
|
}, n.id);
|
|
629
|
-
let c = `${n.id}Macd`, l = `${n.id}Signal`,
|
|
630
|
-
return /* @__PURE__ */
|
|
669
|
+
let c = `${n.id}Macd`, l = `${n.id}Signal`, u = `${n.id}Histogram`;
|
|
670
|
+
return /* @__PURE__ */ R(q, {
|
|
631
671
|
context: r,
|
|
632
|
-
label: `${
|
|
672
|
+
label: `${C.title} MACD`,
|
|
633
673
|
caption: `MACD ${n.fast} · ${n.slow} · ${n.signal}`,
|
|
634
674
|
readout: (e) => [s(e, c), s(e, l, "Signal")],
|
|
635
|
-
height:
|
|
675
|
+
height: S,
|
|
636
676
|
xAxis: a,
|
|
637
677
|
y: {
|
|
638
678
|
includeZero: !0,
|
|
639
679
|
ticks: 2,
|
|
640
|
-
format:
|
|
680
|
+
format: P
|
|
641
681
|
},
|
|
642
|
-
bars: { series: [
|
|
682
|
+
bars: { series: [u] },
|
|
643
683
|
series: [
|
|
644
684
|
{
|
|
645
|
-
id:
|
|
685
|
+
id: u,
|
|
646
686
|
label: "Histogram",
|
|
647
|
-
accessor: o(
|
|
648
|
-
formatValue:
|
|
649
|
-
colorAt: (e) => (
|
|
687
|
+
accessor: o(u),
|
|
688
|
+
formatValue: P,
|
|
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)",
|
|
650
690
|
bar: { radius: 1 }
|
|
651
691
|
},
|
|
652
692
|
{
|
|
@@ -654,10 +694,10 @@ function ye({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
654
694
|
label: "MACD",
|
|
655
695
|
accessor: o(c),
|
|
656
696
|
color: "var(--lilt-series-4)",
|
|
657
|
-
formatValue:
|
|
697
|
+
formatValue: P,
|
|
658
698
|
line: {
|
|
659
699
|
width: 1.5,
|
|
660
|
-
depth:
|
|
700
|
+
depth: C.depth
|
|
661
701
|
}
|
|
662
702
|
},
|
|
663
703
|
{
|
|
@@ -665,7 +705,7 @@ function ye({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
665
705
|
label: "Signal",
|
|
666
706
|
accessor: o(l),
|
|
667
707
|
color: "var(--lilt-series-3)",
|
|
668
|
-
formatValue:
|
|
708
|
+
formatValue: P,
|
|
669
709
|
line: {
|
|
670
710
|
width: 1.5,
|
|
671
711
|
dasharray: "3 3"
|
|
@@ -673,104 +713,105 @@ function ye({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
|
|
|
673
713
|
}
|
|
674
714
|
],
|
|
675
715
|
children: [
|
|
676
|
-
/* @__PURE__ */
|
|
677
|
-
/* @__PURE__ */
|
|
678
|
-
/* @__PURE__ */
|
|
716
|
+
/* @__PURE__ */ L(p, { series: u }),
|
|
717
|
+
/* @__PURE__ */ L(w, { series: c }),
|
|
718
|
+
/* @__PURE__ */ L(w, { series: l })
|
|
679
719
|
]
|
|
680
720
|
}, n.id);
|
|
681
721
|
};
|
|
682
|
-
return /* @__PURE__ */
|
|
683
|
-
...
|
|
684
|
-
data:
|
|
685
|
-
ranges:
|
|
686
|
-
delta:
|
|
687
|
-
valueFormat:
|
|
688
|
-
locale:
|
|
722
|
+
return /* @__PURE__ */ L(v, {
|
|
723
|
+
...C,
|
|
724
|
+
data: j,
|
|
725
|
+
ranges: ee,
|
|
726
|
+
delta: _ ?? (f && t ? Y(f, t, e) : void 0),
|
|
727
|
+
valueFormat: y,
|
|
728
|
+
locale: b,
|
|
689
729
|
aggregate: "last",
|
|
690
730
|
headlineSeries: e,
|
|
691
731
|
pillSeries: e,
|
|
692
732
|
tiles: !1,
|
|
693
|
-
live:
|
|
733
|
+
live: d,
|
|
694
734
|
series: [{
|
|
695
735
|
key: e,
|
|
696
|
-
label:
|
|
697
|
-
color: E === "line" ?
|
|
736
|
+
label: l,
|
|
737
|
+
color: E === "line" ? G ? B : V : void 0
|
|
698
738
|
}, ...k.map((e, t) => ({
|
|
699
739
|
key: e.id,
|
|
700
740
|
label: e.label,
|
|
701
|
-
color:
|
|
741
|
+
color: be[t % be.length]
|
|
702
742
|
}))],
|
|
703
743
|
shape: {
|
|
704
744
|
kind: "marks",
|
|
705
|
-
id: `indicator:${E}:${
|
|
745
|
+
id: `indicator:${E}:${u}:${t}:${n}:${r}:${D}:${O}`,
|
|
706
746
|
includeZero: !1,
|
|
707
|
-
scale:
|
|
747
|
+
scale: u,
|
|
708
748
|
slots: !0,
|
|
709
749
|
xAxis: A.length === 0,
|
|
710
750
|
series: (e) => {
|
|
711
|
-
let t =
|
|
751
|
+
let t = H.get(e);
|
|
712
752
|
return t ? {
|
|
713
753
|
curve: "monotone",
|
|
714
754
|
line: {
|
|
715
755
|
width: 1.5,
|
|
716
756
|
showInspectionPoint: !1,
|
|
717
|
-
depth:
|
|
757
|
+
depth: C.depth
|
|
718
758
|
},
|
|
719
759
|
...t.kind === "bollinger" ? { fields: {
|
|
720
760
|
upper: {
|
|
721
761
|
label: "Upper",
|
|
722
|
-
accessor: (e) =>
|
|
762
|
+
accessor: (e) => Q(e, `${t.id}Upper`)
|
|
723
763
|
},
|
|
724
764
|
lower: {
|
|
725
765
|
label: "Lower",
|
|
726
|
-
accessor: (e) =>
|
|
766
|
+
accessor: (e) => Q(e, `${t.id}Lower`)
|
|
727
767
|
}
|
|
728
768
|
} } : {}
|
|
729
769
|
} : E === "line" ? {
|
|
730
|
-
fields:
|
|
770
|
+
fields: z,
|
|
731
771
|
curve: "linear",
|
|
732
772
|
line: {
|
|
733
773
|
width: 2,
|
|
734
|
-
depth:
|
|
774
|
+
depth: C.depth
|
|
735
775
|
}
|
|
736
|
-
} : { fields:
|
|
776
|
+
} : { fields: z };
|
|
737
777
|
},
|
|
738
|
-
describe: T ?
|
|
778
|
+
describe: T ? ie(M) : void 0,
|
|
739
779
|
draw: (e) => e.map((e) => {
|
|
740
|
-
let t =
|
|
741
|
-
return t ? t.kind === "bollinger" ? [/* @__PURE__ */
|
|
780
|
+
let t = H.get(e);
|
|
781
|
+
return t ? t.kind === "bollinger" ? [/* @__PURE__ */ L(c, {
|
|
742
782
|
series: e,
|
|
743
783
|
lower: "lower",
|
|
744
784
|
upper: "upper"
|
|
745
|
-
}, `band-${e}`), /* @__PURE__ */
|
|
785
|
+
}, `band-${e}`), /* @__PURE__ */ L(w, { series: e }, `line-${e}`)] : /* @__PURE__ */ L(w, { series: e }, e) : E === "line" ? /* @__PURE__ */ L(w, { series: e }, e) : /* @__PURE__ */ L(re, {
|
|
746
786
|
series: e,
|
|
747
787
|
open: "open",
|
|
748
788
|
high: "high",
|
|
749
789
|
low: "low",
|
|
750
|
-
display: E
|
|
790
|
+
display: E,
|
|
791
|
+
depth: C.depth
|
|
751
792
|
}, e);
|
|
752
793
|
})
|
|
753
794
|
},
|
|
754
|
-
panes: A.length ? (e) => /* @__PURE__ */
|
|
795
|
+
panes: A.length ? (e) => /* @__PURE__ */ L(I, { children: A.map((t) => te(t, e)) }) : void 0
|
|
755
796
|
});
|
|
756
797
|
}
|
|
757
798
|
//#endregion
|
|
758
799
|
//#region src/finance/cards/depth-chart-card.tsx
|
|
759
|
-
function
|
|
800
|
+
function Se({ price: e, label: t }) {
|
|
760
801
|
let { snapshot: n } = _();
|
|
761
802
|
if (e < n.xDomain[0] || e > n.xDomain[1]) return null;
|
|
762
803
|
let r = n.xToPixel(e);
|
|
763
|
-
return /* @__PURE__ */
|
|
804
|
+
return /* @__PURE__ */ R("g", {
|
|
764
805
|
className: "lilt-card__depth-mid",
|
|
765
806
|
"aria-hidden": "true",
|
|
766
|
-
children: [/* @__PURE__ */
|
|
807
|
+
children: [/* @__PURE__ */ L("line", {
|
|
767
808
|
x1: r,
|
|
768
809
|
x2: r,
|
|
769
810
|
y1: n.plot.top + 18,
|
|
770
811
|
y2: n.plot.bottom,
|
|
771
812
|
strokeDasharray: "2 4",
|
|
772
813
|
vectorEffect: "non-scaling-stroke"
|
|
773
|
-
}), /* @__PURE__ */
|
|
814
|
+
}), /* @__PURE__ */ L("text", {
|
|
774
815
|
x: r,
|
|
775
816
|
y: n.plot.top + 10,
|
|
776
817
|
textAnchor: "middle",
|
|
@@ -778,100 +819,101 @@ function be({ price: e, label: t }) {
|
|
|
778
819
|
})]
|
|
779
820
|
});
|
|
780
821
|
}
|
|
781
|
-
var
|
|
822
|
+
var Ce = {
|
|
782
823
|
style: "currency",
|
|
783
824
|
currency: "USD",
|
|
784
825
|
minimumFractionDigits: 2,
|
|
785
826
|
maximumFractionDigits: 2
|
|
786
827
|
};
|
|
787
|
-
function
|
|
788
|
-
let
|
|
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 }) {
|
|
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, {
|
|
789
830
|
style: "percent",
|
|
790
831
|
maximumFractionDigits: 3
|
|
791
|
-
}).full, [s]), [
|
|
832
|
+
}).full, [s]), [H, U] = F(null), W = N(() => [{
|
|
792
833
|
id: "bid",
|
|
793
834
|
label: "Bids",
|
|
794
835
|
accessor: (e) => e.bid,
|
|
795
|
-
color:
|
|
836
|
+
color: B,
|
|
796
837
|
curve: "step-before",
|
|
797
838
|
area: { treatment: "fade" },
|
|
798
839
|
line: {
|
|
799
840
|
width: 1.5,
|
|
800
|
-
depth:
|
|
841
|
+
depth: C
|
|
801
842
|
},
|
|
802
|
-
formatValue:
|
|
843
|
+
formatValue: I.full
|
|
803
844
|
}, {
|
|
804
845
|
id: "ask",
|
|
805
846
|
label: "Asks",
|
|
806
847
|
accessor: (e) => e.ask,
|
|
807
|
-
color:
|
|
848
|
+
color: V,
|
|
808
849
|
curve: "step-after",
|
|
809
850
|
area: { treatment: "fade" },
|
|
810
851
|
line: {
|
|
811
852
|
width: 1.5,
|
|
812
|
-
depth:
|
|
853
|
+
depth: C
|
|
813
854
|
},
|
|
814
|
-
formatValue:
|
|
815
|
-
}], [
|
|
816
|
-
return /* @__PURE__ */
|
|
855
|
+
formatValue: I.full
|
|
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;
|
|
857
|
+
return /* @__PURE__ */ R(ee, {
|
|
817
858
|
"aria-label": e,
|
|
818
|
-
surface:
|
|
819
|
-
numberStyle:
|
|
820
|
-
motion:
|
|
821
|
-
className: ["lilt-card--depth",
|
|
822
|
-
style:
|
|
859
|
+
surface: p,
|
|
860
|
+
numberStyle: m,
|
|
861
|
+
motion: v,
|
|
862
|
+
className: ["lilt-card--depth", b].filter(Boolean).join(" "),
|
|
863
|
+
style: x,
|
|
823
864
|
children: [
|
|
824
|
-
/* @__PURE__ */
|
|
825
|
-
value:
|
|
826
|
-
format:
|
|
827
|
-
loading:
|
|
828
|
-
motion:
|
|
829
|
-
children:
|
|
830
|
-
|
|
865
|
+
/* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(A, { children: e }), /* @__PURE__ */ L(k, {
|
|
866
|
+
value: E.mid,
|
|
867
|
+
format: P.full,
|
|
868
|
+
loading: h,
|
|
869
|
+
motion: v,
|
|
870
|
+
children: h ? null : H && K !== null ? /* @__PURE__ */ R(O, { children: [
|
|
871
|
+
I.full(K),
|
|
831
872
|
" ",
|
|
832
|
-
|
|
873
|
+
H.side === "bid" ? "bid" : "ask",
|
|
833
874
|
" depth at",
|
|
834
875
|
" ",
|
|
835
|
-
|
|
836
|
-
] }) : /* @__PURE__ */
|
|
876
|
+
P.full(H.price)
|
|
877
|
+
] }) : /* @__PURE__ */ L(O, { children: "Mid price" })
|
|
837
878
|
})] }),
|
|
838
|
-
/* @__PURE__ */
|
|
879
|
+
/* @__PURE__ */ R("dl", {
|
|
839
880
|
className: "lilt-card__stats",
|
|
840
881
|
children: [
|
|
841
|
-
/* @__PURE__ */
|
|
842
|
-
/* @__PURE__ */
|
|
882
|
+
/* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("dt", { children: "Spread" }), /* @__PURE__ */ L("dd", { children: h ? "—" : G })] }),
|
|
883
|
+
/* @__PURE__ */ R("div", {
|
|
843
884
|
"data-side": "bid",
|
|
844
|
-
children: [/* @__PURE__ */
|
|
885
|
+
children: [/* @__PURE__ */ L("dt", { children: "Bid depth" }), /* @__PURE__ */ L("dd", { children: h ? "—" : I.compact(E.bidDepth) })]
|
|
845
886
|
}),
|
|
846
|
-
/* @__PURE__ */
|
|
887
|
+
/* @__PURE__ */ R("div", {
|
|
847
888
|
"data-side": "ask",
|
|
848
|
-
children: [/* @__PURE__ */
|
|
889
|
+
children: [/* @__PURE__ */ L("dt", { children: "Ask depth" }), /* @__PURE__ */ L("dd", { children: h ? "—" : I.compact(E.askDepth) })]
|
|
849
890
|
})
|
|
850
891
|
]
|
|
851
892
|
}),
|
|
852
|
-
/* @__PURE__ */
|
|
893
|
+
/* @__PURE__ */ L(y, {
|
|
853
894
|
className: "lilt-card__chart",
|
|
854
895
|
"aria-label": `${e} depth by price`,
|
|
855
|
-
data:
|
|
896
|
+
data: E.levels,
|
|
856
897
|
x: {
|
|
857
898
|
type: "number",
|
|
858
899
|
accessor: (e) => e.price,
|
|
859
|
-
format:
|
|
900
|
+
format: P.full
|
|
860
901
|
},
|
|
861
902
|
y: {
|
|
862
903
|
includeZero: !0,
|
|
863
904
|
ticks: 3,
|
|
864
|
-
format:
|
|
905
|
+
format: I.compact
|
|
865
906
|
},
|
|
866
|
-
series:
|
|
867
|
-
onSelectionChange: (e) =>
|
|
868
|
-
motion:
|
|
869
|
-
status:
|
|
870
|
-
|
|
907
|
+
series: W,
|
|
908
|
+
onSelectionChange: (e) => U(e?.row ?? null),
|
|
909
|
+
motion: v,
|
|
910
|
+
status: h ? "loading" : "ready",
|
|
911
|
+
loadingStyle: _,
|
|
912
|
+
children: /* @__PURE__ */ R(a, {
|
|
871
913
|
height: c,
|
|
872
|
-
axis:
|
|
873
|
-
background:
|
|
874
|
-
pill:
|
|
914
|
+
axis: l,
|
|
915
|
+
background: u,
|
|
916
|
+
pill: f,
|
|
875
917
|
margins: {
|
|
876
918
|
top: 8,
|
|
877
919
|
right: 4,
|
|
@@ -879,17 +921,17 @@ function Se({ title: e, bids: r, asks: i, valueFormat: a = xe, sizeFormat: o, lo
|
|
|
879
921
|
left: 4
|
|
880
922
|
},
|
|
881
923
|
children: [
|
|
882
|
-
/* @__PURE__ */
|
|
883
|
-
/* @__PURE__ */
|
|
884
|
-
/* @__PURE__ */
|
|
885
|
-
/* @__PURE__ */
|
|
886
|
-
/* @__PURE__ */
|
|
887
|
-
|
|
888
|
-
price:
|
|
889
|
-
label: `Mid ${
|
|
924
|
+
/* @__PURE__ */ L(T, { pattern: "lines" }),
|
|
925
|
+
/* @__PURE__ */ L(r, { series: "bid" }),
|
|
926
|
+
/* @__PURE__ */ L(r, { series: "ask" }),
|
|
927
|
+
/* @__PURE__ */ L(w, { series: "bid" }),
|
|
928
|
+
/* @__PURE__ */ L(w, { series: "ask" }),
|
|
929
|
+
E.mid === null ? null : /* @__PURE__ */ L(Se, {
|
|
930
|
+
price: E.mid,
|
|
931
|
+
label: `Mid ${P.full(E.mid)}`
|
|
890
932
|
}),
|
|
891
|
-
/* @__PURE__ */
|
|
892
|
-
/* @__PURE__ */
|
|
933
|
+
/* @__PURE__ */ L(d, { labels: "fit" }),
|
|
934
|
+
/* @__PURE__ */ L(S, {})
|
|
893
935
|
]
|
|
894
936
|
})
|
|
895
937
|
})
|
|
@@ -898,206 +940,206 @@ function Se({ title: e, bids: r, asks: i, valueFormat: a = xe, sizeFormat: o, lo
|
|
|
898
940
|
}
|
|
899
941
|
//#endregion
|
|
900
942
|
//#region src/finance/cards/portfolio-chart-card.tsx
|
|
901
|
-
function
|
|
943
|
+
function $(e, t) {
|
|
902
944
|
if (!t) return null;
|
|
903
945
|
let n = e[t];
|
|
904
946
|
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
905
947
|
}
|
|
906
|
-
function
|
|
907
|
-
let r = e.at(-1), i =
|
|
948
|
+
function Te(e, t, n) {
|
|
949
|
+
let r = e.at(-1), i = $(r, t), a = $(r, n);
|
|
908
950
|
return i !== null && a ? i / a - 1 : void 0;
|
|
909
951
|
}
|
|
910
|
-
function
|
|
911
|
-
let
|
|
912
|
-
...
|
|
913
|
-
delta:
|
|
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 }) {
|
|
953
|
+
let d = o ?? s?.[0]?.data ?? [], f = N(() => s?.map((n) => ({
|
|
954
|
+
...n,
|
|
955
|
+
delta: n.delta ?? Te(n.data, e, t)
|
|
914
956
|
})), [
|
|
915
957
|
s,
|
|
916
958
|
e,
|
|
917
|
-
|
|
918
|
-
]),
|
|
959
|
+
t
|
|
960
|
+
]), p = N(() => g(l, {
|
|
919
961
|
style: "percent",
|
|
920
962
|
minimumFractionDigits: 1,
|
|
921
963
|
maximumFractionDigits: 1
|
|
922
|
-
}).full, [l]),
|
|
923
|
-
let t =
|
|
924
|
-
return
|
|
925
|
-
}, [
|
|
926
|
-
return /* @__PURE__ */
|
|
927
|
-
...
|
|
964
|
+
}).full, [l]), m = N(() => {
|
|
965
|
+
let t = fe(d.map((t) => $(t, e))).filter((e) => e !== null);
|
|
966
|
+
return z(t) ?? null;
|
|
967
|
+
}, [d, e]);
|
|
968
|
+
return /* @__PURE__ */ L(v, {
|
|
969
|
+
...u,
|
|
928
970
|
data: o,
|
|
929
|
-
ranges:
|
|
930
|
-
delta: c ?? (o ?
|
|
971
|
+
ranges: f,
|
|
972
|
+
delta: c ?? (o ? Te(o, e, t) : void 0),
|
|
931
973
|
locale: l,
|
|
932
974
|
aggregate: "last",
|
|
933
975
|
headlineSeries: e,
|
|
934
976
|
pillSeries: e,
|
|
935
977
|
tiles: !1,
|
|
936
|
-
restCaption:
|
|
978
|
+
restCaption: t ? () => "over basis" : void 0,
|
|
937
979
|
series: [{
|
|
938
980
|
key: e,
|
|
939
|
-
label:
|
|
940
|
-
}, ...
|
|
941
|
-
key:
|
|
981
|
+
label: n
|
|
982
|
+
}, ...t ? [{
|
|
983
|
+
key: t,
|
|
942
984
|
label: "Basis",
|
|
943
985
|
dashed: !0
|
|
944
986
|
}] : []],
|
|
945
987
|
shape: {
|
|
946
988
|
kind: "marks",
|
|
947
|
-
id: `portfolio:${e}:${
|
|
989
|
+
id: `portfolio:${e}:${t}:${i}:${u.depth}`,
|
|
948
990
|
includeZero: !1,
|
|
949
991
|
xAxis: !i,
|
|
950
|
-
series: (e) => e ===
|
|
992
|
+
series: (e) => e === t ? {
|
|
951
993
|
curve: "step-after",
|
|
952
994
|
color: "var(--lilt-muted)"
|
|
953
995
|
} : {
|
|
954
996
|
area: { treatment: "fade" },
|
|
955
997
|
curve: "monotone"
|
|
956
998
|
},
|
|
957
|
-
draw: (e) => e.map((e) => [/* @__PURE__ */
|
|
999
|
+
draw: (e) => e.map((e) => [/* @__PURE__ */ L(r, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, e)])
|
|
958
1000
|
},
|
|
959
|
-
panes: i ? (
|
|
960
|
-
let
|
|
961
|
-
return /* @__PURE__ */
|
|
962
|
-
context:
|
|
963
|
-
label: `${
|
|
1001
|
+
panes: i ? (t) => {
|
|
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, {
|
|
1004
|
+
context: t,
|
|
1005
|
+
label: `${u.title} drawdown`,
|
|
964
1006
|
caption: "Drawdown",
|
|
965
|
-
readout: (e) => /* @__PURE__ */
|
|
1007
|
+
readout: (e) => /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ L("span", {
|
|
966
1008
|
className: "lilt-card__pane-value",
|
|
967
|
-
children: i.get(e) == null ? "—" :
|
|
968
|
-
}),
|
|
1009
|
+
children: i.get(e) == null ? "—" : p(i.get(e))
|
|
1010
|
+
}), m === null ? null : /* @__PURE__ */ R("span", {
|
|
969
1011
|
className: "lilt-card__pane-value",
|
|
970
|
-
children: ["Max ", m
|
|
1012
|
+
children: ["Max ", p(m)]
|
|
971
1013
|
})] }),
|
|
972
1014
|
height: a,
|
|
973
1015
|
xAxis: !0,
|
|
974
1016
|
y: {
|
|
975
1017
|
includeZero: !0,
|
|
976
1018
|
ticks: 2,
|
|
977
|
-
format:
|
|
1019
|
+
format: p
|
|
978
1020
|
},
|
|
979
1021
|
series: [{
|
|
980
1022
|
id: "drawdown",
|
|
981
1023
|
label: "Drawdown",
|
|
982
1024
|
accessor: (e) => i.get(e) ?? null,
|
|
983
1025
|
color: "var(--lilt-candle-down)",
|
|
984
|
-
formatValue:
|
|
1026
|
+
formatValue: p,
|
|
985
1027
|
area: { treatment: "fade" },
|
|
986
1028
|
line: { width: 1.5 },
|
|
987
1029
|
curve: "monotone"
|
|
988
1030
|
}],
|
|
989
|
-
children: [/* @__PURE__ */
|
|
1031
|
+
children: [/* @__PURE__ */ L(r, { series: "drawdown" }), /* @__PURE__ */ L(w, { series: "drawdown" })]
|
|
990
1032
|
});
|
|
991
1033
|
} : void 0
|
|
992
1034
|
});
|
|
993
1035
|
}
|
|
994
1036
|
//#endregion
|
|
995
1037
|
//#region src/finance/cards/price-chart-card.tsx
|
|
996
|
-
function
|
|
1038
|
+
function De(e, t) {
|
|
997
1039
|
let n = e[t];
|
|
998
1040
|
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
999
1041
|
}
|
|
1000
|
-
function
|
|
1001
|
-
let n = e.map((e) =>
|
|
1042
|
+
function Oe(e, t) {
|
|
1043
|
+
let n = e.map((e) => De(e, t)).filter((e) => e !== null);
|
|
1002
1044
|
return n.length > 1 ? {
|
|
1003
1045
|
first: n[0],
|
|
1004
1046
|
last: n.at(-1)
|
|
1005
1047
|
} : null;
|
|
1006
1048
|
}
|
|
1007
|
-
function
|
|
1049
|
+
function ke(e, t) {
|
|
1008
1050
|
let n = e.map((e) => ({ ...e }));
|
|
1009
|
-
for (let r of t)
|
|
1051
|
+
for (let r of t) pe(e.map((e) => De(e, r))).forEach((e, t) => n[t][`__rebased${r}`] = e);
|
|
1010
1052
|
return n;
|
|
1011
1053
|
}
|
|
1012
|
-
var
|
|
1054
|
+
var Ae = {
|
|
1013
1055
|
style: "currency",
|
|
1014
1056
|
currency: "USD",
|
|
1015
1057
|
minimumFractionDigits: 2,
|
|
1016
1058
|
maximumFractionDigits: 2
|
|
1017
1059
|
};
|
|
1018
|
-
function
|
|
1019
|
-
let
|
|
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, [
|
|
1020
1062
|
s,
|
|
1021
|
-
|
|
1063
|
+
h,
|
|
1022
1064
|
_
|
|
1023
|
-
]),
|
|
1024
|
-
let n =
|
|
1065
|
+
]), b = N(() => c?.map((t) => {
|
|
1066
|
+
let n = Oe(t.data, e);
|
|
1025
1067
|
return {
|
|
1026
1068
|
...t,
|
|
1027
|
-
data:
|
|
1069
|
+
data: h ? ke(t.data, _) : t.data,
|
|
1028
1070
|
delta: t.delta ?? (n && n.first ? n.last / n.first - 1 : void 0)
|
|
1029
1071
|
};
|
|
1030
1072
|
}), [
|
|
1031
1073
|
c,
|
|
1032
|
-
|
|
1074
|
+
h,
|
|
1033
1075
|
_,
|
|
1034
1076
|
e
|
|
1035
|
-
]),
|
|
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, {
|
|
1036
1078
|
style: "percent",
|
|
1037
1079
|
minimumFractionDigits: 1,
|
|
1038
1080
|
maximumFractionDigits: 1
|
|
1039
|
-
}).full, [
|
|
1081
|
+
}).full, [d]), E = (e) => h ? `__rebased${e}` : e, D = /* @__PURE__ */ R("span", {
|
|
1040
1082
|
className: "lilt-card__ticker",
|
|
1041
1083
|
children: [
|
|
1042
|
-
i ? /* @__PURE__ */
|
|
1084
|
+
i ? /* @__PURE__ */ L("span", {
|
|
1043
1085
|
className: "lilt-card__ticker-icon",
|
|
1044
1086
|
children: i
|
|
1045
1087
|
}) : null,
|
|
1046
|
-
/* @__PURE__ */
|
|
1088
|
+
/* @__PURE__ */ L("span", {
|
|
1047
1089
|
className: "lilt-card__ticker-symbol",
|
|
1048
|
-
children:
|
|
1090
|
+
children: t ?? p
|
|
1049
1091
|
}),
|
|
1050
|
-
|
|
1092
|
+
n ? /* @__PURE__ */ L("span", {
|
|
1051
1093
|
className: "lilt-card__ticker-name",
|
|
1052
|
-
children:
|
|
1094
|
+
children: n
|
|
1053
1095
|
}) : null
|
|
1054
1096
|
]
|
|
1055
1097
|
});
|
|
1056
|
-
return /* @__PURE__ */
|
|
1057
|
-
...
|
|
1098
|
+
return /* @__PURE__ */ L(v, {
|
|
1099
|
+
...m,
|
|
1058
1100
|
title: p,
|
|
1059
1101
|
heading: D,
|
|
1060
|
-
data:
|
|
1061
|
-
ranges:
|
|
1062
|
-
delta:
|
|
1063
|
-
valueFormat:
|
|
1102
|
+
data: y,
|
|
1103
|
+
ranges: b,
|
|
1104
|
+
delta: h ? void 0 : l ?? (s && x && x.first ? x.last / x.first - 1 : void 0),
|
|
1105
|
+
valueFormat: h ? {
|
|
1064
1106
|
style: "percent",
|
|
1065
1107
|
maximumFractionDigits: 1
|
|
1066
|
-
} :
|
|
1067
|
-
formatValue:
|
|
1068
|
-
locale:
|
|
1108
|
+
} : u,
|
|
1109
|
+
formatValue: h ? (e) => f(T)(e) : void 0,
|
|
1110
|
+
locale: d,
|
|
1069
1111
|
aggregate: "last",
|
|
1070
1112
|
headlineSeries: E(e),
|
|
1071
|
-
pillSeries:
|
|
1072
|
-
tiles:
|
|
1073
|
-
restCaption:
|
|
1074
|
-
let n =
|
|
1075
|
-
return n ?
|
|
1113
|
+
pillSeries: h ? "nearest" : E(e),
|
|
1114
|
+
tiles: h,
|
|
1115
|
+
restCaption: h ? void 0 : (t) => {
|
|
1116
|
+
let n = Oe(t, e);
|
|
1117
|
+
return n ? f(C)(n.last - n.first) : null;
|
|
1076
1118
|
},
|
|
1077
1119
|
series: [{
|
|
1078
1120
|
key: E(e),
|
|
1079
|
-
label:
|
|
1080
|
-
color:
|
|
1121
|
+
label: t ?? p,
|
|
1122
|
+
color: h ? void 0 : S ? B : V
|
|
1081
1123
|
}, ...(o ?? []).map((e) => ({
|
|
1082
1124
|
...e,
|
|
1083
1125
|
key: E(e.key)
|
|
1084
1126
|
}))],
|
|
1085
1127
|
shape: {
|
|
1086
1128
|
kind: "marks",
|
|
1087
|
-
id: `price:${a}:${_.join()}:${
|
|
1088
|
-
includeZero:
|
|
1089
|
-
series: () => a === "area" && !
|
|
1129
|
+
id: `price:${a}:${_.join()}:${h}`,
|
|
1130
|
+
includeZero: h,
|
|
1131
|
+
series: () => a === "area" && !h ? {
|
|
1090
1132
|
area: { treatment: "fade" },
|
|
1091
1133
|
curve: "monotone"
|
|
1092
1134
|
} : { curve: "monotone" },
|
|
1093
|
-
draw: (e) => e.map((e) => a === "area" && !
|
|
1135
|
+
draw: (e) => e.map((e) => a === "area" && !h ? [/* @__PURE__ */ L(r, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, e)] : /* @__PURE__ */ L(w, { series: e }, e))
|
|
1094
1136
|
},
|
|
1095
|
-
bleed:
|
|
1137
|
+
bleed: m.bleed ?? !0
|
|
1096
1138
|
});
|
|
1097
1139
|
}
|
|
1098
1140
|
//#endregion
|
|
1099
1141
|
//#region src/finance/order-book.tsx
|
|
1100
|
-
function
|
|
1142
|
+
function Me(e, t, n) {
|
|
1101
1143
|
let r = /* @__PURE__ */ new Map();
|
|
1102
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);
|
|
1103
1145
|
let i = [...r].map(([e, t]) => ({
|
|
@@ -1110,9 +1152,9 @@ function ke(e, t, n) {
|
|
|
1110
1152
|
side: t
|
|
1111
1153
|
}));
|
|
1112
1154
|
}
|
|
1113
|
-
function
|
|
1114
|
-
let n =
|
|
1115
|
-
return
|
|
1155
|
+
function Ne(e, t) {
|
|
1156
|
+
let n = P(null), [r, i] = F(/* @__PURE__ */ new Set());
|
|
1157
|
+
return M(() => {
|
|
1116
1158
|
let r = new Map(e.map((e) => [`${e.side}:${e.price}`, e.size])), a = n.current;
|
|
1117
1159
|
if (n.current = r, !t || !a) return;
|
|
1118
1160
|
let o = new Set([...r].filter(([e, t]) => a.get(e) !== t).map(([e]) => e));
|
|
@@ -1122,82 +1164,103 @@ function Ae(e, t) {
|
|
|
1122
1164
|
return () => window.clearTimeout(s);
|
|
1123
1165
|
}, [e, t]), r;
|
|
1124
1166
|
}
|
|
1125
|
-
function
|
|
1167
|
+
function Pe({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFormat: o = {
|
|
1126
1168
|
minimumFractionDigits: 2,
|
|
1127
1169
|
maximumFractionDigits: 2
|
|
1128
|
-
}, sizeFormat:
|
|
1129
|
-
let
|
|
1170
|
+
}, sizeFormat: s, locale: c = "en-US", flash: l = !0, surface: u, loading: d = !1, loadingStyle: f = "shimmer", motion: p, className: m, style: h }) {
|
|
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, {
|
|
1130
1172
|
style: "percent",
|
|
1131
1173
|
maximumFractionDigits: 3
|
|
1132
|
-
}).full, [
|
|
1133
|
-
value:
|
|
1134
|
-
mid: (
|
|
1135
|
-
} : null,
|
|
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 ? {
|
|
1175
|
+
value: j - A,
|
|
1176
|
+
mid: (j + A) / 2
|
|
1177
|
+
} : null, P = (e) => /* @__PURE__ */ R("tr", {
|
|
1136
1178
|
className: "lilt-order-book__level",
|
|
1137
1179
|
"data-side": e.side,
|
|
1138
|
-
"data-flash":
|
|
1139
|
-
style: { "--lilt-depth": `${e.total /
|
|
1180
|
+
"data-flash": O.has(`${e.side}:${e.price}`) || void 0,
|
|
1181
|
+
style: { "--lilt-depth": `${e.total / k * 100}%` },
|
|
1140
1182
|
children: [
|
|
1141
|
-
/* @__PURE__ */
|
|
1183
|
+
/* @__PURE__ */ R("th", {
|
|
1142
1184
|
scope: "row",
|
|
1143
|
-
children: [
|
|
1185
|
+
children: [a ? /* @__PURE__ */ L("span", {
|
|
1144
1186
|
className: "lilt-order-book__bar",
|
|
1145
1187
|
"aria-hidden": "true"
|
|
1146
|
-
}) : null,
|
|
1188
|
+
}) : null, S(e.price)]
|
|
1147
1189
|
}),
|
|
1148
|
-
/* @__PURE__ */
|
|
1149
|
-
/* @__PURE__ */
|
|
1190
|
+
/* @__PURE__ */ L("td", { children: C(e.size) }),
|
|
1191
|
+
/* @__PURE__ */ L("td", { children: C(e.total) })
|
|
1192
|
+
]
|
|
1193
|
+
}, `${e.side}:${e.price}`), F = (e) => Array.from({ length: Math.max(1, Math.min(50, i)) }, (t, n) => /* @__PURE__ */ R("tr", {
|
|
1194
|
+
className: "lilt-order-book__placeholder",
|
|
1195
|
+
"aria-hidden": "true",
|
|
1196
|
+
children: [
|
|
1197
|
+
/* @__PURE__ */ L("td", { children: /* @__PURE__ */ L(b, {
|
|
1198
|
+
width: `${86 - n * 4}%`,
|
|
1199
|
+
step: n
|
|
1200
|
+
}) }),
|
|
1201
|
+
/* @__PURE__ */ L("td", { children: /* @__PURE__ */ L(b, {
|
|
1202
|
+
width: "60%",
|
|
1203
|
+
step: n
|
|
1204
|
+
}) }),
|
|
1205
|
+
/* @__PURE__ */ L("td", { children: /* @__PURE__ */ L(b, {
|
|
1206
|
+
width: "72%",
|
|
1207
|
+
step: n
|
|
1208
|
+
}) })
|
|
1150
1209
|
]
|
|
1151
|
-
}, `${e
|
|
1152
|
-
return /* @__PURE__ */
|
|
1210
|
+
}, `${e}-${n}`));
|
|
1211
|
+
return /* @__PURE__ */ L(ee, {
|
|
1153
1212
|
"aria-label": e,
|
|
1154
|
-
surface:
|
|
1155
|
-
motion:
|
|
1156
|
-
className: ["lilt-card--order-book",
|
|
1157
|
-
style:
|
|
1158
|
-
children: /* @__PURE__ */
|
|
1159
|
-
|
|
1160
|
-
"
|
|
1213
|
+
surface: u,
|
|
1214
|
+
motion: p,
|
|
1215
|
+
className: ["lilt-card--order-book", m].filter(Boolean).join(" "),
|
|
1216
|
+
style: h,
|
|
1217
|
+
children: /* @__PURE__ */ R("table", {
|
|
1218
|
+
ref: v,
|
|
1219
|
+
className: d ? "lilt-order-book lilt-skeleton" : "lilt-order-book",
|
|
1220
|
+
"data-depth": a || void 0,
|
|
1221
|
+
"data-style": d ? f : void 0,
|
|
1222
|
+
"data-reduced-motion": _ || void 0,
|
|
1223
|
+
"aria-busy": d,
|
|
1161
1224
|
children: [
|
|
1162
|
-
/* @__PURE__ */
|
|
1163
|
-
/* @__PURE__ */
|
|
1164
|
-
/* @__PURE__ */
|
|
1225
|
+
/* @__PURE__ */ L("caption", { children: e }),
|
|
1226
|
+
/* @__PURE__ */ L("thead", { children: /* @__PURE__ */ R("tr", { children: [
|
|
1227
|
+
/* @__PURE__ */ L("th", {
|
|
1165
1228
|
scope: "col",
|
|
1166
1229
|
children: "Price"
|
|
1167
1230
|
}),
|
|
1168
|
-
/* @__PURE__ */
|
|
1231
|
+
/* @__PURE__ */ L("th", {
|
|
1169
1232
|
scope: "col",
|
|
1170
1233
|
children: "Size"
|
|
1171
1234
|
}),
|
|
1172
|
-
/* @__PURE__ */
|
|
1235
|
+
/* @__PURE__ */ L("th", {
|
|
1173
1236
|
scope: "col",
|
|
1174
1237
|
children: "Total"
|
|
1175
1238
|
})
|
|
1176
1239
|
] }) }),
|
|
1177
|
-
/* @__PURE__ */
|
|
1240
|
+
/* @__PURE__ */ L("tbody", {
|
|
1178
1241
|
"aria-label": "Asks",
|
|
1179
|
-
children: [...
|
|
1242
|
+
children: d ? F("ask") : [...E].reverse().map(P)
|
|
1180
1243
|
}),
|
|
1181
|
-
/* @__PURE__ */
|
|
1244
|
+
/* @__PURE__ */ L("tbody", {
|
|
1182
1245
|
"aria-label": "Spread",
|
|
1183
|
-
children: /* @__PURE__ */
|
|
1246
|
+
children: /* @__PURE__ */ R("tr", {
|
|
1184
1247
|
className: "lilt-order-book__spread",
|
|
1185
|
-
children: [/* @__PURE__ */
|
|
1248
|
+
children: [/* @__PURE__ */ L("th", {
|
|
1186
1249
|
scope: "row",
|
|
1187
|
-
children:
|
|
1188
|
-
}), /* @__PURE__ */
|
|
1250
|
+
children: d ? "—" : M ? S(M.mid) : "—"
|
|
1251
|
+
}), /* @__PURE__ */ L("td", {
|
|
1189
1252
|
colSpan: 2,
|
|
1190
|
-
children:
|
|
1253
|
+
children: d ? "Loading order book" : M ? `Spread ${S(M.value)} · ${w(M.value / M.mid)}` : "No spread"
|
|
1191
1254
|
})]
|
|
1192
1255
|
})
|
|
1193
1256
|
}),
|
|
1194
|
-
/* @__PURE__ */
|
|
1257
|
+
/* @__PURE__ */ L("tbody", {
|
|
1195
1258
|
"aria-label": "Bids",
|
|
1196
|
-
children:
|
|
1259
|
+
children: d ? F("bid") : T.map(P)
|
|
1197
1260
|
})
|
|
1198
1261
|
]
|
|
1199
1262
|
})
|
|
1200
1263
|
});
|
|
1201
1264
|
}
|
|
1202
1265
|
//#endregion
|
|
1203
|
-
export {
|
|
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 };
|