更新包含关系

This commit is contained in:
jackyu66git
2025-11-18 02:52:54 +08:00
parent d61cbbec21
commit 6383f19004
3 changed files with 17 additions and 10 deletions
+6 -3
View File
@@ -71,6 +71,9 @@ class ChanKLC():
self.end_time = klu.time self.end_time = klu.time
self.close = klu.close self.close = klu.close
for klu in self.klu_list: for klu in self.klu_list:
if klu.exception:
self.exception = True
print(klu.time, "exception")
if klu.separate_div > 0: if klu.separate_div > 0:
self.separate_div = True self.separate_div = True
if klu.continue_div: if klu.continue_div:
@@ -146,9 +149,9 @@ class ChanKLC():
def set_state(self, state): def set_state(self, state):
self.state = state self.state = state
def check_klu_included(self, klu): def check_klu_included(self, klu):
if self.high >= klu.high-10: if self.high >= klu.high:
# high大于,low小于,左包含 # high大于,low小于,左包含
if self.low <= klu.low+10: if self.low <= klu.low:
self.add_klu(klu=klu) self.add_klu(klu=klu)
# gn>gn-1 # gn>gn-1
if self.dir == Chan_KLINE_DIR.UP: if self.dir == Chan_KLINE_DIR.UP:
@@ -176,7 +179,7 @@ class ChanKLC():
return False return False
else: else:
# high小于,low大于,右包含 # high小于,low大于,右包含
if self.low >= klu.low-10: if self.low >= klu.low:
self.add_klu(klu=klu) self.add_klu(klu=klu)
# gn>gn-1 # gn>gn-1
if self.dir == Chan_KLINE_DIR.UP: if self.dir == Chan_KLINE_DIR.UP:
+10 -6
View File
@@ -35,10 +35,10 @@ class ChanKLU:
self.upper_shadow = self.high - max(self.close, self.open) self.upper_shadow = self.high - max(self.close, self.open)
self.lower_shadow = min(self.close, self.open) - self.low self.lower_shadow = min(self.close, self.open) - self.low
self.body_ratio = self.body / self.range self.body_ratio = self.body / self.range
self.upper_shadow_ratio = self.upper_shadow / self.range self.upper_shadow_ratio = self.upper_shadow / self.body
self.lower_shadow_ratio = self.lower_shadow / self.range self.lower_shadow_ratio = self.lower_shadow / self.body
self.exception = False 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.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 self.continue_div = 0
@@ -53,6 +53,7 @@ class ChanKLU:
self.macd_state = Chan_MACD_STATE.UNKNOWN self.macd_state = Chan_MACD_STATE.UNKNOWN
self.macd_hist_gap = 0 self.macd_hist_gap = 0
self.trend = Chan_PRICE_TREND.UNKNOWN self.trend = Chan_PRICE_TREND.UNKNOWN
self.seg_histset_index = 0
# === 归零轴细化与模式/背离 === # === 归零轴细化与模式/背离 ===
self.zero_axis = False # 是否归零轴(穿越或接近) self.zero_axis = False # 是否归零轴(穿越或接近)
self.zero_axis_state = "none" # {none,crossing,near} self.zero_axis_state = "none" # {none,crossing,near}
@@ -70,19 +71,22 @@ class ChanKLU:
self.macd_state = state self.macd_state = state
def set_pattern(self, pattern): def set_pattern(self, pattern):
self.pattern = 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): def to_string(self):
return f"{self.time} {self.candle_dir} {self.pattern}" return f"{self.time} {self.candle_dir} {self.pattern}"
def cal_exception(self): def cal_exception(self):
if self.upper_shadow_ratio > 5 or self.lower_shadow_ratio > 5: if self.upper_shadow_ratio > 5 or self.lower_shadow_ratio > 5:
self.exception = True 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) #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): def set_trend(self, trend):
self.trend = trend self.trend = trend
def set_separate_div(self, separate_div): def set_separate_div(self, separate_div):
self.separate_div = separate_div self.separate_div = separate_div
if self.klc: if self.klc and self.klc.pre and self.klc.next:
if self.klc.klc_fx_type != Chan_KLC_FX.UNKNOWN: 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 self.separate_div = 99
else: else:
self.separate_div = 0 self.separate_div = 0
+1 -1
View File
@@ -40,7 +40,7 @@ class ChanMACD():
sd = klu.separate_div sd = klu.separate_div
if sd > 1 and ((hist > 0 and hist < 200) or (hist < 0 and hist > -200)): if sd > 1 and ((hist > 0 and hist < 200) or (hist < 0 and hist > -200)):
sd_list.append(klu.time) sd_list.append(klu.time)
print(klu.time, sd) #print(klu.time, sd)
return sd_list return sd_list
def cal_macd_state(self): def cal_macd_state(self):
last_seg = None last_seg = None