添加一个新的厕率
This commit is contained in:
@@ -118,7 +118,7 @@ class TF_DF():
|
||||
df['volume_ratio'] = self.cal_volume_ratio(df)
|
||||
return df
|
||||
def get_klu_state(self, dataframe):
|
||||
klc_list = self.get_klc_list(dataframe)
|
||||
klc_list = self.get_klc_list(self.get_klu_list(dataframe))
|
||||
bi_list = self.cal_bi_list(klc_list)
|
||||
klu_state_list = []
|
||||
klc_index = 0
|
||||
@@ -127,24 +127,41 @@ class TF_DF():
|
||||
klc_index = len(klc_list) - 1
|
||||
klc = klc_list[klc_index]
|
||||
if klc.end_klu and klc.end_klu.idx == index:
|
||||
if klc.klc_fx_type == Chan_KLC_FX.TOP4:
|
||||
if klc.klc_fx_type == Chan_KLC_FX.TOP1 or klc.klc_fx_type == Chan_KLC_FX.TOP2:
|
||||
klu_state_list.append("10")
|
||||
elif klc.klc_fx_type == Chan_KLC_FX.BOTTOM4:
|
||||
#print(klc.end_time, klc.klc_fx_type)
|
||||
elif klc.klc_fx_type == Chan_KLC_FX.BOTTOM1 or klc.klc_fx_type == Chan_KLC_FX.BOTTOM2:
|
||||
klu_state_list.append("-10")
|
||||
#print(klc.end_time, klc.klc_fx_type)
|
||||
else:
|
||||
klu_state_list.append("00")
|
||||
if klc.continue_div:
|
||||
if klc.macdhist > 0:
|
||||
klu_state_list.append("20")
|
||||
#print(klc.end_time, "CD", 20)
|
||||
else:
|
||||
klu_state_list.append("-20")
|
||||
#print(klc.end_time, "CD", -20)
|
||||
elif klc.separate_div:
|
||||
if klc.macdhist > 0:
|
||||
klu_state_list.append("30")
|
||||
#print(klc.end_time, "SD", 30)
|
||||
else:
|
||||
klu_state_list.append("-30")
|
||||
#print(klc.end_time, "SD", -30)
|
||||
else:
|
||||
klu_state_list.append("00")
|
||||
klc_index += 1
|
||||
else:
|
||||
klu_state_list.append("00")
|
||||
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:
|
||||
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.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:
|
||||
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.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")
|
||||
@@ -862,6 +879,7 @@ class TF_DF():
|
||||
if fx == Chan_FX_TYPE.BOTTOM:
|
||||
if last_top:
|
||||
if self.check_bottom_fx(last_top, klc) == False:
|
||||
#print(klc.end_time, last_top.end_time, "---")
|
||||
fx = Chan_FX_TYPE.UNKNOWN
|
||||
# Do nothing
|
||||
if fx == Chan_FX_TYPE.UNKNOWN:
|
||||
@@ -1171,12 +1189,12 @@ class TF_DF():
|
||||
#print(bi_list[index].start_time, bi_list[index].start_klc.start_time, bi_list[index].dir)
|
||||
return bi_list
|
||||
def check_top_fx(self, last_bottom, klc):
|
||||
if last_bottom.high > klc.pre.low or last_bottom.high > klc.next.low:
|
||||
if (last_bottom.high > klc.pre.low or last_bottom.high > klc.next.low) and (klc.index - last_bottom.index < 10):
|
||||
return False
|
||||
return True
|
||||
|
||||
def check_bottom_fx(self, last_top, klc):
|
||||
if last_top.low < klc.pre.high or last_top.low < klc.next.high:
|
||||
if (last_top.low < klc.pre.high or last_top.low < klc.next.high) and (klc.index - last_top.index < 10):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user