def forward(self, volume_ts, close_ts): output_tensor = ( ((-1 * tsf.rank(tsf.ts_rank(close_ts, 10))) * tsf.rank(tsf.diff(tsf.diff(close_ts, 1), 1))) * tsf.rank( tsf.ts_rank( (volume_ts / tsf.rolling_mean_(volume_ts, 20)), 5))) return output_tensor
def forward(self, volume_ts, vwap_ts): output_tensor = ((tsf.rank( (vwap_ts - tsf.rolling_min(vwap_ts, 12)))**tsf.ts_rank( tsf.rolling_corr( tsf.ts_rank(vwap_ts, 20), tsf.ts_rank(tsf.rolling_mean_(volume_ts, 60), 2), 18), 3)) * -1) return output_tensor
def forward(self, high_ts, low_ts, close_ts, volume_ts): output_tensor = (tsf.rank( tsf.rolling_corr( ((high_ts * 0.9) + (close_ts * 0.1)), tsf.rolling_mean_(volume_ts, 30), 10))**tsf.rank( tsf.rolling_corr(tsf.ts_rank(((high_ts + low_ts) / 2), 4), tsf.ts_rank(volume_ts, 10), 7))) return output_tensor
def forward(self, close_ts, volume_ts): adv20 = tsf.rolling_mean_(volume_ts, 20) alpha = -1 * tsf.ts_rank(abs(tsf.diff(close_ts, 7)), 60) * torch.sign( tsf.diff(close_ts, 7)) cond = adv20 >= volume_ts ones = torch.ones(close_ts.size()) output_tensor = torch.where( cond, -1 * ones, alpha.float()) # confusing why must .float() return output_tensor
def forward(self, close_ts, returns_ts): return tsf.rolling_min( tsf.rank( tsf.rank( tsf.rolling_scale( torch.log( tsf.rolling_sum_( tsf.rank( tsf.rank(-1 * tsf.rank( tsf.diff((close_ts - 1), 5)))), 2))))), 5) + tsf.ts_rank(tsf.shift((-1 * returns_ts), 6), 5)
def test_tsrank_ties(self): output_tsrank = tsf.ts_rank(self.test_2d_1big, 2) output_tsrank = torch.where(torch.isnan(output_tsrank), torch.full_like(output_tsrank, 666), output_tsrank) # fillna expected = torch.tensor([[np.nan, np.nan], [1, 1], [1, 1], [1, 1], [1, 1]]) expected = torch.where(torch.isnan(expected), torch.full_like(expected, 666), expected) # fillna result = (expected == output_tsrank).all().item() self.assertTrue(result, 'test_tsrank_ties failed')
def forward(self, low_ts, volume_ts, returns_ts): return ((-1 * tsf.diff(tsf.rolling_min(low_ts, 5), 5)) * tsf.rank( ((tsf.rolling_sum_(returns_ts, 60) - tsf.rolling_sum_( returns_ts, 20)) / 55))) * tsf.ts_rank(volume_ts, 5)
def forward(self, close_ts, volume_ts): adv20 = tsf.rolling_mean_(volume_ts, 20) alpha = tsf.ts_rank(volume_ts / adv20, 20) * tsf.ts_rank( (-1 * tsf.diff(close_ts, 7)), 8) return alpha
def forward(self, low_ts): alpha = -1 * tsf.ts_rank(tsf.rank(low_ts), 9) return alpha
def forward(self, open_ts, close_ts): inner = close_ts / open_ts alpha = -1 * tsf.rank(tsf.ts_rank(open_ts, 10)) * tsf.rank(inner) return alpha
def forward(self, high_ts, low_ts, close_ts, volume_ts, returns_ts): return (tsf.ts_rank(volume_ts, 32) * (1 - tsf.ts_rank(close_ts + high_ts - low_ts, 16))) * ( 1 - tsf.ts_rank(returns_ts, 32))
def forward(self, volume_ts, close_ts): output_tensor = (tsf.ts_rank( (volume_ts / tsf.rolling_mean_(volume_ts, 20)), 20) * tsf.ts_rank( (-1 * tsf.diff(close_ts, 7)), 8)) return output_tensor
def forward(self, close_ts, volume_ts): adv20 = tsf.rolling_mean_(volume_ts, 20) alpha = -1 * (tsf.rank(tsf.ts_rank(close_ts, 10)) * tsf.rank(tsf.diff(tsf.diff(close_ts, 1), 1)) * tsf.rank(tsf.ts_rank((volume_ts / adv20), 5))) return alpha
def forward(self, high_ts, low_ts, volume_ts, close_ts, return_ts): output_tensor = ((tsf.ts_rank(volume_ts, 32) * (1 - tsf.ts_rank( ((close_ts + high_ts) - low_ts), 16))) * (1 - tsf.ts_rank(return_ts, 32))) return output_tensor
def forward(self, high_ts, volume_ts): ts = tsf.rolling_cov(tsf.ts_rank(volume_ts, 5), tsf.ts_rank(high_ts, 5), 5) alpha = -1 * tsf.rolling_max(ts, 3) return alpha
def forward(self, volume_ts, high_ts, rank_period): output_tensor = -1 * tsf.rolling_max( tsf.rolling_corr(tsf.ts_rank(volume_ts, rank_period), tsf.ts_rank(high_ts, rank_period), self.window), self.window) return output_tensor
def forward(self, volume_ts, high_ts): output_tensor = -1 * tsf.rolling_max( tsf.rolling_corr(tsf.ts_rank(volume_ts, 5), tsf.ts_rank( high_ts, 5), 5), 3) return output_tensor