def alpha_25(self): """ formula: (-1 * ts_max(correlation(ts_rank(volume, 5), ts_rank(high, 5), 5), 3)) """ return -1 * _utils.ts_max(_utils.correlation( _utils.ts_rank(self.volume, window=5), _utils.ts_rank(self.high, window=5), window=5), window=3).fillna(method='backfill')
def alpha_11(self): """ formula: ((rank(ts_max((vwap - close), 3)) + rank(ts_min((vwap - close), 3)))*rank(delta(volume, 3))) :return:df backfilled """ df = (_utils.rank(_utils.ts_max(self.vwap - self.close, window=3)) + _utils.rank(_utils.ts_min(self.vwap - self.close, window=3)) ) * _utils.delta(self.volume, period=3) return df.fillna(method='backfill')
def alpha_48(self): """ formula: (-1 * ts_max(rank(correlation(rank(volume), rank(vwap), 5)), 5)) :return: """ df = (-1 * _utils.ts_max( _utils.rank( _utils.correlation(_utils.rank(self.volume), _utils.rank(self.vwap), 5)), 5)) return df.fillna(method='bfill')
def alpha_26(self): """ formula: (-1* ts_max(correlation(ts_rank(volume, 5), ts_rank(high, 5), 5), 3)) """ df = _utils.correlation(_utils.ts_rank(self.volume, window=5), _utils.ts_rank(self.high, window=5), window=3) df = df.replace([-np.inf, np.inf], 0) df = -1 * _utils.ts_max(df.fillna(method='backfill'), window=3) return df.fillna(0.5)
def alpha_10(self): """ formula: rank(((0 < ts_min(delta(close, 1), 4)) ? delta(close, 1) : ((ts_max(delta(close, 1), 4) < 0) ? delta(close, 1) : (-1*delta(close, 1))))) """ delta_close = _utils.delta(self.close, period=1) condition_1 = _utils.ts_min(delta_close, window=4) > 0 condition_2 = _utils.ts_max(delta_close, window=4) < 0 alpha = -1 * delta_close alpha[condition_1 | condition_2] = delta_close return _utils.rank(alpha)
def alpha_9(self): """ formula: ((0 < ts_min(delta(close, 1), 5)) ? delta(close, 1) : ((ts_max(delta(close, 1), 5) < 0) ? delta(close, 1) : (-1*delta(close, 1)))) """ delta_close = _utils.delta(self.close, period=1) condition_1 = _utils.ts_min(delta_close, window=5) > 0 condition_2 = _utils.ts_max(delta_close, window=5) < 0 alpha = -1 * delta_close alpha[condition_1 | condition_2] = delta_close return alpha