添加新的bb2633,笔识别改回去了
This commit is contained in:
+24
-5
@@ -61,8 +61,9 @@ class ChanKLC():
|
||||
# 向后兼容:保留 ema52_status 和 ema52_pos
|
||||
self.ema52_status = 0
|
||||
self.ema52_pos = Chan_EMA_POS.UNKNOWN
|
||||
self.cal_all_ema_status()
|
||||
|
||||
self.bb2633upper = klu.bb2633upper
|
||||
self.bb2633lower = klu.bb2633lower
|
||||
self.bb2633middle = klu.bb2633middle
|
||||
# ==================== EMA 通用计算方法 ====================
|
||||
|
||||
@staticmethod
|
||||
@@ -278,13 +279,19 @@ class ChanKLC():
|
||||
# 向后兼容
|
||||
self.ema52_pos = self.ema_status['ema52']['pos']
|
||||
self.ema52_status = ChanKLC.semantic_to_int(self.ema_status['ema52']['semantic'])
|
||||
|
||||
def get_ema_pos(self, ema_name):
|
||||
"""获取指定EMA的客观位置,如 klc.get_ema_pos('ema24')"""
|
||||
if ema_name in self.ema_status:
|
||||
return self.ema_status[ema_name]['pos']
|
||||
return Chan_EMA_POS.UNKNOWN
|
||||
|
||||
def check_ema_pos(self):
|
||||
if len(self.ema_status) > 0:
|
||||
for ema_name, pos in self.ema_status.items():
|
||||
#print(self.end_time, ema_name, pos['pos'])
|
||||
if ((self.klc_fx_type == Chan_KLC_FX.TOP1 or self.klc_fx_type == Chan_KLC_FX.TOP2) and pos['pos'] == Chan_EMA_POS.CROSS_CLOSE_BELOW) or ((self.klc_fx_type == Chan_KLC_FX.BOTTOM1 or self.klc_fx_type == Chan_KLC_FX.BOTTOM2) and pos['pos'] == Chan_EMA_POS.CROSS_CLOSE_ABOVE):
|
||||
#print("---------------------")
|
||||
return ema_name
|
||||
return None
|
||||
def get_ema_semantic(self, ema_name):
|
||||
"""获取指定EMA的语义状态,如 klc.get_ema_semantic('ema52')"""
|
||||
if ema_name in self.ema_status:
|
||||
@@ -303,7 +310,12 @@ class ChanKLC():
|
||||
#print(self.start_time, klc_fx_type, self.get_feature_data()['klu_macd'], self.get_feature_data()['klu_macdhist'], self.get_feature_data()['klu_rsi'])
|
||||
self.klc_fx_type = klc_fx_type
|
||||
#self.cal_fx()
|
||||
self.cal_bb_out()
|
||||
ema_name = self.check_ema_pos()
|
||||
hist_div = abs(self.macdhist - self.next.macdhist)
|
||||
#print(self.end_time, self.dir, abs(self.macdhist), hist_div)
|
||||
#if ema_name:
|
||||
#print(self.end_time, ema_name, self.ema_status[ema_name]['semantic'], hist_div)
|
||||
#self.cal_bb_out()
|
||||
def add_klu(self, klu):
|
||||
self.klu_list.append(klu)
|
||||
def set_end_klu(self, klu):
|
||||
@@ -323,6 +335,7 @@ class ChanKLC():
|
||||
klu.set_klc(self)
|
||||
self.klc_dir = Chan_KLINE_DIR.UP if self.close > self.open else Chan_KLINE_DIR.DOWN
|
||||
self.cal_indicators()
|
||||
self.cal_all_ema_status()
|
||||
def cal_fx(self):
|
||||
if self.klc_fx_type == Chan_KLC_FX.TOP1 or self.klc_fx_type == Chan_KLC_FX.TOP2:
|
||||
#print(self.end_time, self.fx, self.macd, self.macdhist, len(self.klu_list))
|
||||
@@ -368,6 +381,9 @@ class ChanKLC():
|
||||
self.ema104 += self.klu_list[index].ema104
|
||||
self.ema156 += self.klu_list[index].ema156
|
||||
self.ema208 += self.klu_list[index].ema208
|
||||
self.bb2633upper += self.klu_list[index].bb2633upper
|
||||
self.bb2633lower += self.klu_list[index].bb2633lower
|
||||
self.bb2633middle += self.klu_list[index].bb2633middle
|
||||
if self.ema_dir != self.klu_list[index].ema_dir:
|
||||
self.ema_dir = 0
|
||||
n = len(self.klu_list)
|
||||
@@ -380,6 +396,9 @@ class ChanKLC():
|
||||
self.ema104 = self.ema104 / n
|
||||
self.ema156 = self.ema156 / n
|
||||
self.ema208 = self.ema208 / n
|
||||
self.bb2633upper = self.bb2633upper / n
|
||||
self.bb2633lower = self.bb2633lower / n
|
||||
self.bb2633middle = self.bb2633middle / n
|
||||
if len(self.klu_list) > 0:
|
||||
self.macd = self.klu_list[-1].macd
|
||||
self.signal = self.klu_list[-1].signal
|
||||
|
||||
Reference in New Issue
Block a user