feat(fade): EXIT-16 close-confirm SL — stop solo se il CLOSE sfonda sl∓0.5·ATR14 (immune ai wick)

Param sl_confirm_atr (None = comportamento storico) in FadeStrategy.backtest,
MR01.backtest e StrategyWorker.tick; attivo live a 0.5 sulle 6 fade in _defs.py.
TP intrabar al livello e max_bars invariati; in modalita' confirm il TP ha
priorita' nel bar. Ricerca exit-lab (34 agenti, 3 lenti avversariali + tail
audit): gli stop intrabar da wick sono falsi negativi per le fade. PORT06
canonico: FULL Sharpe 6.47->7.84 DD 4.10->2.60, OOS 8.82->10.06 DD 1.30->1.15.
NB path grezzo non filtrato: ret esplode ma DD per-sleeve sale — la riduzione
DD vive nel config live (trend_max+hurst) + diversificazione, come misurato.
5 test nuovi (59 verdi).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Adriano Dal Pastro
2026-06-04 21:25:17 +00:00
parent ad65a0b344
commit a2579d21bc
6 changed files with 171 additions and 12 deletions
+10 -1
View File
@@ -24,8 +24,17 @@ MIN_TP_FRAC = 0.0015
# Validato 2026-06-02, vedi docs/diary/2026-06-02-fade-lossguard.md.
HURST_MAX = 0.55
# 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, "hurst_max": HURST_MAX})
params={"min_tp_frac": MIN_TP_FRAC, "hurst_max": HURST_MAX,
"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.
+17 -5
View File
@@ -106,6 +106,10 @@ class BollingerFade(Strategy):
h, l, c = df["high"].values, df["low"].values, df["close"].values
n = len(c)
# EXIT-16 close-confirm SL (2026-06-04): come in fade_base.FadeStrategy.backtest.
# None = comportamento storico. Vedi docs/diary/2026-06-04-exit-lab.md.
sl_confirm = params.get("sl_confirm_atr")
a14 = _atr(df, 14) if sl_confirm else None
fee = self.fee_rt * self.leverage
capital = peak = float(self.initial_capital)
max_dd = 0.0
@@ -125,12 +129,20 @@ class BollingerFade(Strategy):
j = i + step
if j >= n:
j = n - 1; exit_p = c[j]; break
hit_sl = (d == 1 and l[j] <= sl) or (d == -1 and h[j] >= sl)
hit_tp = (d == 1 and h[j] >= tp) or (d == -1 and l[j] <= tp)
if hit_sl:
exit_p = sl; break
if hit_tp:
exit_p = tp; break
if sl_confirm is None:
hit_sl = (d == 1 and l[j] <= sl) or (d == -1 and h[j] >= sl)
if hit_sl:
exit_p = sl; break
if hit_tp:
exit_p = tp; break
else:
# close-confirm: TP intrabar al livello; SL valutato sul CLOSE
if hit_tp:
exit_p = tp; break
buf = sl_confirm * a14[j]
if (d == 1 and c[j] < sl - buf) or (d == -1 and c[j] > sl + buf):
exit_p = c[j]; break
if step == mb:
exit_p = c[j]