解决除以0的问题

This commit is contained in:
jackyu66git
2026-02-02 12:44:30 +08:00
parent cefd048ab5
commit da3d7cde25
2 changed files with 6 additions and 3 deletions
+3 -3
View File
@@ -34,9 +34,9 @@ class ChanKLU:
self.body = abs(self.close - self.open)
self.upper_shadow = self.high - max(self.close, self.open)
self.lower_shadow = min(self.close, self.open) - self.low
self.body_ratio = self.body / self.range
self.upper_shadow_ratio = self.upper_shadow / self.body
self.lower_shadow_ratio = self.lower_shadow / self.body
self.body_ratio = self.body / self.range if self.range != 0 else 0
self.upper_shadow_ratio = self.upper_shadow / self.body if self.body != 0 else float('inf')
self.lower_shadow_ratio = self.lower_shadow / self.body if self.body != 0 else float('inf')
self.exception = False
#self.cal_exception()
self.candle_dir = Chan_K_DIR.CROSS if self.close == self.open else Chan_K_DIR.BULL if self.close > self.open else Chan_K_DIR.BEAR