Skip to content

Commit

Permalink
fix: KDJ计算溢出
Browse files Browse the repository at this point in the history
  • Loading branch information
Vespa314 committed Sep 25, 2023
1 parent 6ad2c41 commit 89df7b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Math/KDJ.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def add(self, high, low, close) -> KDJ_Item:
hn = max([x['high'] for x in self.arr])
ln = min([x['low'] for x in self.arr])
cn = close
rsv = 100 * (cn - ln) / (hn - ln)
rsv = 100 * (cn - ln) / (hn - ln) if hn != ln else 0.0

cur_k = 2 / 3 * self.pre_kdj.k + 1 / 3 * rsv
cur_d = 2 / 3 * self.pre_kdj.d + 1 / 3 * cur_k
Expand Down

0 comments on commit 89df7b6

Please sign in to comment.