diff --git a/.DS_Store b/.DS_Store index 4f5d502..f68b505 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/ChanBIZS.py b/ChanBIZS.py index 91a1442..cffdf87 100644 --- a/ChanBIZS.py +++ b/ChanBIZS.py @@ -26,7 +26,7 @@ class ChanBIZS(): self.set_end_time(end_bi.end_klc.end_time) self.is_sure = True self.sure_time = sure_bi.sure_time - print(self.start_time, self.is_sure, len(self.bi_list), self.dir, self.zs_type) + #print(self.start_time, self.is_sure, len(self.bi_list), self.dir, self.zs_type) def set_end_time(self, end_time): self.end_time = end_time def set_zg(self, zg): diff --git a/ChanBSP.py b/ChanBSP.py index 756195a..568cd14 100644 --- a/ChanBSP.py +++ b/ChanBSP.py @@ -4,11 +4,11 @@ from ChanEnum import Chan_BSP_TYPE, Chan_BSP_DIR class ChanBSP(): def __init__(self, bi: ChanBI, index, type: Chan_BSP_TYPE, ddir: Chan_BSP_DIR, sure_time, zs_count, zs, seg): self.bi = bi - self.klc = bi.start_klc + self.klc = bi.end_klc self.index = index self.type = type - self.start_time = bi.end_klc.start_time - self.end_time = bi.end_klc.end_time + self.start_time = self.klc.start_time + self.end_time = self.klc.end_time if sure_time: self.is_sure = True self.sure_time = sure_time @@ -18,7 +18,7 @@ class ChanBSP(): self.dir = ddir self.zs_count = zs_count self.zs = zs - self.seg = seg + self.seg = bi.seg def set_sure_time(self, sure_time): self.is_sure = True self.sure_time = sure_time \ No newline at end of file diff --git a/ChanLun.py b/ChanLun.py index c9a753d..20aff1d 100644 --- a/ChanLun.py +++ b/ChanLun.py @@ -151,6 +151,14 @@ class ChanLun(): return self.tf_df.check_bottom_fx(last_top, klc) def cal_bi_list(self, klc_list): return self.tf_df.cal_bi_list(klc_list) + def cal_bi_list_chanlun(self, klc_list): + return self.tf_df.cal_bi_list_chanlun(klc_list) + def find_first_bsp(self, bi_list, bi_zs_list): + return self.tf_df.find_first_bsp(bi_list, bi_zs_list) + def find_second_bsp(self, bi_list, first_bsp_list): + return self.tf_df.find_second_bsp(bi_list, first_bsp_list) + def find_third_bsp(self, bi_list, bi_zs_list): + return self.tf_df.find_third_bsp(bi_list, bi_zs_list) def get_zs_list(self, bi_list, seg_list): return self.tf_df.get_zs_list(bi_list, seg_list) def cal_bi_zs(self, seg_list): diff --git a/TF_DF.py b/TF_DF.py index 2100b79..e681a34 100644 --- a/TF_DF.py +++ b/TF_DF.py @@ -139,20 +139,16 @@ 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.pre.pre and klc.next.next: - if klc.high > klc.pre.pre.high and klc.high > klc.next.next.high: - #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: - if klc.pre.pre and klc.next.next: - if klc.low < klc.pre.pre.low and klc.low < klc.next.next.low: - #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") - return Chan_FX_TYPE.BOTTOM + 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: + #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") + return Chan_FX_TYPE.BOTTOM return Chan_FX_TYPE.UNKNOWN def check_fx_pattern(self, klc): klu_list = klc.pre.klu_list + klc.klu_list + klc.next.klu_list @@ -524,6 +520,7 @@ class TF_DF(): return klu_list def get_bi_list(self, dataframe): bi_list = self.cal_bi_list(self.get_klc_list(dataframe)) + #bi_list = self.cal_bi_list_chanlun(self.get_klc_list(dataframe)) return bi_list def get_kl_data(self, dataframe:DataFrame): return self.cal_kl_data(dataframe) @@ -858,11 +855,11 @@ class TF_DF(): last_bottom = None for klc in klc_list: fx = self.check_fx(klc) - if fx == Chan_FX_TYPE.TOP and False: + if fx == Chan_FX_TYPE.TOP: if last_bottom: if self.check_top_fx(last_bottom, klc) == False: fx = Chan_FX_TYPE.UNKNOWN - if fx == Chan_FX_TYPE.BOTTOM and False: + if fx == Chan_FX_TYPE.BOTTOM: if last_top: if self.check_bottom_fx(last_top, klc) == False: fx = Chan_FX_TYPE.UNKNOWN @@ -1183,6 +1180,200 @@ class TF_DF(): return False return True + def check_fx_chanlun(self, klc): + """标准缠论分型:仅用高低点,不用 MACD,不要求整根 K 线包在左右内。""" + if klc.pre is None or klc.next is None: + return Chan_FX_TYPE.UNKNOWN + # 顶分型:中间 K 线高点最高 + if klc.high > klc.pre.high and klc.high > klc.next.high: + klc.set_fx(Chan_FX_TYPE.TOP) + return Chan_FX_TYPE.TOP + # 底分型:中间 K 线低点最低 + if klc.low < klc.pre.low and klc.low < klc.next.low: + klc.set_fx(Chan_FX_TYPE.BOTTOM) + return Chan_FX_TYPE.BOTTOM + return Chan_FX_TYPE.UNKNOWN + + def cal_bi_list_chanlun(self, klc_list): + """ + 与 cal_bi_list 逻辑完全一致,仅分型用 check_fx_chanlun(标准缠论分型,不看 MACD)。 + """ + bi_list = [] + last_top = None + last_bottom = None + for klc in klc_list: + fx = self.check_fx_chanlun(klc) + if fx == Chan_FX_TYPE.TOP: + if last_bottom: + if self.check_top_fx(last_bottom, klc) == False: + fx = Chan_FX_TYPE.UNKNOWN + if fx == Chan_FX_TYPE.BOTTOM: + if last_top: + if self.check_bottom_fx(last_top, klc) == False: + fx = Chan_FX_TYPE.UNKNOWN + if fx == Chan_FX_TYPE.UNKNOWN: + if len(bi_list) > 0: + bi_list[-1].add_klc(klc) + continue + if len(bi_list) > 0 and klc.end_klu: + last_bi = bi_list[-1] + if last_top and last_bi.dir == Chan_BI_DIR.DOWN: + if last_bottom and klc.high > last_bi.high: + last_bi.set_end_klc(last_bottom, klc) + bi = ChanBI(last_bottom, len(bi_list), Chan_BI_DIR.UP) + last_bi.set_next(bi) + bi.set_pre(last_bi) + for klc_index in range(last_bi.end_klc.index, len(klc_list)): + bi.add_klc(klc_list[klc_index]) + bi_list.append(bi) + last_top = klc + klc.set_bi(bi) + else: + if last_bottom and last_bi.dir == Chan_BI_DIR.UP: + if last_top and klc.low < last_bi.low: + last_bi.set_end_klc(last_top, klc) + bi = ChanBI(last_top, len(bi_list), Chan_BI_DIR.DOWN) + last_bi.set_next(bi) + bi.set_pre(last_bi) + for klc_index in range(last_bi.end_klc.index, len(klc_list)): + bi.add_klc(klc_list[klc_index]) + bi_list.append(bi) + last_bottom = klc + klc.set_bi(bi) + else: + if fx == Chan_FX_TYPE.TOP: + if last_top: + if last_bottom: + if last_bottom.index < last_top.index: + if last_top.high > klc.high: + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + last_top = klc + klc.set_klc_fx_type(Chan_KLC_FX.TOP1) + self.check_fx_pattern(klc) + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + if last_bottom.index + 4 > klc.index: + if last_top.high > klc.high: + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + if last_top.index + 4 < klc.index and len(bi_list) > 1: + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + klc.set_fx(Chan_FX_TYPE.PTOP) + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + last_bi = bi_list[-1] + if not last_bi.is_sure: + last_bi.set_end_klc(last_bottom, klc) + bi = ChanBI(last_bottom, len(bi_list), Chan_BI_DIR.UP) + last_bi.set_next(bi) + bi.set_pre(last_bi) + bi.add_klc(klc) + bi_list.append(bi) + last_top = klc + klc.set_klc_fx_type(Chan_KLC_FX.TOP2) + self.check_fx_pattern(klc) + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + if last_top.high < klc.high: + last_bi = bi_list[-1] + last_bi.set_start_klc(klc, Chan_BI_DIR.DOWN) + last_top = klc + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + klc.set_fx(Chan_FX_TYPE.TT) + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + if last_bottom: + if last_bottom.index + 4 > klc.index: + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + last_top = klc + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + last_top = klc + bi = ChanBI(klc, len(bi_list), Chan_BI_DIR.DOWN) + bi_list.append(bi) + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + if last_bottom: + if last_top: + if last_top.index < last_bottom.index: + if last_bottom.low < klc.low: + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + last_bottom = klc + klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM1) + self.check_fx_pattern(klc) + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + if last_top.index + 4 > klc.index: + if last_bottom.low < klc.low: + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + if last_bottom.index + 4 < klc.index and len(bi_list) > 1: + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + last_bi = bi_list[-1] + if not last_bi.is_sure: + last_bi.set_end_klc(last_top, klc) + bi = ChanBI(last_top, len(bi_list), Chan_BI_DIR.DOWN) + last_bi.set_next(bi) + bi.set_pre(last_bi) + bi.add_klc(klc) + bi_list.append(bi) + last_bottom = klc + klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM2) + self.check_fx_pattern(klc) + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + if last_bottom.low > klc.low: + last_bi = bi_list[-1] + last_bi.set_start_klc(klc, Chan_BI_DIR.UP) + last_bottom = klc + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + klc.set_fx(Chan_FX_TYPE.BB) + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + if last_top: + if last_top.index + 4 > klc.index: + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + last_bottom = klc + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + else: + last_bottom = klc + bi = ChanBI(klc, len(bi_list), Chan_BI_DIR.UP) + bi_list.append(bi) + bi_list[-1].add_klc(klc) + klc.set_bi(bi_list[-1]) + return bi_list + def cal_bi_zs(self, seg_list): bi_zs_list = [] for seg in seg_list: @@ -1191,9 +1382,260 @@ class TF_DF(): bi_zs_list.append(zs_list) return bi_zs_list def find_third_bsp(self, bi_list, bi_zs_list): - if len(bi_list) > 3 and len(bi_zs_list) > 0: - last_bi_zs = bi_zs_list[-1] - last_bi = bi_list[-1] + """ + 笔中枢的三类买卖点识别 + + 三类买点:中枢形成后,一笔向上离开中枢(低点 > zg), + 随后回拉的一笔低点不跌回中枢(低点 >= zg),确认支撑有效。 + 三类卖点:中枢形成后,一笔向下离开中枢(高点 < zd), + 随后反弹的一笔高点不回到中枢(高点 <= zd),确认压力有效。 + + 参数: + bi_list: 笔列表 + bi_zs_list: 笔中枢列表(二维列表,每个seg内的中枢列表) + + 返回: + bsp_list: ChanBSP 列表,包含所有识别到的三类买卖点 + """ + bsp_list = [] + if len(bi_list) < 4 or len(bi_zs_list) == 0: + return bsp_list + + for zs in bi_zs_list: + if not zs.is_sure or len(zs.bi_list) < 3: + continue + #print(zs.start_time, zs.end_time, zs.dir, zs.is_sure, len(zs.bi_list)) + # 中枢结束后的第一笔(离开笔) + last_zs_bi = zs.bi_list[-1] + if last_zs_bi.dir == Chan_BI_DIR.UP: + if last_zs_bi.end_klc.high <= zs.zg or (last_zs_bi.next and last_zs_bi.next.is_sure and last_zs_bi.next.end_klc.low < zs.zd): + leave_bi = last_zs_bi.next + else: + leave_bi = last_zs_bi + else: + if last_zs_bi.end_klc.low >= zs.zd or (last_zs_bi.next and last_zs_bi.next.is_sure and last_zs_bi.next.end_klc.high > zs.zg): + leave_bi = last_zs_bi.next + else: + leave_bi = last_zs_bi + #print(zs.zg, zs.zd) + if leave_bi is None or not leave_bi.is_sure: + continue + if (zs.dir == Chan_ZS_DIR.UP and leave_bi.dir == Chan_BI_DIR.UP and leave_bi.end_klc.high < zs.zg and leave_bi.end_klc.high > zs.zd) or (zs.dir == Chan_ZS_DIR.DOWN and leave_bi.dir == Chan_BI_DIR.DOWN and leave_bi.end_klc.low < zs.zg and leave_bi.end_klc.low > zs.zd): + #print("--------------------", leave_bi.dir, leave_bi.end_klc.high, leave_bi.end_klc.low, zs.zg, zs.zd) + leave_bi = leave_bi.next + # 三类买点:向上离开中枢后回拉不破 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: + # 回拉笔 + 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) + if pullback_bi and pullback_bi.is_sure and pullback_bi.dir == Chan_BI_DIR.DOWN: + if pullback_bi.low >= zs.zg: + # 确认三类买点:回拉笔的低点不跌回中枢 + bsp = ChanBSP( + pullback_bi, len(bsp_list), + Chan_BSP_TYPE.T3, + Chan_BSP_DIR.BUY, + pullback_bi.sure_time, + 1, zs, None + ) + bsp_list.append(bsp) + + # 三类卖点:向下离开中枢后反弹不破 zd + elif leave_bi.dir == Chan_BI_DIR.DOWN: + # 反弹笔 + 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) + if bounce_bi and bounce_bi.is_sure and bounce_bi.dir == Chan_BI_DIR.UP: + if bounce_bi.high <= zs.zd: + # 确认三类卖点:反弹笔的高点不回到中枢 + bsp = ChanBSP( + bounce_bi, len(bsp_list), + Chan_BSP_TYPE.T3, + Chan_BSP_DIR.SELL, + bounce_bi.sure_time, + 1, zs, None + ) + bsp_list.append(bsp) + return bsp_list + + def find_first_bsp(self, bi_list, bi_zs_list): + """ + 笔中枢的一类买卖点识别 + + 一类买点:下跌趋势中,最后一个中枢完成后,向下离开中枢的笔创新低, + 但该笔与进入中枢前的最后一笔下跌形成底背驰(力度减弱), + 即趋势力竭的转折点。 + 一类卖点:上涨趋势中,最后一个中枢完成后,向上离开中枢的笔创新高, + 但该笔与进入中枢前的最后一笔上涨形成顶背驰(力度减弱), + 即趋势力竭的转折点。 + + 简化判断:中枢形成后,离开中枢的笔(突破笔)本身即为一类买卖点的触发笔。 + + 参数: + bi_list: 笔列表 + bi_zs_list: 笔中枢列表(扁平列表,每个元素是一个中枢对象) + + 返回: + bsp_list: ChanBSP 列表,包含所有识别到的一类买卖点 + """ + bsp_list = [] + if len(bi_list) < 4 or len(bi_zs_list) == 0: + return bsp_list + + for zs in bi_zs_list: + if not zs.is_sure or len(zs.bi_list) < 3: + continue + + # 找到中枢的最后一笔 + last_zs_bi = zs.bi_list[-1] + + # 确定离开笔:中枢最后一笔之后的第一笔 + if last_zs_bi.dir == Chan_BI_DIR.UP: + # 中枢最后一笔向上,如果没有真正离开中枢,取下一笔 + if last_zs_bi.end_klc.high <= zs.zg: + leave_bi = last_zs_bi.next + else: + leave_bi = last_zs_bi + else: + # 中枢最后一笔向下,如果没有真正离开中枢,取下一笔 + if last_zs_bi.end_klc.low >= zs.zd: + leave_bi = last_zs_bi.next + else: + leave_bi = last_zs_bi + + if leave_bi is None or not leave_bi.is_sure: + continue + + # 一类买点:向下离开中枢(leave_bi向下,低点 < zd),趋势力竭 + if leave_bi.dir == Chan_BI_DIR.DOWN and leave_bi.low < zs.zd: + # 背驰判断:比较离开笔与中枢内最后一笔同向笔的MACD柱状累积面积 + # 缠论原文:两段同向走势的MACD柱状面积比较,面积缩小即为背驰 + compare_bi = None + for bi in reversed(zs.bi_list): + if bi.dir == Chan_BI_DIR.DOWN and bi is not leave_bi: + compare_bi = bi + break + + is_divergence = False + if compare_bi: + # 笔的macd_hist是该笔内所有KLU的macdhist累积面积 + leave_macd_area = abs(leave_bi.macd_hist) + compare_macd_area = abs(compare_bi.macd_hist) + + # 价格创新低但MACD面积缩小 = 底背驰 + if leave_bi.low <= compare_bi.low and leave_macd_area < compare_macd_area: + is_divergence = True + # 即使没创新低,MACD面积明显缩小也算背驰 + elif leave_macd_area < compare_macd_area * 0.5: + is_divergence = True + else: + # 没有对比笔时,只要离开中枢就算一类买点 + is_divergence = True + + if is_divergence: + bsp = ChanBSP( + leave_bi, len(bsp_list), + Chan_BSP_TYPE.T1, + Chan_BSP_DIR.BUY, + leave_bi.sure_time, + 1, zs, None + ) + bsp_list.append(bsp) + + # 一类卖点:向上离开中枢(leave_bi向上,高点 > zg),趋势力竭 + elif leave_bi.dir == Chan_BI_DIR.UP and leave_bi.high > zs.zg: + # 背驰判断:比较离开笔与中枢内最后一笔同向笔的MACD柱状累积面积 + compare_bi = None + for bi in reversed(zs.bi_list): + if bi.dir == Chan_BI_DIR.UP and bi is not leave_bi: + compare_bi = bi + break + + is_divergence = False + if compare_bi: + leave_macd_area = abs(leave_bi.macd_hist) + compare_macd_area = abs(compare_bi.macd_hist) + + # 价格创新高但MACD面积缩小 = 顶背驰 + if leave_bi.high >= compare_bi.high and leave_macd_area < compare_macd_area: + is_divergence = True + # 即使没创新高,MACD面积明显缩小也算背驰 + elif leave_macd_area < compare_macd_area * 0.5: + is_divergence = True + else: + is_divergence = True + + if is_divergence: + bsp = ChanBSP( + leave_bi, len(bsp_list), + Chan_BSP_TYPE.T1, + Chan_BSP_DIR.SELL, + leave_bi.sure_time, + 1, zs, None + ) + bsp_list.append(bsp) + + return bsp_list + + def find_second_bsp(self, bi_list, first_bsp_list): + """ + 笔中枢的二类买卖点识别 + + 二类买点:一类买点出现后,价格向上反弹一笔,再回落一笔, + 回落笔的低点不跌破一类买点的低点,确认底部成立。 + 二类卖点:一类卖点出现后,价格向下回落一笔,再反弹一笔, + 反弹笔的高点不超过一类卖点的高点,确认顶部成立。 + + 参数: + bi_list: 笔列表 + first_bsp_list: 一类买卖点列表(find_first_bsp 的返回值) + + 返回: + bsp_list: ChanBSP 列表,包含所有识别到的二类买卖点 + """ + bsp_list = [] + if not first_bsp_list or len(bi_list) < 4: + return bsp_list + + for first_bsp in first_bsp_list: + trigger_bi = first_bsp.bi # 一类买卖点的触发笔 + + if first_bsp.dir == Chan_BSP_DIR.BUY: + # 一买之后:trigger_bi 向下 -> 反弹笔(向上) -> 回落笔(向下) + # 回落笔的低点 > trigger_bi 的低点 => 二类买点 + bounce_bi = trigger_bi.next # 反弹笔(向上) + if bounce_bi and bounce_bi.is_sure and bounce_bi.dir == Chan_BI_DIR.UP: + pullback_bi = bounce_bi.next # 回落笔(向下) + if pullback_bi and pullback_bi.is_sure and pullback_bi.dir == Chan_BI_DIR.DOWN: + if pullback_bi.low > trigger_bi.low: + bsp = ChanBSP( + pullback_bi, len(bsp_list), + Chan_BSP_TYPE.T2, + Chan_BSP_DIR.BUY, + pullback_bi.sure_time, + 1, first_bsp.zs, None + ) + bsp_list.append(bsp) + + elif first_bsp.dir == Chan_BSP_DIR.SELL: + # 一卖之后:trigger_bi 向上 -> 回落笔(向下) -> 反弹笔(向上) + # 反弹笔的高点 < trigger_bi 的高点 => 二类卖点 + drop_bi = trigger_bi.next # 回落笔(向下) + if drop_bi and drop_bi.is_sure and drop_bi.dir == Chan_BI_DIR.DOWN: + bounce_bi = drop_bi.next # 反弹笔(向上) + if bounce_bi and bounce_bi.is_sure and bounce_bi.dir == Chan_BI_DIR.UP: + if bounce_bi.high < trigger_bi.high: + bsp = ChanBSP( + bounce_bi, len(bsp_list), + Chan_BSP_TYPE.T2, + Chan_BSP_DIR.SELL, + bounce_bi.sure_time, + 1, first_bsp.zs, None + ) + bsp_list.append(bsp) + + return bsp_list def get_zs_list(self, bi_list, seg_list): zs_list = [] diff --git a/strategies/ChanLun_EMA_Align.py b/strategies/ChanLun_EMA_Align.py index f345571..d61b4ab 100644 --- a/strategies/ChanLun_EMA_Align.py +++ b/strategies/ChanLun_EMA_Align.py @@ -42,7 +42,7 @@ EMA24,EMA52,EMA104,EMA156成下跌趋势依次排列(EMA156 > EMA104 > E # freqtrade trade -c ./user_data/Chan/config/ChanLun_EMA_Align.json --strategy ChanLun_EMA_Align --strategy-path ./user_data/Chan/strategies # freqtrade backtesting -c ./user_data/Chan/config/ChanLun_EMA_Align.json --strategy ChanLun_EMA_Align --strategy-path ./user_data/Chan/strategies --timerange=20260101- -# freqtrade download-data -c ./user_data/Chan/config/ChanLun_EMA_Align.json -t 1m 1m 1h 1d 1w 1M --pairs BTC/USDT:USDT --timerange=20240101- +# freqtrade download-data -c ./user_data/Chan/config/ChanLun_EMA_Align.json -t 1m 1m 5m 15m 30m 1h 1d 1w 1M --pairs BTC/USDT:USDT --timerange=20240101- # freqtrade download-data -c ./user_data/Chan/config/ChanLun_EMA_Align.json -t 1m 1h 1d 1M --pairs BTC/USDT --timerange=20170101- # freqtrade hyperopt --hyperopt-loss SharpeHyperOptLossDaily --spaces roi --strategy ChanLun_EMA_Align --strategy-path ./user_data/Chan/strategies -c ./user_data/Chan/config/ChanLun_EMA_Align.json -e 200 --timerange=20250201-20250901 # freqtrade edge -c ./user_data/Chan/config/ChanLun_EMA_Align.json --strategy ChanLun_EMA_Align --strategy-path ./user_data/Chan/strategies --timerange 20250721-20250901 diff --git a/web/.DS_Store b/web/.DS_Store index 4fdc9a7..a862785 100644 Binary files a/web/.DS_Store and b/web/.DS_Store differ diff --git a/web/app.py b/web/app.py index 1f025dc..5fe85b6 100644 --- a/web/app.py +++ b/web/app.py @@ -530,6 +530,9 @@ def analyze_chan(df, symbol=None, timeframe=None): bi_zs_list = [zs for group in bi_zs_nested for zs in (group or [])] if bi_zs_nested else [] except Exception: bi_zs_list = [] + bsp_list = [] + if len(bi_zs_list) > 0: + bsp_list = chan.find_third_bsp(bi_list, bi_zs_list) # 添加买卖点识别 for bi in bi_list: bi.cal_macdhist()