research(xsec): sweep cross-sectional su Hyperliquid (43 script/257 config) + verifica avversariale

Nuova harness condivisa xslib.py (panel HL certificato, score per-asset causale, book
long-k/short-k vol-targeted leak-free) + 43 script in runs/ su 11 famiglie (MOM/REV/VOL/
DIST/LIQ/VAL/STRUCT/UNIV). Scoring = earns_slot (full>0 AND hold-out>0 AND marginal ADDS
al portafoglio live AND corr XS01<0.6, con jackknife drop-one-month).

Find: 42/257 config earns_slot=True, ma TUTTE con corr TP01 -0.2..-0.4 e PnL ~solo 2025.
Verify (verify_survivors.py, 3 scettici deterministici):
 - S1 redundancy: cluster low-vol = UNA scommessa (XV01=XU02=1.00, XV02/XV03 r 0.44-0.67);
   XM09/XL02/XS06b/XR02 distinti (corr media off-diag +0.20).
 - S2 short-beta: cluster low-vol carica 0.44-0.70 su short-market -> NON market-neutral,
   e' un tilt short-alt-beta di regime. XM09(0.08)/XR02(-0.21) NON short-beta.
 - S3 per-anno: cluster low-vol decade (XV01/XU02 2026 -0.09); XL02 morto (2025 -0.14,
   2026 -0.43); XM09 (0.82/0.50/0.74) e XR02 (0.84/0.40/2.68) positivi in tutti e 3 gli anni.

Esito: nessuna sleeve nuova. Cluster low-vol RIGETTATO (regime-bet), XL02 RIGETTATO (overfit).
2 LEAD genuini (XM09 trend-gated x-sec momentum, XR02 reversal vol-gated) -> forward-monitor,
non deployabili (panel 2.5y regime unico + STAT-MODE esecuzione). Portafoglio live invariato.

Incluso anche options_vrp_managed.py (A/B VRP01 hold-to-expiry vs gestione attiva del doc
credit-spread): la gestione attiva DISTRUGGE l'edge (combo FULL managed Sh -1.29 vs HtE +0.96,
il delta-exit taglia i vincenti) -> scartata, VRP01 resta hold-to-expiry.

Diari: 2026-06-20-xsec-strategies-sweep.md, 2026-06-20-vrp-active-management.md.
gitignore: data/paper_portfolio/ (stato runtime paper) + scripts/research/xsec/runs/out/ (output rigenerabile).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Adriano Dal Pastro
2026-06-20 21:36:57 +00:00
parent 5ac4e16af8
commit 9612560479
50 changed files with 5457 additions and 0 deletions
+102
View File
@@ -0,0 +1,102 @@
"""XU01 — Momentum Universe Sweep
MECHANISM: Best momentum z-blend (blend of past_return z-scores at L=30 and L=90),
run on different universe sizes: majors (19), top20, top30, all (49).
Goal: map where cross-sectional momentum alpha lives — does expanding to top20/top30/all
help or hurt vs the tight 19-major universe of XS01?
Grid (<=5 backtests):
1. majors (19) — baseline reference, should approach XS01
2. top20 — add one more liquid alt
3. top30 — mid-tier liquidity
4. all (49) — known to dilute (confirm)
5. top30, long-only (best mid-tier config variant)
Signal: xs_zscore(past_return(close,30)) + xs_zscore(past_return(close,90)) — same blend as XS01.
H=10, k=5, long_short=True (except run 5 long-only).
"""
import sys
sys.path.insert(0, "/opt/docker/PythagorasGoal/scripts/research/xsec")
import xslib as xs
import numpy as np
print("XU01 — Momentum Universe Sweep")
print("=" * 60)
def blend_score(P):
"""Z-blend of 30d and 90d momentum — same signal as XS01 but on any universe."""
z30 = xs.xs_zscore(xs.past_return(P.close, 30))
z90 = xs.xs_zscore(xs.past_return(P.close, 90))
return np.nanmean(np.stack([z30, z90], axis=0), axis=0)
# 1) Majors (19) — baseline
rep1 = xs.study_xs(
"XU01_MAJORS",
blend_score,
universe="majors", H=10, k=5, long_short=True
)
print(xs.fmt(rep1))
print("JSON:", xs.as_json(rep1))
print()
# 2) Top-20 by $-volume
rep2 = xs.study_xs(
"XU01_TOP20",
blend_score,
universe=20, H=10, k=5, long_short=True
)
print(xs.fmt(rep2))
print("JSON:", xs.as_json(rep2))
print()
# 3) Top-30 by $-volume
rep3 = xs.study_xs(
"XU01_TOP30",
blend_score,
universe=30, H=10, k=5, long_short=True
)
print(xs.fmt(rep3))
print("JSON:", xs.as_json(rep3))
print()
# 4) All (49) — expected dilution
rep4 = xs.study_xs(
"XU01_ALL",
blend_score,
universe="all", H=10, k=5, long_short=True
)
print(xs.fmt(rep4))
print("JSON:", xs.as_json(rep4))
print()
# 5) Top-30, long-only — does dropping the short leg help with mid-tier names?
rep5 = xs.study_xs(
"XU01_TOP30_LO",
blend_score,
universe=30, H=10, k=5, long_short=False
)
print(xs.fmt(rep5))
print("JSON:", xs.as_json(rep5))
print()
# Pick best: prefer earns_slot, then hold-out sharpe, then full sharpe, then distinctness
all_reps = [rep1, rep2, rep3, rep4, rep5]
def score_rep(r):
earns = int(r.get("earns_slot", False))
hold_sh = (r.get("holdout") or {}).get("sharpe", -9)
full_sh = (r.get("full") or {}).get("sharpe", -9)
corr_xs01 = r.get("corr_xs01") or 1.0
distinctness = 1 - abs(corr_xs01)
return (earns, hold_sh, full_sh, distinctness)
best = max(all_reps, key=score_rep)
print("=" * 60)
print(f"BEST CONFIG: {best['name']}")
print(xs.fmt(best))
print("JSON:", xs.as_json(best))