From 4766e38125e249a60aaf5c3cf3e3f65b4e2da87e Mon Sep 17 00:00:00 2001 From: jackyu66git Date: Thu, 18 Sep 2025 02:37:28 +0800 Subject: [PATCH] change something --- ChanEnum.py | 4 ++++ ChanKLC.py | 24 +++++++++++++++++++----- ChanLun.py | 34 ++++++++++++++++++++++++++-------- ChanMACDHistSet.py | 9 +++++---- 4 files changed, 54 insertions(+), 17 deletions(-) diff --git a/ChanEnum.py b/ChanEnum.py index 581c45c..7abeb6a 100644 --- a/ChanEnum.py +++ b/ChanEnum.py @@ -69,12 +69,16 @@ class Chan_KLC_FX(Enum): TOP4 = auto() TOP5 = auto() TOP6 = auto() + TOP7 = auto() + TOP8 = auto() BOTTOM1 = auto() BOTTOM2 = auto() BOTTOM3 = auto() BOTTOM4 = auto() BOTTOM5 = auto() BOTTOM6 = auto() + BOTTOM7 = auto() + BOTTOM8 = auto() UNKNOWN = auto() # 统一的MACD状态枚举,包含所有可能的状态 class Chan_MACD_STATE(Enum): diff --git a/ChanKLC.py b/ChanKLC.py index 7ce75d6..ca431c5 100644 --- a/ChanKLC.py +++ b/ChanKLC.py @@ -42,10 +42,12 @@ class ChanKLC(): self.strength = klu.strength self.last_top_klc = None self.last_bottom_klc = None - self.bb_out = True + self.bb_out = False self.macd = 0 self.signal = 0 self.state = Chan_MACD_STATE.UNKNOWN + self.continue_div = False + self.separate_div = 0 def set_last_top_klu(self, last_top_klc): self.last_top_klc = last_top_klc def set_last_bottom_klc(self, last_bottom_klc): @@ -70,15 +72,19 @@ class ChanKLC(): for klu in self.klus: if klu.macd_state != Chan_MACD_STATE.UNKNOWN: self.state = klu.macd_state + if klu.separate_div > 0: + self.separate_div = True + if klu.continue_div: + self.continue_div = klu.continue_div if self.high >= klu.bbup302 and klu.bbup302 > 0 and (self.klc_fx_type == Chan_KLC_FX.TOP1 or self.klc_fx_type == Chan_KLC_FX.TOP2): - self.bb_out = True #print(self.end_time, self.high, klu.bbup302, self.klc_fx_type) if self.high >= klu.bbup30 and klu.bbup30 > 0 and self.next and (self.next.macd - self.macd) < 0: - self.klc_fx_type = Chan_KLC_FX.TOP4 + self.klc_fx_type = Chan_KLC_FX.TOP4 + #self.bb_out = True if self.low <= klu.bblow302 and klu.bblow302 > 0 and (self.klc_fx_type == Chan_KLC_FX.BOTTOM1 or self.klc_fx_type == Chan_KLC_FX.BOTTOM2): - self.bb_out = True if self.low <= klu.bblow30 and klu.bblow30 > 0 and self.next and (self.macd - self.next.macd) < 0: - self.klc_fx_type = Chan_KLC_FX.BOTTOM4 + self.klc_fx_type = Chan_KLC_FX.BOTTOM4 + #self.bb_out = True if self.klc_fx_type == Chan_KLC_FX.TOP1 or self.klc_fx_type == Chan_KLC_FX.TOP2: #print(self.end_time, self.fx, self.macd, self.macdhist, len(self.klus)) if self.macdhist < 0 and self.macd > 0: @@ -87,6 +93,10 @@ class ChanKLC(): if self.state == Chan_MACD_STATE.HIGH_EMPTY and self.macd > 0: #print(self.end_time, self.state, self.macd, self.klc_fx_type) self.klc_fx_type = Chan_KLC_FX.TOP6 + self.bb_out = True + if self.continue_div: + self.klc_fx_type = Chan_KLC_FX.TOP7 + self.bb_out = True else: if self.klc_fx_type == Chan_KLC_FX.BOTTOM1 or self.klc_fx_type == Chan_KLC_FX.BOTTOM2: if self.macdhist > 0 and self.macd < 0: @@ -94,7 +104,11 @@ class ChanKLC(): self.bb_out = True if self.state == Chan_MACD_STATE.HIGH_EMPTY and self.macd < 0: self.klc_fx_type = Chan_KLC_FX.BOTTOM6 + self.bb_out = True #print(self.end_time, self.state, self.macd, self.klc_fx_type) + if self.continue_div: + self.klc_fx_type = Chan_KLC_FX.BOTTOM7 + self.bb_out = True def cal_macd_state(self, dir): macd_state = 0 return macd_state diff --git a/ChanLun.py b/ChanLun.py index e05b839..203ad2d 100644 --- a/ChanLun.py +++ b/ChanLun.py @@ -68,13 +68,19 @@ class ChanLun(): def check_fx(self, klc): if klc.pre and klc.next: if klc.high > klc.pre.high and klc.high > klc.next.high: - klc.set_fx(Chan_FX_TYPE.TOP) - #print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "TOP") - return Chan_FX_TYPE.TOP + if klc.pre.pre and klc.high > klc.pre.pre.high and klc.next.next and klc.high > klc.next.next.high: + klc.set_fx(Chan_FX_TYPE.TOP) + if klc.pre.pre.pre and klc.high > klc.pre.pre.pre.high and klc.next.next.next and klc.high > klc.next.next.next.high: + klc.set_fx(Chan_FX_TYPE.TOP) + #print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "TOP") + return Chan_FX_TYPE.TOP elif klc.low < klc.pre.low and klc.low < klc.next.low: - klc.set_fx(Chan_FX_TYPE.BOTTOM) - #print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "BOTTOM") - return Chan_FX_TYPE.BOTTOM + if klc.pre.pre and klc.low < klc.pre.pre.low and klc.next.next and klc.low < klc.next.next.low: + klc.set_fx(Chan_FX_TYPE.BOTTOM) + if klc.pre.pre.pre and klc.low < klc.pre.pre.pre.low and klc.next.next.next and klc.low < klc.next.next.next.low: + klc.set_fx(Chan_FX_TYPE.BOTTOM) + #print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "BOTTOM") + return Chan_FX_TYPE.BOTTOM return Chan_FX_TYPE.UNKNOWN def plot_dataframe(self, dataframe): klc_list = self.get_klc_list(dataframe) @@ -661,6 +667,8 @@ class ChanLun(): if last_bottom and klc.high > last_bi.high: last_bi.set_end_klc(last_bottom, klc) bi = ChanBI(last_bottom, len(bi_list), Chan_BI_DIR.UP) + #klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM7) + #klc.bb_out = True last_bi.set_next(bi) bi.set_pre(last_bi) for klc_index in range(last_bi.end_klc.index, len(klc_list)): @@ -674,6 +682,8 @@ class ChanLun(): if last_top and klc.low < last_bi.low: last_bi.set_end_klc(last_top, klc) bi = ChanBI(last_top, len(bi_list), Chan_BI_DIR.DOWN) + #klc.set_klc_fx_type(Chan_KLC_FX.TOP6) + #klc.bb_out = True last_bi.set_next(bi) bi.set_pre(last_bi) for klc_index in range(last_bi.end_klc.index, len(klc_list)): @@ -694,7 +704,7 @@ class ChanLun(): #klc.set_state("20") bi_list[-1].add_klc(klc) klc.set_bi(bi_list[-1]) - klc.set_klc_fx_type(Chan_KLC_FX.TOP3) + #klc.set_klc_fx_type(Chan_KLC_FX.TOP3) klc.set_last_top_klu(last_top) #print(klc.start_time, klc.fx, "二类卖点Sell 1") else: @@ -748,6 +758,8 @@ class ChanLun(): if not last_bi.is_sure: last_bi.set_end_klc(last_bottom, klc) bi = ChanBI(last_bottom, len(bi_list), Chan_BI_DIR.UP) + #klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM7) + #klc.bb_out = True last_bi.set_next(bi) bi.set_pre(last_bi) bi.add_klc(klc) @@ -797,6 +809,8 @@ class ChanLun(): # First temp top last_top = klc bi = ChanBI(klc, len(bi_list), Chan_BI_DIR.DOWN) + #klc.set_klc_fx_type(Chan_KLC_FX.TOP6) + #klc.bb_out = True bi_list.append(bi) bi_list[-1].add_klc(klc) klc.set_bi(bi_list[-1]) @@ -815,7 +829,7 @@ class ChanLun(): #klc.set_state("-20") bi_list[-1].add_klc(klc) klc.set_bi(bi_list[-1]) - klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM3) + #klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM3) klc.set_last_bottom_klc(last_bottom) #print(last_bottom.start_time, last_bottom.end_time, "--------------------------------1") #print(klc.start_time, klc.fx, "二类买点Buy 1") @@ -871,6 +885,8 @@ class ChanLun(): if not last_bi.is_sure: last_bi.set_end_klc(last_top, klc) bi = ChanBI(last_top, len(bi_list), Chan_BI_DIR.DOWN) + #klc.set_klc_fx_type(Chan_KLC_FX.TOP6) + #klc.bb_out = True last_bi.set_next(bi) bi.set_pre(last_bi) bi.add_klc(klc) @@ -921,6 +937,8 @@ class ChanLun(): # First temp bottom and no top yet last_bottom = klc bi = ChanBI(klc, len(bi_list), Chan_BI_DIR.UP) + #klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM7) + #klc.bb_out = True bi_list.append(bi) bi_list[-1].add_klc(klc) klc.set_bi(bi_list[-1]) diff --git a/ChanMACDHistSet.py b/ChanMACDHistSet.py index 879a4e9..56d7a40 100644 --- a/ChanMACDHistSet.py +++ b/ChanMACDHistSet.py @@ -73,15 +73,16 @@ class ChanMACDHistSet(): if klu.pre.macd * klu.pre.macdhist > 0 and klu.pre.signal * klu.pre.macdhist > 0: self.peak_div_list.append(klu.pre) self.div_count += 1 + klu.pre.continue_div = True else: self.peak_klu = klu.pre def set_end_klu(self, end_klu): self.end_klu = end_klu self.end_time = end_klu.time - if len(self.peak_div_list) > 0: - klu = self.peak_div_list[-1] - if klu.macd * klu.macdhist > 0: - end_klu.continue_div = True + #if len(self.peak_div_list) > 0: + #klu = self.peak_div_list[-1] + #if klu.macd * klu.macdhist > 0: + #end_klu.continue_div = True #print(end_klu.time, "Continue Div") if self.start_klu.index == end_klu.index: self.peak_klu = self.start_klu