feat: CSI500 universe + reversal_vol signal + argparse CLI

This commit is contained in:
Yuxuan Yan
2026-06-07 10:01:41 +08:00
parent aedc019d23
commit 241683cc54
4 changed files with 93 additions and 11 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
"""Alpha signal abstractions."""
from signals.base import AlphaSignal
from signals.reversal import ReversalSignal
from signals.reversal_vol import ReversalVolSignal
__all__ = ["AlphaSignal", "ReversalSignal"]
__all__ = ["AlphaSignal", "ReversalSignal", "ReversalVolSignal"]
+27
View File
@@ -0,0 +1,27 @@
"""Volatility-scaled short-horizon reversal signal."""
import pandas as pd
from signals.base import AlphaSignal
class ReversalVolSignal(AlphaSignal):
"""Reversal score normalized by trailing volatility.
The raw reversal ``-close.pct_change(lookback)`` is divided by the rolling
standard deviation of daily returns over ``vol_window``. Scaling by
volatility damps the score of noisy, high-vol names so the signal favors
oversold stocks whose move is large *relative* to their own volatility.
"""
def __init__(self, lookback: int = 5, vol_window: int = 20):
self.lookback = lookback
self.vol_window = vol_window
def compute(self, df: pd.DataFrame) -> pd.Series:
reversal = -df["close"].pct_change(self.lookback)
vol = df["close"].pct_change().rolling(self.vol_window).std()
return reversal / vol
@property
def name(self) -> str:
return f"reversal_vol_{self.lookback}d_{self.vol_window}d"