From a338f50867c4b797f2e8d4f7cb0efc899c124cc1 Mon Sep 17 00:00:00 2001 From: jackyu66git Date: Tue, 9 Sep 2025 01:09:22 +0800 Subject: [PATCH] =?UTF-8?q?SD=E4=B8=8D=E9=9C=80=E8=A6=81=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E5=B0=B1=E6=98=BE=E7=A4=BA=E5=87=BA=E6=9D=A5=EF=BC=8C=E8=A6=81?= =?UTF-8?q?=E4=B8=8D=E7=84=B6=E6=BB=9E=E5=90=8E=E5=A4=AA=E4=B8=A5=E9=87=8D?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChanKLU.py | 6 ++++++ ChanMACD.py | 2 +- ChanMACDHistSet.py | 5 +++-- ChanMACDUnitTF.py | 2 +- web/app.py | 3 ++- web/templates/index.html | 21 +++++++++++++++------ 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ChanKLU.py b/ChanKLU.py index b33217b..7d618ac 100644 --- a/ChanKLU.py +++ b/ChanKLU.py @@ -54,6 +54,7 @@ class ChanKLU: self.continue_div = False self.separate_div = False + self.near0_return = 0 self.ema52 = 0 self.ema24 = 0 self.macd_slop = 0 @@ -680,22 +681,27 @@ class ChanKLU: # 完美形态:白线接近零轴 + 价格触碰/轻破EMA52 + 黄线不穿零轴 if abs(self.macd) <= NEAR0_EPS and touch_52 and (not (self.pre.signal >= 0 and self.signal < 0)) and (not (self.pre.signal <= 0 and self.signal > 0)): self.macd_state = Chan_MACD_STATE.NEAR0_PERFECT + #self.near0_return = 1 return self.macd_state # EMA24 附近 if lines_near_zero and touch_24: self.macd_state = Chan_MACD_STATE.NEAR0_24 + #self.near0_return = 2 return self.macd_state # EMA52 附近 if lines_near_zero and touch_52: self.macd_state = Chan_MACD_STATE.NEAR0_52 + #self.near0_return = 3 return self.macd_state # 白线接近零轴但价格未至EMA52 if abs(self.macd) <= NEAR0_EPS and not touch_52: self.macd_state = Chan_MACD_STATE.NEAR0_DIFF + #self.near0_return = 4 return self.macd_state # 一般近零轴 if lines_near_zero or touch_52: self.macd_state = Chan_MACD_STATE.NEAR0 + #self.near0_return = 5 return self.macd_state # 穿零轴后离开零轴 if self.pre.macd_state == Chan_MACD_STATE.CROSS0_UP and ((self.macd >= self.pre.macd and self.signal >= self.pre.signal) or (abs(self.macdhist) >= abs(self.pre.macdhist))): diff --git a/ChanMACD.py b/ChanMACD.py index dfe8b0a..02d9c75 100644 --- a/ChanMACD.py +++ b/ChanMACD.py @@ -130,7 +130,7 @@ class ChanMACD(): last_seg.add_klu(klu) last_klu = klu klu.cal_macd_state() - print(klu.time, klu.macd_state, klu.continue_div, klu.separate_div, klu.macd, klu.signal, klu.macdhist, klu.ema24, klu.ema52, klu.close) + #print(klu.time, klu.macd_state, klu.continue_div, klu.separate_div, klu.macd, klu.signal, klu.macdhist, klu.ema24, klu.ema52, klu.close) if last_histset: last_histset.set_end_klu(last_klu) if last_unittf: diff --git a/ChanMACDHistSet.py b/ChanMACDHistSet.py index 9a760a4..09277ae 100644 --- a/ChanMACDHistSet.py +++ b/ChanMACDHistSet.py @@ -24,8 +24,9 @@ class ChanMACDHistSet(): def set_pre(self, pre_histset): self.pre = pre_histset def set_middle_klu(self, middle_klu): - self.middle_klu = middle_klu - self.middle_area = abs(middle_klu.macdhist) + #self.middle_klu = middle_klu + #self.middle_area = abs(middle_klu.macdhist) + self.middle_klu = None def set_unittf_div(self, unittf_div): self.unittf_div = unittf_div def add_klu(self, klu): diff --git a/ChanMACDUnitTF.py b/ChanMACDUnitTF.py index 3277927..e0a6f10 100644 --- a/ChanMACDUnitTF.py +++ b/ChanMACDUnitTF.py @@ -50,7 +50,7 @@ class ChanMACDUnitTF(): #if histset.peak_klu: #print("Unittf: ", self.start_klu.time, len(self.histset_list), histset.peak_klu.time) if self.peak_klu: - if histset.peak_klu and histset.end_time: + if histset.peak_klu: if abs(histset.peak_klu.macdhist) >= abs(self.peak_klu.macdhist): self.peak_klu = histset.peak_klu self.div_type = Chan_MACDUNITTF_DIV.UNDIV diff --git a/web/app.py b/web/app.py index a93e707..42093d5 100644 --- a/web/app.py +++ b/web/app.py @@ -1247,7 +1247,8 @@ def serialize_chan_macd_data(chan_macd_data, client_tz): serialized_data['klu_list'].append({ 'time': format_time_safely(getattr(klu, 'time', None), client_tz), 'continue_div': bool(getattr(klu, 'continue_div', False)), - 'separate_div': bool(getattr(klu, 'separate_div', False)) + 'separate_div': bool(getattr(klu, 'separate_div', False)), + 'near0_return': int(getattr(klu, 'near0_return', 0)) if getattr(klu, 'near0_return', 0) is not None else 0 }) except Exception as e: print(f"序列化klu出错: {e}") diff --git a/web/templates/index.html b/web/templates/index.html index 1bdc9fe..91909db 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -3084,6 +3084,17 @@ size: 0.6 }); } + // near0_return > 0:在主图显示具体数值 + if (item.near0_return && Number(item.near0_return) > 0) { + kluDivMarkers.push({ + time: ts, + position: 'belowBar', + color: '#8bc34a', + shape: 'circle', + text: `N${Number(item.near0_return)}`, + size: 0.6 + }); + } }); window.kluDivMarkers = kluDivMarkers; } catch (e) { @@ -5120,7 +5131,7 @@ if (fx.fx_strength < 1.0) { // 降低阈值,让更多分型显示 displayText = fx.fx_strength >= 0.8 ? '' : '' // 0.8以上显示点,0.8以下不显示文本 } - displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "").replace("41", "").replace("51", ""); + displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("3", "").replace("41", "").replace("51", ""); // 添加标记配置 const markerConfig = { time: timestamp, @@ -5184,7 +5195,7 @@ if (fx.fx_strength < 1.0) { // 降低阈值,让更多分型显示 displayText = fx.fx_strength >= 1.5 ? '' : '' // 0.8以上显示点,0.8以下不显示文本 } - displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "").replace("41", "").replace("51", ""); + displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("3", "").replace("41", "").replace("51", ""); // 添加标记配置 const markerConfig = { time: timestamp, @@ -5268,7 +5279,7 @@ if (fx.fx_strength < 1.0){ // 调整小周期阈值 displayText = fx.fx_strength >= 0.6 ? '' : '' // 0.6以上显示点 } - displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "").replace("41", "").replace("51", ""); + displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("3", "").replace("41", "").replace("51", ""); // 小周期分型标记配置 const markerConfig = { time: timestamp, @@ -5324,7 +5335,7 @@ if (fx.fx_strength < 2.0){ // 调整小周期阈值 displayText = fx.fx_strength >= 1.5 ? '' : '' // 0.6以上显示点 } - displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "").replace("41", "").replace("51", ""); + displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("3", "").replace("41", "").replace("51", ""); // 小周期KLU分型标记配置 const markerConfig = { time: timestamp, @@ -5369,7 +5380,6 @@ const combinedMarkers = [ ...(window.mainFxMarkers || []), ...allElementFxMarkers, - ...((typeof window.showUOnMain === 'undefined' || window.showUOnMain) ? (window.unittfMarkers || []) : []), ...(window.kluDivMarkers || []) ]; if (combinedMarkers.length > 0) { @@ -5393,7 +5403,6 @@ // 只设置主周期分型 + UnitTF 标记 const onlyMainAndU = [ ...(window.mainFxMarkers || []), - ...((typeof window.showUOnMain === 'undefined' || window.showUOnMain) ? (window.unittfMarkers || []) : []), ...(window.kluDivMarkers || []) ]; if (onlyMainAndU.length > 0) {