kline-charts-react 0.0.2 → 0.0.4
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/README.md +63 -6
- package/dist/SubPaneTitle-B2y5WQqq.js +2019 -0
- package/dist/SubPaneTitle-BAu9MdQQ.cjs +1 -0
- package/dist/hooks/useEcharts.d.ts +1 -1
- package/dist/hooks/useKlineData.d.ts +2 -2
- package/dist/index.cjs +7 -7
- package/dist/index.d.ts +1 -3
- package/dist/index.js +462 -2231
- package/dist/kline-charts-react.css +1 -1
- package/dist/types/props.d.ts +28 -23
- package/dist/unstable.cjs +1 -0
- package/dist/unstable.d.ts +2 -0
- package/dist/unstable.js +53 -0
- package/dist/utils/controllable.d.ts +7 -0
- package/dist/utils/formatters.d.ts +4 -21
- package/dist/utils/indicatorMeta.d.ts +7 -0
- package/dist/utils/marketSessions.d.ts +2 -0
- package/package.json +27 -8
- package/dist/index.umd.js +0 -7
|
@@ -0,0 +1,2019 @@
|
|
|
1
|
+
var Me = Object.defineProperty;
|
|
2
|
+
var ke = (e, n, t) => n in e ? Me(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
|
|
3
|
+
var oe = (e, n, t) => ke(e, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { useState as U, useRef as z, useEffect as fe, useCallback as D, useMemo as pe } from "react";
|
|
5
|
+
import { StockSDK as De } from "stock-sdk";
|
|
6
|
+
import * as Ie from "echarts/core";
|
|
7
|
+
import { CandlestickChart as _e, LineChart as Ne, BarChart as je, ScatterChart as Le } from "echarts/charts";
|
|
8
|
+
import { TitleComponent as Re, TooltipComponent as Te, GridComponent as Pe, DataZoomComponent as Be, LegendComponent as Ke, AxisPointerComponent as Oe } from "echarts/components";
|
|
9
|
+
import { CanvasRenderer as ze } from "echarts/renderers";
|
|
10
|
+
import { jsxs as M, jsx as w, Fragment as Ae } from "react/jsx-runtime";
|
|
11
|
+
function G(e, n) {
|
|
12
|
+
const t = [];
|
|
13
|
+
let i = 0, u = 0;
|
|
14
|
+
for (let r = 0; r < e.length; r++) {
|
|
15
|
+
const c = e[r];
|
|
16
|
+
if (c != null && (i += c, u++), r >= n) {
|
|
17
|
+
const o = e[r - n];
|
|
18
|
+
o != null && (i -= o, u--);
|
|
19
|
+
}
|
|
20
|
+
r >= n - 1 && u === n ? t.push(i / n) : t.push(null);
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
}
|
|
24
|
+
function E(e, n) {
|
|
25
|
+
const t = [], i = 2 / (n + 1);
|
|
26
|
+
let u = null;
|
|
27
|
+
for (let r = 0; r < e.length; r++) {
|
|
28
|
+
const c = e[r];
|
|
29
|
+
if (c == null) {
|
|
30
|
+
t.push(u);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
u === null ? u = c : u = c * i + u * (1 - i), t.push(u);
|
|
34
|
+
}
|
|
35
|
+
return t;
|
|
36
|
+
}
|
|
37
|
+
function Ee(e, n) {
|
|
38
|
+
const t = [], i = Array.from({ length: n }, (r, c) => c + 1), u = i.reduce((r, c) => r + c, 0);
|
|
39
|
+
for (let r = 0; r < e.length; r++) {
|
|
40
|
+
if (r < n - 1) {
|
|
41
|
+
t.push(null);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
let c = 0, o = 0;
|
|
45
|
+
for (let l = 0; l < n; l++) {
|
|
46
|
+
const s = e[r - n + 1 + l], a = i[l];
|
|
47
|
+
s != null && a !== void 0 && (c += s * a, o++);
|
|
48
|
+
}
|
|
49
|
+
o === n ? t.push(c / u) : t.push(null);
|
|
50
|
+
}
|
|
51
|
+
return t;
|
|
52
|
+
}
|
|
53
|
+
function Ve(e, n = {}) {
|
|
54
|
+
const { periods: t = [5, 10, 20, 30, 60], type: i = "sma" } = n, u = {};
|
|
55
|
+
for (const c of t) {
|
|
56
|
+
const o = `ma${c}`;
|
|
57
|
+
switch (i) {
|
|
58
|
+
case "ema":
|
|
59
|
+
u[o] = E(e, c);
|
|
60
|
+
break;
|
|
61
|
+
case "wma":
|
|
62
|
+
u[o] = Ee(e, c);
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
u[o] = G(e, c);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const r = [];
|
|
69
|
+
for (let c = 0; c < e.length; c++) {
|
|
70
|
+
const o = {};
|
|
71
|
+
for (const l of Object.keys(u)) {
|
|
72
|
+
const s = u[l];
|
|
73
|
+
o[l] = s !== void 0 ? s[c] ?? null : null;
|
|
74
|
+
}
|
|
75
|
+
r.push(o);
|
|
76
|
+
}
|
|
77
|
+
return r;
|
|
78
|
+
}
|
|
79
|
+
function Fe(e, n = {}) {
|
|
80
|
+
const { short: t = 12, long: i = 26, signal: u = 9 } = n, r = E(e, t), c = E(e, i), o = [];
|
|
81
|
+
for (let a = 0; a < e.length; a++) {
|
|
82
|
+
const d = r[a], f = c[a];
|
|
83
|
+
d != null && f !== null && f !== void 0 ? o.push(d - f) : o.push(null);
|
|
84
|
+
}
|
|
85
|
+
const l = E(o, u), s = [];
|
|
86
|
+
for (let a = 0; a < e.length; a++) {
|
|
87
|
+
const d = o[a] ?? null, f = l[a] ?? null;
|
|
88
|
+
s.push({
|
|
89
|
+
dif: d,
|
|
90
|
+
dea: f,
|
|
91
|
+
macd: d !== null && f !== null ? (d - f) * 2 : null
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return s;
|
|
95
|
+
}
|
|
96
|
+
function He(e, n = {}) {
|
|
97
|
+
const { period: t = 20, stdDev: i = 2 } = n, u = G(e, t), r = [];
|
|
98
|
+
for (let c = 0; c < e.length; c++) {
|
|
99
|
+
const o = u[c];
|
|
100
|
+
if (o == null || c < t - 1) {
|
|
101
|
+
r.push({ mid: null, upper: null, lower: null, bandwidth: null });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
let l = 0, s = 0;
|
|
105
|
+
for (let a = c - t + 1; a <= c; a++) {
|
|
106
|
+
const d = e[a];
|
|
107
|
+
d != null && (l += Math.pow(d - o, 2), s++);
|
|
108
|
+
}
|
|
109
|
+
if (s === t) {
|
|
110
|
+
const a = Math.sqrt(l / t), d = o + i * a, f = o - i * a;
|
|
111
|
+
r.push({
|
|
112
|
+
mid: o,
|
|
113
|
+
upper: d,
|
|
114
|
+
lower: f,
|
|
115
|
+
bandwidth: o !== 0 ? (d - f) / o * 100 : null
|
|
116
|
+
});
|
|
117
|
+
} else
|
|
118
|
+
r.push({ mid: o, upper: null, lower: null, bandwidth: null });
|
|
119
|
+
}
|
|
120
|
+
return r;
|
|
121
|
+
}
|
|
122
|
+
function Ue(e, n = {}) {
|
|
123
|
+
const { period: t = 9, kPeriod: i = 3, dPeriod: u = 3 } = n, r = [];
|
|
124
|
+
let c = 50, o = 50;
|
|
125
|
+
for (let l = 0; l < e.length; l++) {
|
|
126
|
+
if (l < t - 1) {
|
|
127
|
+
r.push({ k: null, d: null, j: null });
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
let s = -1 / 0, a = 1 / 0;
|
|
131
|
+
for (let I = l - t + 1; I <= l; I++) {
|
|
132
|
+
const b = e[I];
|
|
133
|
+
b !== void 0 && b.high !== null && b.high !== void 0 && (s = Math.max(s, b.high)), b !== void 0 && b.low !== null && b.low !== void 0 && (a = Math.min(a, b.low));
|
|
134
|
+
}
|
|
135
|
+
const d = e[l], f = d !== void 0 ? d.close : null;
|
|
136
|
+
if (f == null || s === -1 / 0 || a === 1 / 0) {
|
|
137
|
+
r.push({ k: null, d: null, j: null });
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const g = s === a ? 50 : (f - a) / (s - a) * 100, x = (c * (i - 1) + g) / i, y = (o * (u - 1) + x) / u, h = 3 * x - 2 * y;
|
|
141
|
+
r.push({ k: x, d: y, j: h }), c = x, o = y;
|
|
142
|
+
}
|
|
143
|
+
return r;
|
|
144
|
+
}
|
|
145
|
+
function qe(e, n = {}) {
|
|
146
|
+
const { periods: t = [6, 12, 24] } = n, i = {};
|
|
147
|
+
for (const r of t) {
|
|
148
|
+
const c = `rsi${r}`, o = [];
|
|
149
|
+
let l = 0, s = 0;
|
|
150
|
+
for (let a = 0; a < e.length; a++) {
|
|
151
|
+
const d = e[a], f = e[a - 1];
|
|
152
|
+
if (a === 0 || d === null || d === void 0 || f === null || f === void 0) {
|
|
153
|
+
o.push(null);
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const g = d - f, x = g > 0 ? g : 0, y = g < 0 ? -g : 0;
|
|
157
|
+
if (a < r)
|
|
158
|
+
l += x, s += y, o.push(null);
|
|
159
|
+
else if (a === r) {
|
|
160
|
+
l = (l + x) / r, s = (s + y) / r;
|
|
161
|
+
const h = s === 0 ? 100 : l / s;
|
|
162
|
+
o.push(100 - 100 / (1 + h));
|
|
163
|
+
} else {
|
|
164
|
+
l = (l * (r - 1) + x) / r, s = (s * (r - 1) + y) / r;
|
|
165
|
+
const h = s === 0 ? 100 : l / s;
|
|
166
|
+
o.push(100 - 100 / (1 + h));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
i[c] = o;
|
|
170
|
+
}
|
|
171
|
+
const u = [];
|
|
172
|
+
for (let r = 0; r < e.length; r++) {
|
|
173
|
+
const c = {};
|
|
174
|
+
for (const o of Object.keys(i)) {
|
|
175
|
+
const l = i[o];
|
|
176
|
+
c[o] = l !== void 0 ? l[r] ?? null : null;
|
|
177
|
+
}
|
|
178
|
+
u.push(c);
|
|
179
|
+
}
|
|
180
|
+
return u;
|
|
181
|
+
}
|
|
182
|
+
function Ye(e, n = {}) {
|
|
183
|
+
const { periods: t = [6, 10] } = n, i = {};
|
|
184
|
+
for (const r of t) {
|
|
185
|
+
const c = `wr${r}`, o = [];
|
|
186
|
+
for (let l = 0; l < e.length; l++) {
|
|
187
|
+
if (l < r - 1) {
|
|
188
|
+
o.push(null);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
let s = -1 / 0, a = 1 / 0;
|
|
192
|
+
for (let g = l - r + 1; g <= l; g++) {
|
|
193
|
+
const x = e[g];
|
|
194
|
+
x !== void 0 && x.high !== null && x.high !== void 0 && (s = Math.max(s, x.high)), x !== void 0 && x.low !== null && x.low !== void 0 && (a = Math.min(a, x.low));
|
|
195
|
+
}
|
|
196
|
+
const d = e[l], f = d !== void 0 ? d.close : null;
|
|
197
|
+
f == null || s === a ? o.push(null) : o.push((s - f) / (s - a) * -100);
|
|
198
|
+
}
|
|
199
|
+
i[c] = o;
|
|
200
|
+
}
|
|
201
|
+
const u = [];
|
|
202
|
+
for (let r = 0; r < e.length; r++) {
|
|
203
|
+
const c = {};
|
|
204
|
+
for (const o of Object.keys(i)) {
|
|
205
|
+
const l = i[o];
|
|
206
|
+
c[o] = l !== void 0 ? l[r] ?? null : null;
|
|
207
|
+
}
|
|
208
|
+
u.push(c);
|
|
209
|
+
}
|
|
210
|
+
return u;
|
|
211
|
+
}
|
|
212
|
+
function We(e, n = {}) {
|
|
213
|
+
const { periods: t = [6, 12, 24] } = n, i = {};
|
|
214
|
+
for (const r of t) {
|
|
215
|
+
const c = `bias${r}`, o = G(e, r), l = [];
|
|
216
|
+
for (let s = 0; s < e.length; s++) {
|
|
217
|
+
const a = e[s], d = o[s];
|
|
218
|
+
a == null || d === null || d === void 0 || d === 0 ? l.push(null) : l.push((a - d) / d * 100);
|
|
219
|
+
}
|
|
220
|
+
i[c] = l;
|
|
221
|
+
}
|
|
222
|
+
const u = [];
|
|
223
|
+
for (let r = 0; r < e.length; r++) {
|
|
224
|
+
const c = {};
|
|
225
|
+
for (const o of Object.keys(i)) {
|
|
226
|
+
const l = i[o];
|
|
227
|
+
c[o] = l !== void 0 ? l[r] ?? null : null;
|
|
228
|
+
}
|
|
229
|
+
u.push(c);
|
|
230
|
+
}
|
|
231
|
+
return u;
|
|
232
|
+
}
|
|
233
|
+
function Ge(e, n = {}) {
|
|
234
|
+
const { period: t = 14 } = n, i = e.map((c) => c.high === null || c.low === null || c.close === null ? null : (c.high + c.low + c.close) / 3), u = G(i, t), r = [];
|
|
235
|
+
for (let c = 0; c < e.length; c++) {
|
|
236
|
+
const o = i[c], l = u[c];
|
|
237
|
+
if (c < t - 1 || o === null || o === void 0 || l === null || l === void 0) {
|
|
238
|
+
r.push({ cci: null });
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
let s = 0, a = 0;
|
|
242
|
+
for (let f = c - t + 1; f <= c; f++) {
|
|
243
|
+
const g = i[f];
|
|
244
|
+
g != null && (s += Math.abs(g - l), a++);
|
|
245
|
+
}
|
|
246
|
+
const d = a > 0 ? s / a : 0;
|
|
247
|
+
d === 0 ? r.push({ cci: 0 }) : r.push({ cci: (o - l) / (0.015 * d) });
|
|
248
|
+
}
|
|
249
|
+
return r;
|
|
250
|
+
}
|
|
251
|
+
function Ce(e, n = {}) {
|
|
252
|
+
const { period: t = 14 } = n, i = [], u = [];
|
|
253
|
+
for (let r = 0; r < e.length; r++) {
|
|
254
|
+
const c = e[r];
|
|
255
|
+
if (c === void 0 || c.high === null || c.low === null || c.close === null) {
|
|
256
|
+
u.push(null), i.push({ tr: null, atr: null });
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
let o;
|
|
260
|
+
if (r === 0)
|
|
261
|
+
o = c.high - c.low;
|
|
262
|
+
else {
|
|
263
|
+
const l = e[r - 1], s = l !== void 0 ? l.close : null;
|
|
264
|
+
s == null ? o = c.high - c.low : o = Math.max(
|
|
265
|
+
c.high - c.low,
|
|
266
|
+
Math.abs(c.high - s),
|
|
267
|
+
Math.abs(c.low - s)
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
if (u.push(o), r < t - 1)
|
|
271
|
+
i.push({ tr: o, atr: null });
|
|
272
|
+
else if (r === t - 1) {
|
|
273
|
+
let l = 0;
|
|
274
|
+
for (let s = 0; s < t; s++)
|
|
275
|
+
l += u[s] ?? 0;
|
|
276
|
+
i.push({ tr: o, atr: l / t });
|
|
277
|
+
} else {
|
|
278
|
+
const l = i[r - 1], s = l !== void 0 ? l.atr : null;
|
|
279
|
+
s == null ? i.push({ tr: o, atr: null }) : i.push({ tr: o, atr: (s * (t - 1) + o) / t });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return i;
|
|
283
|
+
}
|
|
284
|
+
function Je(e, n = {}) {
|
|
285
|
+
const { maPeriod: t = 30 } = n, i = [];
|
|
286
|
+
let u = 0;
|
|
287
|
+
for (let o = 0; o < e.length; o++) {
|
|
288
|
+
const l = e[o];
|
|
289
|
+
if (l === void 0 || l.close === null || l.volume === null || l.volume === void 0) {
|
|
290
|
+
i.push({ obv: null, obvMa: null });
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (o === 0)
|
|
294
|
+
u = l.volume;
|
|
295
|
+
else {
|
|
296
|
+
const s = e[o - 1], a = s !== void 0 ? s.close : null;
|
|
297
|
+
a == null ? u = l.volume : l.close > a ? u += l.volume : l.close < a && (u -= l.volume);
|
|
298
|
+
}
|
|
299
|
+
i.push({ obv: u, obvMa: null });
|
|
300
|
+
}
|
|
301
|
+
const r = i.map((o) => o.obv), c = G(r, t);
|
|
302
|
+
for (let o = 0; o < i.length; o++) {
|
|
303
|
+
const l = i[o];
|
|
304
|
+
l !== void 0 && (l.obvMa = c[o] ?? null);
|
|
305
|
+
}
|
|
306
|
+
return i;
|
|
307
|
+
}
|
|
308
|
+
function Ze(e, n = {}) {
|
|
309
|
+
const { period: t = 12, signalPeriod: i = 6 } = n, u = [];
|
|
310
|
+
for (let o = 0; o < e.length; o++) {
|
|
311
|
+
const l = e[o], s = e[o - t];
|
|
312
|
+
o < t || l === null || l === void 0 || s === null || s === void 0 || s === 0 ? u.push(null) : u.push((l - s) / s * 100);
|
|
313
|
+
}
|
|
314
|
+
const r = E(u, i), c = [];
|
|
315
|
+
for (let o = 0; o < e.length; o++)
|
|
316
|
+
c.push({
|
|
317
|
+
roc: u[o] ?? null,
|
|
318
|
+
signal: r[o] ?? null
|
|
319
|
+
});
|
|
320
|
+
return c;
|
|
321
|
+
}
|
|
322
|
+
function Xe(e, n = {}) {
|
|
323
|
+
const { period: t = 14, adxPeriod: i = 14 } = n, u = [], r = [], c = [], o = [];
|
|
324
|
+
for (let l = 0; l < e.length; l++) {
|
|
325
|
+
const s = e[l];
|
|
326
|
+
if (s === void 0 || s.high === null || s.low === null || s.close === null) {
|
|
327
|
+
u.push({ pdi: null, mdi: null, adx: null, adxr: null });
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
let a;
|
|
331
|
+
if (l === 0)
|
|
332
|
+
a = s.high - s.low;
|
|
333
|
+
else {
|
|
334
|
+
const m = e[l - 1], A = m !== void 0 ? m.close : null;
|
|
335
|
+
A == null ? a = s.high - s.low : a = Math.max(
|
|
336
|
+
s.high - s.low,
|
|
337
|
+
Math.abs(s.high - A),
|
|
338
|
+
Math.abs(s.low - A)
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
if (r.push(a), l === 0)
|
|
342
|
+
c.push(0), o.push(0);
|
|
343
|
+
else {
|
|
344
|
+
const m = e[l - 1];
|
|
345
|
+
if (m === void 0 || m.high === null || m.low === null)
|
|
346
|
+
c.push(0), o.push(0);
|
|
347
|
+
else {
|
|
348
|
+
const A = s.high - m.high, C = m.low - s.low, $ = A > C && A > 0 ? A : 0, j = C > A && C > 0 ? C : 0;
|
|
349
|
+
c.push($), o.push(j);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (l < t - 1) {
|
|
353
|
+
u.push({ pdi: null, mdi: null, adx: null, adxr: null });
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
let d = 0, f = 0, g = 0;
|
|
357
|
+
for (let m = l - t + 1; m <= l; m++)
|
|
358
|
+
d += r[m] ?? 0, f += c[m] ?? 0, g += o[m] ?? 0;
|
|
359
|
+
const x = d > 0 ? f / d * 100 : 0, y = d > 0 ? g / d * 100 : 0, h = x + y, I = h > 0 ? Math.abs(x - y) / h * 100 : 0;
|
|
360
|
+
let b = null;
|
|
361
|
+
if (l >= t - 1 + i - 1) {
|
|
362
|
+
let m = 0;
|
|
363
|
+
for (let A = l - i + 1; A <= l; A++) {
|
|
364
|
+
if (u[A] === void 0) continue;
|
|
365
|
+
let $ = 0, j = 0, Z = 0;
|
|
366
|
+
for (let N = A - t + 1; N <= A; N++)
|
|
367
|
+
$ += r[N] ?? 0, j += c[N] ?? 0, Z += o[N] ?? 0;
|
|
368
|
+
const X = $ > 0 ? j / $ * 100 : 0, Q = $ > 0 ? Z / $ * 100 : 0, _ = X + Q, le = _ > 0 ? Math.abs(X - Q) / _ * 100 : 0;
|
|
369
|
+
m += le;
|
|
370
|
+
}
|
|
371
|
+
m += I, b = m / i;
|
|
372
|
+
}
|
|
373
|
+
let p = null;
|
|
374
|
+
if (b !== null && l >= t - 1 + i - 1 + i) {
|
|
375
|
+
const m = u[l - i];
|
|
376
|
+
m !== void 0 && m.adx !== null && (p = (b + m.adx) / 2);
|
|
377
|
+
}
|
|
378
|
+
u.push({ pdi: x, mdi: y, adx: b, adxr: p });
|
|
379
|
+
}
|
|
380
|
+
return u;
|
|
381
|
+
}
|
|
382
|
+
function Qe(e, n = {}) {
|
|
383
|
+
var a, d;
|
|
384
|
+
const { afStart: t = 0.02, afIncrement: i = 0.02, afMax: u = 0.2 } = n, r = [];
|
|
385
|
+
if (e.length === 0) return r;
|
|
386
|
+
let c = 1, o = ((a = e[0]) == null ? void 0 : a.low) ?? 0, l = ((d = e[0]) == null ? void 0 : d.high) ?? 0, s = t;
|
|
387
|
+
for (let f = 0; f < e.length; f++) {
|
|
388
|
+
const g = e[f];
|
|
389
|
+
if (g === void 0 || g.high === null || g.low === null) {
|
|
390
|
+
r.push({ sar: null, trend: null, ep: null, af: null });
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
if (f === 0) {
|
|
394
|
+
r.push({ sar: g.low, trend: 1, ep: g.high, af: t }), o = g.low, l = g.high, c = 1, s = t;
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
const x = o;
|
|
398
|
+
if (o = x + s * (l - x), c === 1) {
|
|
399
|
+
const y = e[f - 1], h = e[f - 2];
|
|
400
|
+
y !== void 0 && y.low !== null && (o = Math.min(o, y.low)), h !== void 0 && h.low !== null && (o = Math.min(o, h.low)), g.low < o ? (c = -1, o = l, l = g.low, s = t) : g.high > l && (l = g.high, s = Math.min(s + i, u));
|
|
401
|
+
} else {
|
|
402
|
+
const y = e[f - 1], h = e[f - 2];
|
|
403
|
+
y !== void 0 && y.high !== null && (o = Math.max(o, y.high)), h !== void 0 && h.high !== null && (o = Math.max(o, h.high)), g.high > o ? (c = 1, o = l, l = g.high, s = t) : g.low < l && (l = g.low, s = Math.min(s + i, u));
|
|
404
|
+
}
|
|
405
|
+
r.push({ sar: o, trend: c, ep: l, af: s });
|
|
406
|
+
}
|
|
407
|
+
return r;
|
|
408
|
+
}
|
|
409
|
+
function en(e, n = {}) {
|
|
410
|
+
var s;
|
|
411
|
+
const { emaPeriod: t = 20, atrPeriod: i = 10, multiplier: u = 2 } = n, r = e.map((a) => a.close), c = E(r, t), o = Ce(e, { period: i }), l = [];
|
|
412
|
+
for (let a = 0; a < e.length; a++) {
|
|
413
|
+
const d = c[a], f = (s = o[a]) == null ? void 0 : s.atr;
|
|
414
|
+
if (d == null || f === null || f === void 0) {
|
|
415
|
+
l.push({ mid: null, upper: null, lower: null, width: null });
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
const g = d + u * f, x = d - u * f, y = d !== 0 ? (g - x) / d * 100 : null;
|
|
419
|
+
l.push({ mid: d, upper: g, lower: x, width: y });
|
|
420
|
+
}
|
|
421
|
+
return l;
|
|
422
|
+
}
|
|
423
|
+
const nn = {
|
|
424
|
+
enabled: !0,
|
|
425
|
+
ttl: 300 * 1e3,
|
|
426
|
+
// 5 分钟
|
|
427
|
+
maxSize: 100
|
|
428
|
+
// 增加缓存容量
|
|
429
|
+
};
|
|
430
|
+
function tn(e) {
|
|
431
|
+
switch (e) {
|
|
432
|
+
case "timeline":
|
|
433
|
+
case "timeline5":
|
|
434
|
+
return 30 * 1e3;
|
|
435
|
+
// 30 秒
|
|
436
|
+
case "1":
|
|
437
|
+
case "5":
|
|
438
|
+
case "15":
|
|
439
|
+
case "30":
|
|
440
|
+
case "60":
|
|
441
|
+
return 120 * 1e3;
|
|
442
|
+
// 2 分钟
|
|
443
|
+
case "daily":
|
|
444
|
+
case "weekly":
|
|
445
|
+
case "monthly":
|
|
446
|
+
default:
|
|
447
|
+
return 600 * 1e3;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
class J {
|
|
451
|
+
constructor(n = {}) {
|
|
452
|
+
oe(this, "cache", /* @__PURE__ */ new Map());
|
|
453
|
+
oe(this, "config");
|
|
454
|
+
this.config = { ...nn, ...n };
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* 生成缓存 key
|
|
458
|
+
*/
|
|
459
|
+
static buildKey(n) {
|
|
460
|
+
return Object.entries(n).filter(([, t]) => t !== void 0).sort(([t], [i]) => t.localeCompare(i)).map(([t, i]) => `${t}:${String(i)}`).join("|");
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* 获取缓存
|
|
464
|
+
*/
|
|
465
|
+
get(n) {
|
|
466
|
+
if (!this.config.enabled) return;
|
|
467
|
+
const t = this.cache.get(n);
|
|
468
|
+
if (!t) return;
|
|
469
|
+
const i = t.ttl ?? this.config.ttl;
|
|
470
|
+
if (Date.now() - t.timestamp > i) {
|
|
471
|
+
this.cache.delete(n);
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
return t.data;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* 设置缓存
|
|
478
|
+
* @param key 缓存键
|
|
479
|
+
* @param data 缓存数据
|
|
480
|
+
* @param ttl 可选的自定义 TTL(毫秒)
|
|
481
|
+
*/
|
|
482
|
+
set(n, t, i) {
|
|
483
|
+
if (this.config.enabled) {
|
|
484
|
+
if (this.cache.size >= this.config.maxSize && (this.cleanup(), this.cache.size >= this.config.maxSize)) {
|
|
485
|
+
const u = this.cache.keys().next().value;
|
|
486
|
+
u && this.cache.delete(u);
|
|
487
|
+
}
|
|
488
|
+
this.cache.set(n, { data: t, timestamp: Date.now(), ttl: i });
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* 清理过期缓存
|
|
493
|
+
*/
|
|
494
|
+
cleanup() {
|
|
495
|
+
const n = Date.now();
|
|
496
|
+
for (const [t, i] of this.cache.entries()) {
|
|
497
|
+
const u = i.ttl ?? this.config.ttl;
|
|
498
|
+
n - i.timestamp > u && this.cache.delete(t);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* 删除缓存
|
|
503
|
+
*/
|
|
504
|
+
delete(n) {
|
|
505
|
+
return this.cache.delete(n);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* 清空缓存
|
|
509
|
+
*/
|
|
510
|
+
clear() {
|
|
511
|
+
this.cache.clear();
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* 获取缓存大小
|
|
515
|
+
*/
|
|
516
|
+
size() {
|
|
517
|
+
return this.cache.size;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
new J();
|
|
521
|
+
const ie = new J(), se = new J(), re = /* @__PURE__ */ new Map(), ce = /* @__PURE__ */ new Map(), ln = 150;
|
|
522
|
+
function on(e) {
|
|
523
|
+
const n = new De(e);
|
|
524
|
+
return {
|
|
525
|
+
getKline: async (t) => {
|
|
526
|
+
const { symbol: i, market: u, period: r, adjust: c } = t;
|
|
527
|
+
if (r === "timeline") {
|
|
528
|
+
const s = await n.getTodayTimeline(i);
|
|
529
|
+
return s.data.map((a) => ({
|
|
530
|
+
date: `${s.date.slice(0, 4)}-${s.date.slice(4, 6)}-${s.date.slice(6, 8)} ${a.time}`,
|
|
531
|
+
open: a.price,
|
|
532
|
+
close: a.price,
|
|
533
|
+
high: a.price,
|
|
534
|
+
low: a.price,
|
|
535
|
+
volume: a.volume,
|
|
536
|
+
amount: a.amount
|
|
537
|
+
}));
|
|
538
|
+
}
|
|
539
|
+
if (r === "timeline5") {
|
|
540
|
+
const s = /* @__PURE__ */ new Date(), a = /* @__PURE__ */ new Date();
|
|
541
|
+
a.setDate(a.getDate() - 7);
|
|
542
|
+
const d = (g) => {
|
|
543
|
+
const x = g.getFullYear(), y = String(g.getMonth() + 1).padStart(2, "0"), h = String(g.getDate()).padStart(2, "0");
|
|
544
|
+
return `${x}-${y}-${h}`;
|
|
545
|
+
};
|
|
546
|
+
return (await n.getMinuteKline(i, {
|
|
547
|
+
period: "1",
|
|
548
|
+
startDate: d(a),
|
|
549
|
+
endDate: d(s)
|
|
550
|
+
})).map((g) => ({
|
|
551
|
+
date: "time" in g ? g.time : "",
|
|
552
|
+
open: g.open,
|
|
553
|
+
close: g.close,
|
|
554
|
+
high: g.high,
|
|
555
|
+
low: g.low,
|
|
556
|
+
volume: g.volume,
|
|
557
|
+
amount: g.amount
|
|
558
|
+
}));
|
|
559
|
+
}
|
|
560
|
+
if (["1", "5", "15", "30", "60"].includes(r)) {
|
|
561
|
+
let a = (await n.getMinuteKline(i, {
|
|
562
|
+
period: r,
|
|
563
|
+
adjust: c || "qfq"
|
|
564
|
+
})).map((d) => ({
|
|
565
|
+
date: "time" in d ? d.time : "",
|
|
566
|
+
open: d.open,
|
|
567
|
+
close: d.close,
|
|
568
|
+
high: d.high,
|
|
569
|
+
low: d.low,
|
|
570
|
+
volume: d.volume,
|
|
571
|
+
amount: d.amount,
|
|
572
|
+
changePercent: "changePercent" in d ? d.changePercent : void 0,
|
|
573
|
+
change: "change" in d ? d.change : void 0,
|
|
574
|
+
amplitude: "amplitude" in d ? d.amplitude : void 0,
|
|
575
|
+
turnoverRate: "turnoverRate" in d ? d.turnoverRate : void 0
|
|
576
|
+
}));
|
|
577
|
+
if (r === "1" && a.length > 0) {
|
|
578
|
+
const d = a[a.length - 1].date.split(" ")[0];
|
|
579
|
+
a = a.filter((f) => f.date.startsWith(d));
|
|
580
|
+
}
|
|
581
|
+
return a;
|
|
582
|
+
}
|
|
583
|
+
const l = {
|
|
584
|
+
daily: "daily",
|
|
585
|
+
weekly: "weekly",
|
|
586
|
+
monthly: "monthly"
|
|
587
|
+
}[r] ?? "daily";
|
|
588
|
+
switch (u) {
|
|
589
|
+
case "HK":
|
|
590
|
+
return await n.getHKHistoryKline(i, {
|
|
591
|
+
period: l,
|
|
592
|
+
adjust: c || "qfq"
|
|
593
|
+
});
|
|
594
|
+
case "US":
|
|
595
|
+
return await n.getUSHistoryKline(i, {
|
|
596
|
+
period: l,
|
|
597
|
+
adjust: c || "qfq"
|
|
598
|
+
});
|
|
599
|
+
default:
|
|
600
|
+
return await n.getHistoryKline(i, {
|
|
601
|
+
period: l,
|
|
602
|
+
adjust: c || "qfq"
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
getTimeline: async (t) => (await n.getTodayTimeline(t.symbol)).data
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
function ye(e) {
|
|
610
|
+
return J.buildKey(e);
|
|
611
|
+
}
|
|
612
|
+
function ue(e) {
|
|
613
|
+
return J.buildKey({ ...e, type: "timeline" });
|
|
614
|
+
}
|
|
615
|
+
function sn(e, n, t = {}) {
|
|
616
|
+
if (e.length === 0) return [];
|
|
617
|
+
const i = e.map((p) => p.close), u = e.map((p) => ({
|
|
618
|
+
open: p.open,
|
|
619
|
+
high: p.high,
|
|
620
|
+
low: p.low,
|
|
621
|
+
close: p.close,
|
|
622
|
+
volume: p.volume
|
|
623
|
+
})), r = n.includes("ma") ? Ve(i, typeof t.ma == "object" ? t.ma : {}) : null, c = n.includes("macd") ? Fe(i, typeof t.macd == "object" ? t.macd : {}) : null, o = n.includes("boll") ? He(i, typeof t.boll == "object" ? t.boll : {}) : null, l = n.includes("kdj") ? Ue(u, typeof t.kdj == "object" ? t.kdj : {}) : null, s = n.includes("rsi") ? qe(i, typeof t.rsi == "object" ? t.rsi : {}) : null, a = n.includes("wr") ? Ye(u, typeof t.wr == "object" ? t.wr : {}) : null, d = n.includes("bias") ? We(i, typeof t.bias == "object" ? t.bias : {}) : null, f = n.includes("cci") ? Ge(u, typeof t.cci == "object" ? t.cci : {}) : null, g = n.includes("atr") ? Ce(u, typeof t.atr == "object" ? t.atr : {}) : null, x = n.includes("obv") ? Je(u, typeof t.obv == "object" ? t.obv : {}) : null, y = n.includes("roc") ? Ze(i, typeof t.roc == "object" ? t.roc : {}) : null, h = n.includes("dmi") ? Xe(u, typeof t.dmi == "object" ? t.dmi : {}) : null, I = n.includes("sar") ? Qe(u, typeof t.sar == "object" ? t.sar : {}) : null, b = n.includes("kc") ? en(u, typeof t.kc == "object" ? t.kc : {}) : null;
|
|
624
|
+
return e.map((p, m) => ({
|
|
625
|
+
...p,
|
|
626
|
+
ma: r == null ? void 0 : r[m],
|
|
627
|
+
macd: c == null ? void 0 : c[m],
|
|
628
|
+
boll: o == null ? void 0 : o[m],
|
|
629
|
+
kdj: l == null ? void 0 : l[m],
|
|
630
|
+
rsi: s == null ? void 0 : s[m],
|
|
631
|
+
wr: a == null ? void 0 : a[m],
|
|
632
|
+
bias: d == null ? void 0 : d[m],
|
|
633
|
+
cci: f == null ? void 0 : f[m],
|
|
634
|
+
atr: g == null ? void 0 : g[m],
|
|
635
|
+
obv: x == null ? void 0 : x[m],
|
|
636
|
+
roc: y == null ? void 0 : y[m],
|
|
637
|
+
dmi: h == null ? void 0 : h[m],
|
|
638
|
+
sar: I == null ? void 0 : I[m],
|
|
639
|
+
kc: b == null ? void 0 : b[m]
|
|
640
|
+
}));
|
|
641
|
+
}
|
|
642
|
+
function st(e) {
|
|
643
|
+
const {
|
|
644
|
+
symbol: n,
|
|
645
|
+
market: t,
|
|
646
|
+
period: i,
|
|
647
|
+
adjust: u,
|
|
648
|
+
dataProvider: r,
|
|
649
|
+
sdkOptions: c,
|
|
650
|
+
requestOptions: o,
|
|
651
|
+
indicatorOptions: l,
|
|
652
|
+
indicators: s = ["ma", "volume", "macd"]
|
|
653
|
+
} = e, [a, d] = U([]), [f, g] = U({
|
|
654
|
+
key: "",
|
|
655
|
+
data: []
|
|
656
|
+
}), [x, y] = U(!1), [h, I] = U(null), b = z(null), p = z(null), m = z(null), A = z(0);
|
|
657
|
+
fe(() => {
|
|
658
|
+
r || (m.current = null);
|
|
659
|
+
}, [r, c]);
|
|
660
|
+
const C = D(() => r || (m.current || (m.current = on(c)), m.current), [r, c]), $ = D(async () => {
|
|
661
|
+
(o == null ? void 0 : o.abortOnChange) !== !1 && b.current && b.current.abort();
|
|
662
|
+
const _ = new AbortController(), le = ++A.current;
|
|
663
|
+
b.current = _;
|
|
664
|
+
const N = (o == null ? void 0 : o.dedupe) !== !1, ge = () => le === A.current && !_.signal.aborted;
|
|
665
|
+
y(!0), I(null);
|
|
666
|
+
try {
|
|
667
|
+
const P = C(), V = ye({ symbol: n, market: t, period: i, adjust: u }), R = ue({ symbol: n, market: t }), ve = tn(i);
|
|
668
|
+
let B = N ? ie.get(V) : void 0;
|
|
669
|
+
if (!B) {
|
|
670
|
+
const L = N ? re.get(V) : void 0;
|
|
671
|
+
if (L)
|
|
672
|
+
try {
|
|
673
|
+
B = await L;
|
|
674
|
+
} catch {
|
|
675
|
+
}
|
|
676
|
+
else {
|
|
677
|
+
const F = P.getKline(
|
|
678
|
+
{ symbol: n, market: t, period: i, adjust: u },
|
|
679
|
+
_.signal
|
|
680
|
+
);
|
|
681
|
+
re.set(V, F);
|
|
682
|
+
try {
|
|
683
|
+
B = await F;
|
|
684
|
+
} finally {
|
|
685
|
+
re.delete(V);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
if (!ge() || !B) return;
|
|
690
|
+
if (ie.set(V, B, ve), d(B), i === "timeline" && P.getTimeline) {
|
|
691
|
+
let L = N ? se.get(R) : void 0;
|
|
692
|
+
if (!L) {
|
|
693
|
+
g({ key: R, data: [] });
|
|
694
|
+
const F = N ? ce.get(R) : void 0;
|
|
695
|
+
if (F)
|
|
696
|
+
try {
|
|
697
|
+
L = await F;
|
|
698
|
+
} catch {
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
const be = P.getTimeline({ symbol: n, market: t }, _.signal);
|
|
702
|
+
ce.set(R, be);
|
|
703
|
+
try {
|
|
704
|
+
L = await be;
|
|
705
|
+
} finally {
|
|
706
|
+
ce.delete(R);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
ge() && L && (se.set(R, L, ve), g({ key: R, data: L }));
|
|
711
|
+
}
|
|
712
|
+
} catch (P) {
|
|
713
|
+
if (P.name === "AbortError") return;
|
|
714
|
+
I(P);
|
|
715
|
+
} finally {
|
|
716
|
+
_.signal.aborted || y(!1);
|
|
717
|
+
}
|
|
718
|
+
}, [n, t, i, u, C, o]), j = D(async () => {
|
|
719
|
+
const _ = ye({ symbol: n, market: t, period: i, adjust: u });
|
|
720
|
+
ie.delete(_), i === "timeline" && (se.delete(ue({ symbol: n, market: t })), g({ key: "", data: [] })), await $();
|
|
721
|
+
}, [n, t, i, u, $]);
|
|
722
|
+
fe(() => {
|
|
723
|
+
p.current && clearTimeout(p.current);
|
|
724
|
+
const _ = (o == null ? void 0 : o.debounceMs) ?? ln;
|
|
725
|
+
return p.current = setTimeout($, _), () => {
|
|
726
|
+
p.current && clearTimeout(p.current), b.current && b.current.abort();
|
|
727
|
+
};
|
|
728
|
+
}, [n, t, i, u, $, o == null ? void 0 : o.debounceMs]);
|
|
729
|
+
const Z = pe(
|
|
730
|
+
() => sn(a, s, l),
|
|
731
|
+
[a, s, l]
|
|
732
|
+
), X = i === "timeline" ? ue({ symbol: n, market: t }) : "", Q = f.key === X ? f.data : [];
|
|
733
|
+
return { data: Z, timelineData: Q, loading: x, error: h, refresh: j };
|
|
734
|
+
}
|
|
735
|
+
Ie.use([
|
|
736
|
+
_e,
|
|
737
|
+
Ne,
|
|
738
|
+
je,
|
|
739
|
+
Le,
|
|
740
|
+
Re,
|
|
741
|
+
Te,
|
|
742
|
+
Pe,
|
|
743
|
+
Be,
|
|
744
|
+
Ke,
|
|
745
|
+
Oe,
|
|
746
|
+
ze
|
|
747
|
+
]);
|
|
748
|
+
function rt() {
|
|
749
|
+
const e = z(null), n = z(null);
|
|
750
|
+
fe(() => {
|
|
751
|
+
if (!e.current) return;
|
|
752
|
+
n.current = Ie.init(e.current);
|
|
753
|
+
const l = new ResizeObserver(() => {
|
|
754
|
+
var s;
|
|
755
|
+
(s = n.current) == null || s.resize();
|
|
756
|
+
});
|
|
757
|
+
return l.observe(e.current), () => {
|
|
758
|
+
var s;
|
|
759
|
+
l.disconnect(), (s = n.current) == null || s.dispose(), n.current = null;
|
|
760
|
+
};
|
|
761
|
+
}, []);
|
|
762
|
+
const t = D(
|
|
763
|
+
(l, s, a = !1) => {
|
|
764
|
+
var f;
|
|
765
|
+
let d;
|
|
766
|
+
typeof s == "boolean" ? d = { notMerge: s, lazyUpdate: a } : d = s ?? {}, (f = n.current) == null || f.setOption(l, d);
|
|
767
|
+
},
|
|
768
|
+
[]
|
|
769
|
+
), i = D(() => {
|
|
770
|
+
var l;
|
|
771
|
+
(l = n.current) == null || l.resize();
|
|
772
|
+
}, []), u = D(() => {
|
|
773
|
+
var l;
|
|
774
|
+
(l = n.current) == null || l.dispose(), n.current = null;
|
|
775
|
+
}, []), r = D(
|
|
776
|
+
(l) => n.current ? n.current.getDataURL({
|
|
777
|
+
type: (l == null ? void 0 : l.type) ?? "png",
|
|
778
|
+
pixelRatio: (l == null ? void 0 : l.pixelRatio) ?? 2,
|
|
779
|
+
backgroundColor: (l == null ? void 0 : l.backgroundColor) ?? "#fff"
|
|
780
|
+
}) : "",
|
|
781
|
+
[]
|
|
782
|
+
), c = D(() => n.current, []), o = D(
|
|
783
|
+
(l, s) => {
|
|
784
|
+
const a = n.current;
|
|
785
|
+
return a ? (a.on(l, s), () => {
|
|
786
|
+
a.off(l, s);
|
|
787
|
+
}) : () => {
|
|
788
|
+
};
|
|
789
|
+
},
|
|
790
|
+
[]
|
|
791
|
+
);
|
|
792
|
+
return {
|
|
793
|
+
chartRef: e,
|
|
794
|
+
setOption: t,
|
|
795
|
+
resize: i,
|
|
796
|
+
dispose: u,
|
|
797
|
+
getInstance: c,
|
|
798
|
+
getDataURL: r,
|
|
799
|
+
bindEvent: o
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
const rn = { start: 70, end: 100 }, xe = 50;
|
|
803
|
+
function cn(e, n) {
|
|
804
|
+
return e.start === n.start && e.end === n.end;
|
|
805
|
+
}
|
|
806
|
+
function ct(e = rn) {
|
|
807
|
+
const [n, t] = U({
|
|
808
|
+
history: [e],
|
|
809
|
+
index: 0
|
|
810
|
+
}), i = n.history[n.index] ?? e, u = D((l) => {
|
|
811
|
+
t((s) => {
|
|
812
|
+
const a = s.history[s.index];
|
|
813
|
+
if (a && cn(a, l))
|
|
814
|
+
return s;
|
|
815
|
+
let d = s.history.slice(0, s.index + 1);
|
|
816
|
+
return d = [...d, l], d.length > xe && (d = d.slice(d.length - xe)), {
|
|
817
|
+
history: d,
|
|
818
|
+
index: d.length - 1
|
|
819
|
+
};
|
|
820
|
+
});
|
|
821
|
+
}, []), r = D(() => {
|
|
822
|
+
let l = null;
|
|
823
|
+
return t((s) => {
|
|
824
|
+
if (s.index === 0)
|
|
825
|
+
return s;
|
|
826
|
+
const a = s.index - 1;
|
|
827
|
+
return l = s.history[a] ?? null, {
|
|
828
|
+
...s,
|
|
829
|
+
index: a
|
|
830
|
+
};
|
|
831
|
+
}), l;
|
|
832
|
+
}, []), c = D(() => {
|
|
833
|
+
let l = null;
|
|
834
|
+
return t((s) => {
|
|
835
|
+
if (s.index >= s.history.length - 1)
|
|
836
|
+
return s;
|
|
837
|
+
const a = s.index + 1;
|
|
838
|
+
return l = s.history[a] ?? null, {
|
|
839
|
+
...s,
|
|
840
|
+
index: a
|
|
841
|
+
};
|
|
842
|
+
}), l;
|
|
843
|
+
}, []), o = D((l = e) => {
|
|
844
|
+
t({
|
|
845
|
+
history: [l],
|
|
846
|
+
index: 0
|
|
847
|
+
});
|
|
848
|
+
}, [e]);
|
|
849
|
+
return {
|
|
850
|
+
canUndo: n.index > 0,
|
|
851
|
+
canRedo: n.index < n.history.length - 1,
|
|
852
|
+
currentState: i,
|
|
853
|
+
pushState: u,
|
|
854
|
+
undo: r,
|
|
855
|
+
redo: c,
|
|
856
|
+
reset: o
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
function te(e, n) {
|
|
860
|
+
const t = (e ?? []).filter((i) => Number.isFinite(i) && i > 0).map((i) => Math.floor(i));
|
|
861
|
+
return t.length === 0 ? n : Array.from(new Set(t)).sort((i, u) => i - u);
|
|
862
|
+
}
|
|
863
|
+
function un(e) {
|
|
864
|
+
return te(typeof e == "object" ? e.periods : void 0, [5, 10, 20, 30, 60]);
|
|
865
|
+
}
|
|
866
|
+
function an(e) {
|
|
867
|
+
return te(typeof e == "object" ? e.periods : void 0, [6, 12, 24]);
|
|
868
|
+
}
|
|
869
|
+
function dn(e) {
|
|
870
|
+
return te(typeof e == "object" ? e.periods : void 0, [6, 10]);
|
|
871
|
+
}
|
|
872
|
+
function hn(e) {
|
|
873
|
+
return te(typeof e == "object" ? e.periods : void 0, [6, 12, 24]);
|
|
874
|
+
}
|
|
875
|
+
function we(e) {
|
|
876
|
+
const n = e.match(/(\d+)$/);
|
|
877
|
+
return n ? Number(n[1]) : Number.POSITIVE_INFINITY;
|
|
878
|
+
}
|
|
879
|
+
function q(e, n) {
|
|
880
|
+
return e ? Object.keys(e).filter((t) => t.startsWith(n)).sort((t, i) => we(t) - we(i)).map((t) => [t, e[t]]) : [];
|
|
881
|
+
}
|
|
882
|
+
function Y(e) {
|
|
883
|
+
return e.replace(/^[a-z]+/, (n) => n.toUpperCase());
|
|
884
|
+
}
|
|
885
|
+
function mn(e, n = 2) {
|
|
886
|
+
return e == null || isNaN(e) ? "--" : e.toLocaleString("zh-CN", {
|
|
887
|
+
minimumFractionDigits: n,
|
|
888
|
+
maximumFractionDigits: n
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
function v(e) {
|
|
892
|
+
return mn(e, 2);
|
|
893
|
+
}
|
|
894
|
+
function fn(e) {
|
|
895
|
+
return e == null || isNaN(e) ? "--" : `${e > 0 ? "+" : ""}${e.toFixed(2)}%`;
|
|
896
|
+
}
|
|
897
|
+
function pn(e) {
|
|
898
|
+
return e == null || isNaN(e) ? "--" : `${e > 0 ? "+" : ""}${e.toFixed(2)}`;
|
|
899
|
+
}
|
|
900
|
+
function W(e, n) {
|
|
901
|
+
return Number.isInteger(e) ? e.toString() : e.toFixed(n).replace(/\.?0+$/, "");
|
|
902
|
+
}
|
|
903
|
+
function T(e) {
|
|
904
|
+
return e == null || isNaN(e) ? "--" : e >= 1e8 ? `${W(e / 1e8, 2)}亿` : e >= 1e4 ? `${W(e / 1e4, 2)}万` : e.toFixed(0);
|
|
905
|
+
}
|
|
906
|
+
function gn(e) {
|
|
907
|
+
return e == null || isNaN(e) ? "--" : e >= 1e8 ? `${W(e / 1e8, 2)}亿` : e >= 1e4 ? `${W(e / 1e4, 2)}万` : W(e, 2);
|
|
908
|
+
}
|
|
909
|
+
function ut(e, n = "YYYY-MM-DD") {
|
|
910
|
+
const t = typeof e == "string" ? new Date(e) : e;
|
|
911
|
+
if (isNaN(t.getTime()))
|
|
912
|
+
return e;
|
|
913
|
+
const i = t.getFullYear(), u = String(t.getMonth() + 1).padStart(2, "0"), r = String(t.getDate()).padStart(2, "0"), c = String(t.getHours()).padStart(2, "0"), o = String(t.getMinutes()).padStart(2, "0");
|
|
914
|
+
return n.replace("YYYY", String(i)).replace("MM", u).replace("DD", r).replace("HH", c).replace("mm", o);
|
|
915
|
+
}
|
|
916
|
+
function ee(e, n, t) {
|
|
917
|
+
const i = q(n, t);
|
|
918
|
+
return i.length === 0 ? null : `${e}: ${i.map(([u, r]) => `${Y(u)} ${v(r)}`).join(" / ")}`;
|
|
919
|
+
}
|
|
920
|
+
function vn(e) {
|
|
921
|
+
const n = [
|
|
922
|
+
`<div style="font-weight:bold;margin-bottom:4px">${e.date}</div>`,
|
|
923
|
+
`<div>开盘: <span style="font-weight:500">${v(e.open)}</span></div>`,
|
|
924
|
+
`<div>最高: <span style="font-weight:500">${v(e.high)}</span></div>`,
|
|
925
|
+
`<div>最低: <span style="font-weight:500">${v(e.low)}</span></div>`,
|
|
926
|
+
`<div>收盘: <span style="font-weight:500">${v(e.close)}</span></div>`
|
|
927
|
+
];
|
|
928
|
+
if (e.change !== void 0 && e.changePercent !== void 0) {
|
|
929
|
+
const u = e.change !== null && e.change > 0 ? "#f5222d" : e.change !== null && e.change < 0 ? "#52c41a" : "inherit";
|
|
930
|
+
n.push(
|
|
931
|
+
`<div>涨跌: <span style="color:${u};font-weight:500">${pn(e.change)} (${fn(e.changePercent)})</span></div>`
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
e.volume !== void 0 && n.push(`<div>成交量: ${T(e.volume)}</div>`), e.amount !== void 0 && n.push(`<div>成交额: ${gn(e.amount)}</div>`), e.turnoverRate !== void 0 && e.turnoverRate !== null && n.push(`<div>换手率: ${e.turnoverRate.toFixed(2)}%</div>`), e.amplitude !== void 0 && e.amplitude !== null && n.push(`<div>振幅: ${e.amplitude.toFixed(2)}%</div>`);
|
|
935
|
+
const t = e.indicators ?? [];
|
|
936
|
+
let i = !1;
|
|
937
|
+
if (t.includes("ma") && e.ma) {
|
|
938
|
+
const u = ee("MA", e.ma, "ma");
|
|
939
|
+
u && (i ? n.push(`<div>${u}</div>`) : (n.push(`<div style="margin-top:4px;border-top:1px solid #eee;padding-top:4px">${u}</div>`), i = !0));
|
|
940
|
+
}
|
|
941
|
+
if (t.includes("boll") && e.boll && (i ? n.push(`<div>BOLL: 上 ${v(e.boll.upper)} 中 ${v(e.boll.mid)} 下 ${v(e.boll.lower)}</div>`) : (n.push(`<div style="margin-top:4px;border-top:1px solid #eee;padding-top:4px">BOLL: 上 ${v(e.boll.upper)} 中 ${v(e.boll.mid)} 下 ${v(e.boll.lower)}</div>`), i = !0)), t.includes("sar") && e.sar) {
|
|
942
|
+
const u = e.sar.trend === 1 ? "↑" : "↓";
|
|
943
|
+
i ? n.push(`<div>SAR: ${v(e.sar.sar)} ${u}</div>`) : (n.push(`<div style="margin-top:4px;border-top:1px solid #eee;padding-top:4px">SAR: ${v(e.sar.sar)} ${u}</div>`), i = !0);
|
|
944
|
+
}
|
|
945
|
+
if (t.includes("kc") && e.kc && (i ? n.push(`<div>KC: 上 ${v(e.kc.upper)} 中 ${v(e.kc.mid)} 下 ${v(e.kc.lower)}</div>`) : (n.push(`<div style="margin-top:4px;border-top:1px solid #eee;padding-top:4px">KC: 上 ${v(e.kc.upper)} 中 ${v(e.kc.mid)} 下 ${v(e.kc.lower)}</div>`), i = !0)), t.includes("macd") && e.macd && (i ? n.push(`<div>MACD: DIF ${v(e.macd.dif)} DEA ${v(e.macd.dea)} MACD ${v(e.macd.macd)}</div>`) : (n.push(`<div style="margin-top:4px;border-top:1px solid #eee;padding-top:4px">MACD: DIF ${v(e.macd.dif)} DEA ${v(e.macd.dea)} MACD ${v(e.macd.macd)}</div>`), i = !0)), t.includes("kdj") && e.kdj && n.push(`<div>KDJ: K ${v(e.kdj.k)} D ${v(e.kdj.d)} J ${v(e.kdj.j)}</div>`), t.includes("rsi") && e.rsi) {
|
|
946
|
+
const u = ee("RSI", e.rsi, "rsi");
|
|
947
|
+
u && n.push(`<div>${u}</div>`);
|
|
948
|
+
}
|
|
949
|
+
if (t.includes("wr") && e.wr) {
|
|
950
|
+
const u = ee("WR", e.wr, "wr");
|
|
951
|
+
u && n.push(`<div>${u}</div>`);
|
|
952
|
+
}
|
|
953
|
+
if (t.includes("bias") && e.bias) {
|
|
954
|
+
const u = ee("BIAS", e.bias, "bias");
|
|
955
|
+
u && n.push(`<div>${u}</div>`);
|
|
956
|
+
}
|
|
957
|
+
return t.includes("cci") && e.cci && n.push(`<div>CCI: ${v(e.cci.cci)}</div>`), t.includes("atr") && e.atr && n.push(`<div>ATR: ${v(e.atr.atr)}</div>`), t.includes("obv") && e.obv && n.push(`<div>OBV: ${T(e.obv.obv)} MA ${T(e.obv.obvMa)}</div>`), t.includes("roc") && e.roc && n.push(`<div>ROC: ${v(e.roc.roc)} SIGNAL ${v(e.roc.signal)}</div>`), t.includes("dmi") && e.dmi && n.push(`<div>DMI: +DI ${v(e.dmi.pdi)} -DI ${v(e.dmi.mdi)} ADX ${v(e.dmi.adx)}</div>`), n.join("");
|
|
958
|
+
}
|
|
959
|
+
const ae = ["ma", "boll", "sar", "kc"], bn = "kline-zoom-inside", yn = "kline-zoom-slider";
|
|
960
|
+
function H(e, n) {
|
|
961
|
+
return Number.isInteger(e) ? e.toString() : e.toFixed(n).replace(/\.?0+$/, "");
|
|
962
|
+
}
|
|
963
|
+
function xn(e, n) {
|
|
964
|
+
return n.includes("volume") ? T(e) : Math.abs(e) >= 100 || Math.abs(e) >= 10 || Math.abs(e) >= 1 || Math.abs(e) >= 0.01 ? H(e, 2) : H(e, 4);
|
|
965
|
+
}
|
|
966
|
+
function wn(e, n = {}) {
|
|
967
|
+
const t = Math.min(Math.max(n.maxSubPanes ?? 3, 0), 3), i = e.filter((s) => !ae.includes(s));
|
|
968
|
+
if (t === 0)
|
|
969
|
+
return [
|
|
970
|
+
{
|
|
971
|
+
id: "main",
|
|
972
|
+
height: "95%",
|
|
973
|
+
indicators: ae.filter((s) => e.includes(s))
|
|
974
|
+
}
|
|
975
|
+
];
|
|
976
|
+
const u = i.length, r = Math.min(u, t), o = r === 0 ? { main: "95%", sub: "0%" } : r === 1 ? { main: "78%", sub: "18%" } : r === 2 ? { main: "65%", sub: "15%" } : { main: "55%", sub: "13%" }, l = [
|
|
977
|
+
{
|
|
978
|
+
id: "main",
|
|
979
|
+
height: o.main,
|
|
980
|
+
indicators: ae.filter((s) => e.includes(s))
|
|
981
|
+
}
|
|
982
|
+
];
|
|
983
|
+
return i.slice(0, t).forEach((s, a) => {
|
|
984
|
+
l.push({
|
|
985
|
+
id: `sub_${s}_${a}`,
|
|
986
|
+
height: o.sub,
|
|
987
|
+
indicators: [s]
|
|
988
|
+
});
|
|
989
|
+
}), l;
|
|
990
|
+
}
|
|
991
|
+
const de = {
|
|
992
|
+
gap: 25,
|
|
993
|
+
topMargin: 50,
|
|
994
|
+
bottomMargin: 55,
|
|
995
|
+
leftMargin: 60,
|
|
996
|
+
rightMargin: 60
|
|
997
|
+
};
|
|
998
|
+
function $e(e, n) {
|
|
999
|
+
const t = [], { gap: i, topMargin: u, bottomMargin: r } = de, c = n - u - r - (e.length - 1) * i;
|
|
1000
|
+
let o = 0;
|
|
1001
|
+
const l = [];
|
|
1002
|
+
for (const f of e)
|
|
1003
|
+
if (typeof f.height == "string" && f.height.endsWith("%")) {
|
|
1004
|
+
const g = parseFloat(f.height) / 100;
|
|
1005
|
+
l.push(g), o += g;
|
|
1006
|
+
} else typeof f.height == "number" ? (l.push(f.height / c), o += f.height / c) : l.push(0);
|
|
1007
|
+
const s = l.filter((f) => f === 0).length;
|
|
1008
|
+
if (s > 0 && o < 1) {
|
|
1009
|
+
const f = (1 - o) / s;
|
|
1010
|
+
for (let g = 0; g < l.length; g++)
|
|
1011
|
+
l[g] === 0 && (l[g] = f);
|
|
1012
|
+
}
|
|
1013
|
+
const a = l.reduce((f, g) => f + g, 0);
|
|
1014
|
+
for (let f = 0; f < l.length; f++)
|
|
1015
|
+
l[f] = l[f] / a * c;
|
|
1016
|
+
let d = u;
|
|
1017
|
+
for (let f = 0; f < e.length; f++)
|
|
1018
|
+
t.push({
|
|
1019
|
+
id: e[f].id,
|
|
1020
|
+
left: de.leftMargin,
|
|
1021
|
+
right: de.rightMargin,
|
|
1022
|
+
top: d,
|
|
1023
|
+
height: l[f]
|
|
1024
|
+
}), d += l[f] + i;
|
|
1025
|
+
return t;
|
|
1026
|
+
}
|
|
1027
|
+
function at(e) {
|
|
1028
|
+
const {
|
|
1029
|
+
data: n,
|
|
1030
|
+
theme: t,
|
|
1031
|
+
indicators: i,
|
|
1032
|
+
panes: u = wn(i),
|
|
1033
|
+
containerHeight: r = 500,
|
|
1034
|
+
indicatorOptions: c
|
|
1035
|
+
} = e, o = un(c == null ? void 0 : c.ma), l = an(c == null ? void 0 : c.rsi), s = dn(c == null ? void 0 : c.wr), a = hn(c == null ? void 0 : c.bias);
|
|
1036
|
+
if (n.length === 0)
|
|
1037
|
+
return {
|
|
1038
|
+
title: {
|
|
1039
|
+
text: "暂无数据",
|
|
1040
|
+
left: "center",
|
|
1041
|
+
top: "center",
|
|
1042
|
+
textStyle: { color: t.textColorSecondary }
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
const d = $e(u, r), f = n.map((h) => h.date), g = n.map((h) => h.close), x = {
|
|
1046
|
+
animation: !1,
|
|
1047
|
+
backgroundColor: t.backgroundColor,
|
|
1048
|
+
// 显式清除 title(避免 "暂无数据" 残留)
|
|
1049
|
+
title: { text: "", show: !1 },
|
|
1050
|
+
tooltip: {
|
|
1051
|
+
trigger: "axis",
|
|
1052
|
+
axisPointer: {
|
|
1053
|
+
type: "cross",
|
|
1054
|
+
crossStyle: { color: t.crosshairColor },
|
|
1055
|
+
lineStyle: { color: t.crosshairColor, type: "dashed" }
|
|
1056
|
+
},
|
|
1057
|
+
backgroundColor: t.tooltipBgColor,
|
|
1058
|
+
borderColor: t.tooltipBorderColor,
|
|
1059
|
+
textStyle: { color: t.textColor, fontSize: 12 },
|
|
1060
|
+
formatter: (h) => {
|
|
1061
|
+
if (!Array.isArray(h) || h.length === 0) return "";
|
|
1062
|
+
const I = h[0].dataIndex, b = n[I];
|
|
1063
|
+
return b ? vn({
|
|
1064
|
+
date: b.date,
|
|
1065
|
+
open: b.open,
|
|
1066
|
+
high: b.high,
|
|
1067
|
+
low: b.low,
|
|
1068
|
+
close: b.close,
|
|
1069
|
+
volume: b.volume,
|
|
1070
|
+
amount: b.amount,
|
|
1071
|
+
change: b.change,
|
|
1072
|
+
changePercent: b.changePercent,
|
|
1073
|
+
turnoverRate: b.turnoverRate,
|
|
1074
|
+
amplitude: b.amplitude,
|
|
1075
|
+
// 传递指标数据
|
|
1076
|
+
indicators: i,
|
|
1077
|
+
// 主图指标
|
|
1078
|
+
ma: b.ma,
|
|
1079
|
+
boll: b.boll,
|
|
1080
|
+
sar: b.sar,
|
|
1081
|
+
kc: b.kc,
|
|
1082
|
+
// 副图指标
|
|
1083
|
+
macd: b.macd,
|
|
1084
|
+
kdj: b.kdj,
|
|
1085
|
+
rsi: b.rsi,
|
|
1086
|
+
wr: b.wr,
|
|
1087
|
+
bias: b.bias,
|
|
1088
|
+
cci: b.cci,
|
|
1089
|
+
atr: b.atr,
|
|
1090
|
+
obv: b.obv,
|
|
1091
|
+
roc: b.roc,
|
|
1092
|
+
dmi: b.dmi
|
|
1093
|
+
}) : "";
|
|
1094
|
+
}
|
|
1095
|
+
},
|
|
1096
|
+
axisPointer: {
|
|
1097
|
+
link: [{ xAxisIndex: "all" }]
|
|
1098
|
+
},
|
|
1099
|
+
grid: d.map((h) => ({
|
|
1100
|
+
left: h.left,
|
|
1101
|
+
right: h.right,
|
|
1102
|
+
top: h.top,
|
|
1103
|
+
height: h.height
|
|
1104
|
+
})),
|
|
1105
|
+
xAxis: d.map((h, I) => ({
|
|
1106
|
+
type: "category",
|
|
1107
|
+
data: f,
|
|
1108
|
+
gridIndex: I,
|
|
1109
|
+
axisLine: { lineStyle: { color: t.gridLineColor } },
|
|
1110
|
+
axisTick: { show: !1 },
|
|
1111
|
+
axisLabel: {
|
|
1112
|
+
show: I === d.length - 1,
|
|
1113
|
+
color: t.textColorSecondary,
|
|
1114
|
+
fontSize: 11
|
|
1115
|
+
},
|
|
1116
|
+
splitLine: { show: !1 },
|
|
1117
|
+
boundaryGap: !0,
|
|
1118
|
+
min: "dataMin",
|
|
1119
|
+
max: "dataMax"
|
|
1120
|
+
})),
|
|
1121
|
+
yAxis: d.map((h, I) => ({
|
|
1122
|
+
type: "value",
|
|
1123
|
+
gridIndex: I,
|
|
1124
|
+
position: "right",
|
|
1125
|
+
axisLine: { show: !1 },
|
|
1126
|
+
axisTick: { show: !1 },
|
|
1127
|
+
axisLabel: {
|
|
1128
|
+
color: t.textColorSecondary,
|
|
1129
|
+
fontSize: 11,
|
|
1130
|
+
formatter: (b) => xn(b, h.id)
|
|
1131
|
+
},
|
|
1132
|
+
splitLine: {
|
|
1133
|
+
lineStyle: { color: t.splitLineColor, type: "dashed" }
|
|
1134
|
+
},
|
|
1135
|
+
// 主图 3 根分割线,副图 2 根
|
|
1136
|
+
splitNumber: h.id === "main" ? 3 : 2,
|
|
1137
|
+
scale: h.id !== "volume" && !h.id.includes("volume")
|
|
1138
|
+
})),
|
|
1139
|
+
dataZoom: [
|
|
1140
|
+
{
|
|
1141
|
+
id: bn,
|
|
1142
|
+
type: "inside",
|
|
1143
|
+
xAxisIndex: d.map((h, I) => I),
|
|
1144
|
+
minValueSpan: 10
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
id: yn,
|
|
1148
|
+
type: "slider",
|
|
1149
|
+
xAxisIndex: d.map((h, I) => I),
|
|
1150
|
+
bottom: 8,
|
|
1151
|
+
height: 20,
|
|
1152
|
+
borderColor: t.gridLineColor,
|
|
1153
|
+
fillerColor: "rgba(24,144,255,0.1)",
|
|
1154
|
+
handleStyle: { color: t.activeColor },
|
|
1155
|
+
textStyle: { color: t.textColorSecondary }
|
|
1156
|
+
}
|
|
1157
|
+
],
|
|
1158
|
+
series: []
|
|
1159
|
+
}, y = [];
|
|
1160
|
+
for (let h = 0; h < u.length; h++) {
|
|
1161
|
+
const I = u[h];
|
|
1162
|
+
if (d[h].id === "main" && y.push({
|
|
1163
|
+
type: "candlestick",
|
|
1164
|
+
name: "K线",
|
|
1165
|
+
xAxisIndex: h,
|
|
1166
|
+
yAxisIndex: h,
|
|
1167
|
+
data: n.map((p) => [p.open, p.close, p.low, p.high]),
|
|
1168
|
+
itemStyle: {
|
|
1169
|
+
color: t.upColor,
|
|
1170
|
+
color0: t.downColor,
|
|
1171
|
+
borderColor: t.upColor,
|
|
1172
|
+
borderColor0: t.downColor
|
|
1173
|
+
}
|
|
1174
|
+
}), I.indicators.includes("ma") && o.forEach((p, m) => {
|
|
1175
|
+
const A = `ma${p}`, C = n.map(($) => {
|
|
1176
|
+
var j;
|
|
1177
|
+
return ((j = $.ma) == null ? void 0 : j[A]) ?? null;
|
|
1178
|
+
});
|
|
1179
|
+
y.push({
|
|
1180
|
+
type: "line",
|
|
1181
|
+
name: `MA${p}`,
|
|
1182
|
+
xAxisIndex: h,
|
|
1183
|
+
yAxisIndex: h,
|
|
1184
|
+
data: C,
|
|
1185
|
+
smooth: !0,
|
|
1186
|
+
symbol: "none",
|
|
1187
|
+
lineStyle: {
|
|
1188
|
+
width: 1,
|
|
1189
|
+
color: t.maColors[m] ?? t.maColors[0]
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
}), I.indicators.includes("boll")) {
|
|
1193
|
+
const [p, m, A] = t.bollColors;
|
|
1194
|
+
y.push(
|
|
1195
|
+
{
|
|
1196
|
+
type: "line",
|
|
1197
|
+
name: "BOLL上轨",
|
|
1198
|
+
xAxisIndex: h,
|
|
1199
|
+
yAxisIndex: h,
|
|
1200
|
+
data: n.map((C) => {
|
|
1201
|
+
var $;
|
|
1202
|
+
return (($ = C.boll) == null ? void 0 : $.upper) ?? null;
|
|
1203
|
+
}),
|
|
1204
|
+
smooth: !0,
|
|
1205
|
+
symbol: "none",
|
|
1206
|
+
lineStyle: { width: 1, color: p }
|
|
1207
|
+
},
|
|
1208
|
+
{
|
|
1209
|
+
type: "line",
|
|
1210
|
+
name: "BOLL中轨",
|
|
1211
|
+
xAxisIndex: h,
|
|
1212
|
+
yAxisIndex: h,
|
|
1213
|
+
data: n.map((C) => {
|
|
1214
|
+
var $;
|
|
1215
|
+
return (($ = C.boll) == null ? void 0 : $.mid) ?? null;
|
|
1216
|
+
}),
|
|
1217
|
+
smooth: !0,
|
|
1218
|
+
symbol: "none",
|
|
1219
|
+
lineStyle: { width: 1, color: m }
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
type: "line",
|
|
1223
|
+
name: "BOLL下轨",
|
|
1224
|
+
xAxisIndex: h,
|
|
1225
|
+
yAxisIndex: h,
|
|
1226
|
+
data: n.map((C) => {
|
|
1227
|
+
var $;
|
|
1228
|
+
return (($ = C.boll) == null ? void 0 : $.lower) ?? null;
|
|
1229
|
+
}),
|
|
1230
|
+
smooth: !0,
|
|
1231
|
+
symbol: "none",
|
|
1232
|
+
lineStyle: { width: 1, color: A }
|
|
1233
|
+
}
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
if (I.indicators.includes("volume") && y.push({
|
|
1237
|
+
type: "bar",
|
|
1238
|
+
name: "成交量",
|
|
1239
|
+
xAxisIndex: h,
|
|
1240
|
+
yAxisIndex: h,
|
|
1241
|
+
data: n.map((p, m) => {
|
|
1242
|
+
const A = m > 0 ? g[m - 1] : p.open, C = (p.close ?? 0) >= (A ?? 0);
|
|
1243
|
+
return {
|
|
1244
|
+
value: p.volume,
|
|
1245
|
+
itemStyle: {
|
|
1246
|
+
color: C ? t.volumeUpColor : t.volumeDownColor
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
})
|
|
1250
|
+
}), I.indicators.includes("macd") && y.push(
|
|
1251
|
+
{
|
|
1252
|
+
type: "bar",
|
|
1253
|
+
name: "MACD",
|
|
1254
|
+
xAxisIndex: h,
|
|
1255
|
+
yAxisIndex: h,
|
|
1256
|
+
data: n.map((p) => {
|
|
1257
|
+
var m, A;
|
|
1258
|
+
return {
|
|
1259
|
+
value: ((m = p.macd) == null ? void 0 : m.macd) ?? null,
|
|
1260
|
+
itemStyle: {
|
|
1261
|
+
color: (((A = p.macd) == null ? void 0 : A.macd) ?? 0) >= 0 ? t.upColor : t.downColor
|
|
1262
|
+
}
|
|
1263
|
+
};
|
|
1264
|
+
})
|
|
1265
|
+
},
|
|
1266
|
+
{
|
|
1267
|
+
type: "line",
|
|
1268
|
+
name: "DIF",
|
|
1269
|
+
xAxisIndex: h,
|
|
1270
|
+
yAxisIndex: h,
|
|
1271
|
+
data: n.map((p) => {
|
|
1272
|
+
var m;
|
|
1273
|
+
return ((m = p.macd) == null ? void 0 : m.dif) ?? null;
|
|
1274
|
+
}),
|
|
1275
|
+
symbol: "none",
|
|
1276
|
+
lineStyle: { width: 1, color: "#1890ff" }
|
|
1277
|
+
},
|
|
1278
|
+
{
|
|
1279
|
+
type: "line",
|
|
1280
|
+
name: "DEA",
|
|
1281
|
+
xAxisIndex: h,
|
|
1282
|
+
yAxisIndex: h,
|
|
1283
|
+
data: n.map((p) => {
|
|
1284
|
+
var m;
|
|
1285
|
+
return ((m = p.macd) == null ? void 0 : m.dea) ?? null;
|
|
1286
|
+
}),
|
|
1287
|
+
symbol: "none",
|
|
1288
|
+
lineStyle: { width: 1, color: "#faad14" }
|
|
1289
|
+
}
|
|
1290
|
+
), I.indicators.includes("kdj") && y.push(
|
|
1291
|
+
{
|
|
1292
|
+
type: "line",
|
|
1293
|
+
name: "K",
|
|
1294
|
+
xAxisIndex: h,
|
|
1295
|
+
yAxisIndex: h,
|
|
1296
|
+
data: n.map((p) => {
|
|
1297
|
+
var m;
|
|
1298
|
+
return ((m = p.kdj) == null ? void 0 : m.k) ?? null;
|
|
1299
|
+
}),
|
|
1300
|
+
symbol: "none",
|
|
1301
|
+
lineStyle: { width: 1, color: "#1890ff" }
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
type: "line",
|
|
1305
|
+
name: "D",
|
|
1306
|
+
xAxisIndex: h,
|
|
1307
|
+
yAxisIndex: h,
|
|
1308
|
+
data: n.map((p) => {
|
|
1309
|
+
var m;
|
|
1310
|
+
return ((m = p.kdj) == null ? void 0 : m.d) ?? null;
|
|
1311
|
+
}),
|
|
1312
|
+
symbol: "none",
|
|
1313
|
+
lineStyle: { width: 1, color: "#faad14" }
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
type: "line",
|
|
1317
|
+
name: "J",
|
|
1318
|
+
xAxisIndex: h,
|
|
1319
|
+
yAxisIndex: h,
|
|
1320
|
+
data: n.map((p) => {
|
|
1321
|
+
var m;
|
|
1322
|
+
return ((m = p.kdj) == null ? void 0 : m.j) ?? null;
|
|
1323
|
+
}),
|
|
1324
|
+
symbol: "none",
|
|
1325
|
+
lineStyle: { width: 1, color: "#722ed1" }
|
|
1326
|
+
}
|
|
1327
|
+
), I.indicators.includes("rsi") && l.forEach((p, m) => {
|
|
1328
|
+
y.push({
|
|
1329
|
+
type: "line",
|
|
1330
|
+
name: `RSI${p}`,
|
|
1331
|
+
xAxisIndex: h,
|
|
1332
|
+
yAxisIndex: h,
|
|
1333
|
+
data: n.map((A) => {
|
|
1334
|
+
var C;
|
|
1335
|
+
return ((C = A.rsi) == null ? void 0 : C[`rsi${p}`]) ?? null;
|
|
1336
|
+
}),
|
|
1337
|
+
symbol: "none",
|
|
1338
|
+
lineStyle: { width: 1, color: t.maColors[m] ?? "#1890ff" }
|
|
1339
|
+
});
|
|
1340
|
+
}), I.indicators.includes("wr") && s.forEach((p, m) => {
|
|
1341
|
+
y.push({
|
|
1342
|
+
type: "line",
|
|
1343
|
+
name: `WR${p}`,
|
|
1344
|
+
xAxisIndex: h,
|
|
1345
|
+
yAxisIndex: h,
|
|
1346
|
+
data: n.map((A) => {
|
|
1347
|
+
var C;
|
|
1348
|
+
return ((C = A.wr) == null ? void 0 : C[`wr${p}`]) ?? null;
|
|
1349
|
+
}),
|
|
1350
|
+
symbol: "none",
|
|
1351
|
+
lineStyle: { width: 1, color: t.maColors[m] ?? "#1890ff" }
|
|
1352
|
+
});
|
|
1353
|
+
}), I.indicators.includes("bias") && a.forEach((p, m) => {
|
|
1354
|
+
y.push({
|
|
1355
|
+
type: "line",
|
|
1356
|
+
name: `BIAS${p}`,
|
|
1357
|
+
xAxisIndex: h,
|
|
1358
|
+
yAxisIndex: h,
|
|
1359
|
+
data: n.map((A) => {
|
|
1360
|
+
var C;
|
|
1361
|
+
return ((C = A.bias) == null ? void 0 : C[`bias${p}`]) ?? null;
|
|
1362
|
+
}),
|
|
1363
|
+
symbol: "none",
|
|
1364
|
+
lineStyle: { width: 1, color: t.maColors[m] ?? "#1890ff" }
|
|
1365
|
+
});
|
|
1366
|
+
}), I.indicators.includes("cci") && y.push({
|
|
1367
|
+
type: "line",
|
|
1368
|
+
name: "CCI",
|
|
1369
|
+
xAxisIndex: h,
|
|
1370
|
+
yAxisIndex: h,
|
|
1371
|
+
data: n.map((p) => {
|
|
1372
|
+
var m;
|
|
1373
|
+
return ((m = p.cci) == null ? void 0 : m.cci) ?? null;
|
|
1374
|
+
}),
|
|
1375
|
+
symbol: "none",
|
|
1376
|
+
lineStyle: { width: 1, color: "#1890ff" }
|
|
1377
|
+
}), I.indicators.includes("atr") && y.push({
|
|
1378
|
+
type: "line",
|
|
1379
|
+
name: "ATR",
|
|
1380
|
+
xAxisIndex: h,
|
|
1381
|
+
yAxisIndex: h,
|
|
1382
|
+
data: n.map((p) => {
|
|
1383
|
+
var m;
|
|
1384
|
+
return ((m = p.atr) == null ? void 0 : m.atr) ?? null;
|
|
1385
|
+
}),
|
|
1386
|
+
symbol: "none",
|
|
1387
|
+
lineStyle: { width: 1, color: "#1890ff" }
|
|
1388
|
+
}), I.indicators.includes("obv") && y.push(
|
|
1389
|
+
{
|
|
1390
|
+
type: "line",
|
|
1391
|
+
name: "OBV",
|
|
1392
|
+
xAxisIndex: h,
|
|
1393
|
+
yAxisIndex: h,
|
|
1394
|
+
data: n.map((p) => {
|
|
1395
|
+
var m;
|
|
1396
|
+
return ((m = p.obv) == null ? void 0 : m.obv) ?? null;
|
|
1397
|
+
}),
|
|
1398
|
+
symbol: "none",
|
|
1399
|
+
lineStyle: { width: 1, color: "#1890ff" }
|
|
1400
|
+
},
|
|
1401
|
+
{
|
|
1402
|
+
type: "line",
|
|
1403
|
+
name: "OBV_MA",
|
|
1404
|
+
xAxisIndex: h,
|
|
1405
|
+
yAxisIndex: h,
|
|
1406
|
+
data: n.map((p) => {
|
|
1407
|
+
var m;
|
|
1408
|
+
return ((m = p.obv) == null ? void 0 : m.obvMa) ?? null;
|
|
1409
|
+
}),
|
|
1410
|
+
symbol: "none",
|
|
1411
|
+
lineStyle: { width: 1, color: "#faad14" }
|
|
1412
|
+
}
|
|
1413
|
+
), I.indicators.includes("roc") && y.push(
|
|
1414
|
+
{
|
|
1415
|
+
type: "line",
|
|
1416
|
+
name: "ROC",
|
|
1417
|
+
xAxisIndex: h,
|
|
1418
|
+
yAxisIndex: h,
|
|
1419
|
+
data: n.map((p) => {
|
|
1420
|
+
var m;
|
|
1421
|
+
return ((m = p.roc) == null ? void 0 : m.roc) ?? null;
|
|
1422
|
+
}),
|
|
1423
|
+
symbol: "none",
|
|
1424
|
+
lineStyle: { width: 1, color: "#1890ff" }
|
|
1425
|
+
},
|
|
1426
|
+
{
|
|
1427
|
+
type: "line",
|
|
1428
|
+
name: "ROC_MA",
|
|
1429
|
+
xAxisIndex: h,
|
|
1430
|
+
yAxisIndex: h,
|
|
1431
|
+
data: n.map((p) => {
|
|
1432
|
+
var m;
|
|
1433
|
+
return ((m = p.roc) == null ? void 0 : m.signal) ?? null;
|
|
1434
|
+
}),
|
|
1435
|
+
symbol: "none",
|
|
1436
|
+
lineStyle: { width: 1, color: "#faad14" }
|
|
1437
|
+
}
|
|
1438
|
+
), I.indicators.includes("dmi") && y.push(
|
|
1439
|
+
{
|
|
1440
|
+
type: "line",
|
|
1441
|
+
name: "+DI",
|
|
1442
|
+
xAxisIndex: h,
|
|
1443
|
+
yAxisIndex: h,
|
|
1444
|
+
data: n.map((p) => {
|
|
1445
|
+
var m;
|
|
1446
|
+
return ((m = p.dmi) == null ? void 0 : m.pdi) ?? null;
|
|
1447
|
+
}),
|
|
1448
|
+
symbol: "none",
|
|
1449
|
+
lineStyle: { width: 1, color: t.upColor }
|
|
1450
|
+
},
|
|
1451
|
+
{
|
|
1452
|
+
type: "line",
|
|
1453
|
+
name: "-DI",
|
|
1454
|
+
xAxisIndex: h,
|
|
1455
|
+
yAxisIndex: h,
|
|
1456
|
+
data: n.map((p) => {
|
|
1457
|
+
var m;
|
|
1458
|
+
return ((m = p.dmi) == null ? void 0 : m.mdi) ?? null;
|
|
1459
|
+
}),
|
|
1460
|
+
symbol: "none",
|
|
1461
|
+
lineStyle: { width: 1, color: t.downColor }
|
|
1462
|
+
},
|
|
1463
|
+
{
|
|
1464
|
+
type: "line",
|
|
1465
|
+
name: "ADX",
|
|
1466
|
+
xAxisIndex: h,
|
|
1467
|
+
yAxisIndex: h,
|
|
1468
|
+
data: n.map((p) => {
|
|
1469
|
+
var m;
|
|
1470
|
+
return ((m = p.dmi) == null ? void 0 : m.adx) ?? null;
|
|
1471
|
+
}),
|
|
1472
|
+
symbol: "none",
|
|
1473
|
+
lineStyle: { width: 1, color: "#1890ff" }
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
type: "line",
|
|
1477
|
+
name: "ADXR",
|
|
1478
|
+
xAxisIndex: h,
|
|
1479
|
+
yAxisIndex: h,
|
|
1480
|
+
data: n.map((p) => {
|
|
1481
|
+
var m;
|
|
1482
|
+
return ((m = p.dmi) == null ? void 0 : m.adxr) ?? null;
|
|
1483
|
+
}),
|
|
1484
|
+
symbol: "none",
|
|
1485
|
+
lineStyle: { width: 1, color: "#722ed1", type: "dashed" }
|
|
1486
|
+
}
|
|
1487
|
+
), I.indicators.includes("sar") && y.push({
|
|
1488
|
+
type: "scatter",
|
|
1489
|
+
name: "SAR",
|
|
1490
|
+
xAxisIndex: h,
|
|
1491
|
+
yAxisIndex: h,
|
|
1492
|
+
data: n.map((p) => {
|
|
1493
|
+
var m, A;
|
|
1494
|
+
return {
|
|
1495
|
+
value: ((m = p.sar) == null ? void 0 : m.sar) ?? null,
|
|
1496
|
+
itemStyle: {
|
|
1497
|
+
// 上升趋势用红色,下降趋势用绿色
|
|
1498
|
+
color: ((A = p.sar) == null ? void 0 : A.trend) === 1 ? t.upColor : t.downColor
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1501
|
+
}),
|
|
1502
|
+
symbol: "circle",
|
|
1503
|
+
symbolSize: 4
|
|
1504
|
+
}), I.indicators.includes("kc")) {
|
|
1505
|
+
const [p, m, A] = t.kcColors;
|
|
1506
|
+
y.push(
|
|
1507
|
+
{
|
|
1508
|
+
type: "line",
|
|
1509
|
+
name: "KC上轨",
|
|
1510
|
+
xAxisIndex: h,
|
|
1511
|
+
yAxisIndex: h,
|
|
1512
|
+
data: n.map((C) => {
|
|
1513
|
+
var $;
|
|
1514
|
+
return (($ = C.kc) == null ? void 0 : $.upper) ?? null;
|
|
1515
|
+
}),
|
|
1516
|
+
smooth: !0,
|
|
1517
|
+
symbol: "none",
|
|
1518
|
+
lineStyle: { width: 1, color: p }
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
type: "line",
|
|
1522
|
+
name: "KC中轨",
|
|
1523
|
+
xAxisIndex: h,
|
|
1524
|
+
yAxisIndex: h,
|
|
1525
|
+
data: n.map((C) => {
|
|
1526
|
+
var $;
|
|
1527
|
+
return (($ = C.kc) == null ? void 0 : $.mid) ?? null;
|
|
1528
|
+
}),
|
|
1529
|
+
smooth: !0,
|
|
1530
|
+
symbol: "none",
|
|
1531
|
+
lineStyle: { width: 1, color: m }
|
|
1532
|
+
},
|
|
1533
|
+
{
|
|
1534
|
+
type: "line",
|
|
1535
|
+
name: "KC下轨",
|
|
1536
|
+
xAxisIndex: h,
|
|
1537
|
+
yAxisIndex: h,
|
|
1538
|
+
data: n.map((C) => {
|
|
1539
|
+
var $;
|
|
1540
|
+
return (($ = C.kc) == null ? void 0 : $.lower) ?? null;
|
|
1541
|
+
}),
|
|
1542
|
+
smooth: !0,
|
|
1543
|
+
symbol: "none",
|
|
1544
|
+
lineStyle: { width: 1, color: A }
|
|
1545
|
+
}
|
|
1546
|
+
);
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
return x.series = y, x;
|
|
1550
|
+
}
|
|
1551
|
+
function dt(e, n, t = "safeMerge") {
|
|
1552
|
+
if (!n) return e;
|
|
1553
|
+
if (t === "replace") return n;
|
|
1554
|
+
const i = { ...e };
|
|
1555
|
+
for (const u of Object.keys(n)) {
|
|
1556
|
+
const r = n[u];
|
|
1557
|
+
r !== void 0 && (Array.isArray(r) ? i[u] = r : typeof r == "object" && r !== null ? i[u] = {
|
|
1558
|
+
...i[u],
|
|
1559
|
+
...r
|
|
1560
|
+
} : i[u] = r);
|
|
1561
|
+
}
|
|
1562
|
+
return i;
|
|
1563
|
+
}
|
|
1564
|
+
const In = "_container_119o2_1", An = "_spinner_119o2_11", Cn = "_dot_119o2_16", $n = "_text_119o2_43", K = {
|
|
1565
|
+
container: In,
|
|
1566
|
+
spinner: An,
|
|
1567
|
+
dot: Cn,
|
|
1568
|
+
text: $n
|
|
1569
|
+
};
|
|
1570
|
+
function ht({ text: e = "加载中..." }) {
|
|
1571
|
+
return /* @__PURE__ */ M("div", { className: K.container, children: [
|
|
1572
|
+
/* @__PURE__ */ M("div", { className: K.spinner, children: [
|
|
1573
|
+
/* @__PURE__ */ w("div", { className: K.dot }),
|
|
1574
|
+
/* @__PURE__ */ w("div", { className: K.dot }),
|
|
1575
|
+
/* @__PURE__ */ w("div", { className: K.dot })
|
|
1576
|
+
] }),
|
|
1577
|
+
/* @__PURE__ */ w("span", { className: K.text, children: e })
|
|
1578
|
+
] });
|
|
1579
|
+
}
|
|
1580
|
+
const Sn = "_container_1xu4v_1", Mn = "_group_1xu4v_10", kn = "_button_1xu4v_15", Dn = "_active_1xu4v_30", ne = {
|
|
1581
|
+
container: Sn,
|
|
1582
|
+
group: Mn,
|
|
1583
|
+
button: kn,
|
|
1584
|
+
active: Dn
|
|
1585
|
+
}, _n = [
|
|
1586
|
+
{
|
|
1587
|
+
label: "分时",
|
|
1588
|
+
periods: [
|
|
1589
|
+
{ value: "timeline", label: "分时" },
|
|
1590
|
+
{ value: "timeline5", label: "五日" }
|
|
1591
|
+
]
|
|
1592
|
+
},
|
|
1593
|
+
{
|
|
1594
|
+
label: "周期",
|
|
1595
|
+
periods: [
|
|
1596
|
+
{ value: "daily", label: "日K" },
|
|
1597
|
+
{ value: "weekly", label: "周K" },
|
|
1598
|
+
{ value: "monthly", label: "月K" }
|
|
1599
|
+
]
|
|
1600
|
+
},
|
|
1601
|
+
{
|
|
1602
|
+
label: "分钟",
|
|
1603
|
+
periods: [
|
|
1604
|
+
{ value: "1", label: "1分" },
|
|
1605
|
+
{ value: "5", label: "5分" },
|
|
1606
|
+
{ value: "15", label: "15分" },
|
|
1607
|
+
{ value: "30", label: "30分" },
|
|
1608
|
+
{ value: "60", label: "60分" }
|
|
1609
|
+
]
|
|
1610
|
+
}
|
|
1611
|
+
];
|
|
1612
|
+
function mt({ value: e, onChange: n }) {
|
|
1613
|
+
return /* @__PURE__ */ w("div", { className: ne.container, children: _n.map((t) => /* @__PURE__ */ w("div", { className: ne.group, children: t.periods.map((i) => /* @__PURE__ */ w(
|
|
1614
|
+
"button",
|
|
1615
|
+
{
|
|
1616
|
+
type: "button",
|
|
1617
|
+
className: `${ne.button} ${e === i.value ? ne.active : ""}`,
|
|
1618
|
+
onClick: () => n(i.value),
|
|
1619
|
+
children: i.label
|
|
1620
|
+
},
|
|
1621
|
+
i.value
|
|
1622
|
+
)) }, t.label)) });
|
|
1623
|
+
}
|
|
1624
|
+
const Nn = "_container_1fbmi_1", jn = "_button_1fbmi_11", Ln = "_active_1fbmi_27", Rn = "_divider_1fbmi_33", O = {
|
|
1625
|
+
container: Nn,
|
|
1626
|
+
button: jn,
|
|
1627
|
+
active: Ln,
|
|
1628
|
+
divider: Rn
|
|
1629
|
+
}, Se = [
|
|
1630
|
+
{ value: "ma", label: "MA", group: "main" },
|
|
1631
|
+
{ value: "boll", label: "BOLL", group: "main" },
|
|
1632
|
+
{ value: "sar", label: "SAR", group: "main" },
|
|
1633
|
+
{ value: "kc", label: "KC", group: "main" }
|
|
1634
|
+
], Tn = [
|
|
1635
|
+
{ value: "volume", label: "成交量", group: "sub" },
|
|
1636
|
+
{ value: "macd", label: "MACD", group: "sub" },
|
|
1637
|
+
{ value: "kdj", label: "KDJ", group: "sub" },
|
|
1638
|
+
{ value: "rsi", label: "RSI", group: "sub" },
|
|
1639
|
+
{ value: "wr", label: "WR", group: "sub" },
|
|
1640
|
+
{ value: "bias", label: "BIAS", group: "sub" },
|
|
1641
|
+
{ value: "cci", label: "CCI", group: "sub" },
|
|
1642
|
+
{ value: "atr", label: "ATR", group: "sub" },
|
|
1643
|
+
{ value: "obv", label: "OBV", group: "sub" },
|
|
1644
|
+
{ value: "roc", label: "ROC", group: "sub" },
|
|
1645
|
+
{ value: "dmi", label: "DMI", group: "sub" }
|
|
1646
|
+
];
|
|
1647
|
+
function he(e) {
|
|
1648
|
+
return Se.find((t) => t.value === e) ? "main" : "sub";
|
|
1649
|
+
}
|
|
1650
|
+
function ft({
|
|
1651
|
+
value: e,
|
|
1652
|
+
onChange: n,
|
|
1653
|
+
maxSubPanes: t = 3,
|
|
1654
|
+
maxMainIndicators: i = 2
|
|
1655
|
+
}) {
|
|
1656
|
+
const u = (r) => {
|
|
1657
|
+
const c = he(r);
|
|
1658
|
+
if (e.includes(r))
|
|
1659
|
+
n(e.filter((o) => o !== r));
|
|
1660
|
+
else if (c === "main") {
|
|
1661
|
+
const o = e.filter((l) => he(l) === "main");
|
|
1662
|
+
if (o.length >= i) {
|
|
1663
|
+
const l = o[o.length - 1], s = e.filter((a) => a !== l);
|
|
1664
|
+
n([...s, r]);
|
|
1665
|
+
} else
|
|
1666
|
+
n([...e, r]);
|
|
1667
|
+
} else {
|
|
1668
|
+
const o = e.filter((l) => he(l) === "sub");
|
|
1669
|
+
if (o.length >= t) {
|
|
1670
|
+
const l = o[o.length - 1], s = e.filter((a) => a !== l);
|
|
1671
|
+
n([...s, r]);
|
|
1672
|
+
} else
|
|
1673
|
+
n([...e, r]);
|
|
1674
|
+
}
|
|
1675
|
+
};
|
|
1676
|
+
return /* @__PURE__ */ M("div", { className: O.container, children: [
|
|
1677
|
+
Se.map((r) => /* @__PURE__ */ w(
|
|
1678
|
+
"button",
|
|
1679
|
+
{
|
|
1680
|
+
type: "button",
|
|
1681
|
+
className: `${O.button} ${e.includes(r.value) ? O.active : ""}`,
|
|
1682
|
+
onClick: () => u(r.value),
|
|
1683
|
+
children: r.label
|
|
1684
|
+
},
|
|
1685
|
+
r.value
|
|
1686
|
+
)),
|
|
1687
|
+
/* @__PURE__ */ w("div", { className: O.divider }),
|
|
1688
|
+
Tn.map((r) => /* @__PURE__ */ w(
|
|
1689
|
+
"button",
|
|
1690
|
+
{
|
|
1691
|
+
type: "button",
|
|
1692
|
+
className: `${O.button} ${e.includes(r.value) ? O.active : ""}`,
|
|
1693
|
+
onClick: () => u(r.value),
|
|
1694
|
+
children: r.label
|
|
1695
|
+
},
|
|
1696
|
+
r.value
|
|
1697
|
+
))
|
|
1698
|
+
] });
|
|
1699
|
+
}
|
|
1700
|
+
const Pn = "_container_2tswg_1", Bn = "_group_2tswg_10", Kn = "_divider_2tswg_16", On = "_spacer_2tswg_23", zn = "_iconButton_2tswg_27", En = "_textButton_2tswg_51", Vn = "_active_2tswg_67", S = {
|
|
1701
|
+
container: Pn,
|
|
1702
|
+
group: Bn,
|
|
1703
|
+
divider: Kn,
|
|
1704
|
+
spacer: On,
|
|
1705
|
+
iconButton: zn,
|
|
1706
|
+
textButton: En,
|
|
1707
|
+
active: Vn
|
|
1708
|
+
}, Fn = [
|
|
1709
|
+
{ value: "", label: "不复权" },
|
|
1710
|
+
{ value: "qfq", label: "前复权" },
|
|
1711
|
+
{ value: "hfq", label: "后复权" }
|
|
1712
|
+
];
|
|
1713
|
+
function pt({
|
|
1714
|
+
adjust: e,
|
|
1715
|
+
onAdjustChange: n,
|
|
1716
|
+
canUndo: t,
|
|
1717
|
+
canRedo: i,
|
|
1718
|
+
onUndo: u,
|
|
1719
|
+
onRedo: r,
|
|
1720
|
+
onZoomIn: c,
|
|
1721
|
+
onZoomOut: o,
|
|
1722
|
+
onPanLeft: l,
|
|
1723
|
+
onPanRight: s,
|
|
1724
|
+
onReset: a,
|
|
1725
|
+
onFullscreen: d
|
|
1726
|
+
}) {
|
|
1727
|
+
return /* @__PURE__ */ M("div", { className: S.container, children: [
|
|
1728
|
+
/* @__PURE__ */ M("div", { className: S.group, children: [
|
|
1729
|
+
/* @__PURE__ */ w(
|
|
1730
|
+
"button",
|
|
1731
|
+
{
|
|
1732
|
+
type: "button",
|
|
1733
|
+
className: S.iconButton,
|
|
1734
|
+
onClick: u,
|
|
1735
|
+
disabled: !t,
|
|
1736
|
+
title: "撤销",
|
|
1737
|
+
children: /* @__PURE__ */ w("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "currentColor", children: /* @__PURE__ */ w("path", { d: "M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z" }) })
|
|
1738
|
+
}
|
|
1739
|
+
),
|
|
1740
|
+
/* @__PURE__ */ w(
|
|
1741
|
+
"button",
|
|
1742
|
+
{
|
|
1743
|
+
type: "button",
|
|
1744
|
+
className: S.iconButton,
|
|
1745
|
+
onClick: r,
|
|
1746
|
+
disabled: !i,
|
|
1747
|
+
title: "重做",
|
|
1748
|
+
children: /* @__PURE__ */ w("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "currentColor", children: /* @__PURE__ */ w("path", { d: "M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z" }) })
|
|
1749
|
+
}
|
|
1750
|
+
)
|
|
1751
|
+
] }),
|
|
1752
|
+
/* @__PURE__ */ w("div", { className: S.divider }),
|
|
1753
|
+
/* @__PURE__ */ M("div", { className: S.group, children: [
|
|
1754
|
+
/* @__PURE__ */ w(
|
|
1755
|
+
"button",
|
|
1756
|
+
{
|
|
1757
|
+
type: "button",
|
|
1758
|
+
className: S.iconButton,
|
|
1759
|
+
onClick: c,
|
|
1760
|
+
title: "放大",
|
|
1761
|
+
children: /* @__PURE__ */ w("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "currentColor", children: /* @__PURE__ */ w("path", { d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" }) })
|
|
1762
|
+
}
|
|
1763
|
+
),
|
|
1764
|
+
/* @__PURE__ */ w(
|
|
1765
|
+
"button",
|
|
1766
|
+
{
|
|
1767
|
+
type: "button",
|
|
1768
|
+
className: S.iconButton,
|
|
1769
|
+
onClick: o,
|
|
1770
|
+
title: "缩小",
|
|
1771
|
+
children: /* @__PURE__ */ w("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "currentColor", children: /* @__PURE__ */ w("path", { d: "M19 13H5v-2h14v2z" }) })
|
|
1772
|
+
}
|
|
1773
|
+
)
|
|
1774
|
+
] }),
|
|
1775
|
+
/* @__PURE__ */ w("div", { className: S.divider }),
|
|
1776
|
+
/* @__PURE__ */ M("div", { className: S.group, children: [
|
|
1777
|
+
/* @__PURE__ */ w(
|
|
1778
|
+
"button",
|
|
1779
|
+
{
|
|
1780
|
+
type: "button",
|
|
1781
|
+
className: S.iconButton,
|
|
1782
|
+
onClick: l,
|
|
1783
|
+
title: "向左",
|
|
1784
|
+
children: /* @__PURE__ */ w("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "currentColor", children: /* @__PURE__ */ w("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }) })
|
|
1785
|
+
}
|
|
1786
|
+
),
|
|
1787
|
+
/* @__PURE__ */ w(
|
|
1788
|
+
"button",
|
|
1789
|
+
{
|
|
1790
|
+
type: "button",
|
|
1791
|
+
className: S.iconButton,
|
|
1792
|
+
onClick: s,
|
|
1793
|
+
title: "向右",
|
|
1794
|
+
children: /* @__PURE__ */ w("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "currentColor", children: /* @__PURE__ */ w("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" }) })
|
|
1795
|
+
}
|
|
1796
|
+
)
|
|
1797
|
+
] }),
|
|
1798
|
+
/* @__PURE__ */ w("div", { className: S.divider }),
|
|
1799
|
+
/* @__PURE__ */ w("div", { className: S.group, children: /* @__PURE__ */ w(
|
|
1800
|
+
"button",
|
|
1801
|
+
{
|
|
1802
|
+
type: "button",
|
|
1803
|
+
className: S.textButton,
|
|
1804
|
+
onClick: a,
|
|
1805
|
+
title: "重置",
|
|
1806
|
+
children: "重置"
|
|
1807
|
+
}
|
|
1808
|
+
) }),
|
|
1809
|
+
/* @__PURE__ */ w("div", { className: S.spacer }),
|
|
1810
|
+
/* @__PURE__ */ w("div", { className: S.group, children: Fn.map((f) => /* @__PURE__ */ w(
|
|
1811
|
+
"button",
|
|
1812
|
+
{
|
|
1813
|
+
type: "button",
|
|
1814
|
+
className: `${S.textButton} ${e === f.value ? S.active : ""}`,
|
|
1815
|
+
onClick: () => n(f.value),
|
|
1816
|
+
children: f.label
|
|
1817
|
+
},
|
|
1818
|
+
f.value
|
|
1819
|
+
)) }),
|
|
1820
|
+
d && /* @__PURE__ */ M(Ae, { children: [
|
|
1821
|
+
/* @__PURE__ */ w("div", { className: S.divider }),
|
|
1822
|
+
/* @__PURE__ */ w(
|
|
1823
|
+
"button",
|
|
1824
|
+
{
|
|
1825
|
+
type: "button",
|
|
1826
|
+
className: S.iconButton,
|
|
1827
|
+
onClick: d,
|
|
1828
|
+
title: "全屏",
|
|
1829
|
+
children: /* @__PURE__ */ w("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "currentColor", children: /* @__PURE__ */ w("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" }) })
|
|
1830
|
+
}
|
|
1831
|
+
)
|
|
1832
|
+
] })
|
|
1833
|
+
] });
|
|
1834
|
+
}
|
|
1835
|
+
const Hn = "_container_1vdme_1", Un = "_group_1vdme_11", qn = "_item_1vdme_18", k = {
|
|
1836
|
+
container: Hn,
|
|
1837
|
+
group: Un,
|
|
1838
|
+
item: qn
|
|
1839
|
+
};
|
|
1840
|
+
function gt({ data: e, indicators: n, hoverIndex: t, theme: i }) {
|
|
1841
|
+
const u = i.maColors, r = i.bollColors, c = i.kcColors, o = pe(() => {
|
|
1842
|
+
const f = t ?? e.length - 1, g = e[f];
|
|
1843
|
+
return g || null;
|
|
1844
|
+
}, [e, t]);
|
|
1845
|
+
if (!o)
|
|
1846
|
+
return null;
|
|
1847
|
+
const l = n.includes("ma"), s = n.includes("boll"), a = n.includes("sar"), d = n.includes("kc");
|
|
1848
|
+
return !l && !s && !a && !d ? null : /* @__PURE__ */ M("div", { className: k.container, children: [
|
|
1849
|
+
l && o.ma && /* @__PURE__ */ w("div", { className: k.group, children: q(o.ma, "ma").map(([f, g], x) => {
|
|
1850
|
+
const y = u[x] ?? "#999";
|
|
1851
|
+
return /* @__PURE__ */ M("span", { className: k.item, style: { color: y }, children: [
|
|
1852
|
+
Y(f),
|
|
1853
|
+
": ",
|
|
1854
|
+
v(g)
|
|
1855
|
+
] }, f);
|
|
1856
|
+
}) }),
|
|
1857
|
+
s && o.boll && /* @__PURE__ */ M("div", { className: k.group, children: [
|
|
1858
|
+
/* @__PURE__ */ M("span", { className: k.item, style: { color: r[0] }, children: [
|
|
1859
|
+
"UPPER: ",
|
|
1860
|
+
v(o.boll.upper)
|
|
1861
|
+
] }),
|
|
1862
|
+
/* @__PURE__ */ M("span", { className: k.item, style: { color: r[1] }, children: [
|
|
1863
|
+
"MID: ",
|
|
1864
|
+
v(o.boll.mid)
|
|
1865
|
+
] }),
|
|
1866
|
+
/* @__PURE__ */ M("span", { className: k.item, style: { color: r[2] }, children: [
|
|
1867
|
+
"LOWER: ",
|
|
1868
|
+
v(o.boll.lower)
|
|
1869
|
+
] })
|
|
1870
|
+
] }),
|
|
1871
|
+
a && o.sar && /* @__PURE__ */ w("div", { className: k.group, children: /* @__PURE__ */ M(
|
|
1872
|
+
"span",
|
|
1873
|
+
{
|
|
1874
|
+
className: k.item,
|
|
1875
|
+
style: { color: o.sar.trend === 1 ? i.upColor : i.downColor },
|
|
1876
|
+
children: [
|
|
1877
|
+
"SAR: ",
|
|
1878
|
+
v(o.sar.sar),
|
|
1879
|
+
" ",
|
|
1880
|
+
o.sar.trend === 1 ? "↑" : "↓"
|
|
1881
|
+
]
|
|
1882
|
+
}
|
|
1883
|
+
) }),
|
|
1884
|
+
d && o.kc && /* @__PURE__ */ M("div", { className: k.group, children: [
|
|
1885
|
+
/* @__PURE__ */ M("span", { className: k.item, style: { color: c[0] }, children: [
|
|
1886
|
+
"KC上: ",
|
|
1887
|
+
v(o.kc.upper)
|
|
1888
|
+
] }),
|
|
1889
|
+
/* @__PURE__ */ M("span", { className: k.item, style: { color: c[1] }, children: [
|
|
1890
|
+
"KC中: ",
|
|
1891
|
+
v(o.kc.mid)
|
|
1892
|
+
] }),
|
|
1893
|
+
/* @__PURE__ */ M("span", { className: k.item, style: { color: c[2] }, children: [
|
|
1894
|
+
"KC下: ",
|
|
1895
|
+
v(o.kc.lower)
|
|
1896
|
+
] })
|
|
1897
|
+
] })
|
|
1898
|
+
] });
|
|
1899
|
+
}
|
|
1900
|
+
const Yn = "_title_p093j_1", Wn = "_label_p093j_16", Gn = "_value_p093j_21", me = {
|
|
1901
|
+
title: Yn,
|
|
1902
|
+
label: Wn,
|
|
1903
|
+
value: Gn
|
|
1904
|
+
}, Jn = {
|
|
1905
|
+
ma: "MA",
|
|
1906
|
+
boll: "BOLL",
|
|
1907
|
+
sar: "SAR",
|
|
1908
|
+
kc: "KC",
|
|
1909
|
+
volume: "成交量",
|
|
1910
|
+
macd: "MACD",
|
|
1911
|
+
kdj: "KDJ",
|
|
1912
|
+
rsi: "RSI",
|
|
1913
|
+
wr: "WR",
|
|
1914
|
+
bias: "BIAS",
|
|
1915
|
+
cci: "CCI",
|
|
1916
|
+
atr: "ATR",
|
|
1917
|
+
obv: "OBV",
|
|
1918
|
+
roc: "ROC",
|
|
1919
|
+
dmi: "DMI"
|
|
1920
|
+
};
|
|
1921
|
+
function Zn(e, n) {
|
|
1922
|
+
if (!n) return "";
|
|
1923
|
+
switch (e) {
|
|
1924
|
+
case "volume":
|
|
1925
|
+
return `VOL: ${T(n.volume)}`;
|
|
1926
|
+
case "macd":
|
|
1927
|
+
return n.macd ? `DIF: ${v(n.macd.dif)} DEA: ${v(n.macd.dea)} MACD: ${v(n.macd.macd)}` : "";
|
|
1928
|
+
case "kdj":
|
|
1929
|
+
return n.kdj ? `K: ${v(n.kdj.k)} D: ${v(n.kdj.d)} J: ${v(n.kdj.j)}` : "";
|
|
1930
|
+
case "rsi":
|
|
1931
|
+
return n.rsi ? q(n.rsi, "rsi").map(([t, i]) => `${Y(t)}: ${v(i)}`).join(" ") : "";
|
|
1932
|
+
case "wr":
|
|
1933
|
+
return n.wr ? q(n.wr, "wr").map(([t, i]) => `${Y(t)}: ${v(i)}`).join(" ") : "";
|
|
1934
|
+
case "bias":
|
|
1935
|
+
return n.bias ? q(n.bias, "bias").map(([t, i]) => `${Y(t)}: ${v(i)}`).join(" ") : "";
|
|
1936
|
+
case "cci":
|
|
1937
|
+
return n.cci ? `CCI: ${v(n.cci.cci)}` : "";
|
|
1938
|
+
case "atr":
|
|
1939
|
+
return n.atr ? `ATR: ${v(n.atr.atr)}` : "";
|
|
1940
|
+
case "obv":
|
|
1941
|
+
return n.obv ? `OBV: ${T(n.obv.obv)} MA: ${T(n.obv.obvMa)}` : "";
|
|
1942
|
+
case "roc":
|
|
1943
|
+
return n.roc ? `ROC: ${v(n.roc.roc)} SIGNAL: ${v(n.roc.signal)}` : "";
|
|
1944
|
+
case "dmi":
|
|
1945
|
+
return n.dmi ? `+DI: ${v(n.dmi.pdi)} -DI: ${v(n.dmi.mdi)} ADX: ${v(n.dmi.adx)}` : "";
|
|
1946
|
+
case "sar":
|
|
1947
|
+
return n.sar ? `SAR: ${v(n.sar.sar)} ${n.sar.trend === 1 ? "↑" : "↓"}` : "";
|
|
1948
|
+
case "kc":
|
|
1949
|
+
return n.kc ? `上: ${v(n.kc.upper)} 中: ${v(n.kc.mid)} 下: ${v(n.kc.lower)}` : "";
|
|
1950
|
+
default:
|
|
1951
|
+
return "";
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
function Xn(e, n) {
|
|
1955
|
+
return $e(e, n).map((i) => ({ top: i.top, height: i.height }));
|
|
1956
|
+
}
|
|
1957
|
+
function vt({ panes: e, data: n, hoverIndex: t, containerHeight: i }) {
|
|
1958
|
+
const u = t ?? n.length - 1, r = n[u], c = pe(
|
|
1959
|
+
() => Xn(e, i),
|
|
1960
|
+
[e, i]
|
|
1961
|
+
), o = e.slice(1), l = c.slice(1);
|
|
1962
|
+
return o.length === 0 ? null : /* @__PURE__ */ w(Ae, { children: o.map((s, a) => {
|
|
1963
|
+
if (s.indicators.length === 0) return null;
|
|
1964
|
+
const d = s.indicators.map((x) => Jn[x] || x.toUpperCase()).join(" / "), f = s.indicators.map((x) => Zn(x, r)).filter(Boolean).join(" | "), g = l[a];
|
|
1965
|
+
return /* @__PURE__ */ M(
|
|
1966
|
+
"div",
|
|
1967
|
+
{
|
|
1968
|
+
className: me.title,
|
|
1969
|
+
style: { top: (g == null ? void 0 : g.top) ?? 0 },
|
|
1970
|
+
children: [
|
|
1971
|
+
/* @__PURE__ */ w("span", { className: me.label, children: d }),
|
|
1972
|
+
f && /* @__PURE__ */ w("span", { className: me.value, children: f })
|
|
1973
|
+
]
|
|
1974
|
+
},
|
|
1975
|
+
s.id
|
|
1976
|
+
);
|
|
1977
|
+
}) });
|
|
1978
|
+
}
|
|
1979
|
+
export {
|
|
1980
|
+
Ye as A,
|
|
1981
|
+
gn as B,
|
|
1982
|
+
pn as C,
|
|
1983
|
+
bn as D,
|
|
1984
|
+
ut as E,
|
|
1985
|
+
vn as F,
|
|
1986
|
+
mn as G,
|
|
1987
|
+
fn as H,
|
|
1988
|
+
gt as I,
|
|
1989
|
+
ht as L,
|
|
1990
|
+
mt as P,
|
|
1991
|
+
vt as S,
|
|
1992
|
+
pt as T,
|
|
1993
|
+
T as a,
|
|
1994
|
+
rt as b,
|
|
1995
|
+
ct as c,
|
|
1996
|
+
yn as d,
|
|
1997
|
+
at as e,
|
|
1998
|
+
v as f,
|
|
1999
|
+
wn as g,
|
|
2000
|
+
ft as h,
|
|
2001
|
+
Ce as i,
|
|
2002
|
+
We as j,
|
|
2003
|
+
He as k,
|
|
2004
|
+
Ge as l,
|
|
2005
|
+
dt as m,
|
|
2006
|
+
Xe as n,
|
|
2007
|
+
E as o,
|
|
2008
|
+
en as p,
|
|
2009
|
+
Ue as q,
|
|
2010
|
+
Ve as r,
|
|
2011
|
+
Fe as s,
|
|
2012
|
+
Je as t,
|
|
2013
|
+
st as u,
|
|
2014
|
+
Ze as v,
|
|
2015
|
+
qe as w,
|
|
2016
|
+
Qe as x,
|
|
2017
|
+
G as y,
|
|
2018
|
+
Ee as z
|
|
2019
|
+
};
|