Add 5-day reversal end-to-end pipeline report and repro scripts

Runs the 5-day reversal signal through data→alpha→combo→portfolio on the
full A-share universe and documents the finding: the naive z-score book
loses to outlier concentration, rank weighting on a liquid universe
recovers a real edge, and turnover-driven cost is the binding constraint.
Includes the e2e driver and figure generator that produce the report.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Yuxuan Yan
2026-06-11 17:40:52 +08:00
parent 07ed6ad917
commit b7dd94b032
8 changed files with 1093 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# End-to-end run of the outlier-robust reversal_rank alpha on the full
# all-universe dataset and on a per-date liquid subset. Records per-phase
# wall-clock time to reports/reversal_rank_timings.json.
set -euo pipefail
cd "$(dirname "$0")/.."
DATA=data/daily_bars/all
BOOK=10000000
TIMINGS=reports/reversal_rank_timings.json
mkdir -p reports
echo "{" > "$TIMINGS"
run() { # run <json_key> <cmd...>
local key="$1"; shift
local t0 t1
t0=$(date +%s.%N)
"$@"
t1=$(date +%s.%N)
printf ' "%s": %.2f,\n' "$key" "$(echo "$t1 - $t0" | bc)" >> "$TIMINGS"
echo ">>> $key took $(echo "$t1 - $t0" | bc)s"
}
# ---- full all-universe, robust rank weighting ----
run full_alpha_compute uv run python cli.py alpha compute --data-path "$DATA" \
--alpha-name reversal_rank_all --alpha-type reversal_rank --lookback 5 --output-dir alphas
run full_alpha_eval uv run python cli.py alpha eval \
--alpha-path alphas/reversal_rank_all.pq --data-path "$DATA"
run full_combo uv run python cli.py combo combine \
--alpha-paths alphas/reversal_rank_all.pq --combo-name reversal_rank_all_combo \
--method equal_weight --output-dir combos
run full_portfolio_build uv run python cli.py portfolio build \
--weights-path combos/reversal_rank_all_combo.pq --data-path "$DATA" \
--booksize "$BOOK" --portfolio-name reversal_rank_all_10m --output-dir portfolio
run full_portfolio_eval uv run python cli.py portfolio eval \
--positions-path portfolio/reversal_rank_all_10m.pq --data-path "$DATA"
run full_portfolio_simulate uv run python cli.py portfolio simulate \
--positions-path portfolio/reversal_rank_all_10m.pq --data-path "$DATA" \
--constraint suspension --constraint price_limit --constraint volume_cap \
--cost-bps 5 --slippage-bps 5 --output-dir portfolio
# ---- liquid subset (per-date investable universe), robust rank weighting ----
run liq_alpha_compute uv run python cli.py alpha compute --data-path "$DATA" \
--alpha-name reversal_rank_liq --alpha-type reversal_rank --lookback 5 \
--liquid-universe --universe-top-n 1000 --output-dir alphas
run liq_alpha_eval uv run python cli.py alpha eval \
--alpha-path alphas/reversal_rank_liq.pq --data-path "$DATA"
run liq_combo uv run python cli.py combo combine \
--alpha-paths alphas/reversal_rank_liq.pq --combo-name reversal_rank_liq_combo \
--method equal_weight --output-dir combos
run liq_portfolio_build uv run python cli.py portfolio build \
--weights-path combos/reversal_rank_liq_combo.pq --data-path "$DATA" \
--booksize "$BOOK" --portfolio-name reversal_rank_liq_10m --output-dir portfolio
run liq_portfolio_eval uv run python cli.py portfolio eval \
--positions-path portfolio/reversal_rank_liq_10m.pq --data-path "$DATA"
run liq_portfolio_simulate uv run python cli.py portfolio simulate \
--positions-path portfolio/reversal_rank_liq_10m.pq --data-path "$DATA" \
--constraint suspension --constraint price_limit --constraint volume_cap \
--cost-bps 5 --slippage-bps 5 --output-dir portfolio
printf ' "_done": true\n}\n' >> "$TIMINGS"
echo "Wrote $TIMINGS"