Skip to content

Commit

Permalink
fix: 笔计算bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Vespa314 committed Nov 27, 2023
1 parent 5ad4af7 commit 364992c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Bi/BiList.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ def update_bi(self, klc: CKLine, last_klc: CKLine, cal_virtual: bool) -> bool:
else:
return flag1

def can_update_peak(self, klc: CKLine):
if self.config.bi_allow_sub_peak or len(self.bi_list) < 2:
return False
if self.bi_list[-1].is_down() and klc.high < self.bi_list[-1].get_begin_val():
return False
if self.bi_list[-1].is_up() and klc.low > self.bi_list[-1].get_begin_val():
return False
if not end_is_peak(self.bi_list[-2].begin_klc, klc):
return False
if self[-1].is_down() and self[-1].get_end_val() < self[-2].get_begin_val():
return False
if self[-1].is_up() and self[-1].get_end_val() > self[-2].get_begin_val():
return False
return True

def update_bi_sure(self, klc: CKLine) -> bool:
# klc: 倒数第二根klc
_tmp_end = self.get_last_klu_of_last_bi()
Expand All @@ -70,10 +85,7 @@ def update_bi_sure(self, klc: CKLine) -> bool:
self.add_new_bi(self.last_end, klc)
self.last_end = klc
return True
elif not self.config.bi_allow_sub_peak and ( \
(self.bi_list[-1].is_down() and klc.high >= self.bi_list[-1].get_begin_val()) or \
(self.bi_list[-1].is_up() and klc.high <= self.bi_list[-1].get_begin_val()) \
):
elif self.can_update_peak(klc):
self.bi_list = self.bi_list[:-1]
return self.try_update_end(klc)
return _tmp_end != self.get_last_klu_of_last_bi()
Expand Down

0 comments on commit 364992c

Please sign in to comment.