refactor: class-based alpha factory + month-partitioned data pipeline

Replace the old signal/strategy/backtest modules with a decoupled
data → alpha → combo pipeline (parquet between phases, .pq extension).

Alphas:
- BaseAlpha + @register_alpha factory/plugin registry; one file per
  built-in (reversal, reversal_vol, momentum); external alphas via
  --alpha-module. Alphas are z-scored position weights, not predictors.

Data:
- baostock primary / akshare fallback, treated consistently.
- New --universe all (~5000 A-shares via query_all_stock, filtered).
- login-once batch downloader; empty-string OHLCV coerced to NaN.
- Month-partitioned dataset {output_dir}/{universe}/month=YYYY-MM/*.pq
  with chunked durability flushes; --data-path is the dataset dir.

CLI logs at INFO by default (--log-level) so progress is visible.
Docs (README, CLAUDE.md) updated incl. pipeline diagram and roadmap
TODOs for portfolio construction / backtest / paper trading.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Yuxuan Yan
2026-06-09 14:07:07 +08:00
parent 769cf25daa
commit 1caa63faeb
54 changed files with 1640 additions and 1120 deletions
+16 -2
View File
@@ -11,8 +11,22 @@ def test_download_single_stock():
assert df["close"].notna().all()
def test_download_baostock_fallback():
"""Test baostock works as secondary source."""
def test_download_baostock_primary():
"""baostock is the primary source for 'auto'."""
df = download_daily("sz000001", "2024-06-01", "2024-06-15", source="baostock")
assert df is not None
assert len(df) > 0
def test_download_akshare_fallback():
"""akshare works as the secondary source when reachable.
akshare is the fallback precisely because it is unreliable on some
networks; skip rather than fail when it cannot be reached.
"""
try:
df = download_daily("sh600000", "2024-01-01", "2024-01-31", source="akshare")
except RuntimeError as e:
pytest.skip(f"akshare unreachable on this network: {e}")
assert df is not None
assert len(df) > 0