From 6383f190045ba2f29b80c66f80dbe9a89322b1b4 Mon Sep 17 00:00:00 2001 From: jackyu66git Date: Tue, 18 Nov 2025 02:52:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8C=85=E5=90=AB=E5=85=B3?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChanKLC.py | 9 ++++++--- ChanKLU.py | 16 ++++++++++------ ChanMACD.py | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ChanKLC.py b/ChanKLC.py index 132c52e..7a2c505 100644 --- a/ChanKLC.py +++ b/ChanKLC.py @@ -71,6 +71,9 @@ class ChanKLC(): self.end_time = klu.time self.close = klu.close for klu in self.klu_list: + if klu.exception: + self.exception = True + print(klu.time, "exception") if klu.separate_div > 0: self.separate_div = True if klu.continue_div: @@ -146,9 +149,9 @@ class ChanKLC(): def set_state(self, state): self.state = state def check_klu_included(self, klu): - if self.high >= klu.high-10: + if self.high >= klu.high: # high大于,low小于,左包含 - if self.low <= klu.low+10: + if self.low <= klu.low: self.add_klu(klu=klu) # gn>gn-1 if self.dir == Chan_KLINE_DIR.UP: @@ -176,7 +179,7 @@ class ChanKLC(): return False else: # high小于,low大于,右包含 - if self.low >= klu.low-10: + if self.low >= klu.low: self.add_klu(klu=klu) # gn>gn-1 if self.dir == Chan_KLINE_DIR.UP: diff --git a/ChanKLU.py b/ChanKLU.py index 62d1f84..eaef870 100644 --- a/ChanKLU.py +++ b/ChanKLU.py @@ -35,10 +35,10 @@ class ChanKLU: self.upper_shadow = self.high - max(self.close, self.open) self.lower_shadow = min(self.close, self.open) - self.low self.body_ratio = self.body / self.range - self.upper_shadow_ratio = self.upper_shadow / self.range - self.lower_shadow_ratio = self.lower_shadow / self.range + self.upper_shadow_ratio = self.upper_shadow / self.body + self.lower_shadow_ratio = self.lower_shadow / self.body self.exception = False - self.cal_exception() + #self.cal_exception() self.candle_dir = Chan_K_DIR.CROSS if self.close == self.open else Chan_K_DIR.BULL if self.close > self.open else Chan_K_DIR.BEAR self.continue_div = 0 @@ -53,6 +53,7 @@ class ChanKLU: self.macd_state = Chan_MACD_STATE.UNKNOWN self.macd_hist_gap = 0 self.trend = Chan_PRICE_TREND.UNKNOWN + self.seg_histset_index = 0 # === 归零轴细化与模式/背离 === self.zero_axis = False # 是否归零轴(穿越或接近) self.zero_axis_state = "none" # {none,crossing,near} @@ -70,19 +71,22 @@ class ChanKLU: self.macd_state = state def set_pattern(self, pattern): self.pattern = pattern + def set_seg_histset_index(self, seg_histset_index): + self.seg_histset_index = seg_histset_index + #print(self.time, self.seg_histset_index) def to_string(self): return f"{self.time} {self.candle_dir} {self.pattern}" def cal_exception(self): if self.upper_shadow_ratio > 5 or self.lower_shadow_ratio > 5: self.exception = True #print(self.time, self.upper_shadow_ratio, self.lower_shadow_ratio, self.body, self.lower_shadow, self.upper_shadow, self.high, self.low, self.close, self.open) - self.exception = False + #self.exception = False def set_trend(self, trend): self.trend = trend def set_separate_div(self, separate_div): self.separate_div = separate_div - if self.klc: - if self.klc.klc_fx_type != Chan_KLC_FX.UNKNOWN: + if self.klc and self.klc.pre and self.klc.next: + if self.klc.klc_fx_type != Chan_KLC_FX.UNKNOWN or self.klc.pre.klc_fx_type != Chan_KLC_FX.UNKNOWN or self.klc.next.klc_fx_type != Chan_KLC_FX.UNKNOWN: self.separate_div = 99 else: self.separate_div = 0 diff --git a/ChanMACD.py b/ChanMACD.py index c0756b8..0053e91 100644 --- a/ChanMACD.py +++ b/ChanMACD.py @@ -40,7 +40,7 @@ class ChanMACD(): sd = klu.separate_div if sd > 1 and ((hist > 0 and hist < 200) or (hist < 0 and hist > -200)): sd_list.append(klu.time) - print(klu.time, sd) + #print(klu.time, sd) return sd_list def cal_macd_state(self): last_seg = None