research(alt): sweep 104 strategie alternative su Deribit (153 agenti) + marginal scorer

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>
This commit is contained in:
Adriano Dal Pastro
2026-06-20 19:50:39 +00:00
parent bf84bc91e2
commit 5ac4e16af8
111 changed files with 16924 additions and 0 deletions
+82
View File
@@ -0,0 +1,82 @@
"""MIC05 — Wide-range-bar follow-through.
HYPOTHESIS: After a wide-range bar (range > 2*ATR) closing strong (close near the
top 30% of the bar for longs, or bottom 30% for shorts), enter in the bar's direction
at close[i]; exit after k bars (or on TP/SL).
CAUSAL: ATR is computed up to bar i-1 (shifted), range and close strength computed
from bar i itself (known at close[i]). Entry fills at close[i].
Grid: k_bars in {3, 5, 7, 10} — only 1d, 2 assets, 4 param sets = 8 backtests total.
Best config selected by min-asset hold-out Sharpe.
"""
import sys
sys.path.insert(0, "/opt/docker/PythagorasGoal/scripts/research/alt")
import altlib as al
import numpy as np
# ---------------------------------------------------------------------------
# Signal generator
# ---------------------------------------------------------------------------
def make_entries(df, k_bars: int = 5, atr_mult: float = 2.0, close_pct: float = 0.30):
"""Returns entries list len(df).
Wide range bar: range > atr_mult * ATR(14) at bar i-1 (causal).
Strong close long: close >= low + (1 - close_pct) * range (top 30%)
Strong close short: close <= low + close_pct * range (bottom 30%)
"""
hi = df["high"].values.astype(float)
lo = df["low"].values.astype(float)
cl = df["close"].values.astype(float)
bar_range = hi - lo
# ATR causal: shift by 1 so ATR at bar i uses data up to bar i-1
atr_raw = al.atr(df, win=14)
atr_shifted = np.roll(atr_raw, 1)
atr_shifted[0] = atr_raw[0]
entries = [None] * len(df)
for i in range(1, len(df)):
rng = bar_range[i]
atr_i = atr_shifted[i]
if atr_i <= 0 or not np.isfinite(atr_i):
continue
if rng < atr_mult * atr_i:
continue # not a wide-range bar
close_rel = (cl[i] - lo[i]) / rng if rng > 0 else 0.5
if close_rel >= (1.0 - close_pct):
# Strong bullish wide bar -> long follow-through
entries[i] = {"dir": 1, "tp": None, "sl": None, "max_bars": k_bars}
elif close_rel <= close_pct:
# Strong bearish wide bar -> short follow-through
entries[i] = {"dir": -1, "tp": None, "sl": None, "max_bars": k_bars}
return entries
# ---------------------------------------------------------------------------
# Grid search over k_bars
# ---------------------------------------------------------------------------
K_BARS_GRID = [3, 5, 7, 10]
best_rep = None
best_hold = -999
for k in K_BARS_GRID:
rep = al.study_signals(
f"MIC05-k{k}",
lambda df, _k=k: make_entries(df, k_bars=_k),
tfs=("1d",),
)
min_hold = rep["verdict"].get("best_holdout_sharpe", -999)
print(f"k={k:2d}: grade={rep['verdict']['grade']} "
f"full={rep['verdict'].get('best_full_sharpe', 'N/A')} "
f"hold={min_hold}")
if min_hold > best_hold:
best_hold = min_hold
best_rep = rep
# Rename best rep with canonical ID
best_rep["name"] = "MIC05"
print("\n--- BEST CONFIG ---")
print(al.fmt(best_rep))
print("JSON:", al.as_json(best_rep))