Skip to content

Commit

Permalink
0.9.54 新增信号
Browse files Browse the repository at this point in the history
  • Loading branch information
zengbin93 committed Jun 24, 2024
1 parent 772a4bc commit 0bae08b
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 21 deletions.
1 change: 1 addition & 0 deletions czsc/signals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,5 @@
xl_bar_trend_V240331,
xl_bar_basis_V240411,
xl_bar_basis_V240412,
xl_bar_trend_V240623,
)
71 changes: 51 additions & 20 deletions czsc/signals/xls.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,10 @@ def xl_bar_trend_V240329(c: CZSC, **kwargs) -> OrderedDict:
return create_single_signal(k1=k1, k2=k2, k3=k3, v1=v1, v2=v2)

bar1, bar2 = get_sub_elements(c.bars_raw, di=1, n=2)
if (
check_szx(bar2, n)
and bar1.close < bar1.open
and (bar1.open - bar1.close) / (bar1.high - bar1.low) * 10 >= m
):
if check_szx(bar2, n) and bar1.close < bar1.open and (bar1.open - bar1.close) / (bar1.high - bar1.low) * 10 >= m:
v1 = "底部十字孕线"

if (
check_szx(bar2, n)
and bar1.close > bar1.open
and (bar1.close - bar1.open) / (bar1.high - bar1.low) * 10 >= m
):
if check_szx(bar2, n) and bar1.close > bar1.open and (bar1.close - bar1.open) / (bar1.high - bar1.low) * 10 >= m:
v1 = "顶部十字孕线"

return create_single_signal(k1=k1, k2=k2, k3=k3, v1=v1, v2=v2)
Expand Down Expand Up @@ -311,17 +303,56 @@ def xl_bar_basis_V240411(c: CZSC, **kwargs) -> OrderedDict:

bar1, bar2 = get_sub_elements(c.bars_raw, di=1, n=2)

if (
(bar1.open > bar1.close)
and (bar2.close > bar1.high)
and (bar2.open <= bar1.low)
):
if (bar1.open > bar1.close) and (bar2.close > bar1.high) and (bar2.open <= bar1.low):
v1 = "看涨吞没"

elif (
(bar1.open < bar1.close)
and (bar2.open >= bar1.high)
and (bar2.close < bar1.low)
):
elif (bar1.open < bar1.close) and (bar2.open >= bar1.high) and (bar2.close < bar1.low):
v1 = "看跌吞没"
return create_single_signal(k1=k1, k2=k2, k3=k3, v1=v1)


def xl_bar_trend_V240623(c: CZSC, **kwargs) -> OrderedDict:
"""突破信号; 贡献者:谢磊
参数模板:"{freq}_N{n}_突破信号V240623"
**信号逻辑:**
1, 突破前N日最高价,入场,做多
2. 跌破前N日最低价,入场,做空
**信号列表:**
- Signal('30分钟_N20_突破信号V240623_做多_连续2次上涨_任意_0')
- Signal('30分钟_N20_突破信号V240623_做空_连续2次下跌_任意_0')
:param c: CZSC对象
:param kwargs:
- n: int, 默认20,突破前N日的最高价或最低价
:return: 信号识别结果
"""
n = int(kwargs.get("n", 20))
freq = c.freq.value
k1, k2, k3 = f"{freq}_N{n}_突破信号V240623".split("_")
v1 = "其他"
v2 = "任意"

bars2 = get_sub_elements(c.bars_raw, di=1, n=n + 1)
hh = max([x.high for x in bars2[0:-2]])
ll = min([x.low for x in bars2[0:-2]])
_high = bars2[-2].high
_low = bars2[-2].low

if _high >= hh:
v1 = "做多"
if bars2[-1].high > _high:
v2 = "连续2次上涨"

elif _low <= ll:
v1 = "做空"
if bars2[-1].low < _low:
v2 = "连续2次下跌"

return create_single_signal(k1=k1, k2=k2, k3=k3, v1=v1, v2=v2)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/signals_dev/signal_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
conf = sp.parse(signals_seq)
parsed_name = {x["name"] for x in conf}
print(f"total signal functions: {len(sp.sig_name_map)}; parsed: {len(parsed_name)}")
# total signal functions: 218; parsed: 218
# total signal functions: 241; parsed: 241

# 测试信号配置生成信号
from czsc import generate_czsc_signals, get_signals_freqs, get_signals_config
Expand Down

0 comments on commit 0bae08b

Please sign in to comment.