st-comp 0.0.30 → 0.0.32
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/lib/bundle.js +6524 -6487
- package/lib/bundle.umd.cjs +37 -37
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/packages/Kline/index.vue +1 -6
- package/packages/Kline/option.ts +133 -106
- package/packages/Kline/utils.ts +261 -223
- package/src/pages/Kline/api.ts +15 -1
- package/src/pages/Kline/components/SingleCycleSingleVariety.vue +206 -88
- package/src/pages/TreeMap/index.vue +3 -2
- package/vite.config.ts +0 -5
package/src/pages/Kline/api.ts
CHANGED
|
@@ -68,4 +68,18 @@ export const getNetPositionData = async (data: any) => {
|
|
|
68
68
|
url: 'http://192.168.12.49:88/invest/analysis/queryVarietyNetPositionValue',
|
|
69
69
|
data
|
|
70
70
|
})
|
|
71
|
-
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @description: 绩效-获取需要连线多笔的买卖点数据
|
|
75
|
+
*/
|
|
76
|
+
export const queryPairedRecordByVariety = async (data: any) => {
|
|
77
|
+
return axios({
|
|
78
|
+
method: 'post',
|
|
79
|
+
headers: {
|
|
80
|
+
token: 'e077632625ea4b11506db312e186dd06',
|
|
81
|
+
},
|
|
82
|
+
url: 'http://192.168.12.49:88/invest/analysis/queryPairedRecordByVariety',
|
|
83
|
+
data
|
|
84
|
+
})
|
|
85
|
+
}
|
|
@@ -7,7 +7,7 @@ import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
|
|
|
7
7
|
import { ElMessage } from "element-plus";
|
|
8
8
|
import "element-plus/dist/index.css";
|
|
9
9
|
import { formatValue } from "../../../../packages/Kline/utils";
|
|
10
|
-
import { getSingleCycleSingleVariety, getDict, getNetPositionData } from "../api.ts";
|
|
10
|
+
import { getSingleCycleSingleVariety, getDict, getNetPositionData, queryPairedRecordByVariety } from "../api.ts";
|
|
11
11
|
import { mainIndicatorList } from "st-func";
|
|
12
12
|
|
|
13
13
|
dayjs.extend(isSameOrAfter);
|
|
@@ -77,7 +77,7 @@ const config = ref({
|
|
|
77
77
|
close: true,
|
|
78
78
|
business: false,
|
|
79
79
|
riseAndFall: true,
|
|
80
|
-
netPosition: true
|
|
80
|
+
netPosition: true,
|
|
81
81
|
},
|
|
82
82
|
dynamicLoadConfig: {
|
|
83
83
|
historyVisible: true,
|
|
@@ -157,7 +157,7 @@ const componentInit = async () => {
|
|
|
157
157
|
await getDictCycle();
|
|
158
158
|
await getKlineData();
|
|
159
159
|
await getKlinePointData();
|
|
160
|
-
await getKlineNetPositionData()
|
|
160
|
+
await getKlineNetPositionData();
|
|
161
161
|
loading.value = false;
|
|
162
162
|
await getKlineExtendData();
|
|
163
163
|
} catch (error) {
|
|
@@ -204,93 +204,213 @@ const getKlineData = async () => {
|
|
|
204
204
|
* @description: 获取点位数据
|
|
205
205
|
*/
|
|
206
206
|
const getKlinePointData = async () => {
|
|
207
|
-
//
|
|
208
|
-
const
|
|
207
|
+
// ------
|
|
208
|
+
const params = {
|
|
209
|
+
analyseId: 2229,
|
|
210
|
+
cycle: cycle.value,
|
|
211
|
+
ifStock: 0,
|
|
212
|
+
varietyName: "燃料油",
|
|
213
|
+
};
|
|
214
|
+
const res = await queryPairedRecordByVariety(params);
|
|
215
|
+
const body = res.data.body;
|
|
216
|
+
// console.log(body);
|
|
217
|
+
const formatData = [];
|
|
218
|
+
const markLine = [];
|
|
219
|
+
// 格式化: 每一笔订单都有开,平两对应的点
|
|
220
|
+
body.forEach((item) => {
|
|
221
|
+
let openTime = klineData.value.find((i) => dayjs(i[0]).isSameOrAfter(item.openTime))[0];
|
|
222
|
+
let closeTime = klineData.value.find((i) => dayjs(i[0]).isSameOrAfter(item.closeTime))[0];
|
|
223
|
+
// 日线
|
|
224
|
+
if (cycle.value == 6) {
|
|
225
|
+
// 只看年月日
|
|
226
|
+
const toYMD = (value) => {
|
|
227
|
+
return dayjs(value).format("YYYY-MM-DD");
|
|
228
|
+
};
|
|
229
|
+
openTime = klineData.value.find((i) => dayjs(toYMD(i[0])).isSameOrAfter(toYMD(item.openTime)))[0];
|
|
230
|
+
closeTime = klineData.value.find((i) => dayjs(toYMD(i[0])).isSameOrAfter(toYMD(item.closeTime)))[0];
|
|
231
|
+
}
|
|
232
|
+
// 周线
|
|
233
|
+
if (cycle.value == 7) {
|
|
234
|
+
// 只看这个时间点的周五
|
|
235
|
+
}
|
|
236
|
+
// 月线
|
|
237
|
+
if (cycle.value == 8) {
|
|
238
|
+
// 只看这个时间点的年月
|
|
239
|
+
const toYM = (value) => {
|
|
240
|
+
return dayjs(value).format("YYYY-MM");
|
|
241
|
+
};
|
|
242
|
+
openTime = klineData.value.find((i) => dayjs(toYM(i[0])).isSameOrAfter(toYM(item.openTime)))[0];
|
|
243
|
+
closeTime = klineData.value.find((i) => dayjs(toYM(i[0])).isSameOrAfter(toYM(item.closeTime)))[0];
|
|
244
|
+
}
|
|
245
|
+
const openItem = {
|
|
246
|
+
tradeAction: "开",
|
|
247
|
+
direction: item.tradeDirection ? "空" : "多", // 交易方向
|
|
248
|
+
tradeType: `开${item.tradeDirection ? "空" : "多"}`,
|
|
249
|
+
amount: item.tradeVolume, // 手数
|
|
250
|
+
part: null, // 份数
|
|
251
|
+
profitAndLoss: item.profitAndLoss,
|
|
252
|
+
time: openTime, // 匹配到X轴的时间
|
|
253
|
+
markLineTarget: []
|
|
254
|
+
};
|
|
255
|
+
// 连线逻辑,当天的不连
|
|
256
|
+
if (openTime !== closeTime) {
|
|
257
|
+
openItem.markLineTarget = [
|
|
258
|
+
{
|
|
259
|
+
time: closeTime,
|
|
260
|
+
name: `平${item.tradeDirection ? "空" : "多"}`,
|
|
261
|
+
lineStyle: {
|
|
262
|
+
color: item.profitAndLoss >= 0 ? '#FF0000' : '#389e0d'
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
];
|
|
266
|
+
}
|
|
267
|
+
const closeItem = {
|
|
268
|
+
tradeAction: "平",
|
|
269
|
+
direction: item.tradeDirection ? "空" : "多", // 交易方向
|
|
270
|
+
tradeType: `平${item.tradeDirection ? "空" : "多"}`,
|
|
271
|
+
amount: item.tradeVolume, // 手数
|
|
272
|
+
part: null, // 份数
|
|
273
|
+
profitAndLoss: item.profitAndLoss,
|
|
274
|
+
time: closeTime, // 匹配到X轴的时间
|
|
275
|
+
};
|
|
276
|
+
formatData.push(openItem);
|
|
277
|
+
formatData.push(closeItem);
|
|
278
|
+
// 连线数据
|
|
279
|
+
// markLine.push([
|
|
280
|
+
// {
|
|
281
|
+
// coord: [openTime, 1],
|
|
282
|
+
// },
|
|
283
|
+
// {
|
|
284
|
+
// coord: [closeTime, 1],
|
|
285
|
+
// },
|
|
286
|
+
// ]);
|
|
287
|
+
});
|
|
288
|
+
// 数据合并
|
|
289
|
+
const noRepeatMap = new Map([]);
|
|
290
|
+
formatData.forEach((i) => {
|
|
291
|
+
const { time, tradeType } = i;
|
|
292
|
+
const key = time + tradeType;
|
|
293
|
+
// 判断这个节点是否已存在数据
|
|
294
|
+
if (noRepeatMap.has(key)) {
|
|
295
|
+
// 已存在,说明节点重复,进行数据合并
|
|
296
|
+
const oldItem = noRepeatMap.get(key);
|
|
297
|
+
i.amount += oldItem.amount;
|
|
298
|
+
i.part += oldItem.part;
|
|
299
|
+
i.profitAndLoss += oldItem.profitAndLoss;
|
|
300
|
+
if (i.markLineTarget) {
|
|
301
|
+
// 如果新的markLineTarget没有存在过于老的markLineTarget中
|
|
302
|
+
const isRepeat = oldItem.markLineTarget.find(
|
|
303
|
+
(item) => item.time === i.markLineTarget[0].time && item.name === i.markLineTarget[0].name
|
|
304
|
+
);
|
|
305
|
+
if (!isRepeat) {
|
|
306
|
+
i.markLineTarget = [...i.markLineTarget, ...oldItem.markLineTarget];
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
i.tooltip = `<div>${tradeType}: ${i.amount}手<div>`;
|
|
311
|
+
// 如果是平仓则需要展示盈亏
|
|
312
|
+
if (i.tradeAction === "平") {
|
|
313
|
+
i.tooltip += `盈亏:${i.profitAndLoss.toFixed(2)}`;
|
|
314
|
+
}
|
|
315
|
+
noRepeatMap.set(key, i);
|
|
316
|
+
});
|
|
317
|
+
originPointData.value = [
|
|
209
318
|
{
|
|
210
319
|
key: "sellBuy",
|
|
211
|
-
data: [
|
|
212
|
-
{
|
|
213
|
-
tradeAction: "开", // 交易动作
|
|
214
|
-
direction: "多", // 交易方向
|
|
215
|
-
tradeType: "开多", // 交易类型
|
|
216
|
-
amount: 2, // 手数
|
|
217
|
-
part: 2, // 份数
|
|
218
|
-
time: "2024-01-04 22:30:00", // 交易时间
|
|
219
|
-
tooltip: "<div>买卖点1</div>",
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
tradeAction: "平", // 交易动作
|
|
223
|
-
direction: "空", // 交易方向
|
|
224
|
-
tradeType: "平空", // 交易类型
|
|
225
|
-
amount: 2, // 手数
|
|
226
|
-
part: 2, // 份数
|
|
227
|
-
time: "2024-01-04 22:40:00", // 交易时间
|
|
228
|
-
tooltip: "<div>买卖点2</div>",
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
tradeAction: "开", // 交易动作
|
|
232
|
-
direction: "空", // 交易方向
|
|
233
|
-
tradeType: "开空", // 交易类型
|
|
234
|
-
amount: 2, // 手数
|
|
235
|
-
part: 2, // 份数
|
|
236
|
-
time: "2024-01-04 23:50:00", // 交易时间
|
|
237
|
-
tooltip: "<div>买卖点3</div>",
|
|
238
|
-
},
|
|
239
|
-
],
|
|
320
|
+
data: [...noRepeatMap.values()],
|
|
240
321
|
},
|
|
241
322
|
{
|
|
242
323
|
key: "openClose",
|
|
243
|
-
data: [
|
|
244
|
-
{
|
|
245
|
-
tradeAction: "开", // 交易动作
|
|
246
|
-
direction: "多", // 交易方向
|
|
247
|
-
tradeType: "开多", // 交易类型
|
|
248
|
-
amount: 2, // 手数
|
|
249
|
-
part: 2, // 份数
|
|
250
|
-
time: "2024-01-04 22:30:00", // 交易时间
|
|
251
|
-
tooltip: "<div>开平点1</div>",
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
tradeAction: "平", // 交易动作
|
|
255
|
-
direction: "空", // 交易方向
|
|
256
|
-
tradeType: "平空", // 交易类型
|
|
257
|
-
amount: 2, // 手数
|
|
258
|
-
part: 2, // 份数
|
|
259
|
-
time: "2024-01-04 22:40:00", // 交易时间
|
|
260
|
-
tooltip: "<div>开平点2</div>",
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
tradeAction: "开", // 交易动作
|
|
264
|
-
direction: "空", // 交易方向
|
|
265
|
-
tradeType: "开空", // 交易类型
|
|
266
|
-
amount: 2, // 手数
|
|
267
|
-
part: 2, // 份数
|
|
268
|
-
time: "2024-01-04 23:50:00", // 交易时间
|
|
269
|
-
tooltip: "<div>买卖点3</div>",
|
|
270
|
-
},
|
|
271
|
-
],
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
key: "signal",
|
|
275
|
-
data: [],
|
|
324
|
+
data: [...noRepeatMap.values()],
|
|
276
325
|
},
|
|
277
326
|
];
|
|
327
|
+
// 1.获取点位接口数据 2.格式化处理[数据合并,匹配K线时间轴] 建议分开,此处demo所以简写
|
|
328
|
+
// const resultApi = [
|
|
329
|
+
// {
|
|
330
|
+
// key: "sellBuy",
|
|
331
|
+
// data: [
|
|
332
|
+
// {
|
|
333
|
+
// tradeAction: "开", // 交易动作
|
|
334
|
+
// direction: "多", // 交易方向
|
|
335
|
+
// tradeType: "开多", // 交易类型
|
|
336
|
+
// amount: 2, // 手数
|
|
337
|
+
// part: 2, // 份数
|
|
338
|
+
// time: "2024-01-04 22:30:00", // 交易时间
|
|
339
|
+
// tooltip: "<div>买卖点1</div>",
|
|
340
|
+
// },
|
|
341
|
+
// {
|
|
342
|
+
// tradeAction: "平", // 交易动作
|
|
343
|
+
// direction: "空", // 交易方向
|
|
344
|
+
// tradeType: "平空", // 交易类型
|
|
345
|
+
// amount: 2, // 手数
|
|
346
|
+
// part: 2, // 份数
|
|
347
|
+
// time: "2024-01-04 22:40:00", // 交易时间
|
|
348
|
+
// tooltip: "<div>买卖点2</div>",
|
|
349
|
+
// },
|
|
350
|
+
// {
|
|
351
|
+
// tradeAction: "开", // 交易动作
|
|
352
|
+
// direction: "空", // 交易方向
|
|
353
|
+
// tradeType: "开空", // 交易类型
|
|
354
|
+
// amount: 2, // 手数
|
|
355
|
+
// part: 2, // 份数
|
|
356
|
+
// time: "2024-01-04 23:50:00", // 交易时间
|
|
357
|
+
// tooltip: "<div>买卖点3</div>",
|
|
358
|
+
// },
|
|
359
|
+
// ],
|
|
360
|
+
// },
|
|
361
|
+
// {
|
|
362
|
+
// key: "openClose",
|
|
363
|
+
// data: [
|
|
364
|
+
// {
|
|
365
|
+
// tradeAction: "开", // 交易动作
|
|
366
|
+
// direction: "多", // 交易方向
|
|
367
|
+
// tradeType: "开多", // 交易类型
|
|
368
|
+
// amount: 2, // 手数
|
|
369
|
+
// part: 2, // 份数
|
|
370
|
+
// time: "2024-01-04 22:30:00", // 交易时间
|
|
371
|
+
// tooltip: "<div>开平点1</div>",
|
|
372
|
+
// },
|
|
373
|
+
// {
|
|
374
|
+
// tradeAction: "平", // 交易动作
|
|
375
|
+
// direction: "空", // 交易方向
|
|
376
|
+
// tradeType: "平空", // 交易类型
|
|
377
|
+
// amount: 2, // 手数
|
|
378
|
+
// part: 2, // 份数
|
|
379
|
+
// time: "2024-01-04 22:40:00", // 交易时间
|
|
380
|
+
// tooltip: "<div>开平点2</div>",
|
|
381
|
+
// },
|
|
382
|
+
// {
|
|
383
|
+
// tradeAction: "开", // 交易动作
|
|
384
|
+
// direction: "空", // 交易方向
|
|
385
|
+
// tradeType: "开空", // 交易类型
|
|
386
|
+
// amount: 2, // 手数
|
|
387
|
+
// part: 2, // 份数
|
|
388
|
+
// time: "2024-01-04 23:50:00", // 交易时间
|
|
389
|
+
// tooltip: "<div>买卖点3</div>",
|
|
390
|
+
// },
|
|
391
|
+
// ],
|
|
392
|
+
// },
|
|
393
|
+
// {
|
|
394
|
+
// key: "signal",
|
|
395
|
+
// data: [],
|
|
396
|
+
// },
|
|
397
|
+
// ];
|
|
278
398
|
// 进行时间轴匹配
|
|
279
|
-
const klineTimeAry = klineData.value.map((item: any) => item[0]);
|
|
280
|
-
originPointData.value = resultApi.reduce((result: any, next) => {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}, []);
|
|
399
|
+
// const klineTimeAry = klineData.value.map((item: any) => item[0]);
|
|
400
|
+
// originPointData.value = resultApi.reduce((result: any, next) => {
|
|
401
|
+
// const { data } = next;
|
|
402
|
+
// result.push({
|
|
403
|
+
// key: next.key,
|
|
404
|
+
// data: data.map((item: any) => {
|
|
405
|
+
// const time = klineTimeAry.find((klineTime: string) => dayjs(klineTime).isSameOrAfter(item.time));
|
|
406
|
+
// return {
|
|
407
|
+
// ...item,
|
|
408
|
+
// time,
|
|
409
|
+
// };
|
|
410
|
+
// }),
|
|
411
|
+
// });
|
|
412
|
+
// return result;
|
|
413
|
+
// }, []);
|
|
294
414
|
// 判断展示开平/买卖
|
|
295
415
|
sellBuyTypeChange();
|
|
296
416
|
};
|
|
@@ -377,8 +497,8 @@ const getKlineNetPositionData = async () => {
|
|
|
377
497
|
varietyCode: "FU",
|
|
378
498
|
};
|
|
379
499
|
const res = await getNetPositionData(params);
|
|
380
|
-
const body = res.data.body
|
|
381
|
-
const netPositionMap = new Map()
|
|
500
|
+
const body = res.data.body;
|
|
501
|
+
const netPositionMap = new Map();
|
|
382
502
|
if (Number(cycle.value) <= 5) {
|
|
383
503
|
body.forEach((item: any) => {
|
|
384
504
|
const key = dayjs(item.tradeDate).format("YYYY-MM-DD HH:mm:ss");
|
|
@@ -387,14 +507,12 @@ const getKlineNetPositionData = async () => {
|
|
|
387
507
|
});
|
|
388
508
|
} else {
|
|
389
509
|
body.forEach((item: any) => {
|
|
390
|
-
const key = dayjs(item.tradeDate)
|
|
391
|
-
.add(9, "hour")
|
|
392
|
-
.format("YYYY-MM-DD HH:mm:ss");
|
|
510
|
+
const key = dayjs(item.tradeDate).add(9, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
393
511
|
const value = item.netPositionValue;
|
|
394
512
|
netPositionMap.set(key, value);
|
|
395
513
|
});
|
|
396
514
|
}
|
|
397
|
-
netPositionData.value = klineData.value.map((item: any) => netPositionMap.get(item[0]) ?? null)
|
|
515
|
+
netPositionData.value = klineData.value.map((item: any) => netPositionMap.get(item[0]) ?? null);
|
|
398
516
|
};
|
|
399
517
|
|
|
400
518
|
/**
|
|
@@ -520,16 +520,17 @@ onMounted(() => {
|
|
|
520
520
|
data.value = defaultData.map(item => {
|
|
521
521
|
const itemPercent = Math.random() > 0.5 ? Math.random() * 10 : 0 - Math.random() * 10
|
|
522
522
|
return {
|
|
523
|
+
name: item.name,
|
|
523
524
|
value: item.value,
|
|
524
525
|
labelValue: (item.value / 10000).toFixed(2) + '万',
|
|
525
|
-
name: item.name,
|
|
526
526
|
percent: itemPercent.toFixed(2),
|
|
527
527
|
color: linearLegendRef.value.numberToColor(itemPercent),
|
|
528
528
|
children: item.children.map(child => {
|
|
529
529
|
const childPercent = Math.random() > 0.5 ? Math.random() * 10 : 0 - Math.random() * 10
|
|
530
530
|
return {
|
|
531
|
-
value: child.value,
|
|
532
531
|
name: child.name,
|
|
532
|
+
value: child.value,
|
|
533
|
+
colorValue: childPercent.toFixed(2),
|
|
533
534
|
percent: childPercent.toFixed(2),
|
|
534
535
|
color: linearLegendRef.value.numberToColor(childPercent)
|
|
535
536
|
}
|