group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector)
group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)
group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector)
group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)

add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector))
add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))
subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)))

ts_rank(ts_mean(market_breadth, 60), 60)
ts_rank(ts_mean(vix, 60), 60)
add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60))
ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5)

if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) > 0, 1, -1)
if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) < 0, 1, -1)

multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) > 0, 1, -1), ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250))
multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) < 0, 1, -1), reverse(ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250)))

ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) < ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.2), 1, 0), 60)
ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) > ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.8), 1, 0), 60)

multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) > 0, 1, -1), ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250)), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) < ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.2), 1, 0), 60))
multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) < 0, 1, -1), reverse(ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250))), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) > ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.8), 1, 0), 60))

group_neutralize(multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) > 0, 1, -1), ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250)), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) < ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.2), 1, 0), 60)), pv13_h_min20_top3000_sector)
group_neutralize(multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) < 0, 1, -1), reverse(ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250))), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) > ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.8), 1, 0), 60)), pv13_h_min20_top3000_sector)

subtract(group_neutralize(multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) > 0, 1, -1), ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250)), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) < ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.2), 1, 0), 60)), pv13_h_min20_top3000_sector), group_neutralize(multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) < 0, 1, -1), reverse(ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250))), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) > ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.8), 1, 0), 60)), pv13_h_min20_top3000_sector))

ts_zscore(subtract(group_neutralize(multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) > 0, 1, -1), ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250)), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) < ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.2), 1, 0), 60)), pv13_h_min20_top3000_sector), group_neutralize(multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) < 0, 1, -1), reverse(ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250))), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) > ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.8), 1, 0), 60)), pv13_h_min20_top3000_sector)), 20)

winsorize(ts_zscore(subtract(group_neutralize(multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) > 0, 1, -1), ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250)), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) < ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.2), 1, 0), 60)), pv13_h_min20_top3000_sector), group_neutralize(multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) < 0, 1, -1), reverse(ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250))), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) > ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.8), 1, 0), 60)), pv13_h_min20_top3000_sector)), 20), 4)

scale(winsorize(ts_zscore(subtract(group_neutralize(multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) > 0, 1, -1), ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250)), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) < ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.2), 1, 0), 60)), pv13_h_min20_top3000_sector), group_neutralize(multiply(multiply(if_else(ts_delta(add(ts_rank(ts_mean(market_breadth, 60), 60), ts_rank(ts_mean(vix, 60), 60)), 5) < 0, 1, -1), reverse(ts_rank(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))), 250))), ts_sum(if_else(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector))) > ts_quantile(subtract(add(group_zscore(ts_mean(volume, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(turnover, 20), pv13_h_min20_top3000_sector)), add(group_zscore(ts_mean(bid_ask_spread, 20), pv13_h_min20_top3000_sector), group_zscore(ts_mean(amihud_illiquidity, 20), pv13_h_min20_top3000_sector)), 250, "gaussian"), 0.8), 1, 0), 60)), pv13_h_min20_top3000_sector)), 20), 4))