Remove redundant loss.replace, add constants for magic numbers, document threading safety
This commit is contained in:
1 parent
6c878c4e63
commit
a35e6b6d8e
2 files changed
+17
-2
No files matched your search
@@ -10,7 +10,6 @@ def rsi(data, window=14):
|
||||
delta = data.diff()
|
||||
gain = (delta.where(delta > 0, 0)).rolling(window=window).mean()
|
||||
loss = (-delta.where(delta < 0, 0)).rolling(window=window).mean()
|
||||
loss = loss.replace(0, 1e-10)
|
||||
loss = loss.clip(lower=1e-10)
|
||||
rs = gain / loss
|
||||
rsi_val = 100 - (100 / (1 + rs))
|
||||
|
||||
Reference in new issue
Block a user