Add klc and klu fx strength check
This commit is contained in:
+10
-4
@@ -67,12 +67,12 @@ class ChanLun():
|
||||
else:
|
||||
print(bi.start_klc.end_time, bi.dir, bi.is_sure)
|
||||
def check_fx(self, klc):
|
||||
if klc.pre and klc.next:
|
||||
if klc.pre and klc.next and klc.next.end_klu:
|
||||
if klc.high > klc.pre.high and klc.high > klc.next.high:
|
||||
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.pre and klc.next:
|
||||
if klc.pre and klc.next and klc.next.end_klu:
|
||||
if klc.low < klc.pre.low and klc.low < klc.next.low:
|
||||
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")
|
||||
@@ -149,9 +149,9 @@ class ChanLun():
|
||||
klc = klc_list[klc_index]
|
||||
if klc.end_klu and klc.end_klu.idx == index:
|
||||
klc_index += 1
|
||||
if klc.klc_fx_type == Chan_KLC_FX.TOP1 or klc.klc_fx_type == Chan_KLC_FX.TOP2:
|
||||
if (klc.klc_fx_type == Chan_KLC_FX.TOP1 or klc.klc_fx_type == Chan_KLC_FX.TOP2) and klc.contain_klu_fx():
|
||||
fx_list.append(1)
|
||||
elif klc.klc_fx_type == Chan_KLC_FX.BOTTOM1 or klc.klc_fx_type == Chan_KLC_FX.BOTTOM2:
|
||||
elif (klc.klc_fx_type == Chan_KLC_FX.BOTTOM1 or klc.klc_fx_type == Chan_KLC_FX.BOTTOM2) and klc.contain_klu_fx():
|
||||
fx_list.append(-1)
|
||||
else:
|
||||
fx_list.append(0)
|
||||
@@ -235,6 +235,7 @@ class ChanLun():
|
||||
def get_kl_data(self, dataframe:DataFrame):
|
||||
fields = "time,open,high,low,close,volume"
|
||||
klu_list = []
|
||||
last_klu = None
|
||||
for i in range(0, len(dataframe)):
|
||||
item = dataframe.iloc[i]
|
||||
date = item['date']
|
||||
@@ -258,8 +259,13 @@ class ChanLun():
|
||||
klu = ChanKLU(time_str, o, h, l, c, v)
|
||||
klu.set_idx(i)
|
||||
klu_list.append(klu)
|
||||
if last_klu:
|
||||
klu.set_pre(last_klu)
|
||||
last_klu.set_next(klu)
|
||||
last_klu.detect_realtime_fx()
|
||||
if 'macd' in item:
|
||||
klu.set_indicators(item)
|
||||
last_klu = klu
|
||||
return klu_list
|
||||
def cal_volume_ratio(self, dataframe, window=10):
|
||||
df = dataframe.copy()
|
||||
|
||||
Reference in New Issue
Block a user