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,59 @@
|
||||
"""TRD12 — Triple-MA alignment (SMA10 > SMA50 > SMA200).
|
||||
Long only when all three SMAs are in full bullish alignment; flat otherwise.
|
||||
No look-ahead: SMA values at i use close[0..i], position held during bar i+1.
|
||||
"""
|
||||
import sys
|
||||
sys.path.insert(0, "/opt/docker/PythagorasGoal/scripts/research/alt")
|
||||
import altlib as al
|
||||
import numpy as np
|
||||
|
||||
|
||||
def triple_ma_weights(df, short=10, mid=50, long=200, use_vol_target=True):
|
||||
"""Return position array: +1 when SMA_short > SMA_mid > SMA_long, else 0."""
|
||||
c = df["close"].values
|
||||
s = al.sma(c, short)
|
||||
m = al.sma(c, mid)
|
||||
l = al.sma(c, long)
|
||||
|
||||
# Bullish alignment: short > mid > long
|
||||
bullish = (s > m) & (m > l)
|
||||
|
||||
# Direction: +1 or 0 (long-only)
|
||||
direction = np.where(bullish, 1.0, 0.0)
|
||||
|
||||
# Replace NaN regions (first `long` bars) with 0
|
||||
direction = np.where(np.isnan(s) | np.isnan(m) | np.isnan(l), 0.0, direction)
|
||||
|
||||
if use_vol_target:
|
||||
return al.vol_target(direction, df, target_vol=0.20, vol_win_days=30, leverage_cap=2.0)
|
||||
else:
|
||||
return direction
|
||||
|
||||
|
||||
# Run study on 1d and 12h timeframes (Triple-MA needs long history, so >=12h)
|
||||
# We try two configurations: with and without vol-targeting
|
||||
# That's 2 configs x 2 TFs = 4 total backtests (within the <=6 limit)
|
||||
|
||||
print("=" * 60)
|
||||
print("TRD12 — Triple-MA alignment (SMA10 > SMA50 > SMA200)")
|
||||
print("=" * 60)
|
||||
|
||||
# Config 1: with vol-targeting
|
||||
rep_vt = al.study_weights(
|
||||
"TRD12-VT",
|
||||
lambda df: triple_ma_weights(df, use_vol_target=True),
|
||||
tfs=("1d", "12h"),
|
||||
)
|
||||
print("\n--- Vol-targeted ---")
|
||||
print(al.fmt(rep_vt))
|
||||
print("JSON:", al.as_json(rep_vt))
|
||||
|
||||
# Config 2: raw (no vol-targeting, simple long/flat)
|
||||
rep_raw = al.study_weights(
|
||||
"TRD12-RAW",
|
||||
lambda df: triple_ma_weights(df, use_vol_target=False),
|
||||
tfs=("1d", "12h"),
|
||||
)
|
||||
print("\n--- Raw (no vol-target) ---")
|
||||
print(al.fmt(rep_raw))
|
||||
print("JSON:", al.as_json(rep_raw))
|
||||
Reference in New Issue
Block a user