添加识别中继分型
This commit is contained in:
+37
-1
@@ -4,7 +4,7 @@ from typing import Dict, Optional
|
||||
from ChanEnum import Chan_FX_TYPE, Chan_KLINE_DIR, Chan_BI_DIR, Chan_KLC_FX, Chan_K_DIR, Chan_MACD_STATE, Chan_PRICE_TREND, Chan_EMA_POS, Chan_EMA_SEMANTIC, Chan_BSP_TYPE
|
||||
import ChanKLU
|
||||
import ChanCTime
|
||||
|
||||
import Chan_FX_Box
|
||||
# 根据结合律合并K线后的K线
|
||||
class ChanKLC():
|
||||
def __init__(self, klu: ChanKLU, index, ddir=Chan_KLINE_DIR.UP):
|
||||
@@ -51,6 +51,8 @@ class ChanKLC():
|
||||
self.ema104 = klu.ema104
|
||||
self.ema156 = klu.ema156
|
||||
self.ema208 = klu.ema208
|
||||
self.ema13 = klu.ema13
|
||||
self.ema7 = klu.ema7
|
||||
self.trend = Chan_PRICE_TREND.UNKNOWN
|
||||
self.exception = klu.exception
|
||||
self.klc_dir = Chan_KLINE_DIR.UP if klu.close > klu.open else Chan_KLINE_DIR.DOWN
|
||||
@@ -67,6 +69,7 @@ class ChanKLC():
|
||||
self.bb2633middle = klu.bb2633middle
|
||||
self.ema5 = klu.ema5
|
||||
self.ma5 = klu.ma5
|
||||
self.fx_box = None
|
||||
# ==================== EMA 通用计算方法 ====================
|
||||
|
||||
@staticmethod
|
||||
@@ -320,6 +323,35 @@ class ChanKLC():
|
||||
#print(self.end_time, ema_name, self.ema_status[ema_name]['semantic'], hist_div)
|
||||
#self.cal_bb_out()
|
||||
#print(self.pre.start_time, self.next.end_time, self.klc_fx_type)
|
||||
if klc_fx_type == Chan_KLC_FX.TOP1 or klc_fx_type == Chan_KLC_FX.TOP2 or klc_fx_type == Chan_KLC_FX.BOTTOM1 or klc_fx_type == Chan_KLC_FX.BOTTOM2:
|
||||
self.cal_fx_box()
|
||||
def cal_fx_box(self):
|
||||
# 每次重算前先清空,避免旧box残留
|
||||
self.fx_box = None
|
||||
start_time = None
|
||||
end_time = None
|
||||
high = 0
|
||||
low = 0
|
||||
display = False
|
||||
if self.pre and self.next:
|
||||
if self.fx == Chan_FX_TYPE.TOP:
|
||||
start_time = self.pre.start_time
|
||||
end_time = self.next.end_time
|
||||
high = self.high
|
||||
low = self.pre.low if self.pre.low < self.next.low else self.next.low
|
||||
if self.next.close < self.pre.open:
|
||||
display = True
|
||||
elif self.fx == Chan_FX_TYPE.BOTTOM:
|
||||
start_time = self.pre.start_time
|
||||
end_time = self.next.end_time
|
||||
high = self.pre.high if self.pre.high > self.next.high else self.next.high
|
||||
low = self.low
|
||||
if self.next.close > self.pre.open:
|
||||
display = True
|
||||
if high > 0 and display:
|
||||
print(start_time, end_time, high, low)
|
||||
# Chan_FX_BOX 这里导入的是模块,类名在模块内部为 Chan_FX_Box
|
||||
self.fx_box = Chan_FX_Box.Chan_FX_Box(start_time, end_time, high, low)
|
||||
def add_klu(self, klu):
|
||||
self.klu_list.append(klu)
|
||||
def set_end_klu(self, klu):
|
||||
@@ -397,6 +429,8 @@ class ChanKLC():
|
||||
self.ema104 += self.klu_list[index].ema104
|
||||
self.ema156 += self.klu_list[index].ema156
|
||||
self.ema208 += self.klu_list[index].ema208
|
||||
self.ema13 += self.klu_list[index].ema13
|
||||
self.ema7 += self.klu_list[index].ema7
|
||||
self.bb2633upper += self.klu_list[index].bb2633upper
|
||||
self.bb2633lower += self.klu_list[index].bb2633lower
|
||||
self.bb2633middle += self.klu_list[index].bb2633middle
|
||||
@@ -415,6 +449,8 @@ class ChanKLC():
|
||||
self.ema104 = self.ema104 / n
|
||||
self.ema156 = self.ema156 / n
|
||||
self.ema208 = self.ema208 / n
|
||||
self.ema13 = self.ema13 / n
|
||||
self.ema7 = self.ema7 / n
|
||||
self.ma5 = self.ma5 / n
|
||||
self.ema5 = self.ema5 / n
|
||||
self.bb2633upper = self.bb2633upper / n
|
||||
|
||||
Reference in New Issue
Block a user