INNER CODE UNIT · Python

rsi

zoharbabin/quantum-trader · src/analysis/technical_analysis.py:110

    def rsi(self, period=14):
        """Relative Strength Index"""
        if self.data is None or len(self.data) == 0:
            return None

        # Calculate price changes
        delta = self.data['close'].diff()

        # Handle special cases first
        if len(delta) < period + 1:  # Need at least period + 1 points for RSI
            result = pd.Series([np.nan] * len(self.data), index=self.data.index)
            result.name = None
            return result

        # Check if all prices are the same
        if (self.data['close'] == self.data['close'].iloc[0]).all():
            result = pd.Series([50.0] * len(self.data), index=self.data.index)
            result.name = None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…