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