添加中枢识别在klc和笔
This commit is contained in:
+32
-3
@@ -1,7 +1,9 @@
|
||||
import copy
|
||||
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, Chan_KLC_STATE
|
||||
from ChanEnum import Chan_FX_TYPE, Chan_KLINE_DIR, Chan_BI_DIR, Chan_KLC_FX
|
||||
from ChanEnum import Chan_K_DIR, Chan_MACD_STATE, Chan_PRICE_TREND, Chan_EMA_POS
|
||||
from ChanEnum import Chan_EMA_SEMANTIC, Chan_BSP_TYPE, Chan_KLC_STATE, Chan_FX
|
||||
import ChanKLU
|
||||
import ChanCTime
|
||||
import Chan_FX_Box
|
||||
@@ -41,8 +43,8 @@ class ChanKLC():
|
||||
self.candle_dir = klu.candle_dir
|
||||
self.range = klu.range
|
||||
self.bb_out = True
|
||||
self.macd = 0
|
||||
self.signal = 0
|
||||
self.macd = klu.macd
|
||||
self.signal = klu.signal
|
||||
self.state = Chan_MACD_STATE.UNKNOWN
|
||||
self.continue_div = False
|
||||
self.separate_div = False
|
||||
@@ -73,6 +75,14 @@ class ChanKLC():
|
||||
self.fx_box = None
|
||||
self.in_fx = False
|
||||
self.fx_confirmed = False
|
||||
self.ema52_dis = klu.high - klu.ema52 if klu.close > klu.ema52 else klu.ema52 - klu.low
|
||||
self.ema26_dis = klu.high - klu.ema26 if klu.close > klu.ema26 else klu.ema26 - klu.low
|
||||
self.macd_signal_dis = abs(klu.macd - klu.signal)
|
||||
self.ema52_ema26_dis = abs(klu.ema52 - klu.ema26)
|
||||
self.fx_type = Chan_FX.UNKNOWN
|
||||
self.bi_zs = None
|
||||
self.seg_zs = None
|
||||
self.last_bi_zs = None
|
||||
# ==================== EMA 通用计算方法 ====================
|
||||
|
||||
@staticmethod
|
||||
@@ -315,6 +325,9 @@ class ChanKLC():
|
||||
price_diff = getattr(self, 'price_diff', None)
|
||||
out += str(start) + " " + str(end) + " " + str(self.close) + " " + str(self.ema24) + " " + str(self.ema52) + " " + str(self.trend) + " " + str(self.close - self.ema52)
|
||||
return out
|
||||
def set_bi_zs(self, bi_zs):
|
||||
if bi_zs:
|
||||
self.bi_zs = bi_zs
|
||||
def set_klc_fx_type(self, klc_fx_type):
|
||||
#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
|
||||
@@ -328,6 +341,22 @@ class ChanKLC():
|
||||
#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()
|
||||
self.cal_fx_type()
|
||||
def cal_fx_type(self):
|
||||
if self.fx == Chan_FX_TYPE.TOP and self.next:
|
||||
if self.ema52_dis > self.ema26_dis:
|
||||
if self.pre.macd < self.macd and self.macd < self.next.macd:
|
||||
self.fx_type = Chan_FX.CONTINUATION
|
||||
else:
|
||||
self.fx_type = Chan_FX.REVERSAL
|
||||
elif self.fx == Chan_FX_TYPE.BOTTOM and self.next:
|
||||
if self.ema52_dis < self.ema26_dis:
|
||||
if self.pre.macd > self.macd and self.macd > self.next.macd:
|
||||
self.fx_type = Chan_FX.CONTINUATION
|
||||
else:
|
||||
self.fx_type = Chan_FX.REVERSAL
|
||||
if self.fx_type != Chan_FX.UNKNOWN and self.fx_type != Chan_FX.CONTINUATION:
|
||||
print(self.end_time, self.fx_type)
|
||||
def cal_fx_box(self):
|
||||
# 每次重算前先清空,避免旧box残留
|
||||
self.fx_box = None
|
||||
|
||||
Reference in New Issue
Block a user