Skip to content

Commit

Permalink
feature: bi_fx_check增加totally模式
Browse files Browse the repository at this point in the history
  • Loading branch information
Vespa314 committed Sep 17, 2023
1 parent ff00cf1 commit 53ce516
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Bi/BiConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions ChanConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions Common/CEnum.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class FX_CHECK_METHOD(Enum):
STRICT = auto()
LOSS = auto()
HALF = auto()
TOTALLY = auto()


class SEG_TYPE(Enum):
Expand Down
14 changes: 10 additions & 4 deletions KLine/KLine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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)
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:(默认)对于上升笔,底分型的最低点比顶分型前两元素最低点还低,顶分型的最高点比底分型后两元素高点还高。下降笔反之。
- 线段
Expand Down

0 comments on commit 53ce516

Please sign in to comment.