ed2a9013aa
Punto 9 roadmap sweep. DIP01 era l'unico sleeve BTC con esecuzione reale round-trip ancora sul branch SL intrabar wick-sensitive. Gate dip01_exit16_impact.py (parita' canonica 1.00000; engine GAP-AWARE: orig filla lo SL a worse(livello, open) per rimuovere il bias pro-stop-intrabar dell'engine canonico sui gap-through): - grid 3x3x2 BTC: EXIT-16 >= orig in 36/36 (train E oos), OOS Sharpe ~2-4x (canonica 1.47->3.48); ETH 35/36 (robustezza). - plateau buffer piatto 0.4-1.0 (OOS DD 6.4% identico) -> 0.5 come le fade. - PORT06: FULL Sh 6.43->6.61 DD 3.96->3.58 | OOS Sh 8.58->8.77 DD 1.36->1.34. 5a conferma del principio EXIT-16 (wick-stop = falsi negativi per mean-reversion). hurst_max non valutato (ridondante-dannoso post-EXIT-16, gate trendmax). Deploy: "sl_confirm_atr": 0.5 nei params DIP01_BTC (il worker legge gia'). Trappola di metodo documentata: la prima parita' falliva per l'ancora bfill di _daily_equity (la serie a punti-trade reindexata su IDX aggancia il primo valore al PRIMO trade in finestra, non al capitale portato avanti) — replicata per parita'; finding aperto perche' tocca le metriche canoniche di tutti gli sleeve a punti-trade. Diario docs/diary/2026-06-07-dip01-exit16.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
89 lines
5.5 KiB
Python
89 lines
5.5 KiB
Python
"""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
|
|
|
|
FADE = [SleeveSpec(kind="single", name=c, sid=f"{c}_{a}", asset=a, cluster=f"{a}-rev",
|
|
params={"min_tp_frac": MIN_TP_FRAC, "trend_max": TREND_MAX,
|
|
"ema_long": EMA_LONG, "sl_confirm_atr": SL_CONFIRM_ATR})
|
|
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"),
|
|
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})]
|
|
SHAPE = [SleeveSpec(kind="ml", name="SH01", sid=f"SH_{a}", asset=a, cluster="shape")
|
|
for a in ("BTC", "ETH")]
|
|
|
|
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,
|
|
weighting="cap", caps={"PAIRS": 0.33, "SHAPE": 0.0588}, leverage=2.0),
|
|
}
|