chore(reset): v2.0.0 — storico certificato Deribit mainnet, ripartenza pulita
Reset del progetto su fondamenta verificate dopo la scoperta che l'intera libreria "validata OOS" era artefatto di feed contaminato (print fantasma del feed Cerbero TESTNET + storico Binance/USDT). - Storico ricostruito da Deribit MAINNET (ccxt pubblico, tokenless) e CERTIFICATO (certify_feed.py): BTC/ETH puliti su TUTTA la storia (mediana 2-6 bps vs Coinbase USD), integrita' OHLC + coerenza resample (maxΔ 0.00) + cross-venue OK. Alt esclusi (illiquidi/divergenti: LTC/DOGE 50-82% barre flat; XRP/BNB non certificabili). - Verdetto sul feed pulito: FADE / PAIRS / XS01 / TSM01 morti (ogni portafoglio Sharpe -2.3..-3.0, DD ~40%); solo SH01 e frammenti HONEST con segnale residuo, da ri-validare in isolamento. - Cleanup "restart pulito": strategie, stack live (src/live, src/portfolio, runner/executor, yml, docker), ~100 script ricerca/gate, waste/games/ portfolios, dati non certificati + cache e 60+ diari -> archiviati in Old/ (preservati, non cancellati). Diario consolidato in un unico documento. - Skeleton ricerca tenuto: Strategy ABC + indicatori + src/fractal + src/backtest/engine + load_data; tool dati certificati (rebuild_history, certify_feed, audit_feed, multi_source_check). - Universo dati ATTIVO: solo BTC/ETH (5m/15m/1h); guardrail fisico (load_data su alt -> FileNotFoundError). Esecuzione DISABILITATA, conto flat. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
"""Definizioni canoniche dei portafogli (tutti i tipi visti finora)."""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
from src.portfolio.base import Portfolio, SleeveSpec # noqa: E402
|
||||
|
||||
# Universo live tradabile (8 asset con feed Cerbero v2 + parquet). ROT02/TSM01 ci ruotano sopra.
|
||||
UNIVERSE8 = ["ADA", "BNB", "BTC", "DOGE", "ETH", "LTC", "SOL", "XRP"]
|
||||
|
||||
# Edge minimo (solo live): salta i fade/dip il cui TP cade entro 1.5x il costo round-trip
|
||||
# (perdenti garantiti in regime piatto). Neutro sul backtest storico (0 trade rimossi su
|
||||
# MR01, +leggero su DIP01), protettivo dal vivo. Solo MR01/DIP01 leggono il param;
|
||||
# MR02/MR07 lo ignorano (**params). Vedi docs/diary/2026-06-01-tp-min-edge.md.
|
||||
MIN_TP_FRAC = 0.0015
|
||||
|
||||
# Filtro TREND (live, swap dal loss-guard Hurst il 2026-06-07): salta le fade quando il prezzo
|
||||
# e' esteso oltre trend_max*ATR(14) dalla EMA(ema_long) — non si fada un trend/crollo esteso.
|
||||
# E' la config che la ricerca EXIT-16 (2026-06-04) ha effettivamente promosso (entries
|
||||
# trend-filtrate, niente hurst). Gate PORT06 sul path live (trendmax_port06_impact, 2026-06-07):
|
||||
# TREND-ONLY domina la config hurst-only su TUTTE le metriche (FULL Sharpe 7.23->7.89,
|
||||
# OOS Sharpe 9.35->9.91, OOS DD 1.68->1.20), plateau robusto su trend_max 2.5/3.0/3.5.
|
||||
# Il loss-guard Hurst (validato 2026-06-02 sull'engine PRE-EXIT-16 con SL intrabar) e'
|
||||
# RIDONDANTE-DANNOSO dopo EXIT-16: attacca lo stesso regime (trending) saltando ingressi che
|
||||
# con EXIT-16 sono tornati vincenti; la combinazione hurst+trend over-filtra (meta' dei trade,
|
||||
# FULL Sharpe 7.11). hurst_skip_mask resta disponibile in fade_base (param hurst_max).
|
||||
# Vedi docs/diary/2026-06-07-trendmax-gate.md.
|
||||
TREND_MAX = 3.0
|
||||
EMA_LONG = 200
|
||||
|
||||
# EXIT-16 close-confirm SL (live, 2026-06-04): lo SL intrabar fisso veniva triggerato dai
|
||||
# wick transitori (falsi negativi: l'overshoot che buca lo stop rientra — e' il movimento
|
||||
# che la fade fada). Lo stop scatta solo se il CLOSE sfonda sl ∓ 0.5*ATR14. PORT06:
|
||||
# FULL Sharpe 6.47->7.84 DD 4.10->2.60, OOS 8.82->10.06 DD 1.30->1.15 (gate del loss-guard
|
||||
# superato con margine; 34 agenti, 3 verifiche avversariali + tail-risk: coda ~= base,
|
||||
# esce nei crash veri tipo FTX). Vedi docs/diary/2026-06-04-exit-lab.md.
|
||||
SL_CONFIRM_ATR = 0.5
|
||||
|
||||
|
||||
# Override stop-largo su MR02/ETH (2026-06-09). Lo sleeve a DD piu' alto e peggior performer reale
|
||||
# (whipsaw: fada un downtrend in long, poi shorta il rimbalzo). Ricerca 127 strategie + verifica
|
||||
# avversariale + gate PORT06: nessun SOSTITUTO batte il live EXIT-16; la miglioria e' ALLARGARE lo
|
||||
# stop (sl_atr 2.0->3.0) mantenendo il close-confirm. Cattura il beneficio del no-SL (gli stop di
|
||||
# meta'-discesa sono falsi negativi) SENZA la coda da sl=0 (worst-trade -50% vs -65% del no-SL; la
|
||||
# rete di catastrofe resta -> regola "mai sl=0" rispettata). Gate PORT06 (swap del solo MR02_ETH):
|
||||
# FULL Sh 6.73->6.77 DD 3.67->3.30, OOS Sh 8.80->8.82 DD 1.23 (domina il live, FULL DD -0.37pp).
|
||||
# Scoped a MR02/ETH: gli altri 5 fade (logica diversa) NON sono stati ri-gateati -> invariati.
|
||||
# Diario docs/diary/2026-06-08-mr02eth-replace-search.md (addendum 2026-06-09).
|
||||
SL_ATR_WIDE_MR02ETH = 3.0
|
||||
|
||||
|
||||
def _fade_params(c: str, a: str) -> dict:
|
||||
p = {"min_tp_frac": MIN_TP_FRAC, "trend_max": TREND_MAX,
|
||||
"ema_long": EMA_LONG, "sl_confirm_atr": SL_CONFIRM_ATR}
|
||||
if (c, a) == ("MR02", "ETH"):
|
||||
p["sl_atr"] = SL_ATR_WIDE_MR02ETH
|
||||
return p
|
||||
|
||||
|
||||
# SWAP timeframe 1h -> 15m (2026-06-12, scelta utente "swap secco"). Gate
|
||||
# fade15m_port06_gate.py: parametri 1h trasferiti a 15m NON ri-tunati (pre-registrati,
|
||||
# anti-overfit), corr daily 15m-1h media 0.26 (NON e' lo stesso edge piu' veloce),
|
||||
# SWAP promosso — FULL CAGR 74->101% DD 3.46->2.47%, OOS Sh 10.07->10.86 (OOS DD
|
||||
# 1.48->2.09 accettato); l'edge ETH sopravvive al flat-entry-skip (non e' stale-print
|
||||
# come pairs-alt). Stessi sid -> pesi/alloc invariati; il worker cambia cadenza
|
||||
# (max_bars=24 barre = 6h; EXIT-16 confirm sulla barra 15m completata). Il backtest
|
||||
# canonico segue (combine_portfolio.FADE_TF). MR02_BTC e' il piu' fee-sensitive
|
||||
# (fee2x OOS Sh 0.60): monitorare le fee reali nel report orario.
|
||||
# Diario docs/diary/2026-06-12-fade15m-gate.md.
|
||||
FADE = [SleeveSpec(kind="single", name=c, sid=f"{c}_{a}", asset=a, tf="15m",
|
||||
cluster=f"{a}-rev", params=_fade_params(c, a))
|
||||
for a in ("BTC", "ETH") for c in ("MR01", "MR02", "MR07")]
|
||||
HONEST = [
|
||||
# DIP01: single-asset 1h -> StrategyWorker (Strategy DIP01_dip_buy). TR01/ROT02: multi-asset.
|
||||
# EXIT-16 esteso a DIP01 (2026-06-07, sweep punto 9): gate dip01_exit16_impact.py con
|
||||
# engine GAP-AWARE — grid 36/36 BTC e 35/36 ETH (train E oos), plateau buffer piatto,
|
||||
# PORT06 FULL Sh 6.43->6.61 DD 3.96->3.58, OOS 8.58->8.77. Era l'unico sleeve BTC con
|
||||
# esecuzione reale ancora sul branch SL intrabar wick-sensitive.
|
||||
SleeveSpec(kind="single", name="DIP01", sid="DIP01_BTC", asset="BTC", cluster="BTC-rev",
|
||||
params={"min_tp_frac": MIN_TP_FRAC, "sl_confirm_atr": SL_CONFIRM_ATR}),
|
||||
SleeveSpec(kind="basket", name="TR01", sid="TR01_basket", cluster="trend",
|
||||
params={"universe": ["BNB", "BTC", "DOGE", "SOL", "XRP"], "tf": "4h"}),
|
||||
SleeveSpec(kind="rotation", name="ROT02", sid="ROT02_rot", cluster="rotation",
|
||||
params={"universe": UNIVERSE8, "tf": "1d", "top_k": 3, "gross": 0.45}),
|
||||
]
|
||||
PAIRS = [
|
||||
SleeveSpec(kind="pairs", name="PR01", sid="PR_ETHBTC", a="ETH", b="BTC", cluster="ETH-rev"),
|
||||
# BLEND timeframe: ETH/BTC anche a 15m (flat-skip), accanto al 1h. Decorrelato 0.37 dal
|
||||
# 1h -> diversificatore intra-pairs. Worker validato (validate_worker_pairs 15m, replay
|
||||
# == pairs_sim_flat). Gate PORT06: docs/diary/2026-06-09-pairs15m-live-path.md.
|
||||
SleeveSpec(kind="pairs", name="PR01", sid="PR_ETHBTC_15M", a="ETH", b="BTC", tf="15m",
|
||||
params={"n": 66, "z_in": 1.674, "z_exit": 1.0, "max_bars": 35, "flat_skip": True,
|
||||
"position_size": 0.10}, # meta' del family PAIRS (0.20): blend-tilt
|
||||
cluster="ETH-rev"),
|
||||
SleeveSpec(kind="pairs", name="PR01", sid="PR_LTCETH", a="LTC", b="ETH", cluster="ETH-rev"),
|
||||
SleeveSpec(kind="pairs", name="PR01", sid="PR_ADAETH", a="ADA", b="ETH", cluster="ETH-rev"),
|
||||
SleeveSpec(kind="pairs", name="PR01", sid="PR_BTCLTC", a="BTC", b="LTC", cluster="BTC-rev"),
|
||||
SleeveSpec(kind="pairs", name="PR01", sid="PR_ETHSOL", a="ETH", b="SOL", cluster="ETH-rev"),
|
||||
]
|
||||
TSM = [SleeveSpec(kind="tsmom", name="TSM01", sid="TSM01", cluster="trend",
|
||||
params={"universe": UNIVERSE8, "tf": "1d",
|
||||
"horizons": [63, 126, 252], "thr": 1.0, "gross": 0.30})]
|
||||
# SH01 live (punto-10, 2026-06-07): il runner passa la storia FULL (parquet+feed) e
|
||||
# last_block_only fitta/predice solo l'ultimo blocco del walk-forward (segnali ==
|
||||
# WF completo per costruzione). Il regime corto train-365g NON e' robusto (BTC
|
||||
# negativo a fee 2x, trade-rate 22% vs 10% validato): sh01_trainwindow_validate.py.
|
||||
SHAPE = [SleeveSpec(kind="ml", name="SH01", sid=f"SH_{a}", asset=a, cluster="shape",
|
||||
params={"last_block_only": True})
|
||||
for a in ("BTC", "ETH")]
|
||||
# XS01 — reversione CROSS-SECTIONAL (8 asset, market-neutral). Famiglia nuova, scorrelata
|
||||
# (~0) da pairs e fade. Gate PORT06: +XS01 -> OOS Sharpe 9.66->10.07, FULL DD 3.68->3.46.
|
||||
# 8 gambe -> niente esecuzione reale: gira PAPER (come TR01/ROT02/TSM01). Worker validato
|
||||
# (validate_xsec_worker: replay == backtest esatto). Diario 2026-06-09.
|
||||
# DISPERSION-GATE (2026-06-10): entry solo se std cross-section del momentum lb >= disp_min
|
||||
# (p50 TRAIN = 0.0313). Diagnostica monotona TRAIN+OOS, plateau p30-p70, ogni anno migliora
|
||||
# (standalone Sharpe 2.50->3.46, regge fee 2x), PORT06 OOS Sh 10.07->10.37 a DD pari. Solo
|
||||
# path LIVE (backtest canonico NON filtrato, come trend/hurst sulle fade) -> il live fara'
|
||||
# meglio del backtest. Diario 2026-06-10, gate scripts/analysis/xs01_dispersion_gate.py.
|
||||
# PHASE-TRANCHING (2026-06-11): tranches=3 sub-book sfasati di hold/3, capitale comune.
|
||||
# La fase del roll e' arbitraria e da sola muove Sharpe FULL daily 1.52-2.33 / DD 13.8-33%
|
||||
# (timing-luck): l'ensemble di fase la elimina senza parametri fittati. Gate
|
||||
# xs01_tranche_gate.py: plateau K=2 E K=3 promossi (PORT06 OOS Sh 10.07->10.15, DD
|
||||
# 1.48->1.38, FULL pari). Solo path live come disp_min (backtest canonico single-phase).
|
||||
XSEC = [SleeveSpec(kind="xsec", name="XS01", sid="XS01", cluster="xsec",
|
||||
params={"universe": ["BTC", "ETH", "LTC", "ADA", "SOL", "BNB", "XRP", "DOGE"],
|
||||
"tf": "1h", "lb": 48, "hold": 12, "disp_min": 0.0313,
|
||||
"tranches": 3})]
|
||||
|
||||
PORTFOLIOS = {
|
||||
"PORT01": Portfolio("PORT01", "Honest", HONEST, weighting="equal"),
|
||||
"PORT02": Portfolio("PORT02", "Fade master", FADE, weighting="equal"),
|
||||
"PORT03": Portfolio("PORT03", "Master", FADE + HONEST, weighting="equal"),
|
||||
"PORT04": Portfolio("PORT04", "Master + pairs", FADE + HONEST + PAIRS,
|
||||
weighting="cap", caps={"PAIRS": 0.33}),
|
||||
"PORT05": Portfolio("PORT05", "Master esteso", FADE + HONEST + PAIRS + TSM,
|
||||
weighting="cap", caps={"PAIRS": 0.33}),
|
||||
# SHAPE cappata a ~mezzo sleeve equal (2026-06-05): SH01 non ha SL per design e la
|
||||
# ricerca multi-agente (sh01_exit_lab, 11 famiglie di stop, 0 sopravvissute) dimostra
|
||||
# che NESSUNO stop taglia la coda ETH senza rompere l'edge -> si dimezza l'esposizione
|
||||
# (costo backtest ~0: FULL 6.47->6.43, OOS 8.82->8.58, FULL DD 4.10->3.96). Vedi
|
||||
# docs/diary/2026-06-05-sh01-sl-research.md.
|
||||
"PORT06": Portfolio("PORT06", "Master + shape", FADE + HONEST + PAIRS + TSM + SHAPE + XSEC,
|
||||
weighting="cap", caps={"PAIRS": 0.33, "SHAPE": 0.0588}, leverage=2.0),
|
||||
}
|
||||
Reference in New Issue
Block a user