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