st-comp 0.0.38 → 0.0.40

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "st-comp",
3
3
  "public": true,
4
- "version": "0.0.38",
4
+ "version": "0.0.40",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -310,6 +310,7 @@ const draw = async (type?: string) => {
310
310
  [
311
311
  "future",
312
312
  async () => {
313
+ const chartOption = echartsInstance.getOption();
313
314
  const newOption = await getOption(
314
315
  props.klineData as KlineDataType,
315
316
  props.markData,
@@ -318,7 +319,7 @@ const draw = async (type?: string) => {
318
319
  props.netPositionData
319
320
  );
320
321
  newOption.dataZoom[0].start =
321
- ((props.klineData.length - config.value.defaultShowBarCount) / props.klineData.length) * 100;
322
+ ((props.klineData.length - chartOption.dataZoom[0].endValue + chartOption.dataZoom[0].startValue) / props.klineData.length) * 100;
322
323
  echartsInstance.setOption(newOption, true);
323
324
  },
324
325
  ],
@@ -60,13 +60,6 @@ export const getOption = async (
60
60
  * @todo: 3.标注点位渲染项处理
61
61
  */
62
62
  const markPointData = handlePoint(markData, originData);
63
- const timePointData = markData.reduce((result, next) => {
64
- const { data } = next;
65
- // 无数据直接循环下一组数据
66
- if (data === null || data.length === 0) return result;
67
- result.push(...data);
68
- return result;
69
- }, []);
70
63
  /**
71
64
  * @todo: 4.标注点位连线渲染处理
72
65
  */
@@ -116,10 +109,37 @@ export const getOption = async (
116
109
  body += `<div>资产持仓净值: ${item.data}</div>`;
117
110
  }
118
111
  if (item.componentSubType === "candlestick") {
119
- // 买卖点tooltip渲染逻辑
120
- timePointData.forEach((i) => {
121
- if (i.time === item.axisValue) {
122
- body += i.tooltip;
112
+ // 买卖/开平tooltip渲染逻辑
113
+ markData.forEach((mark) => {
114
+ const { key, data } = mark;
115
+ if (key === "sellBuy") {
116
+ // 买卖点渲染逻辑
117
+ const sellBuy = data.filter((i) => i.time === item.axisValue);
118
+ let buy = 0;
119
+ let sell = 0;
120
+ sellBuy.forEach((i) => {
121
+ if (i.tradeType === "开多" || i.tradeType === "平空") {
122
+ // 买
123
+ buy += i.amount;
124
+ } else {
125
+ // 卖
126
+ sell += i.amount;
127
+ }
128
+ });
129
+ if (buy) {
130
+ body += `<div>买: ${buy}</div>`;
131
+ }
132
+ if (sell) {
133
+ body += `<div>卖: ${sell}</div>`;
134
+ }
135
+ }
136
+ if (key === "openClose") {
137
+ // 开平点渲染逻辑
138
+ data.forEach((i) => {
139
+ if (i.time === item.axisValue) {
140
+ body += i.tooltip;
141
+ }
142
+ });
123
143
  }
124
144
  });
125
145
  }
@@ -108,13 +108,17 @@
108
108
  upperLabel: {
109
109
  padding: [8, 0, 0, 0],
110
110
  formatter: (params: any) => {
111
- return `{title|${params.data.name} ${params.data.labelValue}} {${params.data.percent >= 0 ? 'redPercent' : 'greenPercent'}|${params.data.percent}%}`
111
+ return `{title|${params.data.name} ${params.data.labelValue}} ${params.data.percent === null ? '' : `{${params.data.percent >= 0 ? params.data.percent === 0 ? 'defaultPercent' : 'redPercent' : 'greenPercent'}|${params.data.percent}%}`}`
112
112
  },
113
113
  rich: {
114
114
  title: {
115
115
  color: '#fff',
116
116
  fontSize: 14,
117
117
  },
118
+ defaultPercent: {
119
+ color: '#fff',
120
+ fontSize: 14,
121
+ },
118
122
  redPercent: {
119
123
  color: 'red',
120
124
  fontSize: 14,
@@ -63,7 +63,7 @@ export const getNetPositionData = async (data: any) => {
63
63
  return axios({
64
64
  method: 'post',
65
65
  headers: {
66
- token: 'e077632625ea4b11506db312e186dd06',
66
+ token: 'b1ef55eb206f7ae49b85b528231c5d87',
67
67
  },
68
68
  url: 'http://192.168.12.49:88/invest/analysis/queryVarietyNetPositionValue',
69
69
  data
@@ -77,7 +77,7 @@ export const queryPairedRecordByVariety = async (data: any) => {
77
77
  return axios({
78
78
  method: 'post',
79
79
  headers: {
80
- token: 'e077632625ea4b11506db312e186dd06',
80
+ token: 'b1ef55eb206f7ae49b85b528231c5d87',
81
81
  },
82
82
  url: 'http://192.168.12.49:88/invest/analysis/queryPairedRecordByVariety',
83
83
  data
@@ -116,16 +116,17 @@ const config = ref({
116
116
  const { totalBarCount, preBarCount } = config.value;
117
117
  // 1.如果当前K线数据量就小于API希望得到的数量,说明已经没有数据了,将API得到的数据作全部展示
118
118
  // 并且打上标记,此K线数据已无更多
119
- if (klineData.value.length < totalBarCount + preBarCount) {
120
- config.value.totalBarCount = klineData.value.length;
121
- console.log("K线数据已无更多-1");
122
- futureIsAllLoad.value = true;
123
- return;
124
- }
119
+ // if (klineData.value.length < totalBarCount + preBarCount) {
120
+ // config.value.totalBarCount = klineData.value.length;
121
+ // console.log("K线数据已无更多-1");
122
+ // futureIsAllLoad.value = true;
123
+ // return;
124
+ // }
125
125
  // 2.已当前存储的K线数据最后一条时间作为开始时间,往后再次请求
126
126
  const params = {
127
- right: 1, // 复权方式
128
- variety: "au8888", // 品种
127
+ contractType: 0,
128
+ right: 0, // 复权方式
129
+ variety: "FU", // 品种
129
130
  cycle: cycle.value, // 周期
130
131
  startTime: klineData.value[klineData.value.length - 1][0], // 开始
131
132
  limit: 20, // 总条数
@@ -190,7 +191,7 @@ const getKlineData = async () => {
190
191
  const params = {
191
192
  contractType: 0,
192
193
  cycle: cycle.value,
193
- endTime: "2022-12-23 00:00:00",
194
+ endTime: "2021-01-23 00:00:00",
194
195
  preLimit: 800,
195
196
  queryType: 0,
196
197
  right: 0,