添加笔中枢,删除了很多没有用的方法
This commit is contained in:
+35
-13
@@ -246,7 +246,7 @@ class ChanLun():
|
||||
if last_down_sbi.has_fx_gap:
|
||||
look_for_bottom = True
|
||||
last_seg.pre_set_end_bi(bi_list[last_down_sbi.start_bi.index - 1])
|
||||
seg = ChanSEG(last_down_sbi.start_bi, len(seg_list), Chan_SEG_DIR.DOWN)
|
||||
seg = ChanSEG(last_down_sbi.start_bi, len(seg_list), Chan_SEG_DIR.DOWN, bi)
|
||||
seg_list.append(seg)
|
||||
last_seg.set_next(seg)
|
||||
seg.set_pre(last_seg)
|
||||
@@ -272,7 +272,7 @@ class ChanLun():
|
||||
#print(bi.start_time, look_for_top, "UP 3")
|
||||
else:
|
||||
last_seg.set_end_bi(bi_list[last_down_sbi.start_bi.index - 1], bi)
|
||||
seg = ChanSEG(last_down_sbi.start_bi, len(seg_list), Chan_SEG_DIR.DOWN)
|
||||
seg = ChanSEG(last_down_sbi.start_bi, len(seg_list), Chan_SEG_DIR.DOWN, bi)
|
||||
seg_list.append(seg)
|
||||
last_seg.set_next(seg)
|
||||
seg.set_pre(last_seg)
|
||||
@@ -340,7 +340,7 @@ class ChanLun():
|
||||
if last_up_sbi.has_fx_gap:
|
||||
look_for_top = True
|
||||
last_seg.pre_set_end_bi(bi_list[last_up_sbi.start_bi.index - 1])
|
||||
seg = ChanSEG(last_up_sbi.start_bi, len(seg_list), Chan_SEG_DIR.UP)
|
||||
seg = ChanSEG(last_up_sbi.start_bi, len(seg_list), Chan_SEG_DIR.UP, bi)
|
||||
seg_list.append(seg)
|
||||
last_seg.set_next(seg)
|
||||
seg.set_pre(last_seg)
|
||||
@@ -366,7 +366,7 @@ class ChanLun():
|
||||
#print(bi.start_time, look_for_top, "DOWN 3")
|
||||
else:
|
||||
last_seg.set_end_bi(bi_list[last_up_sbi.start_bi.index - 1], bi)
|
||||
seg = ChanSEG(last_up_sbi.start_bi, len(seg_list), Chan_SEG_DIR.UP)
|
||||
seg = ChanSEG(last_up_sbi.start_bi, len(seg_list), Chan_SEG_DIR.UP, bi)
|
||||
#print(last_up_sbi.start_bi.start_time)
|
||||
last_seg.set_next(seg)
|
||||
seg.set_pre(last_seg)
|
||||
@@ -414,14 +414,14 @@ class ChanLun():
|
||||
else:
|
||||
if bi.check_overlap():
|
||||
if bi.dir == Chan_BI_DIR.UP:
|
||||
seg = ChanSEG(bi, len(seg_list), Chan_SEG_DIR.UP)
|
||||
seg = ChanSEG(bi, len(seg_list), Chan_SEG_DIR.UP, bi)
|
||||
last_up_bi = bi
|
||||
last_up_sbi = ChanSBI(bi, len(up_sbi_list), bi.dir)
|
||||
seg_list.append(seg)
|
||||
last_seg = seg
|
||||
#print(bi.start_time, 'Create first UP SEG')
|
||||
else:
|
||||
seg = ChanSEG(bi, len(seg_list), Chan_SEG_DIR.DOWN)
|
||||
seg = ChanSEG(bi, len(seg_list), Chan_SEG_DIR.DOWN, bi)
|
||||
last_down_bi = bi
|
||||
last_down_sbi = ChanSBI(bi, len(down_sbi_list), bi.dir)
|
||||
seg_list.append(seg)
|
||||
@@ -448,7 +448,7 @@ class ChanLun():
|
||||
# The confirmed
|
||||
print("Last UP seg is broken, create a new seg. 1")
|
||||
seg.pre_set_end_bi(bi_list[i])
|
||||
seg = ChanSEG(bi_list[i+1], len(seg_list), Chan_SEG_DIR.DOWN)
|
||||
seg = ChanSEG(bi_list[i+1], len(seg_list), Chan_SEG_DIR.DOWN, bi)
|
||||
seg_list.append(seg)
|
||||
last_seg = seg_list[-2]
|
||||
if len(last_seg.bi_list) > 3:
|
||||
@@ -460,7 +460,7 @@ class ChanLun():
|
||||
if bi_list[i].low < last_seg_peak:
|
||||
print("Last DOWN seg is broken, create a new seg. 1")
|
||||
seg.pre_set_end_bi(bi_list[i])
|
||||
seg = ChanSEG(bi_list[i+1], len(seg_list), Chan_SEG_DIR.UP)
|
||||
seg = ChanSEG(bi_list[i+1], len(seg_list), Chan_SEG_DIR.UP, bi)
|
||||
seg_list.append(seg)
|
||||
last_seg = seg_list[-2]
|
||||
if len(last_seg.bi_list) > 3:
|
||||
@@ -478,12 +478,13 @@ class ChanLun():
|
||||
if bi_list[i].high > last_seg_peak:
|
||||
print("Last seg is broken, create a new seg. 2")
|
||||
last_seg.pre_set_end_bi(bi_list[i-1])
|
||||
seg = ChanSEG(bi_list[i], len(seg_list), Chan_SEG_DIR.UP)
|
||||
seg = ChanSEG(bi_list[i], len(seg_list), Chan_SEG_DIR.UP, bi)
|
||||
seg_list.append(seg)
|
||||
last_seg = seg
|
||||
last_seg_bi = bi_list[i]
|
||||
break
|
||||
"""
|
||||
self.cal_bi_zs(seg_list)
|
||||
return seg_list
|
||||
def cal_trend(self, klc_list):
|
||||
"""
|
||||
@@ -1170,7 +1171,7 @@ class ChanLun():
|
||||
# SEG is not in ZS
|
||||
if seg.is_sure:
|
||||
if ((seg.low > last_zs.zg and seg.high > last_zs.zg) or (seg.high < last_zs.zd and seg.low < last_zs.zd)):
|
||||
last_zs.set_end_klc(seg.pre.pre.end_bi.end_klc, seg.sure_time, bi_out_count, seg)
|
||||
last_zs.set_end_klc(seg.pre.end_bi.end_klc, seg.sure_time, bi_out_count, seg.pre)
|
||||
bi_out_count = 0
|
||||
#print(seg.start_bi.start_klc.start_time)
|
||||
first_bi_out = None
|
||||
@@ -1285,6 +1286,13 @@ class ChanLun():
|
||||
bsp_list.append(bsp)
|
||||
#self.print_zs(zs_list)
|
||||
return zs_list
|
||||
def cal_bi_zs(self, seg_list):
|
||||
bi_zs_list = []
|
||||
for seg in seg_list:
|
||||
zs_list = seg.cal_bi_zs()
|
||||
if len(zs_list) > 0:
|
||||
bi_zs_list.append(zs_list)
|
||||
return bi_zs_list
|
||||
|
||||
def get_decimal(self, value):
|
||||
return Decimal("{:.2f}".format(value))
|
||||
@@ -1297,19 +1305,33 @@ class ChanLun():
|
||||
for klu in klu_list:
|
||||
if len(klc_list) > 0:
|
||||
last_klc = klc_list[-1]
|
||||
included = last_klc.check_klu_included(klu)
|
||||
if not included:
|
||||
if klu.exception:
|
||||
ddir = Chan_KLINE_DIR.DOWN
|
||||
if last_klc.high < klu.high:
|
||||
ddir = Chan_KLINE_DIR.UP
|
||||
klc = ChanKLC(klu, index=len(klc_list), ddir=ddir)
|
||||
klc.high = klu.close if klu.close > klu.open else klu.open
|
||||
klc.low = klu.open if klu.close > klu.open else klu.close
|
||||
klc_list.append(klc)
|
||||
last_klc.set_next(klc)
|
||||
klc.set_pre(last_klc)
|
||||
last_klc.set_end_klu(last_klu)
|
||||
klc.set_pre_fx()
|
||||
#print(klu.time, klu.high, klu.low, klu.close, klu.open, klu.exception)
|
||||
else:
|
||||
last_klc.add_klu(klu)
|
||||
included = last_klc.check_klu_included(klu)
|
||||
if not included:
|
||||
ddir = Chan_KLINE_DIR.DOWN
|
||||
if last_klc.high < klu.high:
|
||||
ddir = Chan_KLINE_DIR.UP
|
||||
klc = ChanKLC(klu, index=len(klc_list), ddir=ddir)
|
||||
klc_list.append(klc)
|
||||
last_klc.set_next(klc)
|
||||
klc.set_pre(last_klc)
|
||||
last_klc.set_end_klu(last_klu)
|
||||
klc.set_pre_fx()
|
||||
else:
|
||||
last_klc.add_klu(klu)
|
||||
else:
|
||||
ddir = Chan_KLINE_DIR.UP
|
||||
if klu.open > klu.close:
|
||||
|
||||
Reference in New Issue
Block a user