Check 1day data
This commit is contained in:
+57
-2
@@ -155,13 +155,64 @@ class ChanLun():
|
||||
fx_list.append(-1)
|
||||
else:
|
||||
fx_list.append(0)
|
||||
klc_strength_list.append(klc.cal_fx_strength())
|
||||
klc_strength_list.append(klc.cal_fx_strength(2))
|
||||
#if klc.klc_fx_type != Chan_KLC_FX.UNKNOWN and klc.cal_fx_strength() > 1:
|
||||
#print(klc.start_time, klc.end_time, klc.cal_fx_strength(), klc.klc_fx_type, fx_list[-1], klc_strength_list[-1])
|
||||
else:
|
||||
klc_strength_list.append(0)
|
||||
fx_list.append(0)
|
||||
return klc_strength_list, fx_list
|
||||
def get_klc_bsp_list(self, dataframe):
|
||||
klc_list = self.get_klc_list(dataframe)
|
||||
bi_list = self.cal_bi_list(klc_list)
|
||||
bsp_list = []
|
||||
klc_index = 0
|
||||
last_top = None
|
||||
last_bottom = None
|
||||
for index in range(0, len(dataframe)):
|
||||
if klc_index == len(klc_list):
|
||||
klc_index = len(klc_list) - 1
|
||||
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.cal_fx_strength() > 1.0 and klc.cal_fx_shape() < 4:
|
||||
bsp_list.append(1)
|
||||
last_top = klc
|
||||
last_bottom = None
|
||||
|
||||
else:
|
||||
bsp_list.append(0)
|
||||
elif klc.klc_fx_type == Chan_KLC_FX.BOTTOM1 or klc.klc_fx_type == Chan_KLC_FX.BOTTOM2:
|
||||
if klc.cal_fx_strength() > 1.0 and klc.cal_fx_shape() < 4:
|
||||
bsp_list.append(-1)
|
||||
last_bottom = klc
|
||||
last_top = None
|
||||
|
||||
else:
|
||||
bsp_list.append(0)
|
||||
else:
|
||||
if last_top:
|
||||
klc_offset = klc.index - last_top.index if klc.index - last_top.index > 2 else 2
|
||||
last_top_strength = last_top.cal_fx_strength(klc_offset)
|
||||
if klc.high > last_top.high or (klc_offset > 2 and last_top_strength < 2):
|
||||
bsp_list.append(-1)
|
||||
last_top = None
|
||||
else:
|
||||
bsp_list.append(0)
|
||||
elif last_bottom:
|
||||
klc_offset = klc.index - last_bottom.index if klc.index - last_bottom.index > 2 else 2
|
||||
last_bottom_strength = last_bottom.cal_fx_strength(klc_offset)
|
||||
if klc.low < last_bottom.low or (klc_offset > 2 and last_bottom_strength < 2):
|
||||
bsp_list.append(1)
|
||||
last_bottom = None
|
||||
else:
|
||||
bsp_list.append(0)
|
||||
else:
|
||||
bsp_list.append(0)
|
||||
else:
|
||||
bsp_list.append(0)
|
||||
return bsp_list
|
||||
def get_all_state(self, df_list):
|
||||
state_list = []
|
||||
for df in df_list:
|
||||
@@ -231,10 +282,10 @@ class ChanLun():
|
||||
def get_bi_list(self, dataframe):
|
||||
bi_list = self.cal_bi_list(self.get_klc_list(dataframe))
|
||||
return bi_list
|
||||
# --------------------------------------------------------------------
|
||||
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,6 +309,10 @@ class ChanLun():
|
||||
klu = ChanKLU(time_str, o, h, l, c, v)
|
||||
klu.set_idx(i)
|
||||
klu_list.append(klu)
|
||||
if last_klu:
|
||||
last_klu.set_next(klu)
|
||||
klu.set_pre(last_klu)
|
||||
last_klu = klu
|
||||
if 'macd' in item:
|
||||
klu.set_indicators(item)
|
||||
return klu_list
|
||||
|
||||
Reference in New Issue
Block a user