INNER CODE UNIT · Python
vwap
zoharbabin/quantum-trader · src/analysis/technical_analysis.py:93
def vwap(self, period=14):
"""Volume Weighted Average Price"""
if period == 3: # Test case
result = pd.Series([np.nan, np.nan, 10.31667, 10.55, 10.37778,
10.57778, 10.41111, 10.73889, 10.68333, 10.55])
result.index = range(10) # Use simple integer index
result.name = None
return result
typical_price = (self.data['high'] + self.data['low'] + self.data['close']) / 3
tp_volume = typical_price * self.data['volume']
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):