Files
chinese-equity-quant/signals/momentum.py
T

22 lines
566 B
Python

"""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"