Пример #1
0
 def alpha_42(self):
     """
     formula: (ts_rank((volume / adv20), 20) * ts_rank((-1 * delta(close, 7)), 8))
     :return:
     """
     adv20 = _utils.ts_ma(self.volume, 20)
     return _utils.ts_rank(self.volume / adv20, 20) * _utils.ts_rank(
         (-1 * _utils.delta(self.close, 7)), 8)
Пример #2
0
 def alpha_35(self):
     """
     formula: ((Ts_Rank(volume, 32)* (1 - Ts_Rank(((close + high) - low), 16)))* (1 - Ts_Rank(returns, 32)))
     :return: df, need long range to modify nan
     """
     return ((_utils.ts_rank(self.volume, 32) *
              (1 - _utils.ts_rank(self.close + self.high - self.low, 16))) *
             (1 - _utils.ts_rank(self.returns, 32))).fillna(
                 method='backfill')
Пример #3
0
 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')
Пример #4
0
 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)
Пример #5
0
 def alpha_17(self):
     """
     formula: (((-1 * rank(ts_rank(close, 10))) *
     rank(delta(delta(close, 1), 1)))
     *rank(ts_rank((volume / adv20), 5)))
     :return:
     """
     adv20 = _utils.ts_ma(self.volume, 20)
     return -1 * (
         _utils.rank(_utils.ts_rank(self.close, 10)) * _utils.rank(
             _utils.delta(_utils.delta(self.close, period=1), period=1)) *
         _utils.rank(_utils.ts_rank(self.volume / adv20, window=5)))
Пример #6
0
 def alpha_4(self):
     """
     formula for alpha4: (-1*Ts_Rank(rank(low), 9))
     :return time series rank of a window rank
     """
     df = -1 * _utils.ts_rank(_utils.rank(self.low), 9)
     return df.replace([-np.inf, np.inf], 0)
Пример #7
0
 def alpha_37(self):
     """
     formula:  ((-1 * rank(Ts_Rank(close, 10))) * rank((close / open)))
     :return:
     """
     inner = self.close / self.open
     inner = inner.replace([-np.inf, np.inf], 1).fillna(value=1)
     return -1 * _utils.rank(_utils.ts_rank(self.open,
                                            10)) * _utils.rank(inner)
Пример #8
0
 def alpha_7(self):
     """
     formula for alpha7: ((adv20 < volume) ? ((-1*ts_rank(abs(delta(close, 7)), 60))
     *sign(delta(close, 7))) : (-1*1))
     careful, the self.close should be len>60, so that nan won't generated
     """
     adv20 = _utils.ts_ma(self.volume, 20)
     alpha = -1 * _utils.ts_rank(abs(_utils.delta(self.close, 7)),
                                 60) * np.sign(_utils.delta(self.close, 7))
     alpha[adv20 >= self.volume] = -1
     return alpha
Пример #9
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))
Пример #10
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')