INNER CODE UNIT · Python
cumulative_tp
zoharbabin/quantum-trader · src/analysis/technical_analysis.py:104
cumulative_tp = tp_volume.rolling(window=period).sum()
cumulative_vol = self.data['volume'].rolling(window=period).sum()
result = cumulative_tp / cumulative_vol
result.name = None
return result
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