feat: signal abstraction layer + sizer + HS300 universe + PnL/IC reports
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"""Short-horizon reversal signal."""
|
||||
import pandas as pd
|
||||
|
||||
from signals.base import AlphaSignal
|
||||
|
||||
|
||||
class ReversalSignal(AlphaSignal):
|
||||
"""Negative trailing return: oversold stocks score high.
|
||||
|
||||
The signal is ``-close.pct_change(lookback)``, so a stock that fell over the
|
||||
lookback window gets a positive (bullish) score.
|
||||
"""
|
||||
|
||||
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"reversal_{self.lookback}d"
|
||||
Reference in New Issue
Block a user