def volumeTechnicalIndicators(price, volume, tot_lags, prefix): data_result = priceTechnicalIndicator(volume, tot_lags, prefix) # OBV lags = tot_lags obv = OBV(price, volume) for lag in lags: tmp = obv.diff(lag) # diff, otherwise the scale would change if accumulates tmp.name = 'OBV_DIFF_%dD' % lag data_result = data_result.join(tmp) # VOLUME RATIO lag = 5 tmp = volume.rolling(window=lag).mean() volume_ratio = volume / tmp volume_ratio.name = 'VOLUME_RATIO' data_result = data_result.join(volume_ratio) return data_result
def amountTechnicalIndicators(price, amount, tot_lags, prefix): data_result = priceTechnicalIndicator(amount, tot_lags, prefix) # OBV lags = tot_lags amt_obv = OBV(price, amount) for lag in lags: tmp = amt_obv.diff(lag) # diff, otherwise the scale would change if accumulates tmp.name = 'AMT_OBV_DIFF_%dD' % lag data_result = data_result.join(tmp) # AMOUNT RATIO lags = np.array(tot_lags) lags = lags[lags >= 2] for lag in lags: tmp = amount.rolling(window=lag).mean() amt_ratio = amount / tmp amt_ratio.name = 'AMOUNT_RATIO_%dD' % lag data_result = data_result.join(amt_ratio) return data_result