添加第二类卖卖点
This commit is contained in:
+13
-28
@@ -92,20 +92,11 @@ class ChanLun():
|
||||
klc_list = self.get_klc_list(dataframe)
|
||||
bi_list= self.cal_bi_list(klc_list)
|
||||
def get_klc_state_list(self, dataframe):
|
||||
klu_list = self.get_klu_list(dataframe)
|
||||
klc_list = self.get_klc_list(dataframe)
|
||||
bi_list= self.cal_bi_list(klc_list)
|
||||
state_list = []
|
||||
if len(klc_list) > 0:
|
||||
klc_index = 0
|
||||
# 添加趋势强度判断
|
||||
dataframe['trend_strength'] = abs(dataframe['close'].pct_change(20))
|
||||
|
||||
# 添加波动率判断
|
||||
dataframe['volatility'] = dataframe['close'].pct_change().rolling(window=20).std()
|
||||
|
||||
# 添加成交量趋势
|
||||
dataframe['volume_trend'] = dataframe['volume'].rolling(window=20).mean()
|
||||
for index in range(0, len(dataframe)):
|
||||
if klc_index == len(klc_list):
|
||||
klc_index = len(klc_list) - 1
|
||||
@@ -113,27 +104,18 @@ class ChanLun():
|
||||
if klc.end_klu:
|
||||
if klc.end_klu.idx == index:
|
||||
klc_index += 1
|
||||
features = klc.get_feature_data()
|
||||
if (klc.klc_fx_type == Chan_KLC_FX.TOP1 or klc.klc_fx_type == Chan_KLC_FX.TOP2) and klc.bi.dir == Chan_BI_DIR.UP:
|
||||
if klc.klc_fx_type == Chan_KLC_FX.TOP3:
|
||||
state_list.append("10")
|
||||
#print(klc.start_time, klc.klc_fx_type)
|
||||
elif (klc.klc_fx_type == Chan_KLC_FX.BOTTOM1 or klc.klc_fx_type == Chan_KLC_FX.BOTTOM2) and klc.bi.dir == Chan_BI_DIR.DOWN:
|
||||
print(klc.start_time, klc.end_time, klc.klc_fx_type)
|
||||
elif klc.klc_fx_type == Chan_KLC_FX.BOTTOM3:
|
||||
state_list.append("-10")
|
||||
#print(klc.end_time, klc.klc_fx_type, klc.bi.start_time, klc.bi.dir)
|
||||
print(klc.start_time, klc.end_time, klc.klc_fx_type)
|
||||
else:
|
||||
state_list.append("00")
|
||||
else:
|
||||
state_list.append("00")
|
||||
else:
|
||||
state_list.append("00")
|
||||
klu = klu_list[index]
|
||||
if klu.volume_ratio > 4.0:
|
||||
if klu.close < klu.open:
|
||||
state_list[-1] = "99"
|
||||
print(klu.time, klu.volume_ratio, "99")
|
||||
else:
|
||||
state_list[-1] = "-99"
|
||||
print(klu.time, klu.volume_ratio, "-99")
|
||||
else:
|
||||
for index in range(0, len(dataframe)):
|
||||
state_list.append("00")
|
||||
@@ -405,7 +387,6 @@ class ChanLun():
|
||||
up_sbi_list = []
|
||||
last_up_sbi = ChanSBI(last_up_bi, len(up_sbi_list), last_up_bi.dir)
|
||||
up_sbi_list.append(last_up_sbi)
|
||||
last_seg.add_bi(bi)
|
||||
#up_sbi_list.append(last_up_sbi)
|
||||
#print(last_up_bi.start_time, last_up_sbi.start_bi.start_time, "Reset up sbi list 1")
|
||||
#print(bi.start_time, look_for_top, "UP 2")
|
||||
@@ -434,7 +415,6 @@ class ChanLun():
|
||||
up_sbi_list = []
|
||||
last_up_sbi = ChanSBI(last_up_bi, len(up_sbi_list), last_up_bi.dir)
|
||||
up_sbi_list.append(last_up_sbi)
|
||||
last_seg.add_bi(bi)
|
||||
#up_sbi_list.append(last_up_sbi)
|
||||
#print(last_up_bi.start_time, last_up_sbi.start_bi.start_time, "Reset up sbi list 3")
|
||||
last_down_sbi = down_sbi
|
||||
@@ -449,8 +429,9 @@ class ChanLun():
|
||||
down_sbi.set_pre(last_down_sbi)
|
||||
down_sbi_list.append(down_sbi)
|
||||
last_down_sbi = down_sbi
|
||||
last_seg.add_bi(bi)
|
||||
#print(bi.start_time, look_for_top, "UP 4")
|
||||
last_seg.add_bi(bi)
|
||||
|
||||
else:
|
||||
last_down_sbi = ChanSBI(bi, len(down_sbi_list), bi.dir)
|
||||
down_sbi_list.append(last_down_sbi)
|
||||
@@ -466,8 +447,9 @@ class ChanLun():
|
||||
up_sbi.set_pre(last_up_sbi)
|
||||
up_sbi_list.append(up_sbi)
|
||||
last_up_sbi = up_sbi
|
||||
last_seg.add_bi(bi)
|
||||
#print(bi.start_time, look_for_top, "UP 6")
|
||||
last_seg.add_bi(bi)
|
||||
|
||||
# Last seg is down
|
||||
else:
|
||||
if bi.dir == Chan_BI_DIR.UP:
|
||||
@@ -499,7 +481,6 @@ class ChanLun():
|
||||
down_sbi_list = []
|
||||
last_down_sbi = ChanSBI(last_down_bi, len(down_sbi_list), last_down_bi.dir)
|
||||
down_sbi_list.append(last_down_sbi)
|
||||
last_seg.add_bi(bi)
|
||||
#down_sbi_list.append(last_down_sbi)
|
||||
#print(last_down_bi.start_time, last_down_sbi.start_bi.start_time, "Reset down sbi list 1")
|
||||
#print(bi.start_time, look_for_top, "DOWN 2")
|
||||
@@ -528,7 +509,6 @@ class ChanLun():
|
||||
down_sbi_list = []
|
||||
last_down_sbi = ChanSBI(last_down_bi, len(down_sbi_list), last_down_bi.dir)
|
||||
down_sbi_list.append(last_down_sbi)
|
||||
last_seg.add_bi(bi)
|
||||
#down_sbi_list.append(last_down_sbi)
|
||||
#print(last_down_bi.start_time, last_down_sbi.start_bi.start_time, "Reset down sbi list 3")
|
||||
last_up_sbi = up_sbi
|
||||
@@ -586,6 +566,7 @@ class ChanLun():
|
||||
else:
|
||||
last_down_bi = bi
|
||||
down_bi_list.append(bi)
|
||||
"""
|
||||
if len(seg_list) > 1:
|
||||
seg = seg_list[-1]
|
||||
last_seg = seg_list[-2]
|
||||
@@ -635,6 +616,7 @@ class ChanLun():
|
||||
last_seg = seg
|
||||
last_seg_bi = bi_list[i]
|
||||
break
|
||||
"""
|
||||
return seg_list
|
||||
|
||||
def get_bi_zs_list(self, bi_list):
|
||||
@@ -837,6 +819,7 @@ class ChanLun():
|
||||
bi_list[-1].add_klc(klc)
|
||||
klc.set_bi(bi_list[-1])
|
||||
klc.set_klc_fx_type(Chan_KLC_FX.TOP3)
|
||||
klc.set_last_top_klu(last_top)
|
||||
#print(klc.start_time, klc.fx, "二类卖点Sell 1")
|
||||
else:
|
||||
# A new top found
|
||||
@@ -957,6 +940,8 @@ class ChanLun():
|
||||
bi_list[-1].add_klc(klc)
|
||||
klc.set_bi(bi_list[-1])
|
||||
klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM3)
|
||||
klc.set_last_bottom_klc(last_bottom)
|
||||
#print(last_bottom.start_time, last_bottom.end_time, "--------------------------------1")
|
||||
#print(klc.start_time, klc.fx, "二类买点Buy 1")
|
||||
else:
|
||||
# A new bottom found
|
||||
|
||||
Reference in New Issue
Block a user