Esempio n. 1
0
 def alpha_8(self):
     """
     formula: (-1*rank(((sum(open, 5)*sum(returns, 5)) - delay((sum(open, 5)*sum(returns, 5)), 10))))
     """
     df = -1 * _utils.rank(
         _utils.ts_sum(self.open, window=5) *
         _utils.ts_sum(self.returns, window=5) -
         _utils.delay(_utils.ts_sum(self.open, window=5) *
                      _utils.ts_sum(self.returns, window=5),
                      period=10))
     return df.fillna(method='backfill')
Esempio n. 2
0
 def alpha_50(self):
     """
     formula: ((((-1 * ts_min(low, 5)) + delay(ts_min(low, 5), 5)) * rank(((sum(returns, 240) -sum(returns, 20))
     / 220))) * ts_rank(volume, 5))
     :return: long range data needed
     """
     return ((
         (-1 * _utils.delta(_utils.ts_min(self.low, 5), 5)) * _utils.rank(
             ((_utils.ts_sum(self.returns, 240) -
               _utils.ts_sum(self.returns, 20)) / 220))) *
             _utils.ts_rank(self.volume, 5))
Esempio n. 3
0
 def alpha_30(self):
     """
     formula: (((1.0 - rank(((sign((close - delay(close, 1))) + sign((delay(close, 1) - delay(close, 2)))) +
      sign((delay(close, 2) - delay(close, 3))))))* sum(volume, 5)) / sum(volume, 20))
     """
     delta_close = _utils.delta(self.close, 1)  # (close - delay(close, 1)
     inner = np.sign(delta_close) + np.sign(_utils.delay(
         delta_close, 1)) + np.sign(_utils.delay(delta_close, 2))
     df = (1.0 - _utils.rank(inner)) * _utils.ts_sum(
         self.volume, 5) / _utils.ts_sum(self.volume, 20)
     return df.fillna(method='backfill')
Esempio n. 4
0
 def alpha_44(self):
     """
     formula: (-1 * ((rank((sum(delay(close, 5), 20) / 20)) * correlation(close, volume, 2))
     *rank(correlation(sum(close, 5), sum(close, 20), 2))))
     :return: dataframe, need more stock and long range
     """
     df = _utils.correlation(self.close, self.volume, 2)
     df = df.replace([-np.inf, np.inf], 0).fillna(value=0)
     df = -1 * (_utils.rank(_utils.ts_ma(_utils.delay(self.close, 5), 20)) *
                df * _utils.rank(
                    _utils.correlation(_utils.ts_sum(self.close, 5),
                                       _utils.ts_sum(self.close, 20), 2)))
     return df.fillna(method='backfill')
Esempio n. 5
0
 def alpha_5(self):
     """
     formula for alpha5: (rank((open - (sum(vwap, 10) / 10)))*(-1*abs(rank((close - vwap)))))
     :return time series rank of a window rank
     """
     return (_utils.rank(self.open -
                         (_utils.ts_sum(self.vwap, window=10) / 10)) * -1 *
             abs(_utils.rank(self.close - self.vwap)))
Esempio n. 6
0
 def alpha_19(self):
     """
     formula: ((-1 * sign(((close - delay(close, 7)) + delta(close, 7)))) * (1 + rank((1 + sum(returns,250)))))
     be careful with the time range, less than 250 will be nan
     """
     return ((-1 * np.sign((self.close - _utils.delay(self.close, 7)) +
                           _utils.delta(self.close, 7))) *
             (1 + _utils.rank(1 + _utils.ts_sum(self.returns, 250))))
Esempio n. 7
0
 def alpha_15(self):
     """
     formula: (-1 * sum(rank(correlation(rank(high), rank(volume), 3)), 3))
     """
     df = _utils.correlation(_utils.rank(self.high),
                             _utils.rank(self.volume), 3)
     df = df.replace([-np.inf, np.inf], 0).fillna(method='backfill')
     return (-1 * _utils.ts_sum(_utils.rank(df), 3)).fillna(method='ffill')
Esempio n. 8
0
 def alpha_29(self):
     """
     formula: (min(product(rank(rank(scale(log(sum(ts_min(rank(
     rank((-1*rank(delta((close - 1), 5))))), 2), 1))))), 1), 5) +
      ts_rank(delay((-1* returns), 6), 5))
     """
     df = _utils.ts_min(
         _utils.rank(
             _utils.rank(
                 _utils.scale(
                     np.log(
                         _utils.ts_sum(
                             _utils.rank(
                                 _utils.rank(-1 * _utils.rank(
                                     _utils.delta(self.close - 1, 5)))),
                             2))))), 5) + _utils.ts_rank(
                                 _utils.delay(-1 * self.returns, 6), 5)
     return df.fillna(method='backfill')