修改了一些东西
This commit is contained in:
+13
-11
@@ -47,7 +47,9 @@ class ChanKLC():
|
||||
self.signal = 0
|
||||
self.state = Chan_MACD_STATE.UNKNOWN
|
||||
self.continue_div = False
|
||||
self.separate_div = 0
|
||||
self.separate_div = False
|
||||
self.ema52 = klu.ema52
|
||||
self.ema24 = klu.ema24
|
||||
def set_last_top_klu(self, last_top_klc):
|
||||
self.last_top_klc = last_top_klc
|
||||
def set_last_bottom_klc(self, last_bottom_klc):
|
||||
@@ -62,21 +64,17 @@ class ChanKLC():
|
||||
self.end_klu = klu
|
||||
self.end_time = klu.time
|
||||
self.close = klu.close
|
||||
self.cal_indicators()
|
||||
self.cal_shape_1()
|
||||
self.strength = self.cal_klc_strength()
|
||||
self.cal_bb_out()
|
||||
if self.pre:
|
||||
self.pre.cal_bb_out()
|
||||
def cal_bb_out(self):
|
||||
return
|
||||
for klu in self.klus:
|
||||
if klu.macd_state != Chan_MACD_STATE.UNKNOWN:
|
||||
self.state = klu.macd_state
|
||||
if klu.separate_div > 0:
|
||||
self.separate_div = True
|
||||
if klu.continue_div:
|
||||
self.continue_div = klu.continue_div
|
||||
if klu.macd_state != Chan_MACD_STATE.UNKNOWN:
|
||||
self.state = klu.macd_state
|
||||
self.cal_indicators()
|
||||
def cal_bb_out(self):
|
||||
return
|
||||
for klu in self.klus:
|
||||
if self.high >= klu.bbup302 and klu.bbup302 > 0 and (self.klc_fx_type == Chan_KLC_FX.TOP1 or self.klc_fx_type == Chan_KLC_FX.TOP2):
|
||||
#print(self.end_time, self.high, klu.bbup302, self.klc_fx_type)
|
||||
if self.high >= klu.bbup30 and klu.bbup30 > 0 and self.next and (self.next.macd - self.macd) < 0:
|
||||
@@ -119,10 +117,14 @@ class ChanKLC():
|
||||
self.rsi += self.klus[index].rsi
|
||||
self.volume_ratio += self.klus[index].volume_ratio
|
||||
self.macdhist += self.klus[index].macdhist
|
||||
self.ema52 += self.klus[index].ema52
|
||||
self.ema24 += self.klus[index].ema24
|
||||
self.rsi = self.rsi / len(self.klus)
|
||||
self.volume_ratio = self.volume_ratio / len(self.klus)
|
||||
self.volume = self.volume / len(self.klus)
|
||||
self.macdhist = self.macdhist / len(self.klus)
|
||||
self.ema52 = self.ema52 / len(self.klus)
|
||||
self.ema24 = self.ema24 / len(self.klus)
|
||||
if len(self.klus) > 0:
|
||||
self.macd = self.klus[-1].macd
|
||||
self.signal = self.klus[-1].signal
|
||||
|
||||
+9
-13
@@ -1,6 +1,6 @@
|
||||
from datetime import timedelta
|
||||
from pandas import DataFrame
|
||||
from ChanEnum import Chan_FX_TYPE, Chan_KLINE_DIR, Chan_BI_DIR, Chan_SEG_DIR, Chan_ZS_DIR, Chan_BSP_DIR, Chan_BSP_TYPE, Chan_KLC_FX
|
||||
from ChanEnum import Chan_FX_TYPE, Chan_KLINE_DIR, Chan_BI_DIR, Chan_SEG_DIR, Chan_ZS_DIR, Chan_BSP_DIR, Chan_BSP_TYPE, Chan_KLC_FX, Chan_MACD_STATE
|
||||
from ChanKLU import ChanKLU
|
||||
from ChanKLC import ChanKLC
|
||||
from ChanBI import ChanBI
|
||||
@@ -53,19 +53,15 @@ class ChanLun():
|
||||
def check_fx(self, klc):
|
||||
if klc.pre and klc.next:
|
||||
if klc.high > klc.pre.high and klc.high > klc.next.high:
|
||||
if klc.pre.pre and klc.high > klc.pre.pre.high and klc.next.next and klc.high > klc.next.next.high:
|
||||
if klc.pre.pre.pre and klc.high > klc.pre.pre.pre.high and klc.next.next.next and klc.high > klc.next.next.next.high:
|
||||
if klc.signal > 0 and klc.macd > klc.signal:
|
||||
klc.set_fx(Chan_FX_TYPE.TOP)
|
||||
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "TOP")
|
||||
return Chan_FX_TYPE.TOP
|
||||
if klc.signal > 0 and klc.macd > klc.signal:
|
||||
klc.set_fx(Chan_FX_TYPE.TOP)
|
||||
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "TOP")
|
||||
return Chan_FX_TYPE.TOP
|
||||
elif klc.low < klc.pre.low and klc.low < klc.next.low:
|
||||
if klc.pre.pre and klc.low < klc.pre.pre.low and klc.next.next and klc.low < klc.next.next.low:
|
||||
if klc.pre.pre.pre and klc.low < klc.pre.pre.pre.low and klc.next.next.next and klc.low < klc.next.next.next.low:
|
||||
if klc.signal < 0 and klc.macd < klc.signal:
|
||||
klc.set_fx(Chan_FX_TYPE.BOTTOM)
|
||||
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "BOTTOM")
|
||||
return Chan_FX_TYPE.BOTTOM
|
||||
if klc.signal < 0 and klc.macd < klc.signal:
|
||||
klc.set_fx(Chan_FX_TYPE.BOTTOM)
|
||||
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "BOTTOM")
|
||||
return Chan_FX_TYPE.BOTTOM
|
||||
return Chan_FX_TYPE.UNKNOWN
|
||||
def add_indicators(self, df):
|
||||
fast = 12
|
||||
|
||||
@@ -42,19 +42,15 @@ class TF_DF():
|
||||
def check_fx(self, klc):
|
||||
if klc.pre and klc.next:
|
||||
if klc.high > klc.pre.high and klc.high > klc.next.high:
|
||||
if klc.pre.pre and klc.high > klc.pre.pre.high and klc.next.next and klc.high > klc.next.next.high:
|
||||
if klc.pre.pre.pre and klc.high > klc.pre.pre.pre.high and klc.next.next.next and klc.high > klc.next.next.next.high:
|
||||
if klc.macd > 0 and klc.macd > klc.signal and klc.signal > klc.macdhist:
|
||||
klc.set_fx(Chan_FX_TYPE.TOP)
|
||||
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "TOP")
|
||||
return Chan_FX_TYPE.TOP
|
||||
if klc.macd > 0 and klc.macd > klc.signal and klc.signal > klc.macdhist:
|
||||
klc.set_fx(Chan_FX_TYPE.TOP)
|
||||
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "TOP")
|
||||
return Chan_FX_TYPE.TOP
|
||||
elif klc.low < klc.pre.low and klc.low < klc.next.low:
|
||||
if klc.pre.pre and klc.low < klc.pre.pre.low and klc.next.next and klc.low < klc.next.next.low:
|
||||
if klc.pre.pre.pre and klc.low < klc.pre.pre.pre.low and klc.next.next.next and klc.low < klc.next.next.next.low:
|
||||
if klc.macd < 0 and klc.macd < klc.signal and klc.signal < klc.macdhist:
|
||||
klc.set_fx(Chan_FX_TYPE.BOTTOM)
|
||||
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "BOTTOM")
|
||||
return Chan_FX_TYPE.BOTTOM
|
||||
if klc.macd < 0 and klc.macd < klc.signal and klc.signal < klc.macdhist:
|
||||
klc.set_fx(Chan_FX_TYPE.BOTTOM)
|
||||
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "BOTTOM")
|
||||
return Chan_FX_TYPE.BOTTOM
|
||||
return Chan_FX_TYPE.UNKNOWN
|
||||
|
||||
def cal_kl_data(self, dataframe:DataFrame):
|
||||
|
||||
Reference in New Issue
Block a user