feat: improve US alpha pipeline and regime filters
Expand alpha pipeline with additional factors and scoring logic. Update regime filters and add comprehensive test coverage.
This commit is contained in:
@@ -17,7 +17,10 @@ def build_regime_filter(etf_close: pd.DataFrame, market_col: str = "SPY") -> pd.
|
||||
|
||||
rs = prices.pct_change(RS_WINDOW, fill_method=None)
|
||||
non_market_rs = rs.drop(columns=[market_col], errors="ignore")
|
||||
leader_ok = non_market_rs.gt(rs[market_col], axis=0).any(axis=1)
|
||||
if non_market_rs.shape[1] == 0:
|
||||
leader_ok = pd.Series(True, index=prices.index)
|
||||
else:
|
||||
leader_ok = non_market_rs.gt(rs[market_col], axis=0).any(axis=1)
|
||||
|
||||
regime = (market_ok & leader_ok).astype(bool)
|
||||
return regime.shift(1, fill_value=False)
|
||||
|
||||
Reference in New Issue
Block a user