li.shaoyi 1 anno fa
parent
commit
b728d6996d

+ 19 - 9
src/hooks/hqchart/candlestick/dataset.ts

@@ -64,27 +64,31 @@ export function useDataset(goodsCode: string, cycleType = ChartCycleType.Minutes
         return data.map((e, i) => {
             const date = Number(moment(e.ts).format('YYYYMMDD'))
             const time = Number(moment(e.ts).format('HHmm'))
-            const preclose = data[i - 1] // 上一个收盘价
-            const close = preclose ? preclose.c : e.c
+            const prerecord = data[i - 1] // 前一条记录
+            const yclose = prerecord ? prerecord.c : e.c
+            const yfclose = prerecord ? prerecord.s : null
+
             switch (protocol) {
                 // https://blog.csdn.net/jones2000/article/details/103966271
                 case networkProtocol.historyData:
                     return [
                         date, // 日期
-                        close, // 前收盘
+                        yclose, // 前收盘
                         e.o || null, // 开盘价
                         e.h || null, // 最高
                         e.l || null, // 最低
                         e.c, // 收盘
                         e.tv, // 成交量
                         e.tt || null, // 成交金额
-                        e.hv || null // 持仓量
+                        e.hv || null, // 持仓量
+                        e.s ?? null, // 结算价
+                        yfclose // 前结算价
                     ]
                 // https://blog.csdn.net/jones2000/article/details/103882063
                 case networkProtocol.historyMinuteData:
                     return [
                         date, // 日期
-                        close, // 前收盘
+                        yclose, // 前收盘
                         e.o || null, // 开盘价
                         e.h || null, // 最高
                         e.l || null, // 最低
@@ -202,18 +206,24 @@ export function useDataset(goodsCode: string, cycleType = ChartCycleType.Minutes
                         symbol: state.symbol,
                         date: Number(moment(e.ts).format('YYYYMMDD')),
                         price: e.c,
+                        yclose: 0,
                         open: e.o,
                         high: e.h,
                         low: e.l,
                         vol: e.tv,
-                        yclose: 0,
+                        clearing: e.s ?? null,
+                        yclearing: <number | null>null,
                         amount: e.tt || null
                     }
-                    // 获取前一条记录的收盘价
+                    // 获取前一条记录
                     if (i > 0) {
-                        item.yclose = self[i - 1]?.c
+                        const r = self[i - 1]
+                        item.yclose = r?.c
+                        item.yclearing = r?.s
                     } else {
-                        item.yclose = cache[lastIndex - 1]?.c
+                        const r = cache[lastIndex - 1]
+                        item.yclose = r?.c
+                        item.yclearing = r?.c
                     }
                     return item
                 })

+ 7 - 4
src/packages/pc/components/modules/hqchart/candlestick/index.vue

@@ -180,6 +180,7 @@ const customHistoryDataStringFormat = () => {
                 Low: 0,
                 Close: 0,
                 YClose: 0,
+                YFClose: 0,
                 Vol: 0,
                 Amount: 0,
             }
@@ -189,12 +190,14 @@ const customHistoryDataStringFormat = () => {
         Operator: function () {
             const { FormatDateString, FormatTimeString } = Chart.IFrameSplitOperator
             const { Data } = this.Value
+            const preValue = Data.YFClose ?? Data.YClose
+
             this.Text = `<dl class="app-hqchart-tooltip">`
             this.Text += `<dt><span>${FormatDateString(Data.Date)}</span>${Data.Time ? '<span>' + FormatTimeString(Data.Time) + '</span>' : ''}</dt>`
-            this.Text += `<dd><span>开盘:</span><span class="${handlePriceColor(Data.Open, Data.YClose)}">${handleNumberValue(Data.Open.toFixed(decimalplace))}</span></dd>`
-            this.Text += `<dd><span>最高:</span><span class="${handlePriceColor(Data.High, Data.YClose)}">${handleNumberValue(Data.High.toFixed(decimalplace))}</span></dd>`
-            this.Text += `<dd><span>最低:</span><span class="${handlePriceColor(Data.Low, Data.YClose)}">${handleNumberValue(Data.Low.toFixed(decimalplace))}</span></dd>`
-            this.Text += `<dd><span>收盘:</span><span class="${handlePriceColor(Data.Close, Data.YClose)}">${handleNumberValue(Data.Close.toFixed(decimalplace))}</span></dd>`
+            this.Text += `<dd><span>开盘:</span><span class="${handlePriceColor(Data.Open, preValue)}">${handleNumberValue(Data.Open.toFixed(decimalplace))}</span></dd>`
+            this.Text += `<dd><span>最高:</span><span class="${handlePriceColor(Data.High, preValue)}">${handleNumberValue(Data.High.toFixed(decimalplace))}</span></dd>`
+            this.Text += `<dd><span>最低:</span><span class="${handlePriceColor(Data.Low, preValue)}">${handleNumberValue(Data.Low.toFixed(decimalplace))}</span></dd>`
+            this.Text += `<dd><span>收盘:</span><span class="${handlePriceColor(Data.Close, preValue)}">${handleNumberValue(Data.Close.toFixed(decimalplace))}</span></dd>`
             if (goods.value?.trademode !== 99) {
                 this.Text += `<dd><span>数量:</span><span>${changeUnit(Data.Vol)}</span></dd>`
                 this.Text += `<dd><span>金额:</span><span>${changeUnit(Data.Amount)}</span></dd>`