5ac4e16af8
Ondata di ricerca onesta a largo spettro su BTC/ETH+DVOL certificati: 104 ipotesi distinte (11 famiglie), un agente-finder per ipotesi, verifica avversariale a 3 scettici sui promettenti, sintesi (153 agenti totali). Esito: NIENTE di nuovo regge -> conferma del soffitto strutturale ~1.3 BTC/ETH-direzionale; lo stack TP01+XS01+VRP01 resta imbattuto. - altlib.py: harness condiviso vettoriale leak-free (eval_weights/study_weights, fee-sweep, both-asset + hold-out 2025+). Riproduce i numeri canonici di TP01. - MARGINAL SCORER (study_marginal/marginal_vs_tp01): Sharpe INCREMENTALE vs baseline TP01 (corr, blend uplift OOS, alpha residua) + jackknife OOS (clean-year + drop-best-month). earns_slot = abs!=FAIL & ADDS & robust_oos. Smaschera gli overlay su TSMOM con PASS assoluti fasulli (CMB04, VOL11, ...) e il falso positivo KAMA (ADDS ma muore al jackknife). - runs/*.py (104) script riproducibili per ipotesi; wf_altstrat.js workflow. - Verdetto: 0 candidati deployabili; 2 LEAD fragili (VOL08, STA05_LS) da forward-monitor. - test_marginal_scorer.py blocca baseline + invarianti. Suite: 32 verde. Diario: docs/diary/2026-06-20-alt-strategies-100agent-sweep.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
72 lines
2.4 KiB
Python
72 lines
2.4 KiB
Python
"""VOL06 — Realized-vol target standalone (pure inverse-vol risk control, long-only).
|
||
|
||
HYPOTHESIS: No trend signal. Position = target_vol / realized_vol, capped at leverage_cap.
|
||
Long-only (direction always +1). Pure inverse-vol scaling — is risk-scaling alone an edge?
|
||
|
||
We test a small grid of (vol_win_days, target_vol) on 1d and 12h to find the best config
|
||
while keeping total backtests <= 6.
|
||
"""
|
||
import sys
|
||
sys.path.insert(0, "/opt/docker/PythagorasGoal/scripts/research/alt")
|
||
import altlib as al
|
||
import numpy as np
|
||
|
||
# Grid: 2 vol windows × 1 target_vol = 2 param sets × 2 TFs = 4 total backtests (within limit)
|
||
CONFIGS = [
|
||
{"vol_win_days": 21, "target_vol": 0.20, "leverage_cap": 2.0},
|
||
{"vol_win_days": 60, "target_vol": 0.20, "leverage_cap": 2.0},
|
||
]
|
||
|
||
TFS = ("1d", "12h")
|
||
|
||
def make_target(vol_win_days: int, target_vol: float, leverage_cap: float):
|
||
"""Returns a function df -> target array (long-only inverse-vol)."""
|
||
def target_fn(df):
|
||
c = df["close"].values.astype(float)
|
||
bpd = al.bars_per_day(df)
|
||
bpy = bpd * 365.25
|
||
r = al.simple_returns(c)
|
||
vol = al.realized_vol(r, max(2, vol_win_days * bpd), bpy)
|
||
# Long-only: direction = +1 always; scale by target_vol / realized_vol
|
||
pos = np.where(
|
||
(vol > 0) & np.isfinite(vol),
|
||
np.clip(target_vol / vol, 0.0, leverage_cap),
|
||
0.0,
|
||
)
|
||
pos[~np.isfinite(pos)] = 0.0
|
||
return pos
|
||
return target_fn
|
||
|
||
|
||
# Run grid
|
||
best_rep = None
|
||
best_score = -np.inf
|
||
|
||
for cfg in CONFIGS:
|
||
name = f"VOL06_w{cfg['vol_win_days']}_tv{int(cfg['target_vol']*100)}"
|
||
fn = make_target(cfg["vol_win_days"], cfg["target_vol"], cfg["leverage_cap"])
|
||
rep = al.study_weights(name, fn, tfs=TFS)
|
||
|
||
# Score = min across assets of average(full_sharpe, holdout_sharpe)
|
||
score_vals = []
|
||
for cell in rep["cells"]:
|
||
for asset in ("BTC", "ETH"):
|
||
pa = cell["per_asset"].get(asset, {})
|
||
if pa:
|
||
fs = pa["full"]["sharpe"]
|
||
hs = pa["holdout"]["sharpe"]
|
||
score_vals.append((fs + hs) / 2)
|
||
|
||
score = min(score_vals) if score_vals else -np.inf
|
||
print(f"\n--- Config: {cfg} ---")
|
||
print(al.fmt(rep))
|
||
print("JSON:", al.as_json(rep))
|
||
|
||
if score > best_score:
|
||
best_score = score
|
||
best_rep = rep
|
||
|
||
print("\n\n=== BEST CONFIG ===")
|
||
print(al.fmt(best_rep))
|
||
print("JSON:", al.as_json(best_rep))
|