添加新的策略

This commit is contained in:
jackyu66git
2026-03-06 22:08:24 +08:00
parent d8f2269a49
commit d2107db6c0
19 changed files with 2712 additions and 19 deletions
+25 -11
View File
@@ -161,6 +161,7 @@ class TF_DF():
else:
klu_state_list.append("00")
return klu_state_list
def get_ema_state(self, dataframe):
klu_list = self.get_klu_list(dataframe)
klc_list = self.get_klc_list(klu_list)
@@ -918,6 +919,7 @@ class TF_DF():
if last_bottom and klc.high > last_bi.high:
#print(klc.end_time, "Top 7, 1", last_bi.start_time, klc.high, last_bi.high)
#klc.klc_fx_type = Chan_KLC_FX.TOP7
#klc.fx = Chan_FX_TYPE.TOP
"""
last_bi.set_end_klc(last_bottom, klc)
bi = ChanBI(last_bottom, len(bi_list), Chan_BI_DIR.UP)
@@ -934,10 +936,10 @@ class TF_DF():
"""
else:
if last_bottom and last_bi.dir == Chan_BI_DIR.UP:
if last_top and klc.low < last_bi.low:
#print(klc.end_time, "Bottom 8, 2", last_bi.start_time)
#klc.klc_fx_type = Chan_KLC_FX.BOTTOM8
#klc.fx = Chan_FX_TYPE.BOTTOM
"""
last_bi.set_end_klc(last_top, klc)
bi = ChanBI(last_top, len(bi_list), Chan_BI_DIR.DOWN)
@@ -954,6 +956,7 @@ class TF_DF():
"""
else:
if fx == Chan_FX_TYPE.TOP:
#print(klc.end_time, fx, klc.pre.high, klc.high, klc.pre.start_time, klc.pre.end_time)
if last_top:
if last_bottom:
#print(klc.start_time, last_bottom.start_time, last_top.start_time)
@@ -962,6 +965,7 @@ class TF_DF():
if last_top.high > klc.high:
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
klc.set_klc_fx_type(Chan_KLC_FX.TOP3)
#print(klc.end_time, klc.fx, "二类卖点Sell 1")
else:
# A new top found
@@ -973,16 +977,18 @@ class TF_DF():
#print(klc.end_time, klc.fx, "一类卖点Sell 1")
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
# 不满足结合律的分型
else:
# 不满足结合律的分型
#klc.set_klc_fx_type(Chan_KLC_FX.TOP0)
if last_bottom.index + bi_klc_min > klc.index:
if last_top.high > klc.high:
#print(klc.start_time, klc.fx, "二类卖点Sell 1")
#klc.set_fx(Chan_FX_TYPE.PTOP)
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
# New TOP Found没有意义,前面的UKNOWN已经出现TOP7
# New TOP Found前面的UKNOWN可能出现TOP7,但是这里的也可能出现TOP8分型
else:
# 顶分型在出现2之前超过前一个笔的顶 TOP8
if last_top.index + bi_klc_min < klc.index and len(bi_list) > 1:
pre_last_bi = bi_list[-2]
last_bi = bi_list[-1]
@@ -1001,11 +1007,13 @@ class TF_DF():
###klc.set_klc_fx_type(Chan_KLC_FX.TOP2) # when bi is down but the fx is top
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
#klc.set_klc_fx_type(Chan_KLC_FX.TOP8)
#print(klc.start_time, last_bi.start_klc.start_time, "New TOP Found reset last bi")
else:
klc.set_fx(Chan_FX_TYPE.PTOP)
#klc.set_fx(Chan_FX_TYPE.PTOP)
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
#print(klc.start_time, klc.fx, "无效分型")
print(klc.end_time, klc.fx, "无效分型")
# 满足结合律
else:
# New Temp TOP and last bottom confirmed ***** confirm last down bi(last bottom and last top)
@@ -1024,8 +1032,9 @@ class TF_DF():
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
#print(klc.start_time, last_bottom.start_time, "Normal TOP Found, Confirm down bi 4")
# last bottom = None
# last bottom = None 初始化的时候用,其他时间不用
else:
# 初始化的时候用,其他时间不用
if last_top.high < klc.high:
last_bi = bi_list[-1]
last_bi.set_start_klc(klc, Chan_BI_DIR.DOWN)
@@ -1033,11 +1042,13 @@ class TF_DF():
#print(klc.start_time, klc.fx, bi_list[-1].dir, "Last Top Change 3")
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
# 初始化的时候用,其他时间不用
else:
klc.set_fx(Chan_FX_TYPE.TT)
#print(klc.start_time, klc.fx, "二类卖点Sell 2")
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
# last_top == None 初始化的时候用,其他时间不用
else:
if last_bottom:
# 不满足结合律的分型
@@ -1052,7 +1063,7 @@ class TF_DF():
#print(klc.start_time, klc.fx, bi_list[-1].dir, "Last Top Change 4")
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
# Last top = None, last bottom = None, create first down bi
# Last top = None, last bottom = None, create first down bi 初始化的时候用,其他时间不用
else:
# First temp top
last_top = klc
@@ -1071,6 +1082,7 @@ class TF_DF():
if last_bottom.low < klc.low:
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM3)
#print(last_bottom.start_time, last_bottom.end_time, "--------------------------------1")
#print(klc.end_time, klc.fx, "二类买点Buy 1")
else:
@@ -1082,8 +1094,9 @@ class TF_DF():
#print(klc.end_time, klc.fx, "一类买点Buy 1")
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
# 不满足结合律的分型
else:
# 不满足结合律的分型
#klc.set_klc_fx_type(Chan_KLC_FX.TOP0)
if last_top.index + bi_klc_min > klc.index:
if last_bottom.low < klc.low:
#print(klc.end_time, klc.fx, "中枢买点Buy 1")
@@ -1108,11 +1121,12 @@ class TF_DF():
###klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM2) # when bi is up but the fx is bottom
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
#klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM8)
else:
#klc.set_fx(Chan_FX_TYPE.UNKNOWN)
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
#print(klc.start_time, klc.fx, "无效分型")
print(klc.end_time, klc.fx, "无效分型")
# 满足结合律的分型
else:
# New Temp Bottom and last top confirmed ***** confirm last up bi(last bottom and last top)
@@ -1132,7 +1146,7 @@ class TF_DF():
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
#print(klc.start_time, last_top.start_time, "Normal Bottom Found, Confirm up bi 6")
# last_top = None
# last_top = None 初始化的时候用,其他时间不用
else:
if last_bottom.low > klc.low:
last_bi = bi_list[-1]
@@ -1149,7 +1163,7 @@ class TF_DF():
#print(klc.start_time, klc.fx, "二类买点Buy 2")
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
# last_bottom = None
# last_bottom = None 初始化的时候用,其他时间不用
else:
if last_top:
# 不满足结合律的分型