def run(self, hd): ''' Calculate! ''' delay = 1 rank1 = Op.rank_col(hd['volume']) rank2 = Op.rank_col(hd['close']) corr = rank1.rolling(5).corr(rank2) rank3 = Op.rank_col(corr) tsmax = rank3.rolling(5).max() data = -tsmax startdate = hd['startdate'] enddate = hd['enddate'] start = hd['startidx'] end = hd['endidx'] for di in range(start, end + 1): self._alpha[di - start, :] = data.iloc[di - delay, :] print("Alpha is finished!") self._alpha = Op.Neutralize('IND', self._alpha, start, end) print("Neutralize is finished!") self._alpha = Op.personalize(self._alpha) print("Person is finished!") self._alpha, self.trend = Op.trend(self._alpha, startdate, enddate) print("Trend is finished!")
def run(self, hd): ''' Calculate! ''' delay = 1 data1 = (hd['high'] - hd['low']) / (hd['close'].rolling(5).sum() / 5) #rank1 = self.rank_col(data1) rank1 = Op.rank_col(data1.shift(2)) rank2 = Op.rank_col(hd['volume']) data3 = data1 / (hd['vwap'] - hd['close']) data3[data3 == 0] = np.nan data = rank1 * rank2 / data3 start = hd['startidx'] end = hd['endidx'] #self.alpha = data.iloc[start-delay:end+1,:] alpha = np.full([self._alpha.shape[0], self._alpha.shape[1]], np.nan) for di in range(start, end + 1): alpha[di - start, :] = data.iloc[di - delay, :] print("Alpha is finished!") alpha = Op.Neutralize('IND', alpha, start, end) print("Neutralize is finished!") self._alpha = Op.personalize(alpha) print("Person is finished!")
def run(self, hd): ''' Calculate! ''' delay = 1 #data = self.close.shift(5)-self.close rank1 = Op.rank_col(hd['volume']) rank2 = Op.rank_col(hd['vwap']) corr = rank1.rolling(5).corr(rank2) rank3 = Op.rank_col(corr) data = -1 * rank3.rolling(5).max() #for ii in range(window, corr.shape[0]+1): start = hd['startidx'] end = hd['endidx'] #self.alpha = data.iloc[start-delay:end+1,:] for di in range(start, end + 1): self._alpha[di - start, :] = data.iloc[di - delay, :] print("Alpha is finished!") self._alpha = Op.Neutralize('IND', self._alpha, start, end) print("Neutralize is finished!") self._alpha = Op.personalize(self._alpha) print("Personize is finished!")
def run(self, hd): ''' Calculate! ''' delay = 1 #data = self.close.shift(5)-self.close data1 = hd['vwap'] - hd['close'] data1[data1 < 3] = 3 rank1 = Op.rank_col(data1) data2 = hd['vwap'] - hd['close'] data2[data2 > 3] = 3 rank2 = Op.rank_col(data2) volume = hd['volume'] volume[volume == 0] = np.nan rank3 = Op.rank_col(volume - volume.shift(3)) data = rank1 + rank2 * rank3 start = hd['startidx'] end = hd['endidx'] #self.alpha = data.iloc[start-delay:end+1,:] for di in range(start, end + 1): self._alpha[di - start, :] = data.iloc[di - delay, :] print("Alpha is finished!") self._alpha = Op.Neutralize('IND', self._alpha, start, end) print("Neutralize is finished!") self._alpha = Op.personalize(self._alpha) print("Personize is finished!")
def run(self, hd): ''' Calculate! ''' delay = 1 #data = self.close.shift(5)-self.close lnvol = np.log(hd['volume']) lnvol_d = lnvol - lnvol.shift() rank1 = Op.rank_col(lnvol_d) rank2 = Op.rank_col((hd['close'] - hd['open']) / hd['open']) corr = rank1.rolling(6).corr(rank2) data = -corr #data = self.Rank(data) start = hd['startidx'] end = hd['endidx'] #self.alpha = data.iloc[start-delay:end+1,:] for di in range(start, end + 1): self._alpha[di - start, :] = data.iloc[di - delay, :] print("Alpha is finished!") self._alpha = Op.Neutralize('IND', self._alpha, start, end) print("Neutralize is finished!") self._alpha = Op.personalize(self._alpha) print("Personize is finished!")
def run(self, hd): ''' Calculate! ''' delay = 1 #data = self.close.shift(5)-self.close data = -hd['close'].rolling(10).corr(hd['volume']) start = hd['startidx'] end = hd['endidx'] #self.alpha = data.iloc[start-delay:end+1,:] for di in range(start, end + 1): self._alpha[di - start, :] = data.iloc[di - delay, :] print("Alpha is finished!") self._alpha = Op.Neutralize('IND', self._alpha, start, end) print("Neutralize is finished!") self._alpha = Op.personalize(self._alpha) print("Personize is finished!")