添加三类买卖点识别和图上标注,还不错,感觉可以赚钱了,明天继续优化一下

This commit is contained in:
jackyu66git
2026-02-20 01:37:39 +08:00
parent e2726db9c1
commit 01e71b7098
9 changed files with 674 additions and 55 deletions
+70 -11
View File
@@ -156,12 +156,12 @@ class TF_DF():
return klu_state_list
def check_fx(self, klc):
if klc.pre and klc.next:
if klc.high > klc.pre.high and klc.high > klc.next.high and klc.low > klc.pre.low and klc.low > klc.next.low and klc.macd> 0:
if klc.high > klc.pre.high and klc.high > klc.next.high and klc.low > klc.pre.low and klc.low > klc.next.low:
#if (klc.close > klc.ema52 or klc.next.close > klc.next.ema52) and klc.macd > 0:
klc.set_fx(Chan_FX_TYPE.TOP)
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time, klc.macd, klc.state, klc.fx, "TOP")
return Chan_FX_TYPE.TOP
elif klc.low < klc.pre.low and klc.low < klc.next.low and klc.high < klc.pre.high and klc.high < klc.next.high and klc.macd < 0:
elif klc.low < klc.pre.low and klc.low < klc.next.low and klc.high < klc.pre.high and klc.high < klc.next.high:
#if (klc.close < klc.ema52 or klc.next.close < klc.next.ema52) and klc.macd < 0:
klc.set_fx(Chan_FX_TYPE.BOTTOM)
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time, klc.macd, klc.state, klc.fx, "BOTTOM")
@@ -1399,7 +1399,7 @@ class TF_DF():
if len(zs_list) > 0:
bi_zs_list.append(zs_list)
return bi_zs_list
def find_third_bsp(self, bi_list, bi_zs_list):
def find_all_bsp(self, bi_list, bi_zs_list):
"""
笔中枢的三类买卖点识别
@@ -1444,6 +1444,18 @@ class TF_DF():
# 三类买点:向上离开中枢后回拉不破 zg
#print("Leave bi:", leave_bi.start_time, leave_bi.end_time, leave_bi.dir, leave_bi.is_sure, leave_bi.low, leave_bi.high)
if leave_bi.dir == Chan_BI_DIR.UP:
first_bsp_bi_div = self.check_bi_div(zs, leave_bi)
# 确认一类卖点:离开断能量小于进入段能量
if first_bsp_bi_div:
bsp = ChanBSP(
leave_bi, len(bsp_list),
Chan_BSP_TYPE.S1,
Chan_BSP_DIR.SELL,
leave_bi.sure_time,
1, zs, None
)
leave_bi.end_klc.set_bsp_type(Chan_BSP_TYPE.S1)
bsp_list.append(bsp)
# 回拉笔
pullback_bi = leave_bi.next
#print(pullback_bi.start_klc.start_time, pullback_bi.dir, pullback_bi.is_sure, pullback_bi.low, pullback_bi.high)
@@ -1452,15 +1464,41 @@ class TF_DF():
# 确认三类买点:回拉笔的低点不跌回中枢
bsp = ChanBSP(
pullback_bi, len(bsp_list),
Chan_BSP_TYPE.T3,
Chan_BSP_TYPE.B3,
Chan_BSP_DIR.BUY,
pullback_bi.sure_time,
1, zs, None
)
pullback_bi.end_klc.set_bsp_type(Chan_BSP_TYPE.B3)
bsp_list.append(bsp)
# 二类卖点
if first_bsp_bi_div:
second_bsp_bi = pullback_bi.next
if second_bsp_bi and second_bsp_bi.is_sure and second_bsp_bi.end_klc.high < leave_bi.end_klc.high:
# 确认二类卖点:一类卖点后回拉不超过一类卖点高点
bsp = ChanBSP(
second_bsp_bi, len(bsp_list),
Chan_BSP_TYPE.S2,
Chan_BSP_DIR.SELL,
second_bsp_bi.sure_time,
1, zs, None
)
second_bsp_bi.end_klc.set_bsp_type(Chan_BSP_TYPE.B2)
bsp_list.append(bsp)
# 三类卖点:向下离开中枢后反弹不破 zd
elif leave_bi.dir == Chan_BI_DIR.DOWN:
first_bsp_bi_div = self.check_bi_div(zs, leave_bi)
# 确认一类买点:离开段能量小于进入段
if first_bsp_bi_div:
bsp = ChanBSP(
leave_bi, len(bsp_list),
Chan_BSP_TYPE.B1,
Chan_BSP_DIR.BUY,
leave_bi.sure_time,
1, zs, None
)
leave_bi.end_klc.set_bsp_type(Chan_BSP_TYPE.B1)
bsp_list.append(bsp)
# 反弹笔
bounce_bi = leave_bi.next
#print(bounce_bi.start_klc.start_time, bounce_bi.dir, bounce_bi.is_sure, bounce_bi.low, bounce_bi.high)
@@ -1469,14 +1507,35 @@ class TF_DF():
# 确认三类卖点:反弹笔的高点不回到中枢
bsp = ChanBSP(
bounce_bi, len(bsp_list),
Chan_BSP_TYPE.T3,
Chan_BSP_TYPE.S3,
Chan_BSP_DIR.SELL,
bounce_bi.sure_time,
1, zs, None
)
bounce_bi.end_klc.set_bsp_type(Chan_BSP_TYPE.S3)
bsp_list.append(bsp)
# 二类卖点
if first_bsp_bi_div:
second_bsp_bi = bounce_bi.next
if second_bsp_bi and second_bsp_bi.is_sure and second_bsp_bi.end_klc.low > leave_bi.end_klc.low:
# 确认二类买点:一类买点后回拉不超过一类卖点高点
bsp = ChanBSP(
second_bsp_bi, len(bsp_list),
Chan_BSP_TYPE.B2,
Chan_BSP_DIR.BUY,
second_bsp_bi.sure_time,
1, zs, None
)
second_bsp_bi.end_klc.set_bsp_type(Chan_BSP_TYPE.B2)
bsp_list.append(bsp)
return bsp_list
def check_bi_div(self, zs, leave_bi):
enter_bi = zs.bi_list[0].pre
macdhist_div = 0
if enter_bi and enter_bi.dir == leave_bi.dir:
macdhist_div = abs(leave_bi.macd_hist) - abs(enter_bi.macd_hist)
#print(enter_bi.end_time, leave_bi.end_time, macdhist_div < 0)
return macdhist_div < 0
def find_first_bsp(self, bi_list, bi_zs_list):
"""
笔中枢的一类买卖点识别
@@ -1776,7 +1835,7 @@ class TF_DF():
bi_out_count += 1
first_bi_out = bi
if (bi.dir == Chan_BI_DIR.UP and seg.dir == Chan_SEG_DIR.DOWN) or (bi.dir == Chan_BI_DIR.DOWN and seg.dir == Chan_SEG_DIR.UP):
bsp = ChanBSP(first_bi_out, len(bsp_list), Chan_BSP_TYPE.T3, Chan_BSP_DIR.BUY if first_bi_out.dir == Chan_BI_DIR.DOWN else Chan_BSP_DIR.SELL, first_bi_out.sure_time, zs_count, zs, seg)
bsp = ChanBSP(first_bi_out, len(bsp_list), Chan_BSP_TYPE.B3, Chan_BSP_DIR.BUY if first_bi_out.dir == Chan_BI_DIR.DOWN else Chan_BSP_DIR.SELL, first_bi_out.sure_time, zs_count, zs, seg)
bsp_list.append(bsp)
#print("First bi out 3", first_bi_out.start_klc.start_time)
in_again = False
@@ -1812,7 +1871,7 @@ class TF_DF():
bi_out_count += 1
first_bi_out = bi
if (bi.dir == Chan_BI_DIR.UP and seg.dir == Chan_SEG_DIR.DOWN) or (bi.dir == Chan_BI_DIR.DOWN and seg.dir == Chan_SEG_DIR.UP):
bsp = ChanBSP(first_bi_out, len(bsp_list), Chan_BSP_TYPE.T3, Chan_BSP_DIR.BUY if first_bi_out.dir == Chan_BI_DIR.DOWN else Chan_BSP_DIR.SELL, first_bi_out.sure_time, zs_count, zs, seg)
bsp = ChanBSP(first_bi_out, len(bsp_list), Chan_BSP_TYPE.B3, Chan_BSP_DIR.BUY if first_bi_out.dir == Chan_BI_DIR.DOWN else Chan_BSP_DIR.SELL, first_bi_out.sure_time, zs_count, zs, seg)
bsp_list.append(bsp)
#print("First bi out 4", first_bi_out.start_klc.start_time)
in_again = False
@@ -1820,12 +1879,12 @@ class TF_DF():
if seg.dir == Chan_SEG_DIR.UP and bi.dir == Chan_BI_DIR.UP:
#print(bi.start_klc.start_time, bi.high, seg.high)
if bi.high == seg.high:
bsp = ChanBSP(bi, len(bsp_list), Chan_BSP_TYPE.T3E, Chan_BSP_DIR.SELL if bi.dir == Chan_BI_DIR.DOWN else Chan_BSP_DIR.BUY, bi.sure_time, zs_count, zs, seg)
bsp = ChanBSP(bi, len(bsp_list), Chan_BSP_TYPE.S3, Chan_BSP_DIR.SELL if bi.dir == Chan_BI_DIR.DOWN else Chan_BSP_DIR.BUY, bi.sure_time, zs_count, zs, seg)
bsp_list.append(bsp)
else:
if seg.dir == Chan_SEG_DIR.DOWN and bi.dir == Chan_BI_DIR.DOWN:
if bi.low == seg.low:
bsp = ChanBSP(bi, len(bsp_list), Chan_BSP_TYPE.T3E, Chan_BSP_DIR.BUY if bi.dir == Chan_BI_DIR.DOWN else Chan_BSP_DIR.SELL, bi.sure_time, zs_count, zs, seg)
bsp = ChanBSP(bi, len(bsp_list), Chan_BSP_TYPE.B3, Chan_BSP_DIR.BUY if bi.dir == Chan_BI_DIR.DOWN else Chan_BSP_DIR.SELL, bi.sure_time, zs_count, zs, seg)
bsp_list.append(bsp)
#self.print_zs(zs_list)
return zs_list