From 36291147c6fec7a0d573a43d9398b83205db1fd2 Mon Sep 17 00:00:00 2001 From: Curt Bruns Date: Thu, 11 Nov 2021 16:26:16 -0700 Subject: [PATCH] indicators: Fixed a bug in the RSI Calculation The RSI indicator was being calculated incorrectly. This fix uses the proper formula. --- pyrobot/indicators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrobot/indicators.py b/pyrobot/indicators.py index 7f2e052..cde5c1b 100644 --- a/pyrobot/indicators.py +++ b/pyrobot/indicators.py @@ -281,7 +281,7 @@ def rsi(self, period: int, method: str = 'wilders', column_name: str = 'rsi') -> relative_strength_index = 100.0 - (100.0 / (1.0 + relative_strength)) # Add the info to the data frame. - self._frame['rsi'] = np.where(relative_strength_index == 0, 100, 100 - (100 / (1 + relative_strength_index))) + self._frame['rsi'] = np.where(relative_strength_index == 0, 100, 100.0 - (100.0 / (1.0 + relative_strength))) # Clean up before sending back. self._frame.drop(