add more files
This commit is contained in:
+39
-13
@@ -142,14 +142,28 @@ class ChanLun():
|
||||
bi_list = self.cal_bi_list(klc_list)
|
||||
klc_index = 0
|
||||
state_list = []
|
||||
bi_dir_list = []
|
||||
for index in range(0, len(dataframe)):
|
||||
klc = klc_list[klc_index]
|
||||
if klc.bi and klc.bi.dir == Chan_BI_DIR.UP:
|
||||
bi_dir_list.append(1)
|
||||
else:
|
||||
bi_dir_list.append(-1)
|
||||
if klc.end_klu and klc.end_klu.idx == index:
|
||||
klc.set_state("00")
|
||||
if klc.klc_fx_type == Chan_KLC_FX.BOTTOM1:
|
||||
klc.set_state("10")
|
||||
elif klc.klc_fx_type == Chan_KLC_FX.TOP1:
|
||||
klc.set_state("-10")
|
||||
elif klc.klc_fx_type == Chan_KLC_FX.BOTTOM2:
|
||||
klc.set_state("20")
|
||||
elif klc.klc_fx_type == Chan_KLC_FX.TOP2:
|
||||
klc.set_state("-20")
|
||||
state_list.append(klc.state)
|
||||
klc_index += 1
|
||||
else:
|
||||
state_list.append("00")
|
||||
return state_list
|
||||
return state_list, bi_dir_list
|
||||
def get_bi_list(self, dataframe):
|
||||
bi_list = self.cal_bi_list(self.get_klc_list(dataframe))
|
||||
return bi_list
|
||||
@@ -180,12 +194,24 @@ class ChanLun():
|
||||
klu = ChanKLU(time_str, o, h, l, c, v)
|
||||
klu.set_idx(i)
|
||||
klu_list.append(klu)
|
||||
if True:
|
||||
if 'macd' in item:
|
||||
klu.set_indicators(item)
|
||||
return klu_list
|
||||
def cal_volume_ratio(self, dataframe, window=10):
|
||||
df = dataframe.copy()
|
||||
# 计算过去N根K线的平均成交量
|
||||
df['avg_volume'] = df['volume'].rolling(window=window).mean()
|
||||
# 计算量比
|
||||
df['volume_ratio'] = df['volume'] / df['avg_volume']
|
||||
# 填充缺失值(前N根K线)
|
||||
df['volume_ratio'] = df['volume_ratio'].fillna(1.0)
|
||||
return df['volume_ratio']
|
||||
def calculate_zs(self, bi_list, seg_list):
|
||||
return self.get_zs_list(bi_list, seg_list)
|
||||
|
||||
def get_full_klc_list(self, dataframe):
|
||||
klc_list = self.get_klc_list(dataframe)
|
||||
bi_list = self.cal_bi_list(klc_list)
|
||||
return klc_list
|
||||
def get_seg_list(self, bi_list):
|
||||
seg_list = []
|
||||
up_bi_list = []
|
||||
@@ -573,7 +599,7 @@ class ChanLun():
|
||||
# Second top lower to be second sell point
|
||||
if last_top.high > klc.high:
|
||||
#klc.set_fx(Chan_FX_TYPE.TT)
|
||||
klc.set_state("20")
|
||||
#klc.set_state("20")
|
||||
bi_list[-1].add_klc(klc)
|
||||
klc.set_bi(bi_list[-1])
|
||||
#print(klc.start_time, klc.fx, "二类卖点Sell 1")
|
||||
@@ -585,7 +611,7 @@ class ChanLun():
|
||||
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")
|
||||
#klc.set_state("10")
|
||||
bi_list[-1].add_klc(klc)
|
||||
klc.set_bi(bi_list[-1])
|
||||
else:
|
||||
@@ -634,7 +660,7 @@ class ChanLun():
|
||||
last_top = klc
|
||||
#print(klc.start_time, klc.fx, bi_list[-1].dir, "Last Top Change 2")
|
||||
klc.set_klc_fx_type(Chan_KLC_FX.TOP2)
|
||||
klc.set_state('30')
|
||||
#klc.set_state('30')
|
||||
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")
|
||||
@@ -652,7 +678,7 @@ class ChanLun():
|
||||
#print(klc.start_time, klc.fx, "笔卖点Sell 3")
|
||||
else:
|
||||
klc.set_fx(Chan_FX_TYPE.TT)
|
||||
klc.set_state('20')
|
||||
#klc.set_state('20')
|
||||
#print(klc.start_time, klc.fx, "二类卖点Sell 2")
|
||||
bi_list[-1].add_klc(klc)
|
||||
klc.set_bi(bi_list[-1])
|
||||
@@ -691,7 +717,7 @@ class ChanLun():
|
||||
# Second bottom uppper to be second buy point and confirm last bi
|
||||
if last_bottom.low < klc.low:
|
||||
#klc.set_fx(Chan_FX_TYPE.BB)
|
||||
klc.set_state("-20")
|
||||
#klc.set_state("-20")
|
||||
bi_list[-1].add_klc(klc)
|
||||
klc.set_bi(bi_list[-1])
|
||||
#print(klc.start_time, klc.fx, "二类买点Buy 1")
|
||||
@@ -702,7 +728,7 @@ class ChanLun():
|
||||
#print(klc.start_time, klc.fx, bi_list[-1].dir, "Last Bottom Change 1")
|
||||
klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM1)
|
||||
#print(klc.start_time, klc.fx, "一类买点Buy 1")
|
||||
klc.set_state("-10")
|
||||
#klc.set_state("-10")
|
||||
bi_list[-1].add_klc(klc)
|
||||
klc.set_bi(bi_list[-1])
|
||||
else:
|
||||
@@ -730,7 +756,7 @@ class ChanLun():
|
||||
#print(klc.start_time, klc.fx, bi_list[-1].dir, "Last Top Bottom Change 2")
|
||||
klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM2)
|
||||
#print(klc.start_time, last_bi.start_klc.start_time, "New BOTTOM Found reset last bi")
|
||||
klc.set_state("-10")
|
||||
#klc.set_state("-10")
|
||||
#print(klc.start_time, klc.fx, "笔买点Buy 1")
|
||||
bi_list[-1].add_klc(klc)
|
||||
klc.set_bi(bi_list[-1])
|
||||
@@ -753,7 +779,7 @@ class ChanLun():
|
||||
last_bottom = klc
|
||||
#print(klc.start_time, klc.fx, bi_list[-1].dir, "Last Bottom Change 2")
|
||||
klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM2)
|
||||
klc.set_state('-30')
|
||||
#klc.set_state('-30')
|
||||
bi_list[-1].add_klc(klc)
|
||||
klc.set_bi(bi_list[-1])
|
||||
#print(klc.start_time, klc.fx, "笔买点Buy 2")
|
||||
@@ -771,7 +797,7 @@ class ChanLun():
|
||||
#print(klc.start_time, klc.fx, "笔买点Buy 3")
|
||||
else:
|
||||
klc.set_fx(Chan_FX_TYPE.BB)
|
||||
klc.set_state('-20')
|
||||
#klc.set_state('-20')
|
||||
#print(klc.start_time, klc.fx, "二类买点Buy 2")
|
||||
bi_list[-1].add_klc(klc)
|
||||
klc.set_bi(bi_list[-1])
|
||||
@@ -815,7 +841,7 @@ class ChanLun():
|
||||
#for index in range(0, 10):
|
||||
#print(bi_list[index].start_time, bi_list[index].start_klc.start_time, bi_list[index].dir)
|
||||
return bi_list
|
||||
|
||||
|
||||
def get_zs_list(self, bi_list, seg_list):
|
||||
zs_list = []
|
||||
bsp_list = []
|
||||
|
||||
Reference in New Issue
Block a user