更新包含关系
This commit is contained in:
+6
-3
@@ -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:
|
||||
|
||||
+10
-6
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user