Revert chan to the most valuable one

This commit is contained in:
jackyu66git
2025-06-06 17:43:35 +08:00
parent 8662b633ae
commit 6fbdf65422
4 changed files with 93 additions and 136 deletions
+8 -16
View File
@@ -67,12 +67,12 @@ class ChanLun():
else:
print(bi.start_klc.end_time, bi.dir, bi.is_sure)
def check_fx(self, klc):
if klc.pre and klc.next and klc.next.end_klu:
if klc.pre and klc.next:
if klc.high > klc.pre.high and klc.high > klc.next.high:
klc.set_fx(Chan_FX_TYPE.TOP)
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "TOP")
return Chan_FX_TYPE.TOP
if klc.pre and klc.next and klc.next.end_klu:
if klc.pre and klc.next:
if klc.low < klc.pre.low and klc.low < klc.next.low:
klc.set_fx(Chan_FX_TYPE.BOTTOM)
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "BOTTOM")
@@ -149,9 +149,9 @@ class ChanLun():
klc = klc_list[klc_index]
if klc.end_klu and klc.end_klu.idx == index:
klc_index += 1
if (klc.klc_fx_type == Chan_KLC_FX.TOP1 or klc.klc_fx_type == Chan_KLC_FX.TOP2) and klc.contain_klu_fx():
if klc.klc_fx_type == Chan_KLC_FX.TOP1 or klc.klc_fx_type == Chan_KLC_FX.TOP2:
fx_list.append(1)
elif (klc.klc_fx_type == Chan_KLC_FX.BOTTOM1 or klc.klc_fx_type == Chan_KLC_FX.BOTTOM2) and klc.contain_klu_fx():
elif klc.klc_fx_type == Chan_KLC_FX.BOTTOM1 or klc.klc_fx_type == Chan_KLC_FX.BOTTOM2:
fx_list.append(-1)
else:
fx_list.append(0)
@@ -235,7 +235,6 @@ class ChanLun():
def get_kl_data(self, dataframe:DataFrame):
fields = "time,open,high,low,close,volume"
klu_list = []
last_klu = None
for i in range(0, len(dataframe)):
item = dataframe.iloc[i]
date = item['date']
@@ -259,13 +258,8 @@ class ChanLun():
klu = ChanKLU(time_str, o, h, l, c, v)
klu.set_idx(i)
klu_list.append(klu)
if last_klu:
klu.set_pre(last_klu)
last_klu.set_next(klu)
last_klu.detect_realtime_fx()
if 'macd' in item:
klu.set_indicators(item)
last_klu = klu
return klu_list
def cal_volume_ratio(self, dataframe, window=10):
df = dataframe.copy()
@@ -697,11 +691,10 @@ class ChanLun():
else:
# A new top found
#last_top.set_fx(Chan_FX_TYPE.UNKNOWN)
#print(klc.start_time, last_top.start_time, klc.cal_fx_strength(), "一类卖点Sell 1")
last_top = klc
#print(klc.start_time, klc.fx, bi_list[-1].dir, "Last Top Change 1")
klc.set_klc_fx_type(Chan_KLC_FX.TOP1)
#print(klc.start_time, klc.fx, "一类卖点Sell 1")
#klc.set_fx(fx)
#klc.set_state("10")
bi_list[-1].add_klc(klc)
@@ -732,7 +725,6 @@ class ChanLun():
#klc.set_state("10")
#print(klc.start_time, klc.fx, "笔卖点Sell 1")
klc.set_klc_fx_type(Chan_KLC_FX.TOP2)
#print(klc.start_time, last_top.start_time, klc.fx, "二类卖点Sell 2")
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
else:
@@ -757,7 +749,7 @@ class ChanLun():
#klc.set_state('30')
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
#print(klc.start_time, last_top.start_time, "Normal TOP Found, Confirm down bi 4")
#print(klc.start_time, last_bottom.start_time, "Normal TOP Found, Confirm down bi 4")
#print(klc.start_time, klc.fx, "笔卖点Sell 2")
# last bottom = None
else:
@@ -1222,8 +1214,8 @@ class ChanLun():
klc.set_pre(last_klc)
last_klc.set_end_klu(last_klu)
klc.set_pre_fx()
#else:
#last_klc.add_klu(klu)
else:
last_klc.add_klu(klu)
else:
ddir = Chan_KLINE_DIR.UP
if klu.open > klu.close: