diff --git a/Bi/BiConfig.py b/Bi/BiConfig.py index 1315060..6f684f3 100644 --- a/Bi/BiConfig.py +++ b/Bi/BiConfig.py @@ -19,6 +19,8 @@ def __init__( self.bi_fx_check = FX_CHECK_METHOD.LOSS elif bi_fx_check == "half": self.bi_fx_check = FX_CHECK_METHOD.HALF + elif bi_fx_check == 'totally': + self.bi_fx_check = FX_CHECK_METHOD.TOTALLY else: raise CChanException(f"unknown bi_fx_check={bi_fx_check}", ErrCode.PARA_ERROR) diff --git a/ChanConfig.py b/ChanConfig.py index 0881a39..cdb0a11 100644 --- a/ChanConfig.py +++ b/ChanConfig.py @@ -24,6 +24,7 @@ def __init__(self, conf=None): bi_fx_check=conf.get("bi_fx_check", "strict"), gap_as_kl=conf.get("gap_as_kl", True), bi_end_is_peak=conf.get('bi_end_is_peak', True), + ) self.seg_conf = CSegConfig( seg_algo=conf.get("seg_algo", "chan"), diff --git a/Common/CEnum.py b/Common/CEnum.py index 8d6bec2..f9a30ed 100644 --- a/Common/CEnum.py +++ b/Common/CEnum.py @@ -86,6 +86,7 @@ class FX_CHECK_METHOD(Enum): STRICT = auto() LOSS = auto() HALF = auto() + TOTALLY = auto() class SEG_TYPE(Enum): diff --git a/KLine/KLine.py b/KLine/KLine.py index dbf7f5d..7f5b55c 100644 --- a/KLine/KLine.py +++ b/KLine/KLine.py @@ -55,7 +55,7 @@ def check_fx_valid(self, item2: "CKLine", method, for_virtual=False): elif method == FX_CHECK_METHOD.LOSS: # 只检测顶底分形KLC item2_high = item2.high self_low = self.low - elif method == FX_CHECK_METHOD.STRICT: # 检测三个klc + elif method in (FX_CHECK_METHOD.STRICT, FX_CHECK_METHOD.TOTALLY): if for_virtual: item2_high = max([item2.pre.high, item2.high]) else: @@ -64,7 +64,10 @@ def check_fx_valid(self, item2: "CKLine", method, for_virtual=False): self_low = min([self.pre.low, self.low, self.next.low]) else: raise CChanException("bi_fx_check config error!", ErrCode.CONFIG_ERROR) - return self.high > item2_high and item2.low < self_low + if method == FX_CHECK_METHOD.TOTALLY: + return self.low > item2_high + else: + return self.high > item2_high and item2.low < self_low elif self.fx == FX_TYPE.BOTTOM: assert for_virtual or item2.fx == FX_TYPE.TOP if method == FX_CHECK_METHOD.HALF: @@ -73,7 +76,7 @@ def check_fx_valid(self, item2: "CKLine", method, for_virtual=False): elif method == FX_CHECK_METHOD.LOSS: item2_low = item2.low cur_high = self.high - elif method == FX_CHECK_METHOD.STRICT: + elif method in (FX_CHECK_METHOD.STRICT, FX_CHECK_METHOD.TOTALLY): if for_virtual: item2_low = min([item2.pre.low, item2.low]) else: @@ -82,6 +85,9 @@ def check_fx_valid(self, item2: "CKLine", method, for_virtual=False): cur_high = max([self.pre.high, self.high, self.next.high]) else: raise CChanException("bi_fx_check config error!", ErrCode.CONFIG_ERROR) - return self.low < item2_low and item2.high > cur_high + if method == FX_CHECK_METHOD.TOTALLY: + return self.high < item2_low + else: + return self.low < item2_low and item2.high > cur_high else: raise CChanException("only top/bottom fx can check_valid_top_button", ErrCode.BI_ERR) diff --git a/README.md b/README.md index 450db63..27b03e4 100644 --- a/README.md +++ b/README.md @@ -573,7 +573,8 @@ else: # 绘制动画 - gap_as_kl:缺口是否处理成一根K线,默认为 True - bi_end_is_peak: 笔的尾部是否是整笔中最低/最高, 默认为 True - bi_fx_check:检查笔顶底分形是否成立的方法 - - strict:底分型的最低点必须比顶分型 3 元素最低点的最小值还低,顶分型反之。 + - strict(默认):底分型的最低点必须比顶分型3元素最低点的最小值还低,顶分型反之。 + - totally: 底分型3元素的最高点必须必顶分型三元素的最低点还低 - loss:底分型的最低点比顶分型中间元素低点还低,顶分型反之。 - half:(默认)对于上升笔,底分型的最低点比顶分型前两元素最低点还低,顶分型的最高点比底分型后两元素高点还高。下降笔反之。 - 线段