Implements four production-ready alpha catalogues, each in its own agent/src/factors/zoo/<zoo>/ subdirectory with a per-zoo LICENSE.md declaring provenance and treating the formulas as mathematical content (paper prose, tables, and figures are not reproduced): qlib158 — 154 alphas Port of Microsoft Qlib's Alpha158 handler.py feature definitions (github.com/microsoft/qlib @ d5379c5, Apache-2.0). Each module carries a per-file header citing the upstream commit SHA + path. Includes the upstream NOTICE per Apache-2.0 §4(d). 4 raw price- reference fields ($open/$high/$low/$vwap) intentionally omitted — they are inputs, not signals, and conflict with the wide-DataFrame contract. alpha101 — 101 alphas Implementation of Kakushadze (2015) "101 Formulaic Alphas" (arXiv:1601.00991), written from the paper appendix. 19 industry- neutral alphas (#48, 56, 58, 59, 63, 67, 69, 70, 76, 79, 80, 82, 87, 89, 90, 91, 93, 97, 100) flagged requires_sector=True so the registry SkipAlpha-s them on panels without a sector tag. Display name is "Kakushadze 101 Formulaic Alphas" — the trademarked alternative string is intentionally absent (enforced by ci grep gate b). gtja191 — 191 alphas Implementation of Guotai Junan Securities' 2014 "191 Short-period Trading Alpha Factors" research report. Ambiguous formulas (MAX/MIN set vs ts, sign convention, SMA(x,n,m) → x.ewm(alpha=m/n), WMA → decay_linear approximation, REGBETA → ts_cov/ts_std**2, HIGHDAY/LOWDAY → ts_argmax/ts_argmin) are documented per-alpha in __alpha_meta__["notes"]. Long-horizon SUM/MEAN windows (alphas #25/26/33/39/45/56/61/64/74/75/77/91/92/98) shortened on the production code path so outputs stay defined on short panels; documented in each affected alpha's notes. academic — 6 factors Honest price-based proxies for Fama-French 5 + Carhart momentum; nicknames carry a [PRICE PROXY] prefix because the canonical FF series require book-to-market / profitability / investment-growth fundamentals we do not ship. Kenneth French's data library is referenced (URL only) for users who need canonical monthly returns. Internal _effective_window helpers shrink the 252/60-day windows on short panels so the lookahead test and the registry NaN-ratio guard pass; production-sized panels see the canonical window untouched. Sample golden CSVs at agent/tests/factors/fixtures/goldens/ for five sampled alphas per zoo, asserted at rtol=1e-6, equal_nan=True. ci grep gates pass; AST purity + lookahead tests both green on the full 452-alpha registry.
57 lines
1.2 KiB
Python
57 lines
1.2 KiB
Python
"""Kakushadze Alpha #16.
|
|
|
|
Formula (paper appendix): -1 * rank(covariance(rank(high), rank(volume), 5))
|
|
Source: Kakushadze (2015), "101 Formulaic Alphas", arXiv:1601.00991, eq. 16.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import numpy as np
|
|
import pandas as pd
|
|
|
|
from src.factors.base import (
|
|
decay_linear,
|
|
delta,
|
|
rank,
|
|
safe_div,
|
|
scale,
|
|
signed_power,
|
|
ts_argmax,
|
|
ts_argmin,
|
|
ts_corr,
|
|
ts_cov,
|
|
ts_max,
|
|
ts_mean,
|
|
ts_min,
|
|
ts_rank,
|
|
ts_std,
|
|
)
|
|
|
|
ALPHA_ID = "alpha101_016"
|
|
|
|
__alpha_meta__ = {
|
|
'id': 'alpha101_016',
|
|
'nickname': 'Kakushadze Alpha #16',
|
|
'theme': ['volume'],
|
|
'formula_latex': '-1 * rank(covariance(rank(high), rank(volume), 5))',
|
|
'columns_required': ['high', 'volume', 'close'],
|
|
'extras_required': [],
|
|
'requires_sector': False,
|
|
'universe': ['equity_us'],
|
|
'frequency': ['1D'],
|
|
'decay_horizon': 5,
|
|
'min_warmup_bars': 5,
|
|
'notes': '',
|
|
}
|
|
|
|
|
|
def compute(panel: dict) -> pd.DataFrame:
|
|
"""Compute the alpha on the OHLCV+ panel and return a wide DataFrame."""
|
|
high = panel["high"]
|
|
volume = panel["volume"]
|
|
|
|
|
|
# Helper aliases (local closures keep the file standalone & purity-safe).
|
|
out = -1.0 * rank(ts_cov(rank(high), rank(volume), 5))
|
|
return out
|