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:
@@ -0,0 +1,57 @@
|
||||
"""MIC08 — OBV Trend
|
||||
Hypothesis: On-balance-volume trend: long when OBV above its EMA (volume confirms price).
|
||||
Long-flat. Continuous weights via al.study_weights.
|
||||
|
||||
Grid: obv_ema_period in (20, 50) x tfs (1d, 12h) = 4 total backtests.
|
||||
"""
|
||||
import sys
|
||||
sys.path.insert(0, "/opt/docker/PythagorasGoal/scripts/research/alt")
|
||||
import altlib as al
|
||||
import numpy as np
|
||||
|
||||
|
||||
def compute_obv(df) -> np.ndarray:
|
||||
"""Compute On-Balance-Volume causally."""
|
||||
close = df["close"].values
|
||||
volume = df["volume"].values
|
||||
n = len(close)
|
||||
obv = np.zeros(n)
|
||||
for i in range(1, n):
|
||||
if close[i] > close[i - 1]:
|
||||
obv[i] = obv[i - 1] + volume[i]
|
||||
elif close[i] < close[i - 1]:
|
||||
obv[i] = obv[i - 1] - volume[i]
|
||||
else:
|
||||
obv[i] = obv[i - 1]
|
||||
return obv
|
||||
|
||||
|
||||
def make_target(ema_period: int):
|
||||
def target(df) -> np.ndarray:
|
||||
obv = compute_obv(df)
|
||||
obv_ema = al.ema(obv, ema_period)
|
||||
# Long when OBV > its EMA, flat otherwise
|
||||
signal = np.where(obv > obv_ema, 1.0, 0.0)
|
||||
# Use vol-targeting to size the position
|
||||
sized = al.vol_target(signal, df, target_vol=0.20, vol_win_days=30, leverage_cap=2.0)
|
||||
return sized
|
||||
return target
|
||||
|
||||
|
||||
# Grid search: 2 EMA periods x 2 timeframes = 4 total backtests
|
||||
results = []
|
||||
for ema_p in (20, 50):
|
||||
rep = al.study_weights(
|
||||
f"MIC08-OBV-EMA{ema_p}",
|
||||
make_target(ema_p),
|
||||
tfs=("1d", "12h"),
|
||||
)
|
||||
results.append((rep["verdict"].get("best_holdout_sharpe", -9), ema_p, rep))
|
||||
|
||||
# Pick best by hold-out Sharpe
|
||||
results.sort(key=lambda x: x[0], reverse=True)
|
||||
best_holdout, best_ema, best_rep = results[0]
|
||||
|
||||
print(f"\n=== Best config: EMA period={best_ema} ===")
|
||||
print(al.fmt(best_rep))
|
||||
print("JSON:", al.as_json(best_rep))
|
||||
Reference in New Issue
Block a user