fix: rank-based allocator + momentum signal (reversal->momentum flip)

This commit is contained in:
Yuxuan Yan
2026-06-07 09:50:08 +08:00
parent da01312292
commit bd0605072f
7 changed files with 117 additions and 44 deletions
+21
View File
@@ -0,0 +1,21 @@
"""Short-horizon momentum signal."""
import pandas as pd
from signals.base import AlphaSignal
class MomentumSignal(AlphaSignal):
"""Positive trailing return: stocks that rose score high (momentum).
The signal is ``close.pct_change(lookback)`` — opposite of ReversalSignal.
"""
def __init__(self, lookback: int = 5):
self.lookback = lookback
def compute(self, df: pd.DataFrame) -> pd.Series:
return df["close"].pct_change(self.lookback)
@property
def name(self) -> str:
return f"momentum_{self.lookback}d"